/// <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> protected override void Initialize() { // TODO: Add your initialization logic here TerrainSpriteSourceRectangle.LoadSprite(); UISpriteSheetSourceRectangle.LoadSprite(); UnitSpriteSheetRectangle.LoadSprite(); BuildingSpriteSourceRectangle.LoadSprite(); DirectionArrowSpriteSourceRectangle.LoadSprite(); CommandSpriteSourceRectangle.LoadSprite(); BackgroundTerrainSpriteSourceRectangle.LoadSprite(); BackgroundUnitSpriteSourceRectangle.LoadSprite(); SelectedMapCellBorderSpriteSourceRectangle.LoadSprite(); SelectedMapCellCapturePointSpriteSourceRectangle.LoadSprite(); SelectedMapCellDefenseStarSpriteSourceRectangle.LoadSprite(); SelectedMapCellLoadedUnitSpriteSourceRectangle.LoadSprite(); SelectedMapCellUnitInfoSpriteSourceRectangle.LoadSprite(); BuyMenuFactorySpriteSourceRectangle.LoadSprite(); BuyMenuAirportHarborSpriteSourceRectangle.LoadSprite(); graphics.PreferredBackBufferWidth = Constants.Width; // set this value to the desired width of your window graphics.PreferredBackBufferHeight = Constants.Height; // set this value to the desired height of your window graphics.ApplyChanges(); DrawingHelper.Initialize(GraphicsDevice); Unit.Init(); Unit.Load(); CONTENT_MANAGER.gameinstance = this; base.Initialize(); }
public static void Render(Map map, bool[,] fogofwar, SpriteBatch spriteBatch, GameTime gameTime) { if (!map.IsProcessed) { Process(map); } MapCell tempmapcell; for (int i = 0; i < map.Width; i++) { for (int j = 0; j < map.Height; j++) { Vector2 curpos = new Vector2(i * Constants.MapCellWidth, j * Constants.MapCellHeight); tempmapcell = map[i, j]; if (fogofwar[i, j]) { if (tempmapcell.terrainbase != SpriteSheetTerrain.None) { spriteBatch.Draw(CONTENT_MANAGER.spriteSheet, curpos, TerrainSpriteSourceRectangle.GetSpriteRectangle(tempmapcell.terrainbase), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, LayerDepth.TerrainBase); } if (tempmapcell.terrainLower != SpriteSheetTerrain.None) { spriteBatch.Draw(CONTENT_MANAGER.spriteSheet, curpos, TerrainSpriteSourceRectangle.GetSpriteRectangle(tempmapcell.terrainLower), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, LayerDepth.TerrainLower); } if (tempmapcell.terrainUpper != SpriteSheetTerrain.None) { spriteBatch.Draw(CONTENT_MANAGER.spriteSheet, curpos, TerrainSpriteSourceRectangle.GetSpriteRectangle(tempmapcell.terrainUpper), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, LayerDepth.TerrainUpper); } if (tempmapcell.unit != null) { var tempunit = tempmapcell.unit; tempunit.Animation.Position = curpos; tempunit.Animation.Draw(gameTime, spriteBatch); } } else { } } } }
public static void Render(Map map, SpriteBatch spriteBatch, GameTime gameTime) { if (!map.IsProcessed) { Process(map); } MapCell tempmapcell; for (int i = 0; i < map.Width; i++) { for (int j = 0; j < map.Height; j++) { Vector2 curpos = new Vector2(i * Constants.MapCellWidth, j * Constants.MapCellHeight); tempmapcell = map[i, j]; if (tempmapcell.terrainbase != SpriteSheetTerrain.None) { spriteBatch.Draw(CONTENT_MANAGER.spriteSheet, curpos, TerrainSpriteSourceRectangle.GetSpriteRectangle(tempmapcell.terrainbase), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, LayerDepth.TerrainBase); } if (tempmapcell.terrainLower != SpriteSheetTerrain.None) { spriteBatch.Draw(CONTENT_MANAGER.spriteSheet, curpos, TerrainSpriteSourceRectangle.GetSpriteRectangle(tempmapcell.terrainLower), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, LayerDepth.TerrainLower); } if (tempmapcell.terrainUpper != SpriteSheetTerrain.None) { spriteBatch.Draw(CONTENT_MANAGER.spriteSheet, curpos, TerrainSpriteSourceRectangle.GetSpriteRectangle(tempmapcell.terrainUpper), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, LayerDepth.TerrainUpper); } if (tempmapcell.unit != null) { map[i, j].unit.Animation.Position = curpos; map[i, j].unit.Animation.Draw(gameTime, spriteBatch); if (tempmapcell.unit.Animation.IsPlaying) { Point hpPos = new Point((int)curpos.X + 36, (int)curpos.Y + 36); spriteBatch.DrawString(CONTENT_MANAGER.arcadefont, tempmapcell.unit.HitPoint.ToString(), hpPos.ToVector2(), tempmapcell.unit.Owner == Owner.Red ? Color.Blue : Color.Red, 0f, Vector2.Zero, 0.75f, SpriteEffects.None, LayerDepth.GuiUpper); spriteBatch.Draw(CONTENT_MANAGER.blank8x8, new Rectangle(hpPos, new Point(12, 12)), null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, LayerDepth.GuiUpper - 0.01f); } } } } }