protected IXCTileset(string name) : base(name) { myPal = GameInfo.DefaultPalette; mapSize = new MapSize(60, 60, 4); mapDepth = 0; underwater = true; baseStyle = false; }
/// <summary> /// Generates a dungeon, and allows for an optional seed /// </summary> /// <param name="size">The desired size</param> /// <param name="seed">Generation seed</param> /// <returns>An <see cref="ITileMap"/>, a 2D array of tile information</returns> public static ITileMap Generate(MapSize size, uint seed) { var map = new TileMap((int) size, (int) size); var parameters = GeneratorParams.Default; parameters.Seed = seed; new CellBasedGenerator(parameters).Generate(map); return map; }
//Generate empty select mask public static bool[,] GenerateSelectMask(MapSize currentMap) { bool[,] slectionMask = new bool[currentMap.x, currentMap.y]; //Loop over every pixel and set it to false for (int y = 0; y < currentMap.y; y++) { for (int x = 0; x < currentMap.x; x++) { slectionMask[x, y] = false; } } return(slectionMask); }
public static void CreateTempMapFiles(MapSize SizeToCreate, string strNameOfMap, Homm5RMG.Properties.Settings settings, int [] SelectedFactions, int[][] ExcludedPlayersFactions) { DeleteTempMapFiles(); strMapName = strNameOfMap; string strTargetTemp = MAPS_INITIAL_DIR + strMapName; Directory.CreateDirectory(strTargetTemp); DirectoryInfo dirinfEmptyMapFiles = new DirectoryInfo(Assembly.GetExecutingAssembly().CodeBase.Substring(0, Assembly.GetExecutingAssembly().CodeBase.Length - 12).Substring(8) + "Data\\Basic Empty Map Files\\" + SizeToCreate.ToString()); CopyToTarget(dirinfEmptyMapFiles, "", strTargetTemp); SetMapName(); SetMapParameters(settings, SelectedFactions, ExcludedPlayersFactions); }
public Product Map(ProductInfoModel source) { var destination = new Product(); MapManufacturer?.Invoke(source, destination); MapCountryOfOrigin?.Invoke(source, destination); MapImporter?.Invoke(source, destination); MapImporterCountry?.Invoke(source, destination); MapName?.Invoke(source, destination); MapQuantityPerPackage?.Invoke(source, destination); MapImage?.Invoke(source, destination); MapSize?.Invoke(source, destination); MapLogoPath?.Invoke(source, destination); return(destination); }
//Generate empty view mask public static bool[,] GenerateViewMask(MapSize currentMap) { //Create 2d mask array bool[,] mask = new bool[currentMap.x, currentMap.y]; //Loop over every pixel and set it to false for (int y = 0; y < currentMap.y; y++) { for (int x = 0; x < currentMap.x; x++) { mask[x, y] = false; } } return(mask); }
private IAreaMap GenerateMap( int level, MapSize size, out Point playerPosition) { var mapType = GenerateMapType(level); var generator = generators[mapType]; var map = generator.Generate(level, size, out playerPosition); if (writeMapFile) { WriteMapToFile(map, playerPosition); } return(map); }
// Use this for initialization void Start() { var stageController = GameObject.Find("StageController"); stageMake = stageController.GetComponent <StageMake>(); designer = stageController.GetComponent <Designer>(); maxRail = stageMake.maxRail; mapData = designer.mapData; mapSize = this.GetComponent <MapSize>(); CheckFirstOrEnd(); mapSize.getInstance .Where(x => x == 1) .Subscribe(_ => CheckLastSpart()); }
public IAreaMap Generate(int level, MapSize size, out Core.Game.Point playerPosition) { var builder = new MapBuilder(1, 1); switch (size) { case MapSize.Small: ConfigureSmallMap(builder); break; case MapSize.Medium: ConfigureMediumMap(builder); break; case MapSize.Big: ConfigureBigMap(builder); break; default: throw new ArgumentException($"Unknown map size: {size}"); } var mapBuilt = BuildMap(builder); if (!mapBuilt) { throw new MapGenerationException("Unable to build dungeon map."); } var simplifiedMap = SimplifyMap(builder.Map, builder.MapSize.Width, builder.MapSize.Height); var height = simplifiedMap.Length; var width = simplifiedMap[0].Length; var map = ConvertMap(level, simplifiedMap, width, height); playerPosition = FindPlayerPosition(map); if (level > 1) { map.AddObject(playerPosition, mapObjectsFactory.CreateStairs()); } objectsGenerator.GenerateObjects(map, playerPosition); monstersGenerator.GenerateMonsters(map, playerPosition); return(map); }
private void InitMapSizes() { mapSizeDropdown.ClearOptions(); List <string> options = new List <string>(); foreach (MapSize mapSize in mapSizeList.mapSizes) { options.Add(mapSize.name); } mapSizeDropdown.AddOptions(options); mapSizeDropdown.value = 0; mapSizeDropdown.RefreshShownValue(); currentMapSize = mapSizeList.mapSizes[0]; }
public void MergeFrom(EnvironmentMetadata other) { if (other == null) { return; } if (other.mapSize_ != null) { if (mapSize_ == null) { mapSize_ = new global::CyberLife.Protobuff.MapSize(); } MapSize.MergeFrom(other.MapSize); } phenomenaMetadata_.Add(other.phenomenaMetadata_); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
/// <summary> /// Инициализирует экземпляр SunPhenomen, /// занимающий верхнюю половину площади карты /// </summary> /// <param name="mapSize">Размер карты</param> public SunPhenomen(MapSize mapSize) { log.Trace(LogPhenomenMessages.Constructor, "SunPhenomen"); _powerFactor = NormalPowerFactor; if (mapSize == null) { ArgumentNullException ex = new ArgumentNullException(nameof(mapSize)); log.Error(LogPhenomenMessages.NullArgument, "MapSize", ex); throw ex; } List <Point> points = new List <Point>(2); points.Add(new Point(0, 0)); points.Add(new Point(mapSize.Width, (int)Math.Round(mapSize.Height * SunDepthFactor))); _place = new Place(points, PlaceType.Rectangle); log.Trace(LogPhenomenMessages.OkConstructor, "SunPhenomen"); }
//移除墙体 public void JoinWall(int SceneID) { if (m_lWall.Contains(SceneID) == false) { if (Type == GridType.GRID_HOLE || Type == GridType.GRID_HOLESTAIR) { Down = null; int width = MapSize.GetLayerSize(GridPos.Layer); for (int i = 0; i < width; i++) { MapGrid g = GetMG(GridPos.Layer, i); if (g != null) { if (g.m_NpNearestStation[(int)NearestStationDir.NSD_LEFTDOWN] == this) { if (Left != null && (Left.Type == GridType.GRID_HOLE || Left.Type == GridType.GRID_HOLESTAIR)) { g.m_NpNearestStation[(int)NearestStationDir.NSD_LEFTDOWN] = Left; } else { g.m_NpNearestStation[(int)NearestStationDir.NSD_LEFTDOWN] = null; } } if (g.m_NpNearestStation[(int)NearestStationDir.NSD_CENTERDOWN] == this) { g.m_NpNearestStation[(int)NearestStationDir.NSD_CENTERDOWN] = null; } if (g.m_NpNearestStation[(int)NearestStationDir.NSD_RIGHTDOWN] == this) { if (Right != null && (Right.Type == GridType.GRID_HOLE || Right.Type == GridType.GRID_HOLESTAIR)) { g.m_NpNearestStation[(int)NearestStationDir.NSD_RIGHTDOWN] = Right; } else { g.m_NpNearestStation[(int)NearestStationDir.NSD_RIGHTDOWN] = null; } } } } } m_lWall.Add(SceneID); SetGridType(GridType.GRID_WALL); } }
/// <summary> /// Create a new game, using the provided configuration parameters /// </summary> /// <param name="mapType">The map type</param> /// <param name="mapSize">Size of the map</param> /// <param name="numberOfPlayers">Number of players</param> /// <param name="killLimit">Number of kills needed for a player to win the game</param> /// <param name="numberPlanets">Number of randomly generated planets</param> /// <param name="numberBlackHoles">Number of randomly generated black holes</param> public void CreateNewGame(MapType mapType, MapSize mapSize, int numberOfPlayers, int killLimit, int numberPlanets, int numberBlackHoles) { Weapon.GlobalReloadTimeMultiplier = 1; GameOver = false; KillLimit = killLimit; this.numberPlanets = numberPlanets; this.numberBlackHoles = numberBlackHoles; int[] size = Utility.MapSizeToInts(mapSize); Terrain terrain; if (mapType == MapType.Simple) { terrain = new SimpleTerrain(size[0], size[1]); } else { terrain = new RandomTerrain(size[0], size[1]); } NewGame(terrain, rand.Next(2000)); /* Choose a background image */ RandomizeBackground(); /* Add planets */ for (int i = 0; i < numberPlanets; i++) { Planet planet = new Planet(0.03f, 0.03f, 0.3f, 1.0f); PlaceEntity(planet); Add(planet); } /* Add black holes */ for (int i = 0; i < numberBlackHoles; i++) { BlackHole blackHole = new BlackHole(1000, 4000); PlaceEntity(blackHole); Add(blackHole); } /* init players */ InitPlayers(numberOfPlayers); }
private int GetSize(MapSize size) { switch (size) { case MapSize.Small: return(SizeSmall); case MapSize.Medium: return(SizeMedium); case MapSize.Big: return(SizeBig); default: throw new ArgumentException($"Unknown map size: {size}"); } }
private void UpdateMapSize() { MapSize ms = mapSizes[0]; for (int i = 0; i < mapSizeToggles.Length; i++) { if (mapSizeToggles[i].isOn) { ms = mapSizes[i]; break; } } gbStage.SetGroundSizeX(ms.x); gbStage.SetGroundSizeZ(ms.z); networking.TriggerTerrainReset(); SetMapSizeOpen(false); }
/// <summary> /// Message send to the client after login to the server. Contains welcome package for client: map size, starting position /// initial color of the robot, round time. /// </summary> /// <param name="oSender"></param> /// <param name="Args"></param> void ClientsLibrary_InitialMessageReciveEvent(object oSender, InitialMessageRecivedArgs Args) { Position _myLocalPosition = null; _startingPosition = Args.response.MyPosition; _myLocalPosition = Args.response.MyPosition; _myColor = Args.response.Color; _roundTime = Args.response.RoundTime; _globalMapSize = Args.response.GlobalMapSize; if (_myLocalPosition != null) { EventLog.WriteMessageToLog(logFilePath, "Initial Message recived with local position: " + _myLocalPosition.ToString()); } Dispatcher.Invoke(() => changeWindowClientColor(_myColor)); Dispatcher.Invoke(() => roundTextBox.Text = Args.response.RoundNumber.ToString()); Dispatcher.Invoke(() => scoreTextBox.Text = "0"); Dispatcher.Invoke(() => MessageTextBox.Text = Args.response.Message); }
public Vector3 GetDolphineRightPoint() { int height = MapSize.GetMapLayer(); int width = MapSize.GetLayerSize(0) / MapGrid.m_UnitRoomGridNum; int start = 4; for (int i = (height - 1); i >= 0; i--) { for (int j = (width - 1); j >= 0; j--) { MapGrid g = MapGrid.GetMG(i, j * MapGrid.m_UnitRoomGridNum + start); if (g != null && g.Type != GridType.GRID_HOLE && g.Type != GridType.GRID_HOLESTAIR) { return(g.WorldPos); } } } return(Vector3.zero); }
public void GenerateImage(Link link, string faction1, string faction2, string offensiveFaction) { var fileName = link.GetFileName(Galaxy, faction1, faction2, offensiveFaction); var linkDrawing = GetLinkDrawing(link, faction1, faction2, offensiveFaction); if (linkDrawing != null && !File.Exists(fileName)) { var bitmapSize = GetImageBounds(link).Size.Multiply(AntiAliasFactor); using (var bitmap = new Bitmap(bitmapSize.Width, bitmapSize.Height)) { var location = new Point(Padding * AntiAliasFactor, Padding * AntiAliasFactor); using (var g = Graphics.FromImage(bitmap)) { SetHighQuality(g); linkDrawing.Draw(g, location, MapSize.Multiply(AntiAliasFactor)); } bitmap.HighQualityResize(1 / (float)AntiAliasFactor).Save( Path.Combine(ImagePath, fileName), ImageFormat); } } }
private void CreateEnterTrigger() { MapSize finalRoom = FindFinalroom(); MapSize initialRoom = FindInitialroom(); GameObject[] Rooms = GameObject.FindGameObjectsWithTag("Room"); for (int i = 0; i < mapSize.Count; i++) { if (!(mapSize[i].roomNumber == initialRoom.roomNumber) && !(mapSize[i].roomNumber == finalRoom.roomNumber) && !(SpecialRoomNumber.Contains(mapSize[i].roomNumber))) { GameObject EnteranceTrigger = Instantiate(TriggerObject, new Vector3Int(mapSize[i].center.x, mapSize[i].center.y, 0), Quaternion.identity); EnteranceTrigger.GetComponent <BoxCollider2D>().size = new Vector2(mapSize[i].width, mapSize[i].height); EnteranceTrigger.transform.SetParent(Rooms[i].transform); EnteranceTrigger.GetComponentInParent <EnemyArea>().width = mapSize[i].width; EnteranceTrigger.GetComponentInParent <EnemyArea>().height = mapSize[i].height; } } }
public static Map GetEmptyMap(MapSize size) { var map = new Map(); map.MapSize = size; map.MapData = new List <List <ITile> >(); for (int i = 0; i < (int)size; i++) { map.MapData.Add(new List <ITile>()); for (int j = 0; j < (int)size; j++) { map.MapData[i].Add(null); } } return(map); }
private List <MapArea> SetAreas(MapSize mapSize) { List <MapArea> area = new List <MapArea>(); for (int z = 0; z < areasColumn; z++) { for (int x = 0; x < areasRow; x++) { int areaX = (z % 2 == 0) ? x * areaTilesRow : (areasRow - 1 - x) * areaTilesRow; int areaZ = z * areaTilesColumn; MapArea newArea = new MapArea(areaX, areaZ); area.Add(newArea); } } return(area); }
public void TestCellsMatrix() { MapSize size = new MapSize(1000, 1000); MapPlace place = new MapPlace(new MapImage(MapImageType.Bmp, null), 1); MapCell cell = new MapCell(place, null); MapMatrix <MapCell> matrix1 = new MapMatrix <MapCell>(size); MapCell[,] matrix2 = new MapCell[size.Width, size.Height]; for (int x = 0; x < size.Width; x++) { for (int y = 0; y < size.Height; y++) { matrix1[x, y] = cell; matrix2[x, y] = cell; } } DateTime start1 = DateTime.Now; for (int i = 0; i < 1000000; i++) { cell = matrix1[25, 68]; } DateTime finish1 = DateTime.Now; DateTime start2 = DateTime.Now; for (int i = 0; i < 1000000; i++) { cell = matrix2[25, 68]; } DateTime finish2 = DateTime.Now; double result1 = (finish1 - start1).TotalMilliseconds; double result2 = (finish2 - start2).TotalMilliseconds; Assert.IsTrue(result1 < 100); }
public MapInfo(MapSize size) { rows = 3; cols = 3; rooms = new Room[rows, cols]; rooms[0, 0] = new NavRoom(); rooms[0, 1] = new NavRoom(); rooms[0, 2] = new TrapRoom(); rooms[1, 1] = new CombatRoom(); rooms[2, 1] = new NavRoom(); rooms[2, 0] = new TrapRoom(); rooms[2, 2] = new NavRoom(); currRow = 0; currCol = 0; startRoom = rooms[currRow, currCol]; endRoom = rooms[2, 2]; }
public IAreaMap Generate(int level, MapSize size, out Point playerPosition) { var mapSize = GetSize(size); var labyrinthWidth = (mapSize - 1) / 2; var labyrinthHeight = labyrinthWidth; var roomsMap = GenerateLabyrinth(labyrinthWidth, labyrinthHeight, out playerPosition); playerPosition.X = playerPosition.X * 2 + 1; playerPosition.Y = playerPosition.Y * 2 + 1; var map = ConvertToAreaMap(level, roomsMap, mapSize, mapSize); var endPosition = GetEndPosition(map, playerPosition); map.AddObject(playerPosition, mapObjectsFactory.CreateStairs()); map.AddObject(endPosition, mapObjectsFactory.CreateTrapDoor()); return(map); }
public Map ReadMap(MapSize worldSize) { var mapPath = this.ReadSaveString(); var map = Map.FindByPath(mapPath); if (map != null) { map.SetMapSize(worldSize); } else { string mapName = Path.GetFileNameWithoutExtension(mapPath); map = new Map ( name: mapName, mapSize: MapPropertyLib.NonStandardMapSizeProp(worldSize), saveName: mapPath ); } return(map); }
private MapHandler ConfigureMapHandler(MapSize size) { const int sizeSmall = 25; const int sizeMedium = 35; const int sizeBig = 45; switch (size) { case MapSize.Small: return(new MapHandler(sizeSmall, sizeSmall, new int[sizeSmall, sizeSmall])); case MapSize.Medium: return(new MapHandler(sizeMedium, sizeMedium, new int[sizeMedium, sizeMedium])); case MapSize.Big: return(new MapHandler(sizeBig, sizeBig, new int[sizeBig, sizeBig])); default: throw new ArgumentException($"Unknown map size {size}"); } }
void Awake() { if (GlobalVariables.Instance != null)//Else use the default or previous instance { GLOBALS = GlobalVariables.Instance; } mapSize = GLOBALS.mapSize; mapTheme = GLOBALS.mapTheme; platformRowNums = new List <int>(); zoneObjects = new List <GameObject>(); zonePrefabNum = new List <int>(); startingColliderPlatform = new List <int>(); rand = new System.Random(); xZoneOffset = new Vector3(xZoneSize + 6, 0, 0); yZoneOffset = new Vector3(0, yZoneSize + 3, 0); switch (mapSize) { case MapSize.Large: numRows = largeZoneRows; numCols = largeZoneColumns; break; case MapSize.Medium: numRows = mediumZoneRows; numCols = mediumZoneColumns; break; case MapSize.Small: numRows = smallZoneRows; numCols = smallZoneColumns; break; default: Debug.LogError("Map size not Initalized yet!"); break; } GenerateMap(); }
public void setMenuState(MenuState state) { menuState = state; switch (state) { case MenuState.MainMenu: Menu.SetMenuItems(mainMenuItems); break; case MenuState.SettingsMenu: Menu.SetMenuItems(settingsMenuItems); break; case MenuState.GameConfigMenu: // Before entering game config menu, set game config variables (and content of game // configuration menu) to default values. // Map size is set by default to the same dimensions as the current screen resolution. numberPlayers = 2; mapType = MapType.Simple; string size = Settings.Resolution.ToString().Split('_')[1]; // Settings.Resolution.ToString() looks like: Res_1024x768 mapSize = (MapSize)Enum.Parse(typeof(MapSize), "Size_" + size); numberPlanets = 3; numberBlackHoles = 2; killLimit = 10; gameConfigMenuItems[0] = NUM_PLAYERS + numberPlayers; gameConfigMenuItems[1] = MAP_TYPE + mapType; gameConfigMenuItems[2] = MAP_SIZE + size; gameConfigMenuItems[3] = NUM_PLANETS + numberPlanets; gameConfigMenuItems[4] = NUM_BLACKHOLES + numberBlackHoles; gameConfigMenuItems[5] = KILL_LIMIT + killLimit; Menu.SetMenuItems(gameConfigMenuItems); break; case MenuState.PauseMenu: Menu.SetMenuItems(pauseMenuItems); break; } Menu.SelectedIndex = 0; }
public IAreaMap Generate(int level, MapSize size, out Point playerPosition) { var generator = ConfigureMapHandler(size); generator.RandomFillMap(); generator.MakeCaverns(); var simplifiedMap = SimplifyMap(generator.Map, generator.MapWidth, generator.MapHeight); var height = simplifiedMap.Length; var width = simplifiedMap[0].Length; var map = ConvertMap(level, simplifiedMap, width, height); playerPosition = FindPlayerPosition(map); map.AddObject(playerPosition, mapObjectsFactory.CreateStairs()); var trapDoorPosition = FindTrapDoorPosition(map, playerPosition); map.AddObject(trapDoorPosition, mapObjectsFactory.CreateTrapDoor()); return(map); }
public void CreateMap(int x, int y, int z) { mapSize = new MapSize(x, y, z); mapTileArray = new GameObject[x, y, z]; GameObject row; GameObject col; for (int i = 0; i < x; i++) { row = new GameObject(); row.name = "row" + i.ToString(); row.transform.parent = mapContainer.transform; for (int j = 0; j < y; j++) { col = new GameObject(); col.name = "col" + j.ToString(); col.transform.parent = row.transform; } } }
public Map CreateMap(EntryPointInfo entryPointInfo, MapSize mapSize, IMapGenerator generator) { var MapPrototype = generator.getMapPrototype(entryPointInfo, mapSize); float x = transform.position.x; float y = transform.position.y; for (int i = 0; i < mapSize.Horizontal; i++) { for (int j = 0; j < mapSize.Vertical; j++) { GameObject gameObject = Cells.First(g => g.name == MapPrototype[i, j].getTypeName()); Instantiate(gameObject, new Vector3(x + i * SpriteSize.x, y + j * SpriteSize.y), Quaternion.identity, transform); } } CreateItems(MapPrototype, mapSize); MapInfo.mapPrototype = MapPrototype; MapInfo.entryPointInfo = entryPointInfo; MapInfo.MapSize = mapSize; MapInfo.Width = mapSize.Horizontal * SpriteSize.x; MapInfo.Height = mapSize.Vertical * SpriteSize.y; return(MapInfo); }
public GameSettings(int points, string mapType, string mapSize, string mapWealth) { if (mapType == Strings.GAME_SETTINGS_MAP_TYPE_LOWLAND) this.mapType = MapType.LOWLAND; else if (mapType == Strings.GAME_SETTINGS_MAP_TYPE_NORMAL) this.mapType = MapType.NORMAL; else this.mapType = MapType.WASTELAND; if (mapSize == Strings.GAME_SETTINGS_MAP_SIZE_SMALL) this.mapSize = MapSize.SMALL; else if (mapSize == Strings.GAME_SETTINGS_MAP_SIZE_MEDIUM) this.mapSize = MapSize.MEDIUM; else this.mapSize = MapSize.BIG; if (mapWealth == Strings.GAME_SETTINGS_MAP_WEALTH_LOW) this.mapWealth = MapWealth.LOW; else if (mapWealth == Strings.GAME_SETTINGS_MAP_WEALTH_MEDIUM) this.mapWealth = MapWealth.MEDIUM; else this.mapWealth = MapWealth.HIGH; }
public Map ReadMap(MapSize worldSize) { var mapPath = this.ReadSaveString(); var map = Map.FindByPath(mapPath); if (map != null) { map.SetMapSize(worldSize); } else { string mapName = Path.GetFileNameWithoutExtension(mapPath); map = new Map ( name: mapName, mapSize: MapPropertyLib.NonStandardMapSizeProp(worldSize), saveName: mapPath ); } return map; }
public void ResizeTo(int r, int c, int h) { //MapTile[, ,] newMap = new MapTile[r, c, h]; IMapTile[] newMap = new IMapTile[r * c * h]; //newMap[(mapSize.Rows * mapSize.Cols * height) + (row * mapSize.Cols) + col] for (int hc = 0; hc < h; hc++) for (int rc = 0; rc < r; rc++) for (int cc = 0; cc < c; cc++) newMap[(r * c * hc) + (rc * c) + cc] = XCMapTile.BlankTile; //newMap[rc, cc, hc] = MapTile.BlankTile; for (int hc = 0; hc < h && hc < mapSize.Height; hc++) for (int rc = 0; rc < r && rc < mapSize.Rows; rc++) for (int cc = 0; cc < c && cc < mapSize.Cols; cc++) newMap[(r * c * (h - hc - 1)) + (rc * c) + cc] = this[rc, cc, mapSize.Height - hc - 1]; //newMap[rc, cc, h - hc - 1] = this[rc, cc, mapSize.Height - hc - 1]; mapData = newMap; mapSize = new MapSize(r, c, h); currentHeight = (byte)(mapSize.Height - 1); }
private void AdjustMapPathBySize(MapSize mapSize) { if (SizedMaps != null && SizedMaps.Count > 0) Path = SizedMaps[mapSize]; }
public static void SerializeMapSize(BinaryWriter Writer, MapSize Size) { Writer.Write(Size.Width); Writer.Write(Size.Height); }
public void SetMapSize(MapSize mapSize) { this._Size.Value = mapSize; AdjustMapSizeSideEffects(mapSize); }
private void AdjustMapSizeSideEffects(MapSize mapSize) { AdjustMapPathBySize(mapSize); AdjustCityStatesBySize(mapSize); }
/// <summary> /// Generates a dungeon /// </summary> /// <param name="size">The desired size</param> /// <param name="parameters">Generation options</param> /// <returns>An <see cref="ITileMap"/>, a 2D array of tile information</returns> public static ITileMap Generate(MapSize size, GeneratorParams parameters) { var map = new TileMap((int) size, (int) size); new CellBasedGenerator(parameters).Generate(map); return map; }
void Start() { DontDestroyOnLoad(gameObject); m_presets = new List<Preset>(); m_mapSizes = new List<MapSize>(); string text = ((TextAsset)Resources.Load("MapLayouts")).text; JsonData jsonData = JsonMapper.ToObject(text); int numPresets = jsonData.Count; for (int i = 0; i < numPresets; i++) { JsonData preset = jsonData[i.ToString()]; string name = preset["name"].ToString(); int numShips = int.Parse(preset["numShips"].ToString()); Preset newPreset = new Preset(name, numShips); for (int j = 0; j < numShips; j++) { JsonData ship = preset["ship" + (j + 1)]; int team = int.Parse(ship["team"].ToString()); int shipType = 0; string shipTypeString = ship["shipType"].ToString(); switch (shipTypeString) { case "Carrier": shipType = (int)ShipController.eShipType.SHIP_TYPE_CARRIER; break; case "Battleship": shipType = (int)ShipController.eShipType.SHIP_TYPE_BATTLESHIP; break; case "PatrolBoat": shipType = (int)ShipController.eShipType.SHIP_TYPE_PATROLBOAT; break; case "Cruiser": shipType = (int)ShipController.eShipType.SHIP_TYPE_CRUISER; break; case "Destroyer": shipType = (int)ShipController.eShipType.SHIP_TYPE_DESTROYER; break; case "Patrol Boat": shipType = (int)ShipController.eShipType.SHIP_TYPE_PATROL_BOAT; break; } float xPos = float.Parse(ship["xPos"].ToString()); float yPos = float.Parse(ship["yPos"].ToString()); float angle = float.Parse(ship["angle"].ToString()); float respawnTime = float.Parse(ship["respawn"].ToString()); Vector3[] path = new Vector3[4]; for (int k = 0; k < 4; k++) { JsonData point = ship["path"]["p" + (k + 1)]; float x = float.Parse(point["x"].ToString()); float y = float.Parse(point["y"].ToString()); path[k] = new Vector3(x, y, 0); } float pathSpeed = float.Parse(ship["pathSpeed"].ToString()); ShipInfo shipInfo = new ShipInfo(team, shipType, xPos, yPos, angle, respawnTime, path, pathSpeed); newPreset.m_ships.Add(shipInfo); } m_presets.Add(newPreset); } text = ((TextAsset)Resources.Load("MapSizes")).text; jsonData = JsonMapper.ToObject(text); numPresets = jsonData.Count; for (int i = 0; i < numPresets; i++) { JsonData preset = jsonData[i.ToString()]; string name = preset["name"].ToString(); float horz = float.Parse(preset["horizontalSize"].ToString()); float vert = float.Parse(preset["verticalSize"].ToString()); MapSize mapSize = new MapSize(name, horz, vert); m_mapSizes.Add(mapSize); } }
/// <summary> /// Generates a map on a 2D array of TileType. /// The map varies in size and length and may include a mix of any of the following: /// split pathing, tower plots, and decoration. /// </summary> /// <param name="size">Size of the map</param> /// <param name="length">Length of the path</param> /// <param name="splitPath">Whether to add split pathing or not</param> /// <param name="towerPercent">Percent of empty spaces adjacent to path tiles for tower plots</param> /// <param name="decorPercent">Percent of empty space in map for decoration tiles</param> /// <returns>A 2D array of TileType</returns> public static TileType[,] GenerateMap(MapSize size, MapLength length, bool splitPath, float towerPercent, float decorPercent) { StartUp(); TowerPercent = towerPercent; DecorPercent = decorPercent; bool goodMap = false; bool goodSplitPath = true; int startEndDistance = 0; int numOfTowers = 0; // Generate the map do { // initialize grid InitializeGrid(); // create path according to desired length goodMap = MakePath(size, length); // check the start and end point distance startEndDistance = StartEndDistance(); // if split pathing is desired if (splitPath) goodSplitPath = GenerateSplitPath(); } while (!goodMap || !goodSplitPath || startEndDistance < (int)size / 2); // calculate number of desired towers numOfTowers = CalculateTowerAmount(TowerPercent); // check if user wants more than 90% of empty space if (TowerPercent > TOO_MANY_TILES) PlaceTowerSequentially(); // else random placement else while (TowerCount() < numOfTowers) SingleTower(); // Place decorative objects // check if user wants more than 90% of empty space if (DecorPercent > TOO_MANY_TILES) PlaceDecorSequentially(); else PlaceDecor2(CalculateDecorAmount(DecorPercent)); return GetMapAsTileType(); }
protected IXCTileset(string name, StreamReader sr, VarCollection vars) : this(name) { while (sr.Peek() != -1) { string line = VarCollection.ReadLine(sr, vars); if (line == "end" || line == "END") return; int idx = line.IndexOf(':'); string keyword = line.Substring(0, idx); string keywordLow = keyword.ToLower(); string rest = line.Substring(idx + 1); switch (keywordLow) { case "palette": if (rest.ToLower() == "ufo") myPal = Palette.UFOBattle; else if (rest.ToLower() == "tftd") myPal = Palette.TFTDBattle; else myPal = Palette.GetPalette(rest); break; case "dll": string dllName = rest.Substring(rest.LastIndexOf(@"\") + 1); Console.WriteLine(name + " is in dll " + dllName); break; case "rootpath": rootPath = @rest; break; case "rmppath": rmpPath = @rest; break; case "basestyle": baseStyle = true; break; case "ground": groundMaps = rest.Split(' '); break; case "size": string[] dim = rest.Split(','); int rows = int.Parse(dim[0]); int cols = int.Parse(dim[1]); int height = int.Parse(dim[2]); mapSize = new MapSize(rows, cols, height); break; case "landmap": underwater = false; break; case "depth": mapDepth = int.Parse(rest); break; case "blankpath": blankPath = @rest; break; case "scang": scanFile = @rest; break; case "loftemp": loftFile = @rest; break; default: { //user-defined keyword ParseLine(keywordLow, rest, sr, vars); break; } } } }
/// <summary> /// Constructor. /// </summary> public Map(MapSize mapSize) { this.mapSize = mapSize; // The tileGrid is created when the map is generated. }
/// <summary> /// Calls the method to generate tile path. /// Parameters for map generation are dependant upon map size and path length desired /// </summary> /// <param name="size">Desired map size</param> /// <param name="length">Desired path length</param> /// <returns>true or false, whether a good map was generated</returns> private static bool MakePath(MapSize size, MapLength length) { bool map = false; // check for map size switch (size) { // small case MapSize.Small: // check length switch (length) { // short case MapLength.Short: map = RandomMapGenerator(10, 20, 20); break; // medium case MapLength.Medium: map = RandomMapGenerator(20, 35, 20); break; // long case MapLength.Long: map = RandomMapGenerator(30, 50, 20); break; default: break; } break; // medium case MapSize.Medium: switch (length) { case MapLength.Short: map = RandomMapGenerator(20, 24, 20); break; case MapLength.Medium: map = RandomMapGenerator(35, 50, 20); break; case MapLength.Long: map = RandomMapGenerator(50, 75, 20); break; default: break; } break; // large case MapSize.Large: switch (length) { case MapLength.Short: map = RandomMapGenerator(25, 35, 20); break; case MapLength.Medium: map = RandomMapGenerator(50, 70, 20); break; case MapLength.Long: map = RandomMapGenerator(75, 100, 20); break; default: break; } break; } return map; }
private void AdjustCityStatesBySize(MapSize mapSize) { NumberOfCityStates.Value = ((int)mapSize) * 2; }