2021-09-14 20:30:57 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Helicopter : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
//直升机类,控制第二关最后的直升机
|
|
|
|
|
public bool canGo = false;//记录自己目前是否可以前进了,在事件中改变
|
|
|
|
|
[Tooltip("填入直升机追踪的速度")]
|
|
|
|
|
public float speed;
|
2021-09-14 23:56:07 +08:00
|
|
|
|
[Tooltip("拖入枪击音效")]
|
|
|
|
|
public AudioSource gunSound;
|
|
|
|
|
[Tooltip("拖入第二关的普通BGM,死亡后得换回普通BGM")]
|
|
|
|
|
public AudioClip normalClip;
|
2021-09-14 20:30:57 +08:00
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
if(canGo)
|
|
|
|
|
{
|
|
|
|
|
transform.position = new Vector3(
|
|
|
|
|
// x加
|
|
|
|
|
transform.position.x + speed * Time.deltaTime,
|
|
|
|
|
// yz不变
|
|
|
|
|
transform.position.y ,transform.position.z
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnTriggerEnter2D(Collider2D other)
|
|
|
|
|
{
|
|
|
|
|
if (other.tag == "Player")
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("玩家被直升机发现,判定死亡");
|
2021-09-14 23:56:07 +08:00
|
|
|
|
other.GetComponent<M_Player>().YouAreShootingDead();
|
|
|
|
|
gunSound.Play();
|
|
|
|
|
FindObjectOfType<BGMPlayer>().ChangedTheBGM(normalClip);
|
2021-09-14 20:30:57 +08:00
|
|
|
|
//让直升机停下来
|
|
|
|
|
canGo = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|