备份CatanBuilding瘦身独立工程
This commit is contained in:
49
Assets/Scripts/UI/ShootingRange/ShootingTarget.cs
Normal file
49
Assets/Scripts/UI/ShootingRange/ShootingTarget.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShootingTarget : MonoBehaviour
|
||||
{
|
||||
public int stageIdx, targetIdx;
|
||||
public Animation ani;
|
||||
private const string Break = "breaking", Broken = "broken", Normal = "normal", Appear = "into";
|
||||
|
||||
public void InitAndPlayAppearAnimation(bool isHit, int stageIdx, int targetIdx)
|
||||
{
|
||||
this.stageIdx = stageIdx;
|
||||
this.targetIdx = targetIdx;
|
||||
gameObject.SetActive(!isHit);
|
||||
if (!isHit)
|
||||
PlayAppear();
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task PlayBreakAnimationWithDelay(float delay = 0f)
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(delay));
|
||||
ani.Play(Break);
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(14f / 60));
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void PlayAppear()
|
||||
{
|
||||
try{
|
||||
|
||||
ani.Play(Appear);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Debug.LogError(e.Message);
|
||||
Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
// private void Start()
|
||||
// {
|
||||
// var enumerator = ani.GetEnumerator();
|
||||
// using var d = enumerator as IDisposable;
|
||||
// while (enumerator.MoveNext())
|
||||
// {
|
||||
// Debug.Log(enumerator.Current);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user