Roman 19dc0fd822 任务:制作引导系统、修复疑难杂症
1.修复开门演出开幕对话出字音效问题
2.修复序章-家中 角色长大后骨骼同时出现两只手的问题
3.修复第一关 无人说话出字音效错误的问题
4.修复了顺序下来导弹下落速度错误的问题
5.增大地雷音量并加入镜头震动以彰显其威力
6.更换任务书美术素材
7.更换密码本美术素材
8.加入移动操作引导
9.加入交互操作引导
10.加入打码操作引导
11.删除了序章打码关中的句子【八路军】
12.替换对话框下一句按钮
13.加入了奔跑操作引导

(*:第二关的炮火已经越来越好了,但是目前只有炮火,晚上肯定也会开枪吧?希望增加一些随机快速闪烁的光源表示晚上的枪。
(*:建议给倒地后的机枪手也加上调查对话
(*:建议更换【序章-家中】的远处的天空,并加上视差
(*:建议增加机枪手处石堆被击动画,可以是抖动,也可以是扬起一些灰尘之类的

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

接下来的任务:
1.完成按键引导系统
2.更换投掷物堆系统为火堆系统
3.实装第二关最后追逐关卡
4.制作开始界面
5.制作Thanks 4 Play
6.电报系统、打完划掉、显示翻译数字序列
2021-09-13 00:34:06 +08:00

170 lines
5.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;
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.5f;
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;}//返回玩家是否在这个射击区内的结果
}
}