Roman 00aaa37856 任务:实装和完善部分音效,修复场景问题
1.实装死亡重开系统:
*:增加被航弹炸死的死法
*:增加被地雷炸死的死法
*:增加了被碉堡打死的死法
*:增加被夜间碉堡扫死的死法
*:增加被夜间巡逻的人打死的死法
*:增加被直升机打死的死法
2.修改碉堡警告UI颜色
3.编写开始游戏界面
4.编写感谢游玩界面
5.修复老兵牺牲动画的Bug

(*:第二关的炮火已经越来越好了,但是目前只有炮火,晚上肯定也会开枪吧?希望增加一些随机快速闪烁的光源表示晚上的枪。
xx:人声问题请待定,加上音乐后好像又不是很违和了
(*:碉堡警告音效系统做完了,但是人声感觉上非常奇怪,建议修改
(*:敌人被石头吸引系统实装完成,但是很突兀,建议还是不要出现语言了

接下来的任务:
*:试图做得更好
2021-09-14 23:56:07 +08:00

117 lines
3.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NightBlockHouse : MonoBehaviour
{
// Start is called before the first frame update
//晚上的碉堡类
//碉堡类敌人的控制代码
[Tooltip("请填入开枪的间隔时间")]
public float firingInterval;
private ShootingArea[] shootingAreas;
private bool isShooting = false;//记录此时自己是否正在射击
[Tooltip("请拖入两灯游戏物体")]
public GameObject[] lights;
[Tooltip("拖入一个开枪音频")]
public AudioSource GunSound;
private bool hasPlayerGunSound = false;
void Start()
{
shootingAreas = new ShootingArea[transform.childCount];
for(int i = 0; i < transform.childCount; i++)
{
shootingAreas[i] = transform.GetChild(i).
gameObject.AddComponent<ShootingArea>();//给每个子物体挂上射击区的脚本
//并且把它的脚本送到数组里面,免去以后再遍历拖慢速度
}
InvokeRepeating("ShootOrStopShoot",firingInterval,firingInterval);
}
void Update()
{
if(isShooting) Shooting();//如果正在射击,每帧检查射击区
}
// void OnTriggerEnter2D(Collider2D other)
// {
// if(other.tag == "Player")
// {
// //当玩家进入监视区,开始每隔时间进行扫射
// InvokeRepeating("ShootOrStopShoot",firingInterval,firingInterval);
// }
// }
// void OnTriggerExit2D(Collider2D other)
// {
// if(other.tag == "Player")
// {
// //当玩家退出监视区取消扫射的Invoke
// CancelInvoke("ShootOrStopShoot");
// }
// }
//定时触发,反正就是更改射击状态,射到不射或者不射到射
private void ShootOrStopShoot()
{
if(isShooting)//如果在开火
{
isShooting = false;//别让它开了
foreach(GameObject light in lights)
{
light.SetActive(false);
}
}
else//如果没在开火
{
isShooting = true;//标记让它开火
foreach(GameObject light in lights)
{
light.SetActive(true);
}
}
}
//正在射击的时候触发,每帧检测是否被击中
private void Shooting()
{
foreach(ShootingArea s in shootingAreas)
{
if(s.IsPlayerHere())
{
Debug.Log("玩家被击中!");
FindObjectOfType<M_Player>().YouAreShootingDead();
if(GunSound != null && !hasPlayerGunSound){GunSound.Play();hasPlayerGunSound = true;}
}
}
}
private class ShootingArea : MonoBehaviour
{
//射击区类,我懒得再单写一个脚本了,里面东西很少
private bool isPlayerHere = false;//记录玩家是否在内部
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
//当玩家进入射击区,更改判断标志
isPlayerHere = true;
}
}
void OnTriggerExit2D(Collider2D other)
{
if(other.tag == "Player")
{
//当玩家退出射击区,更改判断标志
isPlayerHere = false;
}
}
public bool IsPlayerHere(){return isPlayerHere;}//返回玩家是否在这个射击区内的结果
}
}