// ------------------------------------------------------------------- // Draw // ------------------------------------------------------------------- public void Draw(GameTime gameTime, AlphaTestEffect effect, Camera camera, string DrawType) { // Drawing map portion & events for (int i = -WANOK.PORTION_RADIUS; i <= WANOK.PORTION_RADIUS; i++) { for (int j = -WANOK.PORTION_RADIUS; j <= WANOK.PORTION_RADIUS; j++) { int[] portion = new int[] { i, j }; // map portion GameMapPortion gameMap = Portions[portion]; if (gameMap != null) { gameMap.Draw(Device, effect, MapEditor.TexTileset, camera, DrawType); } // events effect.Alpha = MapEditor.IsViewMode || DrawType == "ItemEvent" ? 1.0f : 0.5f; if (!MapEditor.IsViewMode) { EventsPortions[portion].DrawSquares(Device, effect); } EventsPortions[portion].DrawSprites(Device, effect, camera); } } // Drawing Start position if (StartSquare != null) { effect.Alpha = MapEditor.IsViewMode || DrawType == "ItemEvent" ? 1.0f : 0.5f; StartSquare.Draw(Device, gameTime, effect, MapEditor.TexStartCursor, WANOK.GetVector3Position(StartPosition)); } // Drawing event square selection if (EventPosition != null) { effect.Alpha = DrawType == "ItemEvent" ? 1.0f : 0.5f; EventSquare.Draw(Device, gameTime, effect, MapEditor.TexEventSelectCursor, WANOK.GetVector3Position(EventPosition)); } // Drawing grid effect.Texture = MapEditor.TexGrid; effect.Alpha = DrawType == "ItemEvent" ? 1.0f : 0.5f; Device.BlendState = BlendState.Additive; effect.World = Matrix.Identity * Matrix.CreateScale(WANOK.SQUARE_SIZE, 1.0f, WANOK.SQUARE_SIZE) * Matrix.CreateTranslation(0, WANOK.GetPixelHeight(GridHeight) + 0.1f, 0); if (!MapEditor.IsViewMode && DisplayGrid) { Device.SetVertexBuffer(VBGrid); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); Device.DrawPrimitives(PrimitiveType.LineList, 0, GridVerticesArray.Length / 2); } } Device.BlendState = BlendState.NonPremultiplied; }
public static void SavePortionMap(GameMapPortion map, string mapName, int i, int j) { string path = Path.Combine(MapsDirectoryPath, mapName, "temp", i + "-" + j + ".pmap"); if (map == null) { if (File.Exists(path)) { File.Delete(path); } } else { SaveBinaryDatas(map, path); } }
// ------------------------------------------------------------------- // CreateCopy // ------------------------------------------------------------------- public GameMapPortion CreateCopy() { GameMapPortion newGameMap = new GameMapPortion(); newGameMap.Floors = new Dictionary <int[], int[]>(Floors, new IntArrayComparer()); foreach (KeyValuePair <int, Autotiles> entry in Autotiles) { newGameMap.Autotiles[entry.Key] = entry.Value.CreateCopy(); } foreach (KeyValuePair <int[], Sprites> entry in Sprites) { newGameMap.Sprites[entry.Key] = entry.Value.CreateCopy(); } foreach (KeyValuePair <int, Mountains> entry in Mountains) { newGameMap.Mountains[entry.Key] = entry.Value.CreateCopy(); } return(newGameMap); }