123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections;
- using UnityEngine;
- public class ActionDirect : MonoBehaviour
- {
- public static ActionDirect Instance { get; private set; }
- private void Start()
- {
- ActionDirect.Instance = this;
- base.gameObject.SetActive(false);
- }
- private void UIMove(float time)
- {
- float current_time;
- if (time <= this.m_MoveTime / 2f + this.m_StopTime)
- {
- current_time = Mathf.Min(time, this.m_MoveTime / 2f);
- }
- else
- {
- current_time = time - (this.m_StopTime + this.m_MoveTime / 2f);
- }
- float x = this.m_ParentCanvas.sizeDelta.x;
- if (time <= this.m_MoveTime / 2f)
- {
- base.transform.localPosition = Vector3.Lerp(Vector3.right * x, Vector3.zero, KasaiUtility.SinRate01(current_time, this.m_MoveTime / 2f, false, false));
- }
- else if (time > this.m_MoveTime / 2f + this.m_StopTime)
- {
- base.transform.localPosition = Vector3.Lerp(Vector3.zero, Vector3.left * x, KasaiUtility.SinRate01(current_time, this.m_MoveTime / 2f, false, false));
- }
- }
- private void MoveEnd()
- {
- if (this.MoveendCall != null)
- {
- this.MoveendCall();
- }
- this.MoveendCall = null;
- base.gameObject.SetActive(false);
- }
- public void ActionStart(string action)
- {
- base.gameObject.SetActive(true);
- IEnumerator enumerator = this.m_ActionImage.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform transform = (Transform)obj;
- transform.gameObject.SetActive(transform.name == action);
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- base.StartCoroutine(KasaiUtility.TimeCroutine(this.m_MoveTime + this.m_StopTime, new Action<float>(this.UIMove), new Action(this.MoveEnd)));
- }
- [SerializeField]
- private Transform m_ActionImage;
- [SerializeField]
- private RectTransform m_ParentCanvas;
- [SerializeField]
- private float m_MoveTime = 0.75f;
- [SerializeField]
- private float m_StopTime = 0.25f;
- public Action MoveendCall;
- }
|