示例#1
0
文件: JumpState.cs 项目: kidundead/ow
        public override void NextState(Enemy enemy, float deltaTime, Player player)
        {
            if (enemy.HP <= 0)
            {
                enemy.OnDead();
                enemy.SetState(Enemy.DEAD_STATE);
                return;
            }

            Transform enemyTransform = enemy.GetTransform();

            Hunter hunter = enemy as Hunter;

            if (hunter != null)
            {
                if (hunter.Jump(deltaTime))
                {
                    hunter.SetState(Hunter.IDLE_STATE);
                }
                else
                {
                    if (!hunter.JumpEnded)
                    {
                        hunter.Animate(AnimationName.ENEMY_JUMPING, WrapMode.Loop);
                    }
                }
            }
        }
示例#2
0
        public override void NextState(Enemy enemy, float deltaTime, Player player)
        {
            if (enemy.HP <= 0)
            {
                enemy.OnDead();
                enemy.SetState(Enemy.DEAD_STATE);
                return;
            }

            Hunter hunter = enemy as Hunter;

            enemy.Animate(AnimationName.ENEMY_IDLE, WrapMode.Loop);
            enemy.GetTransform().LookAt(player.GetTransform());
            //hunter.Patrol(deltaTime);
            if (hunter.LookAroundTimOut())
            {
                if (hunter.ReadyForJump())
                {
                    int rnd = Random.Range(0, 100);
                    if (rnd < 100)
                    {
                        hunter.StartJump();

                        hunter.SetState(Hunter.JUMP_STATE);
                    }
                    else
                    {
                        hunter.SetState(Hunter.CATCHING_STATE);
                    }
                }
                else
                {
                    hunter.SetState(Hunter.CATCHING_STATE);
                }
            }
        }