public Mario(uint playerNumber, int x, int y) { Tag = (int)playerNumber; marioPhysics = new MarioPhysics(this); stateMachine = new MarioStateMachine(this, marioPhysics); marioCollisionHandler = new MarioCollisionHandler(this, stateMachine, marioPhysics); marioPhysics.GetStateMachineInstance(); RestrictMovement = false; position.X = x; position.Y = -y; orignalPos[0] = (int)position.X; orignalPos[1] = -(int)position.Y; MarioEvents.OnReset += Reset; //Subscribe to keyboard events based on player number. Indexed from 0, so 0 = player 1, 1 = player 2, etc. if (playerNumber == 1) { MarioEvents.OnP2MoveLeft += MoveLeft; MarioEvents.OnP2MoveRight += MoveRight; MarioEvents.OnP2Jump += Jump; MarioEvents.OnP2Crouch += Crouch; MarioEvents.OnP2ShootFire += MarioFireProjectile; } else { MarioEvents.OnP1MoveLeft += MoveLeft; MarioEvents.OnP1MoveRight += MoveRight; MarioEvents.OnP1Jump += Jump; MarioEvents.OnP1Crouch += Crouch; MarioEvents.OnP1ShootFire += MarioFireProjectile; } }
public MarioCollisionHandler(Mario player, MarioStateMachine marioState, MarioPhysics physics) { state = marioState; mario = player; marioPhysics = physics; }
internal void GetStateMachineInstance() { stateMachine = mario.stateMachine; }