本次加入了不死僵尸,只有被樱桃炸弹、火爆辣椒等一次性植物才能杀死,不然尸体会在短时间后复活
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class UnDieZombie : ZombieBase
{
protected override int MaxHP => 370;
private bool isRevive = false;
protected override float speed => 2;
protected override float attackValue => 100;
protected override GameObject Prefab => GameManager.Instance.GameConf.UnDieZombie;
protected override bool isSpecial => false;
public override void SpecialMove()
{
return;
}
public override void InitZombieHpState()
{
zombieHpState = new ZombieHpState(
0,
new List<int>() { MaxHP,40 },
new List<string>() { "UnDieZombieWalk", "UnDieZombieWalk" },
new List<string>() { "UnDieZombieAttack", "UnDieZombieAttack" },
new List<UnityAction>() { null ,CheckRevive}
);
}
public override void OnDead()
{
if (!isSpecialDie)
{
UnDieZombie_DieBody body = PoolManager.Instance.GetObj(GameManager.Instance.GameConf.UnDieZombie_Diebody).GetComponent<UnDieZombie_DieBody>();
body.Init(animator.transform.position);
}
}
private void CheckRevive()
{
if (!isRevive)
{
isRevive = true;
UnDieZombie_DieBody body = PoolManager.Instance.GetObj(GameManager.Instance.GameConf.UnDieZombie_Diebody).GetComponent<UnDieZombie_DieBody>();
body.Init(animator.transform.position);
}
State = ZombieState.Dead;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UnDieZombie_DieBody : MonoBehaviour
{
private Animator animator;
public bool isOVer;
private Grid currGrid;
public void Init(Vector2 pos)
{
animator = GetComponent<Animator>();
transform.position = pos;
isOVer = false;
animator.speed = 1;
currGrid = GridManager.Instance.GetGridByWorldPos(pos);
animator.Play("UnDieZombieDie");
}
void Update()
{
if (!isOVer && animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
{
animator.speed = 0;
isOVer = true;
Invoke("Destroy",10f);
}
}
private void Destroy()
{
ZombieManager.Instance.CreatUnDieZombie((int)currGrid.Point.y, transform.position);
CancelInvoke();
PoolManager.Instance.PushObj(GameManager.Instance.GameConf.UnDieZombie_Diebody, gameObject);
}
}