/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (var jxqyGame = new JxqyGame()) { jxqyGame.Run(); } }
/// <summary> /// Draw map npcs objs magic sprits /// </summary> /// <param name="spriteBatch"></param> public void Draw(SpriteBatch spriteBatch) { if (DrawColor == Color.Black) { spriteBatch.End(); JxqyGame.BeginSpriteBatch(spriteBatch, Globals.TheGame.GrayScaleEffect); DrawLayer(spriteBatch, DrawColor, 0); spriteBatch.End(); JxqyGame.BeginSpriteBatch(spriteBatch); } else { DrawLayer(spriteBatch, DrawColor, 0); } var start = GetStartTileInView(); var end = GetEndTileInView(); var magicSprites = MagicManager.MagicSpritesInView; var npcs = NpcManager.NpcsInView; var objs = ObjManager.ObjsInView; //Draw body foreach (var obj in objs) { if (obj.Kind == 2) { obj.Draw(spriteBatch); } } for (var y = (int)start.Y; y < (int)end.Y; y++) { for (var x = (int)start.X; x < (int)end.X; x++) { if (IsLayerDraw(1) && GetTileTexture(x, y, 1) != null) { if (DrawColor == Color.Black) { spriteBatch.End(); JxqyGame.BeginSpriteBatch(spriteBatch, Globals.TheGame.GrayScaleEffect); DrawTile(spriteBatch, DrawColor, 1, new Vector2(x, y), 1f); spriteBatch.End(); JxqyGame.BeginSpriteBatch(spriteBatch); } else { DrawTile(spriteBatch, DrawColor, 1, new Vector2(x, y), 1f); } } foreach (var npc in npcs) { if (x == npc.MapX && y == npc.MapY && npc.Kind != 7) { npc.Draw(spriteBatch); } } foreach (var obj in objs) { if (x == obj.MapX && y == obj.MapY && obj.Kind != 2) { obj.Draw(spriteBatch); } } foreach (var magicSprite in magicSprites) { if (x == magicSprite.MapX && y == magicSprite.MapY) { magicSprite.Draw(spriteBatch); } } } } if (DrawColor == Color.Black) { spriteBatch.End(); JxqyGame.BeginSpriteBatch(spriteBatch, Globals.TheGame.GrayScaleEffect); DrawLayer(spriteBatch, DrawColor, 2); spriteBatch.End(); JxqyGame.BeginSpriteBatch(spriteBatch); } else { DrawLayer(spriteBatch, DrawColor, 2); } //Draw fly npc foreach (var npc in npcs) { if (npc.Kind == 7) { npc.Draw(spriteBatch); } } if (IsLayerDraw(3)) { DrawTrapLayer(spriteBatch); //Trap } if (IsLayerDraw(4)) { DrawObstacleLayer(spriteBatch); //Obstacle } }