1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityGameFramework.Runtime;
- using DG;
- using DG.Tweening;
- /// <summary>
- /// 场景组件 抛物线
- /// </summary>
- public class SceneEventParabolic : MonoBehaviour
- {
- Sequence seq;
- bool isComplate = false;
- private void Awake()
- {
- seq = DOTween.Sequence();
- }
- // Start is called before the first frame update
- void Start()
- {
- }
- public void OnTriggerEnter(Collider collider)
- {
- Role r = collider.GetComponent<Role>();
- if(r && !seq.IsPlaying())
- {
- TestDoTween(collider.transform);
- }
- }
- public void OnTriggerExit(Collider collider)
- {
- }
- public void TestDoTween(Transform target)
- {
- var ParabolicDis = Vector3.Distance(target.transform.position, this.transform.position);
- var ParabolicDown = target.transform.position.y;
- var speed = 3.0f;
- var time = ParabolicDis / speed;
- seq.Append(this.transform.DOMoveX(target.position.x, time / 2).SetEase(Ease.Linear));
- seq.Append(this.transform.DOMoveZ(target.position.z, time / 2).SetEase(Ease.Linear));
- seq.Insert(0, this.transform.DOMoveY(target.transform.position.y + ParabolicDis, time / 2).SetEase(Ease.OutQuart));
- seq.Insert(0.5f , this.transform.DOMoveY(ParabolicDown, time * 0.5f).SetEase(Ease.InCirc));
- seq.OnComplete<Sequence>(() => { OnDoTweenComplete(); });
-
- }
- public void OnDoTweenComplete()
- {
- Debug.Log("抛物线完成!");
- }
- }
|