// onTimedEvent for timeKeeper //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void OnTimedEvent(object source, ElapsedEventArgs e) { if (paused == false && gameOver == false) { enemyCounter += 1; if (enemyCounter > 3) { enemyCounter = 1; } if (enemyCounter == 2 || enemyCounter == 3) { for (int i = 0; i < enemyMax; i++) { if (wiiEnemy[i].collided == true) { wiiEnemy[i] = new wiiMoteEnemy(rand); break; } } } if (enemyCounter == 2) { for (int i = 0; i < enemyMax; i++) { if (wiiEnemy2[i].collided == true) { wiiEnemy2[i] = new NunChuckEnemy(rand, engine, soundBank, waveBank); break; } } } for (int i = 0; i < enemyMax; i++) { if (psEnemy[i].collided == true) { psEnemy[i] = new sixaxisEnemy(rand); break; } } for (int i = 0; i < powerUps; i++) { if (gatherThis[i].collided == true) { gatherThis[i] = new scoreUp(rand, kaching); break; } } } }
// Initialize //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// protected override void Initialize() { base.Initialize(); background = new Background(); // Initialize audio objects. engine = new AudioEngine("Content\\Audio\\ConsoleWarsAudioProject.xgs"); soundBank = new SoundBank(engine, "Content\\Audio\\Sound Bank.xsb"); waveBank = new WaveBank(engine, "Content\\Audio\\Wave Bank.xwb", 0, (short) 16); seefeel.Play(); rand = new Random(); player1 = new MainCharacter(click1); score = 0; enemyMax = 100; powerUps = 5; wiiEnemy = new wiiMoteEnemy[enemyMax]; wiiEnemy2 = new NunChuckEnemy[enemyMax]; psEnemy = new sixaxisEnemy[enemyMax]; gatherThis = new scoreUp[powerUps]; for (int i = 0; i < enemyMax; i++) { wiiEnemy[i] = new wiiMoteEnemy(rand); wiiEnemy2[i] = new NunChuckEnemy(rand, engine, soundBank, waveBank); wiiEnemy[i].collided = true; wiiEnemy[i].position = new Vector2(-100f, -100f); wiiEnemy2[i].collided = true; wiiEnemy2[i].position = new Vector2(-100f, -100f); psEnemy[i] = new sixaxisEnemy(rand); psEnemy[i].collided = true; psEnemy[i].position = new Vector2(-100f, -100f); } for (int i = 0; i < powerUps; i++) { gatherThis[i] = new scoreUp(rand, kaching); gatherThis[i].collided = true; } // timer events and upkeep difficulty = 5000; // controls the number of seconds between enemy (and pick-up) spawns difficultyKeeper = new System.Timers.Timer(5000); GC.KeepAlive(difficultyKeeper); difficultyKeeper.AutoReset = true; difficultyKeeper.Enabled = true; difficultyKeeper.Elapsed += new ElapsedEventHandler(OnTimedDifficultyEvent); timeKeeper = new System.Timers.Timer(difficulty); GC.KeepAlive(timeKeeper); timeKeeper.AutoReset = true; timeKeeper.Enabled = true; timeKeeper.Elapsed += new ElapsedEventHandler(OnTimedEvent); // controls to make the player lose points every so many frames shieldCounter = 0; // goes up every frame shieldOffset = 1;// count at which player will lose point for having shield active enemyCounter = 0; paused = false; gameOver = false; gameOverTint = 0; }