You've already forked taptap2024_GJ_chidouren
73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace Game.Component.SceneProp
|
|
{
|
|
public class RedProp : BaseProp
|
|
{
|
|
[SerializeField, Header ("施法时间")] private float _actionDelay = 0.5f;
|
|
[SerializeField, Header ("a区传送点")] private Transform _a_pos;
|
|
[SerializeField, Header ( "b区传送点")] private Transform _b_pos;
|
|
|
|
protected override void OnTrigger (PlayerEntity entity)
|
|
{
|
|
//从a点到b
|
|
this.ToPos (entity, this._a_pos);
|
|
}
|
|
|
|
public void OnTriggerEnterAction (Collider2D other)
|
|
{
|
|
if (other.gameObject.CompareTag ("Player"))
|
|
{
|
|
if (isReady)
|
|
{
|
|
var player = other.gameObject.GetComponent<PlayerEntity> ();
|
|
this.ToPos (player , this._b_pos);
|
|
if (HasOnce)
|
|
{
|
|
this.gameObject.SetActive (false);
|
|
}
|
|
else
|
|
{
|
|
RefreshInvalidTime ();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private async UniTask ToPos (PlayerEntity playerEntity, Transform target)
|
|
{
|
|
//消失动画
|
|
playerEntity.gameObject.SetActive (false);
|
|
var playerEntityTransform = playerEntity.transform;
|
|
playerEntityTransform.position = target.position;
|
|
playerEntityTransform.rotation = target.rotation;
|
|
await UniTask.Delay ((int)(this._actionDelay * 1000));
|
|
playerEntity.gameObject.SetActive (true);
|
|
//出场动画
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
private void OnDrawGizmos ()
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (this._a_pos != null)
|
|
{
|
|
Gizmos.color = new Color (1f, 0.38f, 0.13f);
|
|
Gizmos.DrawWireSphere (this._a_pos.position, 0.2f);
|
|
}
|
|
|
|
if (this._b_pos != null)
|
|
{
|
|
Gizmos.color = new Color (0.2f, 0.4f, 1f);
|
|
Gizmos.DrawWireSphere (this._b_pos.position, 0.2f);
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
} |