private bool StartGame() { if (State != GameState.Initial) { return(false); } State = GameState.Transition; trex.BeginJump(); _groundManager.Initialize(); _backroundManager.Initilaize(); return(true); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _sfxButtonPress = Content.Load <SoundEffect>(ASSET_NAME_SFX_BUTTON_PRESS); _sfxHit = Content.Load <SoundEffect>(ASSET_NAME_SFX_HIT); _sfxScoreReached = Content.Load <SoundEffect>(ASSET_NAME_SFX_SCORE_REACHED); _spriteSheetTexture = Content.Load <Texture2D>(ASSET_NAME_SPRITESHEET); _fadeInAnimation = new Texture2D(GraphicsDevice, 1, 1); _fadeInAnimation.SetData(new Color[] { Color.White }); _TRex = new TRex(_spriteSheetTexture, new Vector2(Trexpos, TrexYpos - TRex.TrexHeiht), _sfxButtonPress); _TRex.DrewOrder = 10; _InputController = new ImputController(_TRex); _groundmanager = new GroundManager(_spriteSheetTexture, _entityManager, _TRex); _entityManager.AddEntity(_TRex); _entityManager.AddEntity(_groundmanager); _groundmanager.Initialize(); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); var ballTexture = Content.Load <Texture2D>(ASSET_NAME_BALL); _ball = new BallEntity(ballTexture, new Vector2(BALL_POS_X, BALL_POS_Y)); _ballManager = new BallManager(_ball); var groundTexture = Content.Load <Texture2D>(ASSET_NAME_GROUND); _groundManager = new GroundManager(groundTexture, _ball, _entityManager); _ballInputController = new BallInputController(_ball); _scoreBoardFont = Content.Load <SpriteFont>(ASSET_NAME_SCORE_BOARD_FONT); _scoreBoard = new ScoreBoardEntity(_scoreBoardFont, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_Y), _ball); var wallTexture = Content.Load <Texture2D>(ASSET_NAME_WALL); _wallManager = new WallManager(wallTexture, _ball, _scoreBoard, _entityManager); _coinPickupSoundEffect = Content.Load <SoundEffect>(ASSET_NAME_COIN_PICKUP); _rotatingCoinAnimation = new TextureAnimation(); _coin0 = Content.Load <Texture2D>(ASSET_NAME_COIN_0); _coin1 = Content.Load <Texture2D>(ASSET_NAME_COIN_1); _coin2 = Content.Load <Texture2D>(ASSET_NAME_COIN_2); _coin3 = Content.Load <Texture2D>(ASSET_NAME_COIN_3); _coin4 = Content.Load <Texture2D>(ASSET_NAME_COIN_4); _rotatingCoinAnimation.AddFrame(_coin0, ROTATING_COIN_ANIMATION_FRAME_DURATION); _rotatingCoinAnimation.AddFrame(_coin1, ROTATING_COIN_ANIMATION_FRAME_DURATION * 2); _rotatingCoinAnimation.AddFrame(_coin2, ROTATING_COIN_ANIMATION_FRAME_DURATION * 3); _rotatingCoinAnimation.AddFrame(_coin3, ROTATING_COIN_ANIMATION_FRAME_DURATION * 4); _rotatingCoinAnimation.AddFrame(_coin4, ROTATING_COIN_ANIMATION_FRAME_DURATION * 5); _rotatingCoinAnimation.Play(); _coinManager = new CoinManager(_coin0, _ball, _scoreBoard, _entityManager, _coinPickupSoundEffect, _rotatingCoinAnimation); _entityManager.AddEntity(_ball); _entityManager.AddEntity(_ballManager); _entityManager.AddEntity(_groundManager); _entityManager.AddEntity(_scoreBoard); _entityManager.AddEntity(_wallManager); _entityManager.AddEntity(_coinManager); _groundManager.Initialize(); }
public bool Replay() { _ball.Initialize(); _wallManager.Reset(); _coinManager.Reset(); _scoreBoard.Reset(); _groundManager.Initialize(); return(true); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); _sfxButtonPress = Content.Load <SoundEffect>(ASSET_NAME_SFX_BUTTON_PRESS); _sfxHit = Content.Load <SoundEffect>(ASSET_NAME_SFX_HIT); _sfxScoreReached = Content.Load <SoundEffect>(ASSET_NAME_SFX_SCORE_REACHED); _spriteSheetTexture = Content.Load <Texture2D>(ASSET_NAME_SPRITESHEET); _invertedSpriteSheet = _spriteSheetTexture.InvertColors(Color.Transparent); _fadeInTexture = new Texture2D(GraphicsDevice, 1, 1); _fadeInTexture.SetData(new Color[] { Color.White }); _trex = new Trex(_spriteSheetTexture, new Vector2(TREX_START_POS_X, TREX_START_POS_Y - Trex.TREX_DEFAULT_SPRITE_HEIGHT), _sfxButtonPress); _trex.DrawOrder = 100; _trex.JumpComplete += trex_JumpComplete; _trex.Died += trex_Died; _scoreBoard = new ScoreBoard(_spriteSheetTexture, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_Y), _trex, _sfxScoreReached); //_scoreBoard.Score = 498; //_scoreBoard.HighScore = 12345; _inputController = new InputController(_trex); _groundManager = new GroundManager(_spriteSheetTexture, _entityManager, _trex); _obstacleManager = new ObstacleManager(_entityManager, _trex, _scoreBoard, _spriteSheetTexture); _skyManager = new SkyManager(_trex, _spriteSheetTexture, _invertedSpriteSheet, _entityManager, _scoreBoard); _gameOverScreen = new GameOverScreen(_spriteSheetTexture, this); _gameOverScreen.Position = new Vector2(WINDOW_WIDTH / 2 - GameOverScreen.GAME_OVER_SPRITE_WIDTH / 2, WINDOW_HEIGHT / 2 - 30); _entityManager.AddEntity(_trex); _entityManager.AddEntity(_groundManager); _entityManager.AddEntity(_scoreBoard); _entityManager.AddEntity(_obstacleManager); _entityManager.AddEntity(_gameOverScreen); _entityManager.AddEntity(_skyManager); _groundManager.Initialize(); LoadSaveState(); }
public bool Replay() { if (State != GameState.GameOver) { return(false); } State = GameState.Playing; _trex.Initialize(); _obstacleManager.Reset(); _obstacleManager.IsEnabled = true; _groundManager.Initialize(); _gameOverScreen.IsEnabled = false; _scoreBoard.Score = 0; _inputController.BlockInputTemporarily(); return(true); }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here _sfxHit = Content.Load <SoundEffect>(ASSET_NAME_SFX_HIT); _sfxButtonPress = Content.Load <SoundEffect>(ASSET_NAME_SFX_BUTTON_PRESS); _sfxScoredReached = Content.Load <SoundEffect>(ASSET_NAME_SFX_SCORE_REACHED); _spriteSheetTexture = Content.Load <Texture2D>(ASSET_NAME_SPRITESHEET); _fadeInTexture = new Texture2D(GraphicsDevice, 1, 1); _fadeInTexture.SetData(new Color[] { Color.White }); _tRex = new TRex(_spriteSheetTexture, new Vector2(TREX_START_POS_X, TREX_START_POS_Y - TRex.GetHeight()), _sfxButtonPress); _tRex.DrawOrder = 10; _tRex.JumpComplete += tRex_JumpComplete; _tRex.Died += tRex_Died; _scoreBoard = new ScoreBoard(_spriteSheetTexture, new Vector2(SCORE_BOARD_POS_X, SCORE_BOARD_POS_y), _tRex); _inputController = new InputController(_tRex); _groundManager = new GroundManager(_spriteSheetTexture, _entityManager, _tRex); _obstacleManager = new ObstacleManager(_entityManager, _tRex, _scoreBoard, _spriteSheetTexture); _gameOverScreen = new GameOverScreen(_spriteSheetTexture, this); _gameOverScreen.Position = new Vector2(WINDOW_WIDTH / 2 - GameOverScreen.GAME_OVER_SPRITE_WIDTH / 2, WINDOW_HEIGHT / 2 - 30); _entityManager.AddEntity(_tRex); _entityManager.AddEntity(_groundManager); _entityManager.AddEntity(_scoreBoard); _entityManager.AddEntity(_obstacleManager); _entityManager.AddEntity(_gameOverScreen); _groundManager.Initialize(); }