Warcorrespondents/Assets/Scripts/事件/VeteranSacrifice.cs
Roman f65f199aee 任务:替换现有美术素材和动画、完善游戏的流程化
*修复状态机蜜汁Bug
【序章-家中】
1.替换【序章-家中】场景中的场景图,使得藏水缸的坑存在
2.替换水缸后面的隐藏的电报机的贴图
3.替换第二段CG
4.替换对话框角色美术素材和对话框美术素材
5.替换电报机界面美术素材
6.创建AC【电报机翻页】
7.制作逐帧动画【电报机翻页】
8.适配动画,使得监测到清除语句时执行【电报机翻页】动画

【第一关】
1.调整机枪手位置,防止其一只脚在外面
2.调整机枪手层数,使得其能完全遮挡玩家
3.删除楼梯
4.修改地形,使得玩家可以过桥
5.修改敌人碰撞体,使得其更贴近骨骼
6.创建事件【老兵牺牲】,其包含以下流程:
(1.关闭玩家操作地图
(2.移动相机至老兵位置
(3.召唤一颗导弹在老兵头顶
(4.导弹下落爆炸
(5.老兵被炸后播放死亡动画
(6.主角转身
(7.相机移回主角处
(8.恢复玩家操作地图
2021-09-02 02:02:32 +08:00

75 lines
2.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using Cinemachine;
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;
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()
{
//1.关闭玩家操作地图
FindObjectOfType<PlayerInput>().SwitchCurrentActionMap("NullMap");
//2.移动相机至老兵位置
target = new Vector3(-19.8600006f,-0.600000024f,-10f)*3;
//3.召唤一颗导弹在老兵头顶
Shell thisShell = Instantiate(shell,new Vector3(43.9799995f,10.01999998f,0),Quaternion.identity).
GetComponent<Shell>();
thisShell.M_BombingArea = bombingArea;
thisShell.YouAreSpecal();
//4.打开老兵的碰撞体,等待播放完毕老兵死亡动画
FindObjectOfType<Veteran>().GetComponent<BoxCollider2D>().isTrigger = false;
//5.若干秒后,使镜头返回主角,顺便让主角转个身
yield return new WaitForSeconds(5f);
FindObjectOfType<M_Player>().TurnAround();
target = origin;
//7.恢复玩家操作地图
FindObjectOfType<PlayerInput>().SwitchCurrentActionMap("PlayerNormal");
//8.关闭老兵碰撞体方便玩家回头查看
FindObjectOfType<Veteran>().GetComponent<BoxCollider2D>().isTrigger = true;
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
//当玩家进入事件范围内
StartCoroutine("SelfOnCall");
}
}
}