public Megaman(ContentManager content) { buster = new Buster(this); actionStateMachine = new MegamanActionStateMachine(this); powerUpStateMachine = new MegamanPowerUpStateMachine(this); spriteFactory = new MegamanSpriteFactory(content); currentActionState = actionStateMachine.GetActionState(ActionState.Idle); currentPowerUpState = powerUpStateMachine.getState(MegamanState.Small); currentSprite = spriteFactory.GetSprite(MegamanStateHelper.GetState(currentActionState, currentPowerUpState)); currentSprite.Position = new Vector2(); initialPosition = new Vector2(); direction = MegamanState.Right; MaxHealth = 100; Health = MaxHealth; armor = 0; this.content = content; }
public IMegamanPowerUpState getState(MegamanState state) { MegamanState powerUpState = (MegamanState)((int)state & 0xFF00); switch (powerUpState) { case MegamanState.Small: if (!states.ContainsKey(MegamanState.Small)) { states.Add(MegamanState.Small, new MegamanSmallState(megaman)); } return states[MegamanState.Small]; case MegamanState.Large: if (!states.ContainsKey(MegamanState.Large)) { states.Add(MegamanState.Large, new MegamanLargeState(megaman)); } return states[MegamanState.Large]; case MegamanState.Zero: if (!states.ContainsKey(MegamanState.Zero)) { states.Add(MegamanState.Zero, new MegamanZeroState(megaman)); } return states[MegamanState.Zero]; case MegamanState.Falcon: if (!states.ContainsKey(MegamanState.Falcon)) { states.Add(MegamanState.Falcon, new MegamanFalconState(megaman)); } return states[MegamanState.Falcon]; case MegamanState.Dead: default: // TODO: This isn't very safe. What's a better way? Exception? if (!states.ContainsKey(MegamanState.Dead)) { states.Add(MegamanState.Dead, new MegamanDeadState()); } return states[MegamanState.Dead]; } }
public void Reset() { currentActionState = actionStateMachine.GetActionState(ActionState.Idle); currentPowerUpState = powerUpStateMachine.getState(MegamanState.Small); StateChanged(); currentSprite = spriteFactory.GetSprite(MegamanStateHelper.GetState(currentActionState, currentPowerUpState)); currentSprite.Position = initialPosition; direction = MegamanState.Right; Health = MaxHealth; }
public Sprite GetSprite(MegamanState state) { //TODO: Implement dictionary to keep these things in memory switch ((int)state & 0xFFFF) { case 0x0101: return new SmallIdle(content); case 0x0102: return new SmallRunning(content); case 0x0104: return new SmallJumping(content); //no crouching for small MM, should we set it to falling sprite? case 0x0108: return new SmallFalling(content); case 0x0110: return new SmallFalling(content); case 0x0201: return new LargeIdle(content); case 0x0202: return new LargeRunning(content); case 0x0204: return new LargeJumping(content); case 0x0208: return new LargeCrouching(content); case 0x0210: return new LargeFalling(content); case 0x0401: return new ZeroIdle(content); case 0x0402: return new ZeroRunning(content); case 0x0404: return new ZeroJumping(content); case 0x0408: return new ZeroCrouching(content); case 0x0410: return new ZeroFalling(content); case 0x0801: return new FalconIdle(content); case 0x0802: return new FalconRunning(content); case 0x0804: return new FalconJumping(content); case 0x0808: return new FalconCrouching(content); case 0x0810: return new FalconFalling(content); case 0x1001: case 0x1002: case 0x1004: case 0x1008: case 0x1010: return new Dead(content); case 0x81: case 0x82: case 0x84: case 0x88: default: return new Dead(content); } }