备份CatanBuilding瘦身独立工程
This commit is contained in:
35
Assets/Scripts/UI/Washing/EventWashingGestureFollow.cs
Normal file
35
Assets/Scripts/UI/Washing/EventWashingGestureFollow.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EventWashingGestureFollow : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public float displayTime = 0f;
|
||||
|
||||
private float remainingTime;
|
||||
|
||||
public void SetFollowPosition(Vector3 position, float speed)
|
||||
{
|
||||
float distance = Vector3.Distance(this.gameObject.transform.position, position);
|
||||
float time = distance / speed;
|
||||
this.gameObject.transform.DOKill();
|
||||
this.gameObject.transform.DOMove(position, time).SetEase(Ease.Linear);
|
||||
|
||||
remainingTime = displayTime;
|
||||
if (this.gameObject.activeSelf == false) this.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
remainingTime -= Time.deltaTime;
|
||||
if (remainingTime <= 0f)
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user