protected override void Initialize() { controllerList = new List<IController> { new KeyboardController() }; SpriteBatch = new SpriteBatch(GraphicsDevice); graphics.PreferredBackBufferHeight = (int)(Utility.SCREEN_WIDTH * Utility.CAMERA_SCALE); graphics.PreferredBackBufferWidth = (int)(Utility.SCREEN_HEIGHT * Utility.CAMERA_SCALE); graphics.ApplyChanges(); IsMouseVisible = true; Mario = new Mario(Vector2.Zero); Mario.CurrentState = new JumpingMarioState(true, Utility.SMALL, Mario); Components.Add(Mario); background = new BackgroundImageCollection(); Components.Add(background); delay = Utility.GAME_LOAD_DELAY; overlay = new Overlay(); Components.Add(overlay); CollisionDetectionManager.Initialize(); BoggusLoader.LoadQuotes("quotes.txt"); //level = new Level("Level1.csv"); //level = new InfiniteLevel(); Camera.Initialize(); SoundManager.Initialize(this); HighScore.Initialize(); BulletBillMachine.Initialize(this); if (initialLoadup) { CurrentGameState = GameState.LevelSelect; cursor = new Cursor(); levelSelect = new LevelSelectController(); levelSelectGP = new LevelSelectGamePadController(); } else { if (CurrentGameState != GameState.Lost) { CurrentGameState = GameState.Loading; } if (LevelIsInfinite) level = new InfiniteLevel(); else { level = new Level("Level1.csv"); Components.Add(new Collectibles.Rifle(Vector2.One * 200)); } } Paused = true; base.Initialize(); }
public static void Initialize() { EnemyList = new List<IEnemy>(); blockList = new List<IBlock>(); itemList = new List<ICollectible>(); projList = new List<IProjectile>(); toRemoveC = new List<ICollectible>(); toRemoveB = new List<IBlock>(); ToRemoveE = new List<IEnemy>(); toRemoveP = new List<IProjectile>(); mario = SprintFourGame.GetInstance().Mario; BumpDelay = Utility.ZERO; }
void InitializeObjects() { SpriteBatch = new SpriteBatch(GraphicsDevice); Mario = new Mario(new Vector2(400, 400)); Mario.CurrentState = new JumpingMarioState(true, 2, Mario); Components.Add(Mario); background = new BackgroundImageCollection(); Components.Add(background); overlay = new Overlay(); Components.Add(overlay); CollisionDetectionManager.Initialize(); level = new Level("Level1.csv"); //Camera must be initialized after Level Camera.Initialize(); SoundManager.Initialize(this); }
public Recticle() : base (SprintFourGame.GetInstance()) { player = SprintFourGame.GetInstance().Mario; Ammo = MAX_CLIP; DrawOrder = Utilities.Utility.RIFLE_DRAW_ORDER; }
public static bool PlayerBlockCollision(Mario player, IBlock sender, Vector2 direction, Rectangle playerOffsetBounds) { if (sender.BlockState is FlagpoleState) { sender.BlockState.ActivateBlock(direction, player); return false; } if (player.CurrentState is DeadMarioState) return true; Block block = sender as Block; if (block == null) return false; if (Math.Abs(direction.Length()) < Utility.DOUBLE_TOLERANCE) return false; direction.Normalize(); Vector2 newPosition = new Vector2(); if (direction.X < Utility.ZERO) { newPosition = new Vector2(block.Position.X + player.Bounds.Width, player.Position.Y); if (CollisionDetectionManager.BumpDelay == Utility.ZERO) { if ((block.BlockState is PipeRightBlockState || block.BlockState is StairBlockState) && player.OnGround) SoundManager.PlayBumpSound(); CollisionDetectionManager.BumpDelay = Utility.BUMP_DELAY; } } else if (direction.X > Utility.ZERO) { newPosition = new Vector2(block.Position.X - block.Bounds.Width, player.Position.Y); if (CollisionDetectionManager.BumpDelay == Utility.ZERO) { if ((block.BlockState is PipeLeftBlockState || block.BlockState is StairBlockState) && player.OnGround) { SoundManager.PlayBumpSound(); CollisionDetectionManager.BumpDelay = Utility.BUMP_DELAY; } } } else if (direction.Y < Utility.ZERO) { newPosition = new Vector2(player.Position.X, block.Position.Y - block.Bounds.Height); } else if (direction.Y > Utility.ZERO) { newPosition = new Vector2(player.Position.X, block.Position.Y + player.Bounds.Height); } if (Vector2.Subtract(player.Position, newPosition).Length() > block.Bounds.Width) return false; player.Position = newPosition; //cancel movement in x or y depending on how the brick was hit if (Math.Abs(direction.X) > Utility.DOUBLE_TOLERANCE) { player.Velocity *= Vector2.UnitY; } if(Math.Abs(direction.Y) > Utility.DOUBLE_TOLERANCE) { player.Velocity *= Vector2.UnitX; if (direction.Y < Utility.ZERO) { player.OnGround = true; player.CurrentState = Math.Abs(player.Velocity.X) < Utility.DOUBLE_TOLERANCE ? (MarioStateBase)new IdleMarioState(player.CurrentState.FacingRight, player.CurrentState.Row, player) : new RunningMarioState(player.CurrentState.FacingRight, player.CurrentState.Row, player); } } block.BlockState.ActivateBlock(direction, player); return true; }