Warcorrespondents/Assets/Scripts/事件/VeteranSacrifice.cs
Roman 93808cc53b 任务:替换现有美术素材和动画、完善游戏的流程化
场景【第一关】
1.使得事件【老兵牺牲】只会被触发一次
2.调节层数,解决角色手穿模的问题
3.放置碉堡美术素材
4.使碉堡开枪的时候地面上出现枪光
5.制作AC【挡板枪光】
6.制作AM【挡板枪光】
7.适配挡板枪光动画,使碉堡开枪的时候挡板出现枪光动画。
8.制作UI层,碉堡警告,其具有功能:
(1.当玩家进入警戒区,UI层以卷轴方式卷开
(2.当碉堡开火的前若干秒,让UI层的图片挥手表示进攻
(3.攻击结束后,替换UI层图片为预备态
(4.当玩家离开警戒区,以出现时同样的方式卷回UI层
9.布置好了第一关碉堡处的地雷和投掷物
10.调整了地雷的层数,使得其爆炸动画能够遮挡玩家
11.控制了摄像机的移动范围
12.更新了电报机界面
13.解决了通过爆炸产生的投掷物堆投掷无力的问题
14.解决了老兵牺牲后的穿模问题
15.更新对话框样式
16.更新对话头像
17.更新机枪手监测范围,使玩家落入坑中后才开始开枪
18.(暂无)添加事件【打完电码后】,包含以下内容:
(1.关闭电报机界面
(2.在玩家周围生成一颗导弹
(3.导弹炸不到玩家,但是仍触发玩家被炸死的动画,表示被震晕
(4.逐渐聚焦到玩家,若干时间后突然屏幕全黑
(5.转移到场景【第二关】
2021-09-02 22:06:12 +08:00

87 lines
3.4 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;
private bool hasBeenOnCall;//记录事件是否被触发的变量
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");
//*让老兵转个身放置牺牲后穿模
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(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;
//9.标记自己已经被触发过
hasBeenOnCall = true;
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Player")
{
//当玩家进入事件范围内
if(!hasBeenOnCall)StartCoroutine("SelfOnCall");
}
}
}