Ejemplo n.º 1
0
        public Mario(Game1 game, Scene scene)
        {
            MarioFactory = new MarioFactory(game);
            currentSprite = (MarioSprite)MarioFactory.MakeProduct(1);
            powerupStateFactor = 0;
            actionStateFactor = 1;
            direction = 1;
            idle = new MarioIdleState(this);
            jump = new MarioJumpingState(this);
            walk = new MarioWalkingState(this);
            crouch = new MarioCrouchingState(this);
            fall = new MarioFallingState(this);
            standard = new MarioStandard(this);
            super = new MarioSuper(this);
            fire = new MarioFire(this);
            dead = new MarioDead(this);
            powerupState = standard;
            currentState = idle;
            previousState = currentState;
            previousSprite = currentSprite;
            this.game = game;
            this.scene = scene;
            gravity = scene.Gravity;

            isGrounded = false;

            points = 0;
            coins = 10;
            lives = 3;
            sounds = new SoundMachine(game);
        }
Ejemplo n.º 2
0
        public Mario(Game1 game, int posX, int posY)
        {
            MarioFactory = new MarioFactory(game);
            currentSprite = (MarioSprite)MarioFactory.MakeProduct(1);
            powerupStateFactor = 0;
            actionStateFactor = 1;
            direction = 1;
            idle = new MarioIdleState(this);
            jump = new MarioJumpingState(this);
            walk = new MarioWalkingState(this);
            crouch = new MarioCrouchingState(this);
            fall = new MarioFallingState(this);
            standard = new MarioStandard(this);
            super = new MarioSuper(this);
            fire = new MarioFire(this);
            dead = new MarioDead(this);

            powerupState = standard;
            currentState = idle;
            previousState = currentState;
            previousSprite = currentSprite;

            marioVec.X = posX;
            marioVec.Y = posY;
        }
Ejemplo n.º 3
0
        private void CheckBorders()
        {
            if(this.CollisionBox.Max_Y >= 600 && !(this.currentState is MarioDead)) {
                this.marioVec.Y = 400;
                lives--;
                currentState = dead;
                if (lives > 0)
                {
                    Vector2 latestCheck = game.scene.FindLatestCheckpoint();
                    int life = lives;
                    game.ResetCommand();//Why isn't the theme music playing?
                    game.scene.mario.MarioVec = latestCheck;
                    game.scene.mario.Lives = life;
                }
                else
                {
                    game.scene.Mute();
                    sounds.PlayGameOver();
                    game.GameoverCommand();
                }
            }

            else if(this.CollisionBox.Min_X < 0) {
                this.marioVec.X = 0;
                this.marioVel.X = 0;
                this.marioAccel.X = 0;
            }

            else if(this.CollisionBox.Max_X >= 4000) {
                this.marioVec.X = 4000 - this.CollisionBox.Width;
                this.marioVel.X = 0;
                this.marioAccel.X = 0;
            }
        }
Ejemplo n.º 4
0
        public void ToWalk()
        {
            this.MarioAccel = new Vector2(marioAccel_X, 0);

            previousState = currentState;
            currentState = walk;
            previousSprite = currentSprite;
        }
Ejemplo n.º 5
0
        public void ToJump()
        {
            this.MarioVel = new Vector2(marioVel_X, -36);

            previousState = currentState;
            currentState = jump;
            previousSprite = currentSprite;
            if (this.powerupState.Factor() >= 10 ) {
                sounds.PlayBigJump();
            }
            else
            {
                sounds.PlaySmallJump();
            }
        }
Ejemplo n.º 6
0
 public void ToIdle()
 {
     previousState = currentState;
     currentState = idle;
     previousSprite = currentSprite;
     this.MarioVel = new Vector2(0, 0);
     this.MarioAccel = new Vector2(0, 0);
 }
Ejemplo n.º 7
0
 public void ToFall()
 {
     previousState = currentState;
     currentState = fall;
     previousSprite = currentSprite;
     this.MarioAccel = new Vector2(0, 5);
 }
Ejemplo n.º 8
0
 public void toDead()
 {
     currentState = dead;
     //How do we make time stop before reseting?
      //   if (lives > 1) {
      //        Vector2 latestCheck = game.scene.FindLatestCheckpoint();
      //        int life = lives;
      //        game.ResetCommand();//Why isn't the theme music playing?
      //        game.scene.mario.MarioVec = latestCheck;
      //        game.scene.mario.Lives = life;
      //   }
      //else {
      // game.scene.Mute();
      // sounds.PlayGameOver();
      // game.GameoverCommand();
      //   }
 }
Ejemplo n.º 9
0
 public void ToCrouch()
 {
     previousState = currentState;
     currentState = crouch;
     previousSprite = currentSprite;
 }
Ejemplo n.º 10
0
 public void ToWalk()
 {
     previousState = currentState;
     currentState = walk;
     previousSprite = currentSprite;
 }
Ejemplo n.º 11
0
 public void ToJump()
 {
     previousState = currentState;
     currentState = jump;
     previousSprite = currentSprite;
 }
Ejemplo n.º 12
0
 public void ToIdle()
 {
     previousState = currentState;
     currentState = idle;
     previousSprite = currentSprite;
 }
Ejemplo n.º 13
0
 public void toFall()
 {
     previousState = currentState;
     currentState = fall;
     previousSprite = currentSprite;
 }
Ejemplo n.º 14
0
 public void toDead()
 {
     currentState = dead;
 }