public void PauseGame() { ParticleSystems ps = this._mainGame.GameManager.GetComponent <ParticleSystems>(); MusicPlayer mp = this._mainGame.GameManager.GetComponent <MusicPlayer>(); if (this._mainGame.IsPaused) { //unpause mp.UnPauseSong(); this._mainGame.IsPaused = false; ps.PauseParticles(false); } else { //pause mp.PauseSong(); this._mainGame.IsPaused = true; ps.PauseParticles(true); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> public void Initialize() { InputHandler ih = this._mainGame.GameManager.GetComponent <InputHandler>(); ParticleSystems ps = this._mainGame.GameManager.GetComponent <ParticleSystems>(); MusicPlayer mp = this._mainGame.GameManager.GetComponent <MusicPlayer>(); Menu m = this._mainGame.GameManager.GetComponent <Menu>(); ih.EscapePressed += Ih_EscapePressed; ih.SpacePressed += Ih_SpacePressed; ih.GamePadBackPressed += Ih_GamePadBackPressed; ps.BonusFieldDisabled += Ps_BonusFieldDisabled; ps.ParticleHitMouse += Ps_ParticleHitMouse; ps.ParticleOutOfScreen += Ps_ParticleOutOfScreen; ps.ParticleHitPlayer += Ps_ParticleHitPlayer; mp.BeforeSongArchiveClosed += Mp_BeforeSongArchiveClosed; mp.SongArchiveOpend += Mp_SongArchiveOpend; mp.SongChanged += Mp_SongChanged; this._isSongFinished = false; }
public void NewGame() { DynamicWorldCounter dwc = this._mainGame.GameManager.GetComponent <DynamicWorldCounter>(); ParticleSystems ps = this._mainGame.GameManager.GetComponent <ParticleSystems>(); Player player = this._mainGame.GameManager.GetComponent <Player>(); MusicPlayer mp = this._mainGame.GameManager.GetComponent <MusicPlayer>(); this._actualSongScore = 0; player.ReInit(); this._particlesPerGame = 0; this._isSongFinished = false; this._shieldHit = 0; this._particleCatch = 0; dwc.ReInit(); this._bonusTime = 5; this._timeToBonus = 35; this._musicMinutes = mp.GetActiveSongDuration().Minutes; this._musicSeconds = mp.GetActiveSongDuration().Seconds; ps.ReInit(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public void Draw(GameTime gameTime) { MusicPlayer mp = this._mainGame.GameManager.GetComponent <MusicPlayer>(); ParticleSystems ps = this._mainGame.GameManager.GetComponent <ParticleSystems>(); Player p = this._mainGame.GameManager.GetComponent <Player>(); ResourcesComponent rc = this._mainGame.GameManager.GetComponent <ResourcesComponent>(); this._mainGame.MainSpriteBatch.DrawString(rc.BiggerFont, "Score: " + this._actualSongScore, new Vector2(2, 2), Color.Magenta * mp.AvarageFrequency * 1.6f); this._mainGame.MainSpriteBatch.DrawString(rc.BiggerFont, "Score: " + this._actualSongScore, new Vector2(0, 0), Color.White); this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Multiply: " + p.Multiplier + "x", new Vector2(0, 35), Color.White); this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Time: " + this._musicTimeText, new Vector2(this._mainGame.MainViewport.Width - 150, 15), Color.White); this._mainGame.MainSpriteBatch.DrawString(rc.SmallerFont, "[esc]to menu", new Vector2(this._mainGame.MainViewport.Width - 150, 2), Color.White); if (this._actualSongHightScore > 0) { this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "High score: " + this._actualSongHightScore, new Vector2(0, 55), Color.White); this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, ", " + this._actualSongStatus, new Vector2(200, 55), Color.Purple); } else { this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "High score: First time playing", new Vector2(0, 55), Color.White); } this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Shield: " + p.Shield + "%", new Vector2(0, 75), Color.White); if ((ps.BonusPower >= 0) && (ps.BonusPower < 25)) { this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Bonus Lux", new Vector2(0, 175), Color.Red); } else if ((ps.BonusPower >= 25) && (ps.BonusPower < 50)) { this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 160), Color.Red); this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Bonus Lux", new Vector2(0, 175), Color.Red); } else if ((ps.BonusPower >= 50) && (ps.BonusPower < 75)) { this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 145), Color.Red); this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 160), Color.Red); this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Bonus Lux", new Vector2(0, 175), Color.Red); } else if ((ps.BonusPower >= 75) && (ps.BonusPower < 100)) { this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 130), Color.Orange); this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 145), Color.Orange); this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 160), Color.Orange); this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Bonus Lux", new Vector2(0, 175), Color.Orange); } else if (ps.BonusPower >= 100) { this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 115), Color.Green); this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 130), Color.Green); this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 145), Color.Green); this._mainGame.MainSpriteBatch.Draw(rc.MenuBackground, new Vector2(10, 160), Color.Green); this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "Bonus Lux", new Vector2(0, 175), Color.Green); } if (this._timeToBonus > 0) { if (this._timeToBonus > 9) { this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "bonus shield: 0:" + this._timeToBonus, new Vector2(0, 195), Color.Red); } else { this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "bonus shield: 0:0" + this._timeToBonus, new Vector2(0, 195), Color.Red); } } else { if ((this._timeToBonus == 0) && (!ps.BonusFieldActive)) { this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "bonus shield: 0:00", new Vector2(0, 195), Color.Green); } if (ps.BonusFieldActive) { this._mainGame.MainSpriteBatch.DrawString(rc.ScoreFont, "bonus shield: 0:0" + this._bonusTime, new Vector2(0, 195), Color.Purple); } } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public void Update(GameTime gameTime) { MusicPlayer mp = this._mainGame.GameManager.GetComponent <MusicPlayer>(); DynamicWorldCounter dwc = this._mainGame.GameManager.GetComponent <DynamicWorldCounter>(); InputHandler ih = this._mainGame.GameManager.GetComponent <InputHandler>(); if (!this._mainGame.IsActive) { this._mainGame.ResetElapsedTime(); if (!this._mainGame.IsPaused) { this.PauseGame(); } } if (!this._mainGame.IsPaused) { if (gameTime.TotalGameTime - this._previouslyGameTime > this._mainGame.OneSecond) { this._previouslyGameTime = gameTime.TotalGameTime; } if (gameTime.TotalGameTime - this._prevMusicTime > mp.MusicTick) { ParticleSystems ps = this._mainGame.GameManager.GetComponent <ParticleSystems>(); if (this._timeToBonus > 0) { this._timeToBonus--; } if (this._timeToBonus == 0) { ps.BonusFieldPrepar = true; } if (ps.BonusFieldActive) { this._bonusTime--; } if (this._bonusTime == 0) { ps.BonusFieldPrepar = false; ps.BonusFieldActive = false; this._timeToBonus = 35; this._bonusTime = 5; } //when music time is over and song didnt changed if (this._musicMinutes == 0 && this._musicSeconds == 0) { mp.ShuffledNextSong(); } this.CalculateTimeToEnd(); this._prevMusicTime = gameTime.TotalGameTime; } } }