public override void Enter(StateMario previousState)
 {
     base.Enter(previousState);
     this.StateMachine.Mario.SetSpriteState(SpriteStates.Sprites.JUMPING);
     this.StateMachine.Mario.Info.velocity.Y = -8.5f;
     SoundFactory.PlaySoundEffect(SoundFactory.Jump());
 }
Exemple #2
0
        public override void Enter(StateMario previousState)
        {
            base.Enter(previousState);

            this.StateMachine.Mario.SetSpriteState(SpriteStates.Sprites.JUMPING);
            this.StateMachine.Mario.Info.velocity.Y = .05f;
        }
        public override void Enter(StateMario previousState)
        {
            base.Enter(previousState);

            this.StateMachine.Mario.SetSheetState(SpriteStates.Sheets.NORMAL);
            this.StateMachine.Mario.SetSpriteState(SpriteStates.Sprites.DEAD);
            this.StateMachine.Mario.Info.velocity = new Vector2(0f, -8f);

            MediaPlayer.Stop();
            SoundEffect dying = SoundFactory.Death();

            SoundFactory.PlaySoundEffect(dying);
            Task.Factory.StartNew(delegate() {
                Console.WriteLine("Waiting {0}ms before resetting", dying.Duration.Milliseconds * 10);
                Thread.Sleep(dying.Duration.Milliseconds * 10);

                this.StateMachine.Mario.lives--;

                if (this.StateMachine.Mario.lives > 0)
                {
                    Console.WriteLine("Resetting after next update loop");
                    this.StateMachine.Mario.SetSpriteState(SpriteStates.Sprites.IDLE);
                    this.StateMachine.Mario.game.RunAfterUpdate = this.StateMachine.Mario.game.Reset;
                }
                //else, mediaplayer remains stopped
            });
        }
 public override void Enter(StateMario previousState)
 {
     base.Enter(previousState);
     this.StateMachine.Mario.SetSpriteState(SpriteStates.Sprites.IDLE);
     this.StateMachine.Mario.Info.acceleration = Vector2.Zero;
     this.StateMachine.Mario.Info.velocity     = Vector2.Zero;
 }
Exemple #5
0
        public override void Enter(StateMario previousState)
        {
            base.Enter(previousState);

            this.StateMachine.Mario.SetSpriteState(SpriteStates.Sprites.WALKING);
            this.StateMachine.Mario.Info.velocity.X     = this.previousX;
            this.StateMachine.Mario.Info.acceleration.X = 0.2f;
        }
Exemple #6
0
        public virtual void Enter(StateMario previousState)
        {
            if (previousState != null)
            {
                Console.WriteLine("Mario ActionState {0} -> {1}", previousState.GetType().Name, this.GetType().Name);
                previousState.Exit();
            }

            this.StateMachine.CurrentState = this;
            this.StateMachine.CurrentState.PreviousState = previousState;
        }
        public StateMachineMarioAction(SpriteMario mario)
        {
            this.Mario = mario;

            this.Idle    = new StateMarioIdle(this);
            this.Walking = new StateMarioWalking(this);
            this.Jump    = new StateMarioJump(this);
            this.Dead    = new StateMarioDead(this);
            this.Falling = new StateMarioFalling(this);

            this.CurrentState = this.Idle;
            this.CurrentState.Enter(null);
        }