1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-20 14:15:23 +00:00

Generate a very simple version of blood moore outside of camp.

This commit is contained in:
Tim Sarbin 2018-11-28 22:22:48 -05:00
parent 7a1aea686b
commit 4021fc9793
2 changed files with 33 additions and 8 deletions

View File

@ -123,7 +123,7 @@ namespace OpenDiablo2.Core.GameState_
LevelType = levelType,
FileData = fileData,
CellInfo = new Dictionary<eRenderCellType, MapCellInfo[]>(),
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<eRenderCellType, MapCellInfo[]>(),
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;

View File

@ -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;
}
}