
1.更改第二关敌人的音效特性,修复无论何时都能听见敌人脚步声的问题 2.接纳建议,更换第一关父亲离家CG为新 3.给各场景衔接处加上黑屏转场,包括以下几处 (*:序章-家中 --> 序章-战场 间 (*:序章-战场 --> 序章-家中 间 (*:序章-家中 --> 第一关 间 (*:第一关 --> 第二关 间 4.实装建议,给碉堡的发令员添加音效 (*:做是做完了,但是感觉上非常奇怪,建议修改 5.实装建议,增加电报机撕页音效 (*:补上了第一关处的音效适配 6.实装建议,添加打开电报机界面的音效 (*:补上了第一关处的音效适配 7.减小了机枪音效的音量,现在太吵了 8.实装建议,加上碉堡处的挡板被击动画 (*:制作AC“挡板” (*:制作AM“挡板受击” (*:实装受击动画 9.实装建议,加上敌人被声音吸引后的音效(霓虹语) (*:系统实装完成,但是很突兀,建议还是不要出现语言了 10.给序章战场的修电话UI换上新的素材 11.调整两段CG的淡出效果 (*:建议考虑玩家回去查看牺牲的老兵的可能性 (*:建议把碉堡发令员的指挥做成动态的 (*:建议优化一下第二关的背景枪火光,现在太虚了,没有什么实际感 (*:建议开始寻找BGM,希望能找到有主旋律的一整套,试着从电影原声找合适的吧 (*:建议更换对话系统的出字音效,用FunGus的组太多了,这个音效既视感极强,建议修改 (*:建议增加当玩家还没修完电话线就跟电报机互动时的反馈 (*目前碉堡音效出现和消失得十分突然,建议在首尾稍微加一些淡入淡出效果 (*:碉堡警告音效系统做完了,但是人声感觉上非常奇怪,建议修改 (*:撕纸的音效太短了,和动画匹配不上,建议修改 (*:敌人被石头吸引系统实装完成,但是很突兀,建议还是不要出现语言了 (*:第二段CG,建议渲染好淡出效果,不然会出一些问题…………
170 lines
5.5 KiB
C#
170 lines
5.5 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class Blockhouse : MonoBehaviour
|
||
{
|
||
//碉堡类敌人的控制代码
|
||
|
||
[Tooltip("请填入开枪的间隔时间")]
|
||
public float firingInterval;
|
||
private ShootingArea[] shootingAreas;
|
||
private bool isShooting;//记录此时自己是否正在射击
|
||
[Tooltip("需要因为碉堡开火触发开火动画的都拖进来")]
|
||
public Animator[] fireAnimations;
|
||
[Tooltip("请拖入碉堡警告UI")]
|
||
public Image warningUI;
|
||
[Tooltip("拖入准备图片")]
|
||
public Sprite ready;
|
||
[Tooltip("拖入挥旗图片")]
|
||
public Sprite done;
|
||
private bool isStartedToShowUI = false;//记录自己是否正在准备启动警告UI
|
||
private bool isCencledToShowUI = false;//记录自己是否正在准备关闭警告UI
|
||
[Tooltip("请填入UI出现的速度")]
|
||
public float speed;
|
||
[Tooltip("请填入提前时间,即在警告后多少时间开枪")]
|
||
public float advanceTime;
|
||
|
||
public AudioSource blockHouseAudio;//获取音频对象
|
||
public BlackHouseGunLight blackHouseGunLight;//获取碉堡枪光的脚本
|
||
private AudioSource audioPlayer;
|
||
public AudioClip[] warningSounds;
|
||
|
||
void Start()
|
||
{
|
||
shootingAreas = new ShootingArea[transform.childCount];
|
||
for(int i = 0; i < transform.childCount; i++)
|
||
{
|
||
shootingAreas[i] = transform.GetChild(i).
|
||
gameObject.AddComponent<ShootingArea>();//给每个子物体挂上射击区的脚本
|
||
//并且把它的脚本送到数组里面,免去以后再遍历拖慢速度
|
||
}
|
||
audioPlayer = GetComponent<AudioSource>();
|
||
}
|
||
|
||
void Update()
|
||
{
|
||
if(isShooting) Shooting();//如果正在射击,每帧检查射击区
|
||
if(isStartedToShowUI && warningUI.fillAmount < 1)//如果正在启动UI,每帧加一点fill直到加满
|
||
{
|
||
warningUI.fillAmount += speed*Time.deltaTime;
|
||
}
|
||
if(isCencledToShowUI && warningUI.fillAmount > 0)//如果正在关闭UI,每帧减一点fill直到清空
|
||
{
|
||
warningUI.fillAmount -= speed*Time.deltaTime;
|
||
}
|
||
}
|
||
|
||
void OnTriggerEnter2D(Collider2D other)
|
||
{
|
||
if(other.tag == "Player")
|
||
{
|
||
//当玩家进入监视区,开始每隔时间进行扫射
|
||
InvokeRepeating("ShootOrStopShoot",firingInterval,firingInterval);
|
||
//启动警告UI
|
||
isCencledToShowUI = false;
|
||
isStartedToShowUI = true;
|
||
//每隔一定时间进行警告,即替换UI图片
|
||
InvokeRepeating("ReplaceWarningUIImage",firingInterval - advanceTime,firingInterval);
|
||
}
|
||
}
|
||
|
||
//invoke执行,每隔一段时间改变警示UI的图片
|
||
void ReplaceWarningUIImage()
|
||
{
|
||
if(!isShooting)//如果没在开枪,则把图片改为挥下的
|
||
{
|
||
warningUI.sprite = done;
|
||
//播放警告音效
|
||
audioPlayer.clip = warningSounds[(int)Random.Range(0,warningSounds.Length)];
|
||
audioPlayer.volume = 0.8f;
|
||
audioPlayer.Play();
|
||
}
|
||
else
|
||
{
|
||
warningUI.sprite = ready;
|
||
}
|
||
}
|
||
|
||
void OnTriggerExit2D(Collider2D other)
|
||
{
|
||
if(other.tag == "Player")
|
||
{
|
||
//当玩家退出监视区,取消扫射的Invoke
|
||
CancelInvoke("ShootOrStopShoot");
|
||
CancelInvoke("ReplaceWarningUIImage");
|
||
isCencledToShowUI = true;
|
||
isStartedToShowUI = false;
|
||
warningUI.sprite = ready;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
//定时触发,反正就是更改射击状态,射到不射或者不射到射
|
||
private void ShootOrStopShoot()
|
||
{
|
||
if(isShooting)//如果在开火
|
||
{
|
||
blockHouseAudio.Stop();
|
||
blackHouseGunLight.isFire = false;
|
||
isShooting = false;//别让它开了
|
||
//关闭所有动画组件的开火动画
|
||
foreach(Animator fire in fireAnimations)
|
||
{
|
||
fire.SetBool("IsFiring",false);
|
||
}
|
||
}
|
||
else//如果没在开火
|
||
{
|
||
blockHouseAudio.Play();
|
||
blackHouseGunLight.isFire = true;
|
||
isShooting = true;//标记让它开火
|
||
|
||
//打开所有动画组件的开火动画
|
||
foreach(Animator fire in fireAnimations)
|
||
{
|
||
fire.SetBool("IsFiring",true);
|
||
}
|
||
}
|
||
}
|
||
//正在射击的时候触发,每帧检测是否被击中
|
||
private void Shooting()
|
||
{
|
||
foreach(ShootingArea s in shootingAreas)
|
||
{
|
||
if(s.IsPlayerHere())
|
||
{
|
||
Debug.Log("玩家被击中!");
|
||
}
|
||
}
|
||
}
|
||
|
||
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;}//返回玩家是否在这个射击区内的结果
|
||
}
|
||
|
||
}
|