public override void Update(GameTime gameTime) { for (int i = 0; i < gameAssets_.EnemyListCount; i++) //Enemy logic { gameAssets_.EnemyListItem(i).Update(gameTime); } for (int i = 0; i < gameAssets_.TowerListCount; i++) //Player logic { //pass a reference to the playstate, if the playstate is set to overwhelmed then it is a game over. gameAssets_.TowerListItem(i).Update(gameTime, ref playState); } if (playState == PLAY_STATES.OVERWHELMED) { } else { MoveViewPort(); //Viewport control viewPort_.Update(); for (int i = 0; i < gameAssets_.GUIListCount; i++) //Move GUI Elements with Viewport { gameAssets_.GUIListItem(i).Update(viewPort_.X, viewPort_.Y); } SpellManagement(); //Spells - suggest input handler later to cover some functions already being handled by this function gameAssets_.RemoveEntitiesMarkedForDelete(); //Removing all objects marked as !active from appropriate lists CollisionTesting(gameTime); //Collisions UpdateState(); } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.ForestGreen); // TODO: Add your drawing code here spriteBatch.Begin(); for (int i = 0; i < gameAssets.DrawListCount; i++) { if (gameAssets.DrawListItem(i).Active) { viewPort.Draw(gameAssets.DrawListItem(i)); } } //Add GUI to separate drawlist - Always draw on top of everything else for (int i = 0; i < gameAssets.GUIListCount; i++) { if (gameAssets.GUIListItem(i).Active) { viewPort.Draw(gameAssets.GUIListItem(i)); } } if (currentGameState == (int)GAME_STATES.PLAY_GAME) { string output = gameAssets.TowerListItem(0).Essence.ToString(); spriteBatch.DrawString(myFont, output, fontPos, Color.Black); if (gameState is PlayGame) { if (((PlayGame)gameState).CurrentPlayState == PLAY_STATES.ABOUT_TO_GENERATE_WAVE) { spriteBatch.DrawString(waveStateFont, "ABOUT_TO_GENERATE_WAVE", waveStateFontPos, Color.Black); } if (((PlayGame)gameState).CurrentPlayState == PLAY_STATES.WAVE_IN_PROGRESS) { spriteBatch.DrawString(waveStateFont, "WAVE_IN_PROGRESS", waveStateFontPos, Color.Black); } if (((PlayGame)gameState).CurrentPlayState == PLAY_STATES.WAITING_FOR_WAVE_TO_START) { spriteBatch.DrawString(waveStateFont, "WAITING_FOR_WAVE_TO_START", waveStateFontPos, Color.Black); } if (((PlayGame)gameState).CurrentPlayState == PLAY_STATES.WAVE_COMPLETE) { spriteBatch.DrawString(waveStateFont, "WAVE_COMPLETE", waveStateFontPos, Color.Black); } if (((PlayGame)gameState).CurrentPlayState == PLAY_STATES.OVERWHELMED) { spriteBatch.DrawString(waveStateFont, "OVERWHELMED", waveStateFontPos, Color.Black); } } } spriteBatch.End(); base.Draw(gameTime); }
//public void CreateTestWave() //{ // uint spawnNumber = 0; // const uint SPAWN_INTERVAL = 5000; // const uint TIMER_INTERVAL = 350; // const float ENEMIES_WAVE_ONE = 5.0f; // const float ENEMIES_INCREMENTER = 0.6f; // const float ENEMIES_WAVE_END = 50.0f; // //const float ENEMIES_WAVE_ONE = 1.0f; // //const float ENEMIES_INCREMENTER = 0.6f; // //const float ENEMIES_WAVE_END = 1.5f; // //had to move CreatePlayer here as the creation of the spawn circle needs it to exist. // CreatePlayer(); // //even though these enemySpawner instances instantly go out of scope. they are not destroyed while their timers are running. // for (float i = ENEMIES_WAVE_ONE; i < ENEMIES_WAVE_END; i += ENEMIES_INCREMENTER) // { // //grab a random rules // EnemySpawnRules rules = spawnRulesList[spawnRulesSelector.Roll()]; // Circle circle = new Circle(new Vector2(gameAssets.TowerListItem(0).X, gameAssets.TowerListItem(0).Y), 400.0); // EnemySpawner enemySpawner = new EnemySpawner(this, rules, TIMER_INTERVAL, (uint)(spawnNumber * SPAWN_INTERVAL) + 1, (uint)i * 2, circle); // ++spawnNumber; // } //} public List <EnemySpawner> GenerateWave(int pointsToSpendPerSpawner_, int numOfSpawners_, int timeBetweenSpawners_) { List <EnemySpawner> wave = new List <EnemySpawner>(); uint spawnNumber = 0; const uint TIMER_INTERVAL = 350; //even though these enemySpawner instances instantly go out of scope. they are not destroyed while their timers are running. for (float i = 1; i < numOfSpawners_; ++i) { //grab a random rules EnemySpawnRules rules = spawnRulesList[spawnRulesSelector.Roll()]; Circle circle = new Circle(new Vector2(gameAssets.TowerListItem(0).X, gameAssets.TowerListItem(0).Y), 600.0); uint startTimerMS = (uint)(spawnNumber * timeBetweenSpawners_) + 1; EnemySpawner enemySpawner = new EnemySpawner(this, rules, TIMER_INTERVAL, startTimerMS, circle, pointsToSpendPerSpawner_); wave.Add(enemySpawner); ++spawnNumber; } return(wave); }