public void PerformSummaryLayout(Graphics grDungeon, StringBuilder sbBGMapEditorFileContents) { // Load the summary tile image Image iTileImage = TokenUtilities.GetTokenImage(this, false, "", true); if (null != iTileImage) { grDungeon.DrawImage(iTileImage, new Rectangle(ptLayoutTileLayoutLocation.X, ptLayoutTileLayoutLocation.Y, iTileImage.Width, iTileImage.Height)); } // Add the current summary tile to the MAP file sbBGMapEditorFileContents.AppendLine(sBGMapEditorLayoutTilePath + ";tile;" + ptLayoutTileLayoutLocation.X.ToString() + "x" + ptLayoutTileLayoutLocation.Y.ToString() + ";5"); // Add the bridge if (null != cBridge) { Point ptBridgeLocation = new Point(ptLayoutTileLayoutLocation.X, ptLayoutTileLayoutLocation.Y); switch (iConnectedCorridorZoneEdge) { case 1: ptBridgeLocation.Offset(2 * (iLayoutTileWidth / 3), iLayoutTileHeight); break; case 2: ptBridgeLocation.Offset(iLayoutTileWidth / 3, iLayoutTileHeight); break; case 3: ptBridgeLocation.Offset(0, iLayoutTileHeight); break; case 4: // It is rotated 90 degrees, so use the Height for the X-width offset ptBridgeLocation.Offset(-1 * cBridge.LayoutTileHeight, 2 * (iLayoutTileHeight / 3)); break; case 5: // It is rotated 90 degrees, so use the Height for the X-width offset ptBridgeLocation.Offset(-1 * cBridge.LayoutTileHeight, iLayoutTileHeight / 3); break; case 6: // It is rotated 90 degrees, so use the Height for the X-width offset ptBridgeLocation.Offset(-1 * cBridge.LayoutTileHeight, 0); break; case 7: ptBridgeLocation.Offset(0, -1 * cBridge.LayoutTileHeight); break; case 8: ptBridgeLocation.Offset(iLayoutTileWidth / 3, -1 * cBridge.LayoutTileHeight); break; case 9: ptBridgeLocation.Offset(2 * (iLayoutTileWidth / 3), -1 * cBridge.LayoutTileHeight); break; case 10: ptBridgeLocation.Offset(iLayoutTileWidth, 0); break; case 11: ptBridgeLocation.Offset(iLayoutTileWidth, iLayoutTileHeight / 3); break; case 12: ptBridgeLocation.Offset(iLayoutTileWidth, 2 * (iLayoutTileHeight / 3)); break; default: break; } sbBGMapEditorFileContents.AppendLine(cBridge.BGMapEditorLayoutTilePath + ";tile;" + ptBridgeLocation.X.ToString() + "x" + ptBridgeLocation.Y.ToString() + ";5"); Image iBridgeImage = TokenUtilities.GetTokenImage(cBridge, false, "", true); if (null != iBridgeImage) { grDungeon.DrawImage(iBridgeImage, new Rectangle(ptBridgeLocation.X, ptBridgeLocation.Y, iBridgeImage.Width, iBridgeImage.Height)); } } }
public void PerformLayout(Graphics grDungeon, StringBuilder sbBGMapEditorFileContents, bool bUseFullColorTiles) { // Load the tile image Image iTileImage = TokenUtilities.GetTokenImage(this, bUseFullColorTiles); if (null != iTileImage) { grDungeon.DrawImage(iTileImage, new Rectangle(ptDungeonLayoutLocation.X, ptDungeonLayoutLocation.Y, iTileImage.Width, iTileImage.Height)); } // Add the current tile to the MAP file if (true == bUseFullColorTiles) { sbBGMapEditorFileContents.AppendLine(sBGMapEditorFullColorTilePath + ";tile;" + ptDungeonLayoutLocation.X.ToString() + "x" + ptDungeonLayoutLocation.Y.ToString() + ";25"); } else { sbBGMapEditorFileContents.AppendLine(sBGMapEditorTilePath + ";tile;" + ptDungeonLayoutLocation.X.ToString() + "x" + ptDungeonLayoutLocation.Y.ToString() + ";25"); } // Add the bridge if (null != cBridge) { string sBridgeTokenPath = cBridge.BGMapEditorTilePath; Point ptBridgeLocation = new Point(ptDungeonLayoutLocation.X, ptDungeonLayoutLocation.Y); switch (iConnectedCorridorZoneEdge) { case 1: ptBridgeLocation.Offset(2 * (iWidth / 3), iHeight); break; case 2: ptBridgeLocation.Offset(iWidth / 3, iHeight); break; case 3: ptBridgeLocation.Offset(0, iHeight); break; case 4: // It is rotated 90 degrees, so use the Height for the X-width offset ptBridgeLocation.Offset(-1 * cBridge.Height, 2 * (iHeight / 3)); sBridgeTokenPath = sBridgeTokenPath.Replace("r_0.png", "r_90.png"); break; case 5: // It is rotated 90 degrees, so use the Height for the X-width offset ptBridgeLocation.Offset(-1 * cBridge.Height, iHeight / 3); sBridgeTokenPath = sBridgeTokenPath.Replace("r_0.png", "r_90.png"); break; case 6: // It is rotated 90 degrees, so use the Height for the X-width offset ptBridgeLocation.Offset(-1 * cBridge.Height, 0); sBridgeTokenPath = sBridgeTokenPath.Replace("r_0.png", "r_90.png"); break; case 7: ptBridgeLocation.Offset(0, -1 * cBridge.Height); break; case 8: ptBridgeLocation.Offset(iWidth / 3, -1 * cBridge.Height); break; case 9: ptBridgeLocation.Offset(2 * (iWidth / 3), -1 * cBridge.Height); break; case 10: ptBridgeLocation.Offset(iWidth, 0); sBridgeTokenPath = sBridgeTokenPath.Replace("r_0.png", "r_90.png"); break; case 11: ptBridgeLocation.Offset(iWidth, iHeight / 3); sBridgeTokenPath = sBridgeTokenPath.Replace("r_0.png", "r_90.png"); break; case 12: ptBridgeLocation.Offset(iWidth, 2 * (iHeight / 3)); sBridgeTokenPath = sBridgeTokenPath.Replace("r_0.png", "r_90.png"); break; default: break; } sbBGMapEditorFileContents.AppendLine(sBridgeTokenPath + ";chip;" + ptBridgeLocation.X.ToString() + "x" + ptBridgeLocation.Y.ToString() + ";0"); Image iBridgeImage = TokenUtilities.GetTokenImage(cBridge, false, sBridgeTokenPath); if (null != iBridgeImage) { grDungeon.DrawImage(iBridgeImage, new Rectangle(ptBridgeLocation.X, ptBridgeLocation.Y, iBridgeImage.Width, iBridgeImage.Height)); } } // Add the start marker int iStartZone = 0; if (null != cStart) { iStartZone = TokenUtilities.DetermineFarthestZone(iConnectedCorridorZone, lstCorridorZones); // Determine where the center of the start zone is, then offset the point so that the start token is centered in the zone Point ptStart = TokenUtilities.DetermineZoneCenter(this, iStartZone); ptStart.Offset(-1 * (cStart.Width / 2), -1 * (cStart.Height / 2)); sbBGMapEditorFileContents.AppendLine(cStart.BGMapEditorTilePath + ";chip;" + ptStart.X.ToString() + "x" + ptStart.Y.ToString() + ";0"); Image imgStartImage = TokenUtilities.GetTokenImage(cStart); if (null != imgStartImage) { grDungeon.DrawImage(imgStartImage, new Rectangle(ptStart.X, ptStart.Y, cStart.Width, cStart.Height)); } } // Add the exit marker int iExitZone = 0; if (null != cExit) { iExitZone = TokenUtilities.DetermineFarthestZone(iPreviousConnectedCorridorZone, lstCorridorZones); // Determine where the center of the exit zone is, then offset the point so that the exit token is centered in the zone Point ptExit = TokenUtilities.DetermineZoneCenter(this, iExitZone); ptExit.Offset(-1 * (cExit.Width / 2), -1 * (cExit.Height / 2)); sbBGMapEditorFileContents.AppendLine(cExit.BGMapEditorTilePath + ";chip;" + ptExit.X.ToString() + "x" + ptExit.Y.ToString() + ";0"); Image imgExitImage = TokenUtilities.GetTokenImage(cExit); if (null != imgExitImage) { grDungeon.DrawImage(imgExitImage, new Rectangle(ptExit.X, ptExit.Y, cExit.Width, cExit.Height)); } } // Add the level marker // ** The level marker must go in a cooridor // - Give preference to the center of the tile // - Do not put the level marker in the same zone as the start or Exit marker int iSelectedZone = 5; if (false == lstCorridorZones.Contains(5)) { // randomly choose another zone, since the center of the tile is not a cooridor ArrayList lstPossibleLevelCorridorZones = new ArrayList(lstCorridorZones); if (null != cStart) { // This is a START tile, exclude the start zone lstPossibleLevelCorridorZones.Remove(iStartZone); } else if (null != cExit) { // This is an Exit tile, exclude the start zone lstPossibleLevelCorridorZones.Remove(iExitZone); } int iZoneIndex = TokenUtilities.rndGenerator.Next(0, lstPossibleLevelCorridorZones.Count); iSelectedZone = (int)(lstPossibleLevelCorridorZones[iZoneIndex]); } // Determine where the center of the selected zone is, then offset the point so that the level token is centered in the zone Point ptLevel = TokenUtilities.DetermineZoneCenter(this, iSelectedZone); ptLevel.Offset(-1 * (cLevel.Width / 2), -1 * (cLevel.Height / 2)); sbBGMapEditorFileContents.AppendLine(cLevel.BGMapEditorTilePath + ";chip;" + ptLevel.X.ToString() + "x" + ptLevel.Y.ToString() + ";0"); Image imgLevelImage = TokenUtilities.GetTokenImage(cLevel); if (null != imgLevelImage) { grDungeon.DrawImage(imgLevelImage, new Rectangle(ptLevel.X, ptLevel.Y, cLevel.Width, cLevel.Height)); } // Add the doors if (0 < iDoors) { // Get a list of all possible door locations, based upon the corridors on the tile ArrayList lstAvailableDoorLocations = TokenUtilities.DetermineAvailableDoorLocations(lstCorridorZones); for (int iDoorIterator = 0; iDoorIterator < iDoors; iDoorIterator++) { if (0 >= lstAvailableDoorLocations.Count) { // No available locations left break; } // Determine door location int iDoorIndex = TokenUtilities.rndGenerator.Next(0, lstAvailableDoorLocations.Count); string sDoorToPlace = (string)(lstAvailableDoorLocations[iDoorIndex]); // Remove the selected door placement so that it cannot be used again lstAvailableDoorLocations.Remove(sDoorToPlace); string[] asDoorToPlaceComponents = sDoorToPlace.Split("-".ToCharArray()); // Wastefully create a new point here, as we need to declare it outside of the If statement below Point ptDoorLocation = new Point(ptDungeonLayoutLocation.X, ptDungeonLayoutLocation.Y); int iDoorZone; string sDoorTokenPath = cDoor.BGMapEditorTilePath; if (true == int.TryParse(asDoorToPlaceComponents[0], out iDoorZone)) { ptDoorLocation = TokenUtilities.DetermineZoneCenter(this, iDoorZone); switch (asDoorToPlaceComponents[1]) { case "Top": sDoorTokenPath = sDoorTokenPath.Substring(0, sDoorTokenPath.LastIndexOf("r_0.png")) + "r_180.png"; //sDoorTokenPath = sDoorTokenPath.Replace("r_0.png", "r_180.png"); // Offset the point up so that it is at the top, middle of the current zone ptDoorLocation.Offset(0, -1 * (this.Height / 6)); // Now offset the door location by half of the door width and height ptDoorLocation.Offset(-1 * (cDoor.Width / 2), -1 * (cDoor.Height / 2)); break; case "Bottom": // Offset the point up so that it is at the bottom, middle of the current zone ptDoorLocation.Offset(0, (this.Height / 6)); // Now offset the door location by half of the door width and height ptDoorLocation.Offset(-1 * (cDoor.Width / 2), -1 * (cDoor.Height / 2)); break; case "Left": sDoorTokenPath = sDoorTokenPath.Substring(0, sDoorTokenPath.LastIndexOf("r_0.png")) + "r_90.png"; // Offset the point up so that it is at the left, middle of the current zone ptDoorLocation.Offset(-1 * (this.Width / 6), 0); // Now offset the door location by half of the door width and height (swap width/height since the door is to be rotated 90 degrees) ptDoorLocation.Offset(-1 * (cDoor.Height / 2), -1 * (cDoor.Width / 2)); break; case "Right": default: sDoorTokenPath = sDoorTokenPath.Substring(0, sDoorTokenPath.LastIndexOf("r_0.png")) + "r_270.png"; // Offset the point up so that it is at the right, middle of the current zone ptDoorLocation.Offset((this.Height / 6), 0); // Now offset the door location by half of the door width and height (swap width/height since the door is to be rotated 270 degrees) ptDoorLocation.Offset(-1 * (cDoor.Height / 2), -1 * (cDoor.Width / 2)); break; } } sbBGMapEditorFileContents.AppendLine(sDoorTokenPath + ";chip;" + ptDoorLocation.X.ToString() + "x" + ptDoorLocation.Y.ToString() + ";0"); Image imgDoorImage = TokenUtilities.GetTokenImage(cDoor, false, sDoorTokenPath); if (null != imgDoorImage) { grDungeon.DrawImage(imgDoorImage, new Rectangle(ptDoorLocation.X, ptDoorLocation.Y, imgDoorImage.Width, imgDoorImage.Height)); } } } }