50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
![]() |
using System.Collections;
|
||
|
using BlueWater.Tycoons;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class TycoonCard : MonoBehaviour
|
||
|
{
|
||
|
public float rotationDuration = 1.0f;
|
||
|
public void Start()
|
||
|
{
|
||
|
StartCoroutine(RotateOverTime(180f));
|
||
|
// var a = TycoonManager.Instance.GetLevelDataByIdx("1");
|
||
|
// Resources.Load()
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
private IEnumerator RotateOverTime(float relativeYRotation)
|
||
|
{
|
||
|
RectTransform rectTransform = this.GetComponent<RectTransform>();
|
||
|
|
||
|
Transform backObject = rectTransform.Find("Back");
|
||
|
Quaternion startRotation = rectTransform.localRotation;
|
||
|
Quaternion targetRotation = startRotation * Quaternion.Euler(0, relativeYRotation, 0);
|
||
|
|
||
|
float elapsedTime = 0f;
|
||
|
|
||
|
while (elapsedTime < rotationDuration)
|
||
|
{
|
||
|
elapsedTime += Time.deltaTime;
|
||
|
|
||
|
float t = elapsedTime / rotationDuration;
|
||
|
|
||
|
float easedT = 1 - Mathf.Pow(2, -10 * t);
|
||
|
|
||
|
rectTransform.localRotation = Quaternion.Lerp(startRotation, targetRotation, easedT);
|
||
|
|
||
|
|
||
|
float currentYRotation = rectTransform.localRotation.eulerAngles.y;
|
||
|
|
||
|
if (currentYRotation <= 90.0f && backObject.gameObject.activeSelf)
|
||
|
{
|
||
|
backObject.gameObject.SetActive(false);
|
||
|
}
|
||
|
|
||
|
yield return null;
|
||
|
}
|
||
|
|
||
|
rectTransform.localRotation = targetRotation;
|
||
|
}
|
||
|
}
|