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

178 lines
7.2 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 Cinemachine;
public class Shell : MonoBehaviour
{
//炮弹类,控制轰炸区内的炮弹和炮弹的阴影🎇
// Start is called before the first frame update
public GameObject shadow;//阴影游戏物体
private Transform ground;//地面的位置信息
private float shellSpeed;//炮弹速度
private IndexRecoder indexRecoder;
private float fallingTime;
private bool isDroping = false;
private Transform m_shadow;
public GameObject boomObj;
public BombingArea M_BombingArea;
private bool amISpecal = false;//记录自己是不是特殊的的变量。特殊的炮弹才能炸烂石头。
private Animator animator;
private delegate float BuildAFitX(float deleta);
[Tooltip("请填入阴影的最大值")]
public float MaxShadowSize;
[Tooltip("请填入阴影的最小值")]
public float MinShadowSize;
public Animator target;//如果是特殊炮弹则有targe这个变量当这个炮弹爆炸触发目标的死亡动画
public AudioSource boomAudio;//航弹爆炸音效
public GameObject boomLight;//航弹爆炸光效
private CinemachineImpulseSource impulseSource;//镜头震动呼出者
void Start()
{
indexRecoder = FindObjectOfType<IndexRecoder>();
shellSpeed = indexRecoder.shellSpeed;
fallingTime = indexRecoder.shellFallingTime;
ground = GameObject.FindWithTag("地面").transform;
if(!amISpecal)//特殊炮弹不予阴影
{
m_shadow = Instantiate(shadow,//生成一片阴影
new Vector3(transform.position.x,//在这枚炮弹的X
ground.transform.position.y + //地面的Y
M_BombingArea.shellShadowYOffset,//加上偏移量
0),
Quaternion.identity)
.transform;
}
Invoke("Drop",fallingTime);
Invoke("DestroySelf",10f);
animator = GetComponent<Animator>();
impulseSource = GetComponent<CinemachineImpulseSource>();
}
// Update is called once per frame
void Update()
{
if(m_shadow != null) ShadowShock();
if(isDroping)
{
transform.position -= new Vector3(0,shellSpeed*Time.deltaTime,0);
}
}
public bool AmISpecal(){return amISpecal;}//外部调用,返回这个炮弹是不是特殊的
public void YouAreSpecal(){amISpecal = true;}//外部调用,生成炮弹时,给其标记它是特殊的。
//控制阴影变化的函数,每帧调用一次
private void ShadowShock()
{
//首先构造一个本帧变化x
BuildAFitX buildAFitX = (float deleta)
=>
{
float newX = m_shadow.transform.localScale.x + deleta;
if(newX > MinShadowSize && newX < MaxShadowSize)
{return newX;}
else return m_shadow.transform.localScale.x;
};
float x = buildAFitX(Random.Range(-indexRecoder.shellShadowRangeOfChange,
indexRecoder.shellShadowRangeOfChange));
//使得本地大小改变为
m_shadow.transform.localScale = new Vector3(
//x
// m_shadow.localScale.x +
// Random.Range(-indexRecoder.shellShadowRangeOfChange,
// indexRecoder.shellShadowRangeOfChange),
x
,
//yz不变
m_shadow.localScale.y,
m_shadow.localScale.z);
}
private void Drop()
{
isDroping = true;
}
public void DestroySelf()
{
//动画中调用,爆炸动画结束后删除自身和阴影
//由于音效需要,等炮弹动画结束后两秒才销毁物体
Invoke("DestoryInvoke",2f);
//销毁前还会存在一段时间。所以要关闭自身的触发器和图片
GetComponent<BoxCollider2D>().enabled = false;
GetComponent<SpriteRenderer>().enabled = false;
//还得把灯关了
boomLight.SetActive(false);
}
private void DestoryInvoke()
{
Destroy(gameObject);
}
void OnTriggerEnter2D(Collider2D other)
{
//Debug.Log(other.name);
//当炮弹爆炸根据目标物体的tag分化
switch (other.tag)
{
case "Player":
//玩家被炮弹击中
Debug.Log("玩家被炮弹击中");
break;
case "地面":
boomAudio.Play();
boomLight.SetActive(true);
//Destroy(m_shadow.gameObject);
//Destroy(gameObject);
Instantiate(boomObj, new Vector2(transform.position.x, transform.position.y),Quaternion.identity);
animator.SetBool("IsBoom",true);
if(m_shadow != null) Destroy(m_shadow.gameObject);
isDroping = false;
break;
case "石头":
// Destroy(m_shadow.gameObject);
// Destroy(gameObject);//摧毁炮弹
boomAudio.Play();
boomLight.SetActive(true);
animator.SetBool("IsBoom",true);
//Destroy(m_shadow.gameObject);
isDroping = false;
//如果自己是特殊的炮弹,则触发石头的程序段
if(amISpecal) other.GetComponent<Stone>().BeHitBySpecalShell();
break;
case "老兵":
animator.SetBool("IsBoom",true);
boomAudio.Play();
boomLight.SetActive(true);
isDroping = false;
other.transform.Find("老兵").GetComponent<Animator>().SetBool("IsBoomDead",true);//执行老兵被炸死动画
break;
// case "电报机":
// animator.SetBool("IsBoom",true);
// isDroping = false;//播放爆炸动画
// FindObjectOfType<M_Player>().GetComponent<Animator>().
// SetBool("IsBoomDead",true);//播放玩家被炸死动画
// FindObjectOfType<AfterCoding>().OnDeadAnimation();
// break;
case "爆炸点":
boomAudio.Play();
boomLight.SetActive(true);
animator.SetBool("IsBoom",true);
isDroping = false;//播放爆炸动画
FindObjectOfType<AfterCoding>().OnDeadAnimation();
break;
}
if(amISpecal) //如果自己是特殊炸弹,则要考虑触发目标的死亡动画
{
if(target!=null)target.SetBool("IsBoomDead",true);
}
impulseSource.GenerateImpulse();
}
}