
*:合并了SAIPOVersion 场景【第一关】 1.修复了动画文件丢失的问题 2.制作地面枪光AM 3.制作了机枪枪光AM *:匹配两处坑的深度和跳跃力度,避免出现跳不上去或者跳太高的问题 4.制作了机枪枪口AC 5.制作地面枪光AC 6.匹配机枪枪口枪光AC和AM,使开枪时播放枪光动画 7.修正玩家掉入坑内后的镜头偏移量 8.加入角色,老兵,使其始终处于待机动画 9.调整了老兵的层数,使得其不能遮挡玩家 10.添加老兵控制脚本,当玩家还没击晕敌人,若玩家想要冲锋上前,则触发对话,老兵转身阻止玩家。若玩家已经击晕敌人,则冲锋上前时不会强制触发对话,但如果玩家按了交互键,则弹出对话【你还挺有能耐】。 11.创建老兵对话形象(因为缺图先随意用了一张) 12.创建了对话【你想送命?】 13.实装了对话【你想送命?】 14.使玩家在砸晕敌人之前无法离开坑 15.使对话【你想送命?】只会触发一次 16.修改投掷系统框架,使得投掷力度成为public变量保存于投掷物堆中,而不是原来的保存在策划接口中 17.使敌人被击中后,播放被击动画,并且机枪停止射击 18.创建对话【你还挺有能耐】 19.给机枪手脚底加了一块地面,使得投掷物能够落在上面 20.给场景放上楼梯 21.布置类似上下坑的触发器,当玩家靠近自动播放下楼梯动画。 22.非常难写,明天再说吧,cnm
83 lines
3.2 KiB
C#
83 lines
3.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class MachineGunner : MonoBehaviour
|
|
{
|
|
//机枪手类,控制检测前方一片区域的敌人
|
|
// Start is called before the first frame update
|
|
private bool hasBeHit = false;//是否已被打中
|
|
private Animator person;
|
|
private Animator gun;//声明两个部件的动画组件
|
|
private Animator groundFireAnimation;
|
|
private Animator groundFireAnimation2;
|
|
private Animator gunFireAnimation;
|
|
[Tooltip("请拖入第二个上坑点的游戏物体,将在敌人被击晕后激活这个上坑点")]
|
|
public GameObject UpPoint2;
|
|
|
|
|
|
void Start()
|
|
{
|
|
person = transform.Find("敌人").GetComponent<Animator>();
|
|
gun = transform.Find("机枪").GetComponent<Animator>();
|
|
groundFireAnimation = transform.Find("地面枪光").GetComponent<Animator>();
|
|
groundFireAnimation2 = transform.Find("地面枪光2").GetComponent<Animator>();
|
|
gunFireAnimation = transform.Find("枪口枪光").GetComponent<Animator>();//找到部件的动画组件
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
//触发器是敌人的前方监测区域,当玩家进入检测区域,机枪手进入射击状态,目前用变红表示
|
|
void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
if(other.tag == "Player" && !hasBeHit)//同时需要满足未被击中这个条件
|
|
{
|
|
//GetComponent<SpriteRenderer>().color = Color.red;
|
|
//播放开火动画
|
|
person.SetBool("IsFiring",true);
|
|
gun.SetBool("IsFiring",true);
|
|
groundFireAnimation.SetBool("IsFiring",true);
|
|
groundFireAnimation2.SetBool("IsFiring",true);
|
|
gunFireAnimation.SetBool("IsFiring",true);
|
|
}
|
|
}
|
|
//当玩家退出检测区域,停止射击状态,变为通常状态,现在用白色表示
|
|
void OnTriggerExit2D(Collider2D other)
|
|
{
|
|
if(other.tag == "Player")
|
|
{
|
|
//GetComponent<SpriteRenderer>().color = Color.white;
|
|
//关闭开火动画
|
|
person.SetBool("IsFiring",false);
|
|
gun.SetBool("IsFiring",false);
|
|
groundFireAnimation.SetBool("IsFiring",false);
|
|
groundFireAnimation2.SetBool("IsFiring",false);
|
|
gunFireAnimation.SetBool("IsFiring",false);
|
|
}
|
|
}
|
|
//碰撞体是机枪手自身的碰撞体,如果被投掷物砸中,则陷入昏迷状态,目前用绿色表示
|
|
void OnCollisionEnter2D(Collision2D other)
|
|
{
|
|
if(other.gameObject.tag == "投掷物")
|
|
{
|
|
hasBeHit = true;//标记自身已被击中
|
|
//关闭开火动画
|
|
gun.SetBool("IsFiring",false);
|
|
groundFireAnimation.SetBool("IsFiring",false);
|
|
groundFireAnimation2.SetBool("IsFiring",false);
|
|
gunFireAnimation.SetBool("IsFiring",false);
|
|
//播放死亡动画
|
|
person.SetBool("IsDead",true);
|
|
//把上坑点2激活
|
|
UpPoint2.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public bool AreYouOK(){return !hasBeHit;}//返回机枪手状态是否良好,如果被打,则返回状态不好
|
|
|
|
}
|