54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class BullitMove : MonoBehaviour
|
|
{
|
|
public float moveSpeed = 5;
|
|
public float desTime = 10f;
|
|
public string playerID;
|
|
float currShowTime = 0f;
|
|
Vector3 vector3_startPosition;
|
|
public bool isTriggerFirst=true;
|
|
// Start is called before the first frame update
|
|
void Awake()
|
|
{
|
|
Init();
|
|
Destroy(gameObject, desTime);
|
|
}
|
|
/// <summary>
|
|
/// 对象池用
|
|
/// </summary>
|
|
public void Init()
|
|
{
|
|
vector3_startPosition = transform.position;
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
//方便帧同步
|
|
currShowTime += Time.deltaTime;
|
|
Vector3 targetPoint = transform.up.normalized * currShowTime * moveSpeed;
|
|
transform.position = vector3_startPosition + targetPoint;
|
|
|
|
|
|
}
|
|
|
|
public void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (isTriggerFirst)
|
|
{
|
|
if (collision.tag == "Monster")
|
|
{
|
|
isTriggerFirst=false;
|
|
//受激
|
|
collision.transform.GetComponent<MonsterControl>().monsterData.charactersHealth.OnHurt(10, CharacterHurtType.none);
|
|
Destroy(collision.gameObject);
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|