Warcorrespondents/Assets/Scripts/事件/VeteranSacrifice.cs
SAIPO 4e37998e72 *.合并了分支
1.处理了昨天提出的建议
 1)给第一个CG加上了音效,已经上传Coding
 2)给第一关添加了微弱的雨声
 3)触发老兵牺牲时添加了管弦乐
 4)发令员和敌人被吸引的音效已经裁剪完成,在Soundeffect文件夹里,罕见语音1-7
 5)添加了发报机启动和记录纸张被撕去的声音
 6)修正了第二关的视差组件
 7)稍微优化了第二关背景火光,但还需要再研究
 8)机枪开枪音效已经替换为更有力的
 9)修正了第二关夜晚的蟋蟀声音

2.二进制文件(音乐,图片等不能直接以文本表示的文件)无法参与分支合并,导致我这里程序改过的电报音乐还是之前的,建议以后处理这类文件直接添加新文件

3.对玩家回去看老兵事件的建议
  直接弹出对话
  1)......
  2)(肩章上面写着 八路军 中华民国28年度配用)
  3)可以休息了,同志。
  4)任务很紧急,要继续前进了。
2021-09-10 22:17:49 +08:00

97 lines
3.8 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.InputSystem;
using Cinemachine;
using UnityEngine.InputSystem.Processors;
public class VeteranSacrifice : Event
{
//事件:老兵牺牲
private CinemachineVirtualCamera M_Camera;//虚拟相机组件
private Vector3 origin;//原始相机追踪偏移量
private CinemachineTransposer cinemachineTransposer;//相机追踪数据结构
private Vector3 target;//目标偏移量,通过修改这个达到转移镜头的目的
[Tooltip("请填入镜头移动的速度")]
public float speed;
[Tooltip("要召唤,得先有,对吧?拖进炮弹的预制体")]
public GameObject shell;
[Tooltip("召唤的炮弹需要知道自己属于哪个轰炸区,请拖入其轰炸区")]
public BombingArea bombingArea;
private bool hasBeenOnCall;//记录事件是否被触发的变量
public WVParallax parallax;
public AudioSource deadAudio;
void Start()
{
M_Camera = FindObjectOfType<CinemachineVirtualCamera>();
cinemachineTransposer = M_Camera.GetCinemachineComponent<CinemachineTransposer>();
target = cinemachineTransposer.m_FollowOffset;
origin = target;
}
void FixedUpdate()
{
if(!target.Equals(cinemachineTransposer.m_FollowOffset))//当没到目标的时候才移动
{
//每帧都要使得相机的offset向目标移动
cinemachineTransposer.m_FollowOffset += (target - cinemachineTransposer.m_FollowOffset)*//目标偏移量
Time.fixedDeltaTime*//使其与时间无关
speed;//乘以速度
}
}
public IEnumerator SelfOnCall()
{
parallax.canParallax = false;
deadAudio.Play();
//1.关闭玩家操作地图
FindObjectOfType<PlayerInput>().SwitchCurrentActionMap("NullMap");
//*让老兵转个身防止牺牲后穿模
FindObjectOfType<Veteran>().transform.localScale = new Vector3(
//x
FindObjectOfType<Veteran>().transform.localScale.x*-1,
//y
FindObjectOfType<Veteran>().transform.localScale.y,
//z
FindObjectOfType<Veteran>().transform.localScale.z
);
//2.移动相机至老兵位置
target = new Vector3(-19.8600006f,-0.600000024f,-10f)*3;
//3.召唤一颗导弹在老兵头顶
Shell thisShell = Instantiate(shell,new Vector3(46.9799995f,10.01999998f,0),Quaternion.identity).
GetComponent<Shell>();
thisShell.M_BombingArea = bombingArea;
thisShell.YouAreSpecal();
// //4.打开老兵的碰撞体,等待播放完毕老兵死亡动画
// FindObjectOfType<Veteran>().GetComponent<BoxCollider2D>().isTrigger = false;
//*修改给炸弹的爆炸瞬间在此给这个炸弹赋予Animator的值然后在事件中触发对象的死亡动画
thisShell.target = FindObjectOfType<Veteran>().GetComponentInChildren<Animator>();
//5.若干秒后,使镜头返回主角,顺便让主角转个身
yield return new WaitForSeconds(5f);
FindObjectOfType<M_Player>().TurnAround();
target = origin;
//7.恢复玩家操作地图
FindObjectOfType<PlayerInput>().SwitchCurrentActionMap("PlayerNormal");
//8.关闭老兵碰撞体方便玩家回头查看
FindObjectOfType<Veteran>().GetComponent<BoxCollider2D>().isTrigger = true;
//9.标记自己已经被触发过
hasBeenOnCall = true;
parallax.canParallax = true;
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
//当玩家进入事件范围内
if(!hasBeenOnCall)StartCoroutine("SelfOnCall");
}
}
}