CultivateImmortal/Assets/Scripts/GameObject/FeiJian.cs

40 lines
1006 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FeiJian : MonoBehaviour
{
public RectTransform rec;
public float moveSpeed;
private Vector3 startPos;
void OnEnable()
{
startPos = rec.localPosition;
GameMgr.Instance.isFeijianClose = false;
}
void Update()
{
//飞剑在飞行过程中,如果切换了地图,要放入对象池
if (GameMgr.Instance.isFeijianClose)
{
this.transform.position = Vector3.zero;
PoolMgr.Instance.PushObj(this.gameObject);
return;
}
startPos.x += Time.deltaTime* moveSpeed;
rec.localPosition= startPos;
}
void OnTriggerEnter2D(Collider2D collider2D)
{
EventCenter.Instance.EventTrigger<PlayerData>(E_EventType.E_Monster_Wound,GameDataMgr.Instance.player);
this.transform.position=Vector3.zero;
rec.localScale = Vector3.one;
PoolMgr.Instance.PushObj(this.gameObject);
}
}