public Details(EndianBinaryReader r) { Flags = r.ReadEnum <MapFlags>(); Section = r.ReadEnum <MapSection>(); Weather = r.ReadEnum <MapWeather>(); Music = r.ReadEnum <Song>(); }
public void StartWeather(MapDetails map) { mapDetails = map; weather = map.mapWeather; if (weather == MapWeather.Snow) { Snow(); } if (weather == MapWeather.Rain) { Rain(); } if (weather == MapWeather.Sunny) { StartCoroutine(Sun()); } wind.windMain = 1 * (1 + intensity); wind.windPulseMagnitude = 3 * (1 + intensity); weatherClip.Play(); windClip.Play(); }
public Details(JToken j) { Flags = j[nameof(Flags)].EnumValue <MapFlags>(); Section = j[nameof(Section)].EnumValue <MapSection>(); Weather = j[nameof(Weather)].EnumValue <MapWeather>(); Music = j[nameof(Music)].EnumValue <Song>(); }
public MapData(MapData mapData) { timeOfDay = mapData.timeOfDay; mapType = mapData.mapType; mapLocation = mapData.mapLocation; mapTheme = mapData.mapTheme; mapWeather = mapData.mapWeather; }
public MapData(float timeOfDay, MapType mapType, MapLocation mapLocation, MapTheme mapTheme, MapWeather mapWeather) { this.timeOfDay = timeOfDay; this.mapType = mapType; this.mapLocation = mapLocation; this.mapTheme = mapTheme; this.mapWeather = mapWeather; }
public MapData() { timeOfDay = 0f; mapType = MapType.None; mapLocation = MapLocation.None; mapTheme = MapTheme.None; mapWeather = MapWeather.None; }
public Details(JToken j) { Flags = j[nameof(Flags)].ReadFlagsEnumValue <MapFlags>(); Section = j[nameof(Section)].ReadEnumValue <MapSection>(); Weather = j[nameof(Weather)].ReadEnumValue <MapWeather>(); Music = j[nameof(Music)].ReadEnumValue <Song>(); BurmyForm = j[nameof(BurmyForm)].ReadEnumValue <PBEForm>(); }
public string RandomTileName(MapType maptype, MapWeather weathertype) { if (maptype == MapType.NULL) { maptype = MapType.Dungeon; } if (weathertype == MapWeather.NULL) { weathertype = MapWeather.Normal; } return(NGenMap.GetMapName(maptype, weathertype)); }
public static MapData Generate() { float timeOfDay = Random.Range(0f, 1f); MapType mapType = (MapType)Random.Range(0, (int)MapType.Number); MapLocation mapLocation = (MapLocation)Random.Range(0, (int)MapLocation.Number); MapTheme mapTheme = (MapTheme)Random.Range(0, (int)MapTheme.Number); MapWeather mapWeather = (MapWeather)Random.Range(0, (int)MapWeather.Number); MapData mapData = new MapData(timeOfDay, mapType, mapLocation, mapTheme, mapWeather); return(mapData); }
public static PBEWeather GetPBEWeatherFromMap(MapWeather mapWeather) { switch (mapWeather) { case MapWeather.Drought: return(PBEWeather.HarshSunlight); case MapWeather.Rain_Light: case MapWeather.Rain_Medium: return(PBEWeather.Rain); case MapWeather.Sandstorm: return(PBEWeather.Sandstorm); case MapWeather.Snow_Hail: return(PBEWeather.Hailstorm); } return(PBEWeather.None); }
public static PBEWeather GetPBEWeatherFromMap(Map map) { MapWeather weather = map.MapDetails.Weather; switch (weather) { case MapWeather.Drought: return(PBEWeather.HarshSunlight); case MapWeather.Rain_Light: case MapWeather.Rain_Medium: return(PBEWeather.Rain); case MapWeather.Sandstorm: return(PBEWeather.Sandstorm); case MapWeather.Snow_Hail: return(PBEWeather.Hailstorm); default: return(PBEWeather.None); } }
//use this to Load a map to be made in to a prefab public void LoadMap(string name) { var allMaps = GameManager.Instance.GetComponent <Maps>().allMapsDict; mapName = name; mapInformation.playerEnergy = 10; mapInformation.playerEnergyMax = 100; mapInformation.mapHealthMax = allMaps[mapName].maxHP; mapInformation.mapHealthCurrent = allMaps[mapName].maxHP; if (allMaps.ContainsKey(mapName)) { mapCode = allMaps[mapName].mapCode; //get a list of all possible path codes from the map data and creates a list of them foreach (string pathCode in allMaps[mapName].pathCode) { pathCodes.Add(pathCode); } //pathCode = allMaps[mapName].pathCode; enemyMax = allMaps[mapName].enemyMax; levelMin = allMaps[mapName].levelMin; levelMax = allMaps[mapName].levelMax; spawnInterval = allMaps[mapName].spawnInterval; width = allMaps[mapName].width; height = allMaps[mapName].height; mapLevel = allMaps[mapName].mapLevel; mapWeather = allMaps[mapName].weather; columns = int.Parse(width.ToString()) / 50; rows = int.Parse(height.ToString()) / 50; //add the IDs for the possible enemies this map can have foreach (int enemy in allMaps[mapName].enemies) { enemies.Add(enemy); } //add the IDs for the possible enemies and their spawn rates this map can have for (int e = 0; e < allMaps[mapName].enemies.Length; e++) { spawnRates.Add(allMaps[mapName].enemies[e], allMaps[mapName].enemyChance[e]); } int charCount = 0; for (int i = 1; i < rows * 2; i++) { //Debug.Log(i); for (int c = 1; c <= columns; c++) { var tile = Instantiate(mapTile, transform.position, Quaternion.identity); var tile2 = Instantiate(mapTile, transform.position, Quaternion.identity); //tile.GetComponent<MapTile>().GetType(int.Parse(chars[charCount])); tile.GetComponent <MapTile>().tileNumber = tileNumber; tile.name = tileNumber.ToString(); tile.GetComponent <MapTile>().info.row = c * 2; tile.GetComponent <MapTile>().info.column = i * 2 - 1; tile.GetComponent <MapTile>().mapDetails = this; tile2.GetComponent <MapTile>().mapDetails = this; tileNumber += 1; charCount += 1; //tile2.GetComponent<MapTile>().GetType(int.Parse(chars[charCount])); tile2.GetComponent <MapTile>().tileNumber = tileNumber; tile2.name = tileNumber.ToString(); tile2.GetComponent <MapTile>().info.row = c * 2 - 1; tile2.GetComponent <MapTile>().info.column = i * 2; tileNumber += 1; tile.transform.position = new Vector2((-width / 2) + (i * 50), (height / 2) - (c * 25)); tile2.transform.position = new Vector2((-width / 2) + (i * 50) + 25, (height / 2) - (c * 25) + 12.50f); //tile.transform.position = new Vector2((-width / 2) + (i * 75) - 25, (height / 2) - (c * 25)); //tile2.transform.position = new Vector2((-width / 2) + (i * 75) + 25, (height / 2) - (c * 25) + 12.50f); tile.GetComponent <SpriteRenderer>().sortingOrder = (int)-tile.transform.position.y; tile.GetComponent <MapTile>().roadSprite.sortingLayerName = "Pathways"; tile.GetComponent <MapTile>().roadSprite.sortingOrder = 2 + (int)-tile.transform.position.y; tile2.GetComponent <SpriteRenderer>().sortingOrder = (int)-tile2.transform.position.y; tile2.GetComponent <MapTile>().roadSprite.sortingLayerName = "Pathways"; tile2.GetComponent <MapTile>().roadSprite.sortingOrder = 2 + (int)-tile2.transform.position.y; tile.transform.SetParent(mapCanvas.transform, false); tile2.transform.SetParent(mapCanvas.transform, false); charCount += 1; } } //set the tile attributes based on their attribute code string[] tileChars = new string[mapCode.Length]; int g = 1; for (int t = 0; t < mapCode.Length / 2; t++) { tileChars[t] = mapCode[g - 1].ToString() + mapCode[g].ToString(); g += 2; var tile = GameObject.Find(t.ToString()).GetComponent <MapTile>(); tile.GetAttribute(int.Parse(tileChars[t])); tile.Build(); //add the tile to the list of active tiles GameManager.Instance.activeTiles.Add(t, tile.GetComponent <MapTile>()); //set the level and EXP of the tile tile.SetLevel(mapLevel); } //make a path code for each possible path, and add them to a Dictionary of PathCodes for (int p = 0; p < pathCodes.Count; p++) { //break up each path code in to sections of 3, since each tile is a 3 digit number, and store them in a dictionary of path codes that an enemy will choose at random upon their spawn //string[] pathChars = new string[pathCode.Length]; string[] pathChars = new string[pathCodes[p].Length]; string code = pathCodes[p]; List <string> pathCode = new List <string>(); List <MapTile> pathTiles = new List <MapTile>(); //make sure to clear this if there is more than 1 path so that the game knows to generate more than just one path path.Clear(); int h = 2; for (int i = 0; i < code.Length / 3; i++) { pathChars[i] = code[h - 2].ToString() + code[h - 1].ToString() + code[h].ToString(); h += 3; int tileCheck = int.Parse(pathChars[i]); //path[i] = GameObject.Find(tileCheck.ToString()).GetComponent<MapTile>(); //path[i] = allTiles[tileCheck]; path.Add(allTiles[tileCheck]); path[i].Road(); pathTiles.Add(path[i]); ////add the first tile in each path to a dictionary, so the spawning monster knows where to spawn //if (i == 0) //{ // spawnPoints.Add(p, path[i].transform.position); //} if (i > 0) { //get the direction of the road sprite from this class //TileSprite tileSprite = new TileSprite(path[i], path[i - 1], "road"); TileSprite tileSprite = new TileSprite(pathTiles[i], pathTiles[i - 1], "road"); } } } //pathEnd.transform.position = new Vector2(pathEndX, pathEndY); InvokeRepeating("SpawnEnemy", 4f, spawnInterval); } GetComponentInParent <MonsterInfoMenus>().LoadYourTowers(); weatherSystem.intensity = UnityEngine.Random.Range(0, 3); weatherSystem.StartWeather(this); }