Roman d61a850951 *合并了SAIPOVersion
任务:实装和完善部分音效,修复场景问题
1.增加走路时的脚步声音效
2.将Listener转移到玩家身上防止立体声出现问题
3.删除了跑步扬尘效果
4.增加了跑步时的脚步声音效
5.加快了跑步动画为原来的1.2倍,使之步频加快,看起来更加真实。
6.加快了导弹的下落速度,但是加长了导弹的下落前阴影提示时间
7.加强了阴影的闪烁幅度和宽度
8.提高了阴影的阿尔法值
9.提高了修完第一根电报线后生成导弹的高度,防止其漏个头出来
10.添加了修复电报线的音效
11.添加了打开任务书的音效
12.削弱地雷音效的3D特性,使得其爆炸时音量不至于过小
13.增加了爬坑音效
14.修复了电报机音效
15.降低了电报机音量
16.增加了跳下坑的音效
17.关闭了战场背景音的3D特性
18.调整了水流音效的影响范围和衰弱等级
19.降低了水流声的音量
(*:拾取投掷物的音效过于机械,建议更换
20.实装了投掷系统的音效(拾取物品、丢出物品、投掷物着地)
(*:着地音效太重了,而投掷物是很轻的石块
(*:投出音效太假了,像是什么棍子挥动的声音
2021-09-09 00:59:27 +08:00

162 lines
5.1 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;//获取碉堡枪光的脚本
void Start()
{
shootingAreas = new ShootingArea[transform.childCount];
for(int i = 0; i < transform.childCount; i++)
{
shootingAreas[i] = transform.GetChild(i).
gameObject.AddComponent<ShootingArea>();//给每个子物体挂上射击区的脚本
//并且把它的脚本送到数组里面,免去以后再遍历拖慢速度
}
}
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);
}
}
void ReplaceWarningUIImage()
{
if(!isShooting)
{
warningUI.sprite = done;
}
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;}//返回玩家是否在这个射击区内的结果
}
}