public bool CanPlaceDecoration(byte id, byte x, byte y) { if (PlacedDecorations.Count >= 16) { return(false); } SecretBasePlacementTypes[,] finalGrid = FinalPlacementGrid; DecorationData decorationData = ItemDatabase.GetDecorationFromID(id); for (int x2 = 0; x2 < decorationData.Width; x2++) { for (int y2 = 0; y2 < decorationData.Height; y2++) { int finalX = x - decorationData.OriginX + x2; int finalY = y - decorationData.OriginY + y2; if (finalX < 0 || finalY < 0 || finalX >= RoomData.Width || finalY >= RoomData.Height) { return(false); } SecretBasePlacementTypes place = decorationData.PlacementGrid[x2, y2]; if (!CanPlaceTypeOn(finalGrid[finalX, finalY], place)) { return(false); } } } return(true); }
public Brush GetTypeColor(SecretBasePlacementTypes type) { byte opacity = 90; Color color = new Color(); switch (type) { case SecretBasePlacementTypes.Blocked: color = Color.FromArgb(opacity, 255, 0, 0); break; case SecretBasePlacementTypes.Floor: color = Color.FromArgb(opacity, 255, 255, 255); break; case SecretBasePlacementTypes.Wall: color = Color.FromArgb(opacity, 255, 0, 255); break; case SecretBasePlacementTypes.Hole: color = Color.FromArgb(opacity, 140, 0, 255); break; case SecretBasePlacementTypes.Rock: color = Color.FromArgb(opacity, 0, 255, 255); break; case SecretBasePlacementTypes.Reserved: color = Color.FromArgb(opacity, 0, 255, 0); break; } return new SolidColorBrush(color); }
protected bool CanPlaceTypeOn(SecretBasePlacementTypes roomType, SecretBasePlacementTypes decorationType) { if (decorationType == SecretBasePlacementTypes.Empty) { return(true); } else if (decorationType == SecretBasePlacementTypes.DollBack) { return(roomType != SecretBasePlacementTypes.BedroomFloor); } else { return(AllowedPlacements[decorationType].Contains(roomType)); } }
private void CompilePlacementGrid(string grid) { placementGrid = new SecretBasePlacementTypes[width, height]; grid = grid.Replace("\n", "").Replace("\r", ""); if (grid.Length != width * height) { throw new Exception("Secret Base Room placement grid incorrect length"); } for (int i = 0; i < grid.Length; i++) { SecretBasePlacementTypes type = SecretBasePlacementTypes.Blocked; if (grid[i] == 'B') { type = SecretBasePlacementTypes.Blocked; } else if (grid[i] == 'F') { type = SecretBasePlacementTypes.Floor; } else if (grid[i] == 'W') { type = SecretBasePlacementTypes.Wall; } else if (grid[i] == 'R') { type = SecretBasePlacementTypes.Rock; } else if (grid[i] == 'H') { type = SecretBasePlacementTypes.Hole; } else if (grid[i] == 'S') { type = SecretBasePlacementTypes.Reserved; } else { throw new Exception("Invalid placement grid letter"); } placementGrid[i % width, i / width] = type; } }
public Brush GetTypeColor(SecretBasePlacementTypes type) { byte opacity = 90; Color color = new Color(); switch (type) { case SecretBasePlacementTypes.Blocked: color = Color.FromArgb(opacity, 255, 0, 0); break; case SecretBasePlacementTypes.Floor: color = Color.FromArgb(opacity, 255, 255, 255); break; case SecretBasePlacementTypes.Wall: color = Color.FromArgb(opacity, 255, 0, 255); break; case SecretBasePlacementTypes.Hole: color = Color.FromArgb(opacity, 140, 0, 255); break; case SecretBasePlacementTypes.Rock: color = Color.FromArgb(opacity, 0, 255, 255); break; case SecretBasePlacementTypes.Reserved: color = Color.FromArgb(opacity, 0, 255, 0); break; } return(new SolidColorBrush(color)); }
private bool CanPlaceTypeOn(SecretBasePlacementTypes roomType, SecretBasePlacementTypes decorationType) { if (decorationType == SecretBasePlacementTypes.Empty) return true; else if (decorationType == SecretBasePlacementTypes.DollBack) return roomType != SecretBasePlacementTypes.BedroomFloor; else return AllowedPlacements[decorationType].Contains(roomType); }
private void CompileTypeData(string type) { if (type == "SMALL SOLID") { dataType = DecorationDataTypes.SmallSolid; originX = 0; originY = 0; placementGrid = new SecretBasePlacementTypes[1, 1] { { SecretBasePlacementTypes.Solid } }; } else if (type == "WIDE DESK") { dataType = DecorationDataTypes.WideDesk; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 3] { { SecretBasePlacementTypes.Mat, SecretBasePlacementTypes.MatCenter, SecretBasePlacementTypes.Mat }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid } }; } else if (type == "LARGE DESK") { dataType = DecorationDataTypes.LargeDesk; originX = 0; originY = 2; placementGrid = new SecretBasePlacementTypes[3, 3] { { SecretBasePlacementTypes.Mat, SecretBasePlacementTypes.MatCenter, SecretBasePlacementTypes.Mat }, { SecretBasePlacementTypes.Mat, SecretBasePlacementTypes.MatCenter, SecretBasePlacementTypes.Mat }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid } }; } else if (type == "SMALL STEPABLE") { dataType = DecorationDataTypes.SmallStepable; originX = 0; originY = 0; placementGrid = new SecretBasePlacementTypes[1, 1] { { SecretBasePlacementTypes.Solid } }; } else if (type == "SMALL STATUE") { dataType = DecorationDataTypes.SmallStatue; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 1] { { SecretBasePlacementTypes.Back }, { SecretBasePlacementTypes.Solid } }; } else if (type == "LARGE STATUE") { dataType = DecorationDataTypes.LargeStatue; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 2] { { SecretBasePlacementTypes.Back, SecretBasePlacementTypes.Back }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid } }; } else if (type == "BRICK") { dataType = DecorationDataTypes.Brick; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 1] { { SecretBasePlacementTypes.Mat }, { SecretBasePlacementTypes.Solid } }; } else if (type == "TENT") { dataType = DecorationDataTypes.Tent; originX = 0; originY = 2; placementGrid = new SecretBasePlacementTypes[3, 3] { { SecretBasePlacementTypes.BackNoWall, SecretBasePlacementTypes.BackNoWall, SecretBasePlacementTypes.BackNoWall }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid } }; } else if (type == "BOARD") { dataType = DecorationDataTypes.Board; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 1] { { SecretBasePlacementTypes.Board }, { SecretBasePlacementTypes.Board } }; } else if (type == "SLIDE") { dataType = DecorationDataTypes.Slide; originX = 0; originY = 3; placementGrid = new SecretBasePlacementTypes[4, 2] { { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid } }; } else if (type == "TIRE") { dataType = DecorationDataTypes.Tire; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 2] { { SecretBasePlacementTypes.Mat, SecretBasePlacementTypes.Mat }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid } }; } else if (type == "STAND") { dataType = DecorationDataTypes.Stand; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 4] { { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Solid } }; } else if (type == "DOOR") { dataType = DecorationDataTypes.Door; originX = 0; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 1] { { SecretBasePlacementTypes.Back }, { SecretBasePlacementTypes.Solid } }; } else if (type == "NOTE MAT") { dataType = DecorationDataTypes.NoteMat; originX = 0; originY = 0; placementGrid = new SecretBasePlacementTypes[1, 1] { { SecretBasePlacementTypes.Solid } }; } else if (type == "LARGE MAT") { dataType = DecorationDataTypes.LargeMat; originX = 0; originY = 2; placementGrid = new SecretBasePlacementTypes[3, 3] { { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Mat, SecretBasePlacementTypes.Solid }, { SecretBasePlacementTypes.Mat, SecretBasePlacementTypes.MatCenter, SecretBasePlacementTypes.Mat }, { SecretBasePlacementTypes.Solid, SecretBasePlacementTypes.Mat, SecretBasePlacementTypes.Solid } }; } else if (type == "SMALL POSTER") { dataType = DecorationDataTypes.SmallPoster; originX = 0; originY = 0; placementGrid = new SecretBasePlacementTypes[1, 1] { { SecretBasePlacementTypes.Poster } }; } else if (type == "LARGE POSTER") { dataType = DecorationDataTypes.LargePoster; originX = 0; originY = 0; placementGrid = new SecretBasePlacementTypes[1, 2] { { SecretBasePlacementTypes.Poster, SecretBasePlacementTypes.Poster } }; } else if (type == "SMALL DOLL") { dataType = DecorationDataTypes.SmallDoll; originX = 0; originY = 0; placementGrid = new SecretBasePlacementTypes[1, 1] { { SecretBasePlacementTypes.Doll } }; } else if (type == "LARGE DOLL") { dataType = DecorationDataTypes.LargeDoll; originX = 1; originY = 1; placementGrid = new SecretBasePlacementTypes[2, 3] { { SecretBasePlacementTypes.Empty, SecretBasePlacementTypes.DollBack, SecretBasePlacementTypes.Empty }, { SecretBasePlacementTypes.DollSide, SecretBasePlacementTypes.Doll, SecretBasePlacementTypes.DollSide } }; } else if (type == "UNKNOWN") { dataType = DecorationDataTypes.Unknown; originX = 0; originY = 0; placementGrid = new SecretBasePlacementTypes[0, 0]; } SecretBasePlacementTypes[,] finalPlacementGrid = new SecretBasePlacementTypes[placementGrid.GetLength(1), placementGrid.GetLength(0)]; for (int x = 0; x < placementGrid.GetLength(1); x++) { for (int y = 0; y < placementGrid.GetLength(0); y++) { finalPlacementGrid[x, y] = placementGrid[y, x]; } } placementGrid = finalPlacementGrid; }
protected void RemoveInvalidDecorations() { SecretBasePlacementTypes[,] finalGrid = (SecretBasePlacementTypes[, ])RoomData.PlacementGrid.Clone(); List <DecorationDataTypes> dollTypes = new List <DecorationDataTypes>() { DecorationDataTypes.SmallDoll, DecorationDataTypes.LargeDoll }; // Everything else foreach (PlacedDecoration decoration in PlacedDecorations) { if (dollTypes.Contains(decoration.DecorationData.DataType)) { continue; } for (int x = 0; x < decoration.DecorationData.Width; x++) { for (int y = 0; y < decoration.DecorationData.Height; y++) { int finalX = decoration.X - decoration.DecorationData.OriginX + x; int finalY = decoration.Y - decoration.DecorationData.OriginY + y; if (finalX < 0 || finalY < 0 || finalX >= RoomData.Width || finalY >= RoomData.Height) { continue; } SecretBasePlacementTypes place = decoration.DecorationData.PlacementGrid[x, y]; if (CanPlaceTypeOn(finalGrid[finalX, finalY], place)) { if (place != SecretBasePlacementTypes.Empty && place != SecretBasePlacementTypes.DollSide && place != SecretBasePlacementTypes.DollBack) { finalGrid[finalX, finalY] = place; } } } } } List <PlacedDecoration> toRemove = new List <PlacedDecoration>(); // Dolls foreach (PlacedDecoration decoration in PlacedDecorations) { if (!dollTypes.Contains(decoration.DecorationData.DataType)) { continue; } for (int x = 0; x < decoration.DecorationData.Width; x++) { for (int y = 0; y < decoration.DecorationData.Height; y++) { int finalX = decoration.X - decoration.DecorationData.OriginX + x; int finalY = decoration.Y - decoration.DecorationData.OriginY + y; if (finalX < 0 || finalY < 0 || finalX >= RoomData.Width || finalY >= RoomData.Height) { if (!toRemove.Contains(decoration)) { toRemove.Add(decoration); } continue; } SecretBasePlacementTypes place = decoration.DecorationData.PlacementGrid[x, y]; if (CanPlaceTypeOn(finalGrid[finalX, finalY], place)) { if (place != SecretBasePlacementTypes.Empty && place != SecretBasePlacementTypes.DollSide && place != SecretBasePlacementTypes.DollBack) { finalGrid[finalX, finalY] = place; } } else if (!toRemove.Contains(decoration)) { toRemove.Add(decoration); } } } } foreach (PlacedDecoration decoration in toRemove) { PlacedDecorations.Remove(decoration); } }