public EnemyState HandleInput(Elements.Enemy enemy, EStateInput input, EnemyState state)
        {
            switch (input)
            {
                case EStateInput.Move:
                    return new EnemyRunning(direction);
                case EStateInput.SwitchDir:
                    if (direction != 0)
                    {
                        enemy.velocity.X = 0;
                        direction = (EDirection)((int)direction * -1);
                    }
                    return state;
                case EStateInput.Dead:
                    return new EnemyDead();
                case EStateInput.Hit:
                    break;
                case EStateInput.AnimEnd:

                    break;
                case EStateInput.PlayerCollision:
                    enemy.velocity = Vector2.Zero;
                    return new EnemyAttack(direction);
                case EStateInput.Stop:
                    if (state.GetType() != typeof(EnemyIdle))
                        return new EnemyIdle();
                    return this;
                default:
                    break;
            }
            return state;
        }
Example #2
0
 public Enemy(Vector2 _position, string _name) : base(_position, _name)
 {
     gravity = 0.2f;
     endTime = 300f;
     colorTimer = endTime + 1;
     state = new States.Enemy.EnemyIdle();
     animStarts = Managers.AssetManager.GetAnimIndexes(name)[0];
     animEnds = Managers.AssetManager.GetAnimIndexes(name)[1];
     animStarts = new List<Point>();
     animEnds = new List<Point>();
     animStarts = Managers.AssetManager.GetAnimIndexes(name)[0];
     animEnds = Managers.AssetManager.GetAnimIndexes(name)[1];
     NewAnimation(state.animState);
     flip = SpriteEffects.None;
     knockbackSpeed = 2f;
     heart = Managers.AssetManager.GetTextureAsset("Heart");
 }
Example #3
0
 public void SendStateInput(States.Enemy.EStateInput input)
 {
     if (input == States.Enemy.EStateInput.Stop)
         velocity = Vector2.Zero;
     States.Enemy.EnemyState newState = state.HandleInput(this, input);
     if (state.GetType() != newState.GetType())
     {
         state = state.HandleInput(this, input);
         NewAnimation(state.animState);
     }
 }