备份CatanBuilding瘦身独立工程
This commit is contained in:
86
Assets/Scripts/EventWashing/Stuff/StuffTrash.cs
Normal file
86
Assets/Scripts/EventWashing/Stuff/StuffTrash.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace game
|
||||
{
|
||||
public class StuffTrash : LongPressStuffBase
|
||||
{
|
||||
private ToolForFollowerAndNormalPosition m_Cleaner;
|
||||
private float m_Distance;
|
||||
private float m_DisappearTime = 0.1f;
|
||||
|
||||
private bool m_Running = true;
|
||||
|
||||
private UnityAction<StuffTrash> m_OnCompleteAction = null; // 更新事件
|
||||
|
||||
#region 功能
|
||||
public void SetCleaner(ToolForFollowerAndNormalPosition cleaner, float distance, float disappearTime, UnityAction<StuffTrash> completeAction)
|
||||
{
|
||||
m_Cleaner = cleaner;
|
||||
m_Distance = distance;
|
||||
m_DisappearTime = disappearTime;
|
||||
m_OnCompleteAction = completeAction;
|
||||
m_Running = true;
|
||||
}
|
||||
|
||||
private void CheckDistance()
|
||||
{
|
||||
if (m_Cleaner == null) return;
|
||||
float distance = Vector3.Distance(this.transform.position, m_Cleaner.OperatingPoint);
|
||||
if (distance <= m_Distance)
|
||||
{
|
||||
var self = this.gameObject;
|
||||
//this.transform.DOKill();
|
||||
this.transform.DOMove(m_Cleaner.OperatingPoint, m_DisappearTime).SetEase(Ease.OutQuad).OnComplete(() =>
|
||||
{
|
||||
self.SetActive(false);
|
||||
});
|
||||
this.transform.DOLookAt(m_Cleaner.OperatingPoint, m_DisappearTime).SetEase(Ease.OutQuad);
|
||||
this.transform.DOScale(0.1f, m_DisappearTime).SetEase(Ease.Linear);
|
||||
|
||||
if (m_OnCompleteAction != null)
|
||||
{
|
||||
m_OnCompleteAction(this);
|
||||
}
|
||||
|
||||
//this.gameObject.SetActive(false);
|
||||
this.m_Status = EventWashingActionStatus.Ending;
|
||||
StopAction();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 外部接口
|
||||
public override void StartAction(UnityAction<LongPressStuffBase> overAction)
|
||||
{
|
||||
//base.StartAction(overAction);
|
||||
m_Running = true;
|
||||
}
|
||||
public override void StopAction()
|
||||
{
|
||||
//base.StopAction();
|
||||
m_Running = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生命周期
|
||||
public override void InitStuff()
|
||||
{
|
||||
base.InitStuff();
|
||||
m_Type = EventWashingStuffType.Trash;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (m_Running)
|
||||
{
|
||||
CheckDistance();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user