public EnemyAnimatedSprite(Texture2D[] pTextures, Vector2 pPosition, SpriteBatch pSpriteBatch, DifficulityLevel pDifficulityLevel) : base(pTextures, pPosition) { _spriteBatch = pSpriteBatch; Lives = (pDifficulityLevel == DifficulityLevel.Easy) ? 1 : 2; _currentFrame = Rng.Next(0, 3); }
public void Update(GameTime pGameTime) { _inputManager.Update(); if (_inputManager.IsPressed(Input.Enter)) { IsEnterPressed = true; } if (_inputManager.IsPressed(Input.Escape)) { IsEscapePressed = true; } if (_inputManager.IsPressed(Input.MoveUp) || _inputManager.IsPressed(Input.MoveDown)) { if (!_wasPressedUpOrDown) { DifficulityLevel = ((DifficulityLevel == DifficulityLevel.Easy) ? DifficulityLevel.Hard : DifficulityLevel.Easy); _timeWhenPressedUpOrDown = pGameTime.TotalGameTime.TotalMilliseconds; _wasPressedUpOrDown = true; } else { var currentTime = pGameTime.TotalGameTime.TotalMilliseconds; if (currentTime - _timeWhenPressedUpOrDown > DelayInMilliseconds) { _wasPressedUpOrDown = false; } } } }
public OnGameScreen(SpriteBatch pSpriteBatch, GameTime pGameTime, DifficulityLevel pDifficulityLevel) { _graphicsDevice = pSpriteBatch.GraphicsDevice; _spriteBatch = pSpriteBatch; _difficulityLevel = pDifficulityLevel; _timeLastChangeTimer = pGameTime.TotalGameTime.Seconds; _enemyGrid = new EnemyGrid(Vector2.Zero, 8, 5, pSpriteBatch, pDifficulityLevel, 2.2f); }
public IntroScreen(SpriteBatch pSpriteBatch) { IsEnterPressed = false; IsEscapePressed = false; DifficulityLevel = DifficulityLevel.Easy; _graphicsDevice = pSpriteBatch.GraphicsDevice; _spriteBatch = pSpriteBatch; _inputManager = new InputManager(); _wasPressedUpOrDown = false; }
public PlayerSprite(Texture2D pTexture, DifficulityLevel pDifficulityLevel, Vector2 pPosition, // Content\\Textures\\Hero.png GraphicsDevice pGraphicsDevice) : base(pTexture, pPosition) { Lives = (pDifficulityLevel == DifficulityLevel.Easy) ? 3 : 1; _textureLoaded = pTexture; _playerShot = ContentManager.GetSoundEffect("Content\\SFX\\PlayerShot.wav"); _textureUnloaded = ContentManager.GetTexture2D(pGraphicsDevice, "Content\\Textures\\Hero\\Unloaded.png"); var shotTexture = ContentManager.GetTexture2D(pGraphicsDevice, "Content\\Textures\\Hero\\LaserShot.png"); ShotSprite = new ShotSprite(shotTexture, new Vector2(Position.X + Texture.Width / 2f, Position.Y), -10); }
private static Texture2D[] GetTextures(SpriteBatch pSpriteBatch, DifficulityLevel pDifficulityLevel) { Texture2D[] textures = new Texture2D[3]; for (int i = 0; i < textures.Length; ++i) { var fileName = (pDifficulityLevel == DifficulityLevel.Easy) ? "Easy" : "Hard"; fileName += (i + 1) + ".png"; textures[i] = ContentManager.GetTexture2D(pSpriteBatch.GraphicsDevice, "Content\\Textures\\Enemy\\" + fileName); } return(textures); }
public FlyingEnemy(EnemyAnimatedSprite[][] pEnemies, SpriteBatch pSpriteBatch, DifficulityLevel pDifficulityLevel, Vector2 pTargetPosition) : base(GetTextures(pSpriteBatch, pDifficulityLevel), Vector2.One, pSpriteBatch, pDifficulityLevel) { _spriteBatch = pSpriteBatch; _targetPosition.X = pTargetPosition.X; _targetPosition.Y = GalaxianGame.WindowSize.Height + 10; Random rng = new Random(); var x = (int)(rng.NextDouble() * pEnemies.Length); var y = (int)(rng.NextDouble() * pEnemies[0].Length); while (pEnemies[x][y] == null) { x = (int)(rng.NextDouble() * pEnemies.Length); y = (int)(rng.NextDouble() * pEnemies[0].Length); } Position = pEnemies[x][y].Position; CoordsInGrid = new Vector2(x, y); }