/// <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) { this.GraphicsDevice.Clear(Color.CornflowerBlue); this.spriteBatch.Begin(); switch (this.gameState) { case GameState.FreeRoam: this.spriteBatch.Draw(this.waterMapTexture, this.watermapRect, Color.White); this.continent1.Draw(this.spriteBatch); this.continent2.Draw(this.spriteBatch); this.continent3.Draw(this.spriteBatch); this.fishingVillage1.Draw(this.spriteBatch); this.tradeCenter1.Draw(this.spriteBatch); this.militaryPort1.Draw(this.spriteBatch); this.playerShip.Draw(this.spriteBatch); this.shipPopup.Draw(this.spriteBatch); this.fishingPopup.Draw(this.spriteBatch); this.tradePopup.Draw(this.spriteBatch); this.militaryPopup.Draw(this.spriteBatch); foreach (var item in this.npcs) { item.Draw(this.spriteBatch); } if (this.upgradeFlagWeapons) { if (this.upgradeTime == 0) { this.wUpgrade = new WeaponUpgrade(this.Content, "Arial", "Weapon Upgraded", this.playerShip); this.wUpgrade.UpgradeShip(); this.shipPopup.Messages.RemoveAt(1); this.shipPopup.Messages.Insert(1, string.Format("Weapons:{0}", this.playerShip.Weapons)); this.upgradeTime = gameTime.TotalGameTime.TotalSeconds; } if (gameTime.TotalGameTime.TotalSeconds - this.upgradeTime < 4) { this.wUpgrade = new WeaponUpgrade(this.Content, "Arial", "Weapon Upgraded", this.playerShip); this.wUpgrade.Draw(this.spriteBatch); } else { this.upgradeFlagWeapons = false; this.upgradeTime = 0; } } if (this.upgradeFlagHull) { if (this.upgradeTime == 0) { this.wUpgrade = new HullUpgrade(this.Content, "Arial", "Hull Upgraded", this.playerShip); this.wUpgrade.UpgradeShip(); this.shipPopup.Messages.RemoveAt(0); this.shipPopup.Messages.Insert(0, string.Format("Hull:{0}", this.playerShip.Hull)); this.upgradeTime = gameTime.TotalGameTime.TotalSeconds; } if (gameTime.TotalGameTime.TotalSeconds - this.upgradeTime < 4) { this.wUpgrade = new WeaponUpgrade(this.Content, "Arial", "Hull Upgraded", this.playerShip); this.wUpgrade.Draw(this.spriteBatch); } else { this.upgradeFlagHull = false; this.upgradeTime = 0; } } break; case GameState.Combat: if (this.npcs.Find(x => x.IsInCombat).IsDestroyed) { this.gameState = GameState.FreeRoam; break; } this.spriteBatch.Draw(this.waterMapTexture, this.watermapRect, Color.White); this.playerShip.Draw(this.spriteBatch); foreach (var item in this.playerShip.Bullets) { item.Draw(this.spriteBatch); } foreach (var item in this.npcs.Find(x => x.IsInCombat).Bullets) { item.Draw(this.spriteBatch); } this.npcs.Find(x => x.IsInCombat).Draw(this.spriteBatch); break; case GameState.GameOver: this.spriteBatch.DrawString(this.gameFont, "You got sunk!", new Vector2(GlobalConstants.WINDOW_WIDTH / 2 - 50,GlobalConstants.WINDOW_HEIGHT / 2), Color.Red); break; case GameState.YouWin: break; default: break; } for (int index = 0; index < this.UIElements.Count; index++) { this.UIElements[index].Draw(this.spriteBatch); } this.spriteBatch.End(); base.Draw(gameTime); }
public void Upgrade(Upgrade upg) { this.upgrades.Add(upg); }