幽灵僵尸,该僵尸可以无视地形,但是没有攻击
代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class Ghost : ZombieBase
{
protected override int MaxHP => 270;
protected override float speed => 1.5f;
protected override GameObject Prefab => GameManager.Instance.GameConf.Ghost;
protected override bool isSpecial => true;
public override void SpecialMove()
{
if (isSpeedUp) { nowSpeed = speed / SpeedRatio; StartCoroutine(StopSpeedUp()); }
else nowSpeed = speed;
if (spriteRenderer.color == new Color(0.16f, 0.17f, 0.74f)) nowSpeed = nowSpeed * 2;
else nowSpeed = nowSpeed;
if (currGrid == null) return;
currGrid = GridManager.Instance.GetGridByWorldPos(transform.position + (Vector3)offset);
if (currGrid.Point.x == 0 && currGrid.Position.x - transform.position.x - ((Vector3)offset).x > 1f)
{
Vector2 pos = transform.position + (Vector3)offset;
Vector2 target = new Vector2(-9.17f, -1.37f);
Vector2 dir = (target - pos).normalized * 3f;
transform.Translate((dir * (Time.deltaTime / 1)) / nowSpeed);
if (Vector2.Distance(target, pos) < 0.05f)
{
LVManager.Instance.GameOver();
}
return;
}
transform.Translate((new Vector2(-1.33f, 0) * (Time.deltaTime / 1)) / nowSpeed);
}
public override void InitZombieHpState()
{
zombieHpState = new ZombieHpState(
0,
new List<int>() { MaxHP },
new List<string>() { "Ghost_Walk" },
new List<string>() { "" },
new List<UnityAction>() { null }
);
}
public override void OnDead()
{
if (!isSpecialDie)
{
Ghost_Diebody body = PoolManager.Instance.GetObj(GameManager.Instance.GameConf.Ghost_Diebody).GetComponent<Ghost_Diebody>();
body.Init(animator.transform.position);
}
}
}