项目实训-幽灵僵尸

幽灵僵尸,该僵尸可以无视地形,但是没有攻击

代码

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();
                //BOSSLVmanager.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);
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值