本篇介绍对僵尸基类的完善以及增添旗帜僵尸,路障僵尸,铁桶僵尸。
对于僵尸的死亡如果主要分为炸死和被射手攻击死亡两种,对应了不同的死亡动画实现,如果是正常被射手炸死则创建一个只有身体的动画,将之前的僵尸动画进行删除。
对于旗帜僵尸而言需要在接近死亡值时转化为只剩身体的动画。
public override void OnDead()
{
if (!isSpecialDie)
{// 创建一个死亡身体
Zombie_DieBody body = PoolManager.Instance.GetObj(GameManager.Instance.GameConf.Zombie_DieBody).GetComponent<Zombie_DieBody>();
body.Init(animator.transform.position);
}
}
同时需要对僵尸是否头部掉落进行检测。
private void CheckLostHead()
{
if (!isLostHead)
{
// 头需要失去
isLostHead = true;
// 创建一个头
Zombie_Head head = PoolManager.Instance.GetObj(GameManager.Instance.GameConf.Zombie_Head).GetComponent<Zombie_Head>();
head.Init(animator.transform.position);
// 状态检测
CheckState();
}
}
对于路障僵尸以及铁桶僵尸则需要在接近一定生命值时销毁之前动画并创建出一个身体然后进行生成一个普通僵尸然后再将其作为普通僵尸进行攻击。
public void HpStateEvent()
{
// 先召唤一个普通僵尸
Zombie zombie = ZombieManager.Instance.CreatStandZombie((int)currGrid.Point.y, transform.position);
// 同步动画
zombie.InitForOhterZombieCreat(animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
// 自身死亡-不涉及到动画,直接消失
State = ZombieState.Dead;
}