From 4021fc979316fa822f4b2d09d7cd23817362b0bc Mon Sep 17 00:00:00 2001 From: Tim Sarbin Date: Wed, 28 Nov 2018 22:22:48 -0500 Subject: [PATCH] Generate a very simple version of blood moore outside of camp. --- OpenDiablo2.Core/GameState/GameState.cs | 7 ++--- OpenDiablo2.Core/MapGenerator.cs | 34 +++++++++++++++++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/OpenDiablo2.Core/GameState/GameState.cs b/OpenDiablo2.Core/GameState/GameState.cs index 64c18769..75480ee4 100644 --- a/OpenDiablo2.Core/GameState/GameState.cs +++ b/OpenDiablo2.Core/GameState/GameState.cs @@ -123,7 +123,7 @@ namespace OpenDiablo2.Core.GameState_ LevelType = levelType, FileData = fileData, CellInfo = new Dictionary(), - TileLocation = new Rectangle(origin, new Size(fileData.Width, fileData.Height)) + TileLocation = new Rectangle(origin, new Size(fileData.Width - 1, fileData.Height - 1)) }; mapInfo.Add(result); @@ -162,7 +162,7 @@ namespace OpenDiablo2.Core.GameState_ LevelType = levelType, FileData = fileData, CellInfo = new Dictionary(), - TileLocation = new Rectangle(origin, new Size(fileData.Width, fileData.Height)) + TileLocation = new Rectangle(origin, new Size(fileData.Width - 1, fileData.Height - 1)) }; mapInfo.Add(result); @@ -205,7 +205,8 @@ namespace OpenDiablo2.Core.GameState_ { var x = cellX; var y = cellY; - var map = mapInfo.FirstOrDefault(z => z.TileLocation.Contains(x, y)); + var map = mapInfo.FirstOrDefault(z => (x >= z.TileLocation.X) && (y >= z.TileLocation.Y) + && (x < z.TileLocation.Right) && (y < z.TileLocation.Bottom)); if (map == null) { return null; diff --git a/OpenDiablo2.Core/MapGenerator.cs b/OpenDiablo2.Core/MapGenerator.cs index 40c17812..9fb73b53 100644 --- a/OpenDiablo2.Core/MapGenerator.cs +++ b/OpenDiablo2.Core/MapGenerator.cs @@ -21,28 +21,52 @@ namespace OpenDiablo2.Core public void Generate() { + var random = new Random(gameState.Seed); + + var test = gameState.LoadSubMap(2, new Point(10000, 10000)); var wildBorder = 5; // (4-15) // TODO: Is there no data file that explicitly defines this?? var townMap = gameState.LoadMap(eLevelId.Act1_Town1, new Point(0, 0)); + Rectangle bloodMooreRect; + + // 32-37 is grassy field? + if (townMap.FileData.MapFile.Contains("S1")) { var defId = 3; // Act 1 - Town 1 Transition S - var borderMap = gameState.LoadSubMap(defId, new Point(0, townMap.FileData.Height)); + var borderMap = gameState.LoadSubMap(defId, new Point(0, townMap.FileData.Height - 2)); borderMap.PrimaryMap = townMap; var wilderness = gameState.LoadSubMap(wildBorder, new Point(26, townMap.FileData.Height + borderMap.FileData.Height)); wilderness.PrimaryMap = townMap; + + bloodMooreRect = new Rectangle(-40, townMap.FileData.Height + borderMap.FileData.Height, 120, 80); } else if (townMap.FileData.MapFile.Contains("E1")) { var defId = 2; // Act 1 - Town 1 Transition E - var borderMap = gameState.LoadSubMap(defId, new Point(townMap.FileData.Width, 0)); + var borderMap = gameState.LoadSubMap(defId, new Point(townMap.FileData.Width - 2, 0)); borderMap.PrimaryMap = townMap; - for (int i = 4; i <= 15; i++) + bloodMooreRect = new Rectangle(townMap.FileData.Width + borderMap.FileData.Width, -40, 80, 120); + } + else if (townMap.FileData.MapFile.Contains("W1")) + { + bloodMooreRect = new Rectangle(-120, 0, 120, townMap.FileData.Height); + } else // North + { + bloodMooreRect = new Rectangle(0, -120, townMap.FileData.Width, 120); + } + + // Generate the Blood Moore? + for (var y = 0; y < (bloodMooreRect.Height); y+= 8) + { + + for (var x = 0; x < (bloodMooreRect.Width); x += 8) { - var wilderness = gameState.LoadSubMap(i, new Point(townMap.FileData.Width + borderMap.FileData.Width + ((i-4) * 10), 26)); - wilderness.PrimaryMap = townMap; + var tileIdx = 35; + var mapTile = gameState.LoadSubMap(tileIdx, new Point(bloodMooreRect.Left + x, bloodMooreRect.Top + y)); + mapTile.PrimaryMap = townMap; } }