Roman 01a670fb19 任务:实装和完善部分音效,修复场景问题
1.实装玩家回头查看老兵出发对话的情节
2.降低了打开电报机音效的音量
3.更换第二段CG,实现淡入淡出效果
4.当玩家还没修完电话线就和电报机互动,触发对话【没修完呢】
5.将新的出字音效实装到每一个场景
6.解决如果玩家投掷过快会导致无法退出投掷状态的Bug
7.实装大部分BGM
8.给序章战场的假电报机也加上没连完线的对话
9.新增开发者捷径,如果输入。。--。直接判定打完全部句子

(*:建议把碉堡发令员的指挥做成动态的
(*:第二关的炮火已经越来越好了,但是目前只有炮火,晚上肯定也会开枪吧?希望增加一些随机快速闪烁的光源表示晚上的枪。
(*目前碉堡音效出现和消失得十分突然,建议在首尾稍微加一些淡入淡出效果
(*:建议把倒地后的机枪手也加上调查对话

xx:人声问题请待定,加上音乐后好像又不是很违和了
(*:碉堡警告音效系统做完了,但是人声感觉上非常奇怪,建议修改
(*:敌人被石头吸引系统实装完成,但是很突兀,建议还是不要出现语言了

接下来的任务:
1.实装按键引导
2.更换投掷物堆系统为火堆系统
3.实装第二关最后追逐关卡
4.制作开始界面
5.制作Thanks 4 Play

能看到效果的努力,这回有动力了吧?加油吧
2021-09-12 02:19:08 +08:00

105 lines
3.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MachineGunner : MonoBehaviour
{
//机枪手类,控制检测前方一片区域的敌人
// Start is called before the first frame update
private bool hasBeHit = false;//是否已被打中
private Animator person;
private Animator gun;//声明两个部件的动画组件
private Animator groundFireAnimation;
private Animator groundFireAnimation2;
private Animator gunFireAnimation;
[Tooltip("请拖入第二个上坑点的游戏物体,将在敌人被击晕后激活这个上坑点")]
public GameObject UpPoint2;
public AudioSource gunnerAudio;//获取机枪音效
[Tooltip("请拖入挡墙石头的碰撞体")]
public PolygonCollider2D stone;//
public GunLight gunLight;//枪口的光闪烁控制脚本
[Tooltip("拖入老兵旁边的投掷物堆")]
public BoxCollider2D heap;
void Start()
{
person = transform.Find("敌人").GetComponent<Animator>();
gun = transform.Find("机枪").GetComponent<Animator>();
groundFireAnimation = transform.Find("地面枪光").GetComponent<Animator>();
groundFireAnimation2 = transform.Find("地面枪光2").GetComponent<Animator>();
gunFireAnimation = transform.Find("枪口枪光").GetComponent<Animator>();//找到部件的动画组件
}
// Update is called once per frame
void Update()
{
}
//触发器是敌人的前方监测区域,当玩家进入检测区域,机枪手进入射击状态,目前用变红表示
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player" && !hasBeHit)//同时需要满足未被击中这个条件
{
//GetComponent<SpriteRenderer>().color = Color.red;
//播放开火动画
gunnerAudio.Play();
gunLight.isFire = true;
person.SetBool("IsFiring",true);
gun.SetBool("IsFiring",true);
groundFireAnimation.SetBool("IsFiring",true);
groundFireAnimation2.SetBool("IsFiring",true);
gunFireAnimation.SetBool("IsFiring",true);
}
}
//当玩家退出检测区域,停止射击状态,变为通常状态,现在用白色表示
void OnTriggerExit2D(Collider2D other)
{
if(other.tag == "Player")
{
//GetComponent<SpriteRenderer>().color = Color.white;
//关闭开火动画
person.SetBool("IsFiring",false);
gun.SetBool("IsFiring",false);
groundFireAnimation.SetBool("IsFiring",false);
groundFireAnimation2.SetBool("IsFiring",false);
gunFireAnimation.SetBool("IsFiring",false);
}
}
//碰撞体是机枪手自身的碰撞体,如果被投掷物砸中,则陷入昏迷状态,目前用绿色表示
void OnCollisionEnter2D(Collision2D other)
{
if(other.gameObject.tag == "投掷物")
{
gunLight.isFire = false;
gunnerAudio.Stop();//关闭音效
hasBeHit = true;//标记自身已被击中
//关闭开火动画
gun.SetBool("IsFiring",false);
groundFireAnimation.SetBool("IsFiring",false);
groundFireAnimation2.SetBool("IsFiring",false);
gunFireAnimation.SetBool("IsFiring",false);
//播放死亡动画
person.SetBool("IsDead",true);
//把上坑点2激活
UpPoint2.SetActive(true);
//关闭自身碰撞体
foreach(BoxCollider2D collider in GetComponents<BoxCollider2D>())
{
collider.enabled = false;
}
//关闭挡枪石头的碰撞体
stone.enabled = false;
//关闭投掷物堆的触发器
heap.enabled = false;
}
}
public bool AreYouOK(){return !hasBeHit;}//返回机枪手状态是否良好,如果被打,则返回状态不好
}