1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- using System;
- public class FinishTrigger : MonoBehaviour
- {
- public Animator Animator;
- public Transform Pivot;
- private float normalTime;
- public void ResetAnimation()
- {
- Animator.enabled = false;
- Animator.Play("FlyToTower", 0,0);
- }
- private void OnTriggerEnter(Collider other)
- {
- if(other.tag == "Player" && !Core.Instance.LevelEnd)
- {
- if (other.GetComponent<RunnersController>().IsPlayer)
- {
- normalTime = 0;
- other.GetComponent<RunnersController>().enabled = false;
- other.GetComponent<RunnersController>().Agent.enabled = false;
- other.transform.SetParent(Pivot);
- other.transform.DOLocalMove(Vector3.zero, 0.3f);
- Animator.enabled = true;
- Animator.Play("FlyToTower", 0, normalTime);
- Core.Instance.IsGameMode = Core.StateModeGame.Kiss;
- //NotificationCenter.Post(NotificationType.GameOver);
- //UIManager.Instance.SetTimerKissTower();
- StartCoroutine(FlyToTower());
-
- }
- else
- {
-
- Core.Instance.PlayerGame.Agent.speed = 0;
- other.GetComponent<RunnersController>().Agent.enabled = false;
- UIManager.Instance.GameOverPanel.gameObject.SetActive(true);
- UIManager.Instance.GameOverPanel.DOFade(1, 0.5f);
- }
- Core.Instance.LevelEnd = true;
- other.GetComponent<RunnersController>().SetFlyToTowerAnim();
- }
-
- }
- private IEnumerator FlyToTower()
- {
- while(normalTime<=1)
- {
- normalTime += Time.deltaTime;
- yield return new WaitForEndOfFrame();
- Animator.SetFloat("NormalizedTime",normalTime);
- }
- //normalTime = 0;
- }
- }
|