public void SetCurrArea(ContinentType currArea) { switch (currArea) { case (ContinentType.GRASSLAND): currAreaList = grasslandPartiesList; currBackground = grasslandBackground; break; case (ContinentType.MOUNTAIN): currAreaList = mountainPartiesList; currBackground = caveBackground; break; case (ContinentType.GLACIER): currAreaList = glacierPartiesList; currBackground = glacierBackground; break; case (ContinentType.DESERT): currAreaList = desertPartiesList; currBackground = desertBackground; break; case (ContinentType.VOLCANO): currAreaList = volcanoPartiesList; currBackground = volcanoBackground; break; case (ContinentType.FOREST): currAreaList = forestPartiesList; currBackground = forestBackground; break; case (ContinentType.MOUNTAINCAVE): currAreaList = mountainCavePartiesList; currBackground = caveBackground; break; case (ContinentType.LAVACAVE): currAreaList = lavaCavePartiesList; currBackground = lavacaveBackground; break; case (ContinentType.PYRAMID): currAreaList = pyramidPartiesList; currBackground = pyramidBackground; break; case (ContinentType.ICECAVE): currAreaList = iceCavePartiesList; currBackground = icecaveBackground; break; default: currAreaList = grasslandPartiesList; currBackground = grasslandBackground; break; } }
public static void SetGroundType(ContinentType currArea, bool isExiting) { switch (currArea) { case (ContinentType.MOUNTAINCAVE): groundType = 'r'; break; case (ContinentType.FOREST): groundType = 'g'; break; case (ContinentType.ICECAVE): groundType = 'h'; break; case (ContinentType.LAVACAVE): groundType = 'o'; break; case (ContinentType.PYRAMID): groundType = 's'; break; default: groundType = 'g'; break; } RandomEncounterManager.currArea = currArea; mazeGenerator.currMaze = currArea; mazeGenerator.EnableMazeParent(currArea, !isExiting); }
static LocationModel GenerateRandomLocation(ContinentType continent) { var random = new Random((int)DateTime.Now.Ticks); return(new LocationModel { Name = new PlaceNameGenerator(random).GenerateRandomPlaceName(), Continent = continent }); }
public void EnableMazeParent(ContinentType mazeToEnter, bool disableIfFalse) { switch (mazeToEnter) { case (ContinentType.FOREST): currMazeParent = forestMazeParent; forestMazeParent.SetActive(disableIfFalse); break; case (ContinentType.ICECAVE): currMazeParent = iceCaveParent; currMazeParent.SetActive(disableIfFalse); break; case (ContinentType.PYRAMID): currMazeParent = pyramidParent; currMazeParent.SetActive(disableIfFalse); break; case (ContinentType.MOUNTAINCAVE): currMazeParent = mountainCaveParent; currMazeParent.SetActive(disableIfFalse); break; case (ContinentType.LAVACAVE): currMazeParent = lavaCaveParent; currMazeParent.SetActive(disableIfFalse); break; case (ContinentType.GRASSLAND): currMazeParent = forestMazeParent; forestMazeParent.SetActive(disableIfFalse); break; case (ContinentType.DESERT): currMazeParent = iceCaveParent; currMazeParent.SetActive(disableIfFalse); break; case (ContinentType.GLACIER): currMazeParent = pyramidParent; currMazeParent.SetActive(disableIfFalse); break; case (ContinentType.MOUNTAIN): currMazeParent = mountainCaveParent; currMazeParent.SetActive(disableIfFalse); break; case (ContinentType.VOLCANO): currMazeParent = lavaCaveParent; currMazeParent.SetActive(disableIfFalse); break; } }
public EnemyPartyManager GetChestEnemy(ContinentType whatRegion) { switch (whatRegion) { case (ContinentType.GLACIER): return(glacierEnemyChestEncounter); default: return(null); } }
// returns true if a battle started public static bool AdvanceStepCount(char groundType) { if (encountersEnabled) { ContinentType currArea = ContinentType.GRASSLAND; switch (groundType) { case ('g'): encounterStep -= 1; break; case ('s'): encounterStep -= 1; currArea = ContinentType.DESERT; break; case ('r'): encounterStep -= 2; currArea = ContinentType.GRASSLAND; break; case ('\0'): encounterStep -= 1; currArea = ContinentType.OCEAN; break; default: encounterStep--; break; } GameManager.currAreaName = currArea; if (encounterStep < 0) { encounterStep = UnityEngine.Random.Range(8, 24); BattleManager.bManager.StartBattle(); return(true); } return(false); } return(false); }
public static void SetCurrArea(char groundChar) { switch (groundChar) { case ('g'): currArea = ContinentType.GRASSLAND; break; case ('h'): currArea = ContinentType.GLACIER; break; case ('b'): currArea = ContinentType.GLACIER; break; case ('o'): currArea = ContinentType.VOLCANO; break; case ('s'): currArea = ContinentType.DESERT; break; case ('d'): currArea = ContinentType.DESERT; break; case ('r'): currArea = ContinentType.MOUNTAIN; break; case ('\0'): currArea = ContinentType.OCEAN; break; default: break; } }
ContinentType GetContinentCorrespondingToMazeType(ContinentType mazeType) { switch (mazeType) { case (ContinentType.FOREST): return(ContinentType.GRASSLAND); case (ContinentType.ICECAVE): return(ContinentType.GLACIER); case (ContinentType.LAVACAVE): return(ContinentType.VOLCANO); case (ContinentType.MOUNTAINCAVE): return(ContinentType.MOUNTAIN); case (ContinentType.PYRAMID): return(ContinentType.DESERT); default: throw new System.Exception("Invalid maze exit type?"); } }
public BaseItem GetTreasureBasedOnLocation(ContinentType area = ContinentType.None) { switch (area) { case (ContinentType.FOREST): return(mazeItemSpawns[Random.Range(0, mazeItemSpawns.Count)]); case (ContinentType.ICECAVE): return(mazeItemSpawns[Random.Range(0, mazeItemSpawns.Count)]); case (ContinentType.LAVACAVE): return(mazeItemSpawns[Random.Range(0, mazeItemSpawns.Count)]); case (ContinentType.MOUNTAINCAVE): return(mazeItemSpawns[Random.Range(0, mazeItemSpawns.Count)]); case (ContinentType.PYRAMID): return(mazeItemSpawns[Random.Range(0, mazeItemSpawns.Count)]); default: return(itemsToSpawn[Random.Range(0, itemsToSpawn.Count)]); } }
public void PlacePartyAtMazeEntrance(ContinentType typeOfMaze) { BattleManager.hpm.MovePartyTo(new Vector2( transform.position.x + mazeWidth / 2 * 16, transform.position.y + mazeWidth / 2 * -16)); }
public void GenerateMaze(ContinentType continentType, Vector2 enteredFrom) { objectsToAdd = new List <GameObject>(); this.enteredFrom = enteredFrom; switch (continentType) { case (ContinentType.FOREST): Debug.Log("Added forest objects"); objectsToAdd.Add(moneyChest); objectsToAdd.Add(archer.gameObject); objectsToAdd.Add(swordChest); groundType = 'g'; wallTile = forestWallTile; currMazeParent = forestMazeParent; break; case (ContinentType.ICECAVE): objectsToAdd.Add(moneyChest); objectsToAdd.Add(swordChest); objectsToAdd.Add(mage.gameObject); groundType = 'h'; wallTile = iceWallTile; currMazeParent = iceCaveParent; break; case (ContinentType.PYRAMID): objectsToAdd.Add(enemyOrTreasureChest); objectsToAdd.Add(treasureChest); groundType = 's'; wallTile = pyramidWallTile; currMazeParent = pyramidParent; break; case (ContinentType.MOUNTAINCAVE): objectsToAdd.Add(moneyChest); objectsToAdd.Add(swordChest); groundType = 'd'; wallTile = mountainWallTile; currMazeParent = mountainCaveParent; break; case (ContinentType.LAVACAVE): objectsToAdd.Add(moneyChest); objectsToAdd.Add(swordChest); groundType = 'r'; wallTile = lavaWallTile; currMazeParent = lavaCaveParent; break; default: Debug.Log("Invalid continent type provided"); objectsToAdd.Add(moneyChest); objectsToAdd.Add(swordChest); break; } RandomEncounterManager.currArea = continentType; mazeArray = new char[mazeWidth, mazeHeight]; walkLevelArray = new char[mazeWidth, mazeHeight]; startPathDir = (Direction)Random.Range(0, 4); branchPoints = new List <CoorPathLengthPair>(); mazeArray[mazeWidth / 2, mazeHeight / 2] = 'p'; walkLevelArray[mazeWidth / 2, mazeHeight / 2] = 'e'; GeneratePathFrom(mazeWidth / 2, mazeHeight / 2, mazeSize, 'c'); for (int i = 0; i < branchPoints.Count; i++) { GeneratePathFrom(branchPoints[i].coor.x, branchPoints[i].coor.y, branchPoints[i].pathLength, 'c'); } StartCoroutine(InstantiateTiles()); }
public EnemyPartyManager GetRandomEncounter(ContinentType currArea) { switch (currArea) { case (ContinentType.GRASSLAND): currAreaList = grasslandPartiesList; currBackground = grasslandBackground; break; case (ContinentType.MOUNTAIN): currAreaList = mountainPartiesList; currBackground = caveBackground; break; case (ContinentType.GLACIER): currAreaList = glacierPartiesList; currBackground = glacierBackground; break; case (ContinentType.DESERT): currAreaList = desertPartiesList; currBackground = desertBackground; break; case (ContinentType.VOLCANO): currAreaList = volcanoPartiesList; currBackground = volcanoBackground; break; case (ContinentType.FOREST): currAreaList = forestPartiesList; currBackground = forestBackground; break; case (ContinentType.MOUNTAINCAVE): currAreaList = mountainCavePartiesList; currBackground = caveBackground; break; case (ContinentType.LAVACAVE): currAreaList = lavaCavePartiesList; currBackground = lavacaveBackground; break; case (ContinentType.PYRAMID): currAreaList = pyramidPartiesList; currBackground = pyramidBackground; break; case (ContinentType.ICECAVE): currAreaList = iceCavePartiesList; currBackground = icecaveBackground; break; default: currAreaList = grasslandPartiesList; currBackground = grasslandBackground; break; } int randPartyIndex = UnityEngine.Random.Range(0, currAreaList.Length); int occurrenceChance = UnityEngine.Random.Range(1, 6); if (occurrenceChance <= currAreaList[randPartyIndex].occurrenceRate) { return(currAreaList[randPartyIndex]); } else { if (tries-- < 0) { throw new System.Exception("Invalid party Occurrence rate!"); } return(GetRandomEncounter(currArea)); } }
void TestGenerateMap(int width, int height, int numContinents, float continentSize) { groundGrid = new char[width, height]; walkLevelGrid = new char[width, height]; dontCheckGrid = new char[width, height]; mapHeight = height; mapWidth = width; // A map must always have a starting zone, but the other continents are mostly random. // ContinentType[] cTypes = new ContinentType[numContinents]; int rand = UnityEngine.Random.Range(0, numContinents); cTypes[rand] = ContinentType.STARTING_AREA; // Make sure the continents are varied; // if there is already a mountain, for example, a different type will be picked unless all types have been picked /* * for (int i = 1; i < numContinents; i++) * { * int randContinent = UnityEngine.Random.Range(0, numContinents); * while (cTypes[randContinent] != ContinentType.None) * { * randContinent = UnityEngine.Random.Range(0, numContinents); * } * * if (!isMountain) * { * cTypes[randContinent] = ContinentType.MOUNTAINOUS; * isMountain = true; * } * else * { * cTypes[randContinent] = (ContinentType)Random.Range(1, 3); * } * } */ MapCoor mapCenter = new MapCoor(mapWidth / 2, mapHeight / 2); CreateMapFeature(FeatureTypes.FOREST_CIRCLE, new MapCoor(mapWidth / 2, mapHeight / 2)); /* * for (int continent = 0; continent < numContinents - 0; continent++) * { * MapCoor continentStartPos = new MapCoor((int)(mapCenter.x + fromMapCenterRadius * Mathf.Cos(theta)), (int)(mapCenter.y + fromMapCenterRadius * Mathf.Sin(theta))); * //Debug.Log(string.Format("Type: {3}, Radius = {0}, theta = {1}, Center = {2}", fromMapCenterRadius, theta, continentStartPos, cTypes[continent])); * * // Continents are created in a circle around the center of the map * /**EXAMPLE: * WIDTH numContinents = 3 * _____________________ * H | | * E | C3 C2 | * I | | * G | C1 | * H | C4 | * T | C5 | * |_____________________| * * * * */ /* * int circleRadius = (int)(ratio * continentSize * 2.5f); * * * // A continent is formed by several circles of varying size built off of each other. * CreateContinent(continentStartPos.ToVector(), circleRadius, 8, cTypes[continent]); * * // Calculations for next circle * theta += 6.28f / (float)(numContinents); * fromMapCenterRadius = defaultRadius - Mathf.Abs(Mathf.Sin(theta) * defaultRadius * (1 - 1 / ratio)); * }*/ //BuildCoast(); StartCoroutine(InstantiateTiles()); }
public static bool AdvanceStepCount(Vector2 currPos) { MapCoor currCoor = new MapCoor((int)currPos.x / 16, (int)currPos.y / 16); if (encountersEnabled) { char groundType = 'g'; ContinentType currArea = ContinentType.GRASSLAND; if (MazeGenerator.inMaze) { groundType = MazeGenerator.groundType; switch (groundType) { case ('g'): encounterStep -= 1; currArea = ContinentType.FOREST; break; case ('\0'): encounterStep -= 1; currArea = ContinentType.OCEAN; break; default: encounterStep--; currArea = ContinentType.DESERT; break; } } else { currCoor.x %= MapGenerator.mapWidth; currCoor.y %= MapGenerator.mapHeight; currCoor.y = Mathf.Abs(currCoor.y) + 1; groundType = MapGenerator.mg.GetTile(currCoor, true); switch (groundType) { case ('g'): encounterStep -= 1; break; case ('s'): encounterStep -= 1; currArea = ContinentType.DESERT; break; case ('r'): encounterStep -= 2; currArea = ContinentType.GRASSLAND; break; case ('\0'): encounterStep -= 1; currArea = ContinentType.OCEAN; break; case ('o'): encounterStep -= 1; currArea = ContinentType.VOLCANO; break; default: encounterStep--; break; } } GameManager.currAreaName = currArea; if (encounterStep < 0) { encounterStep = UnityEngine.Random.Range(8, 24); BattleManager.bManager.StartBattle(); return(true); } return(false); } return(false); }
void GenerateMap(int width, int height, int numContinents, float continentSize) { //Debug.Log(string.Format("Width {0}, height {1}, numContinents {2}, continentSize {3}", width, height, numContinents, continentSize)); groundGrid = new char[width, height]; walkLevelGrid = new char[width, height]; dontCheckGrid = new char[width, height]; instantiatedTiles = new List <GameObject> [width, height]; mapHeight = height; mapWidth = width; // A map must always have a starting zone, but the other continents are mostly random. // ContinentType[] cTypes = new ContinentType[numContinents]; cTypes[0] = ContinentType.GRASSLAND; // Make sure the continents are varied; cTypes[1] = ContinentType.DESERT; cTypes[2] = ContinentType.GLACIER; cTypes[3] = ContinentType.MOUNTAIN; cTypes[4] = ContinentType.VOLCANO; MapCoor mapCenter = new MapCoor(mapWidth / 2, mapHeight / 2); float fromMapCenterRadius = mapWidth / 3; float defaultRadius = fromMapCenterRadius; float theta = 0; float ratio = (float)mapWidth / mapHeight; for (int continent = 0; continent < numContinents - 0; continent++) { MapCoor continentStartPos = new MapCoor((int)(mapCenter.x + fromMapCenterRadius * Mathf.Cos(theta)), (int)(mapCenter.y + fromMapCenterRadius * Mathf.Sin(theta))); //Debug.Log(string.Format("Type: {3}, Radius = {0}, theta = {1}, Center = {2}", fromMapCenterRadius, theta, continentStartPos, cTypes[continent])); // Continents are created in a circle around the center of the map /**EXAMPLE: * WIDTH numContinents = 5 * _____________________ * H | | * E | C3 C2 | * I | | * G | C1 | * H | C4 | * T | C5 | * |_____________________| * * */ int circleRadius = (int)(ratio * continentSize * 2.5f); // A continent is formed by several circles of varying size built off of each other. CreateContinent(continentStartPos.ToVector(), circleRadius, 12, cTypes[continent]); // Calculations for next circle theta += 6.28f / (float)(numContinents); fromMapCenterRadius = defaultRadius - Mathf.Abs(Mathf.Sin(theta) * defaultRadius * (1 - 1 / ratio)); } BuildCoast(); PlaceFeatures(); StartCoroutine(InstantiateTiles()); }
void CreateContinent(Vector2 center, int largestRadius, int complexity, ContinentType continentType, bool hasCoast = true) { Vector2 newCenter = center; Vector2 tempCenter = center; float curveAngle = 0; // The continents generally twist inwards // if the center is high on the map if (center.y > groundGrid.GetLength(1) / 2) { curveAngle = 270 + UnityEngine.Random.Range(-3.14f / 2, 3.14f / 2); } else { //if the center is low on the map curveAngle = 90 + UnityEngine.Random.Range(-3.14f / 2, 3.14f / 2); } curveAngle = UnityEngine.Random.Range(0, 360); char groundType = 'g'; switch (continentType) { case (ContinentType.GRASSLAND): if (GameManager.gm.leader == null) { GameManager.gm.GetComponent <HeroPartyManager>() .AddKnight(center); knightStartPoint = new MapCoor((int)center.x, (int)center.y); walkLevelGrid[knightStartPoint.x, knightStartPoint.y] = '-'; dontCheckGrid[knightStartPoint.x, knightStartPoint.y] = '-'; //leaderCoorX = (int) center.x / 16; //leaderCoorY = (int)(Mathf.Abs(center.y / 16)); // @@@@ Place test tiles @@@@ dontCheckGrid[(int)center.x - 6, (int)center.y] = '&'; dontCheckGrid[(int)center.x - 5, (int)center.y] = '&'; //featuresToPlaceOnMap.Add(new FeatureCenterPair(new MapCoor((int)center.x + 4, (int)center.y - 4), FeatureTypes.CASTLE)); } else { } break; case (ContinentType.MOUNTAIN): dontCheckGrid[(int)center.x, (int)center.y + 2] = '$'; groundType = 'r'; // TODO break; case (ContinentType.DESERT): dontCheckGrid[(int)center.x, (int)center.y + 2] = '#'; groundType = 's'; // TODO break; case (ContinentType.GLACIER): dontCheckGrid[(int)center.x, (int)center.y + 2] = '@'; groundType = 'h'; // TODO break; case (ContinentType.VOLCANO): dontCheckGrid[(int)center.x, (int)center.y + 2] = '%'; groundType = 'o'; // TODO break; } List <Vector2> circleCenters = new List <Vector2>(); for (int circleNum = 0; circleNum < complexity; circleNum++) { CreateCircle(new MapCoor((int)tempCenter.x, (int)tempCenter.y), largestRadius, groundType, hasCoast); circleCenters.Add(tempCenter); int radius = largestRadius; int randGeoFeature = UnityEngine.Random.Range(0, 14); // Create geographical features particular to the continentType; // this is where the majority of the environmental features // will be implemented switch (continentType) { case (ContinentType.GRASSLAND): if (circleNum == 3 && darkForestCounter-- == 0) { featuresToPlaceOnMap.Add(new FeatureCenterPair( new MapCoor(tempCenter), FeatureTypes.DARK_FOREST)); } if (randGeoFeature < 6) { // create a forest CreateForest(tempCenter, largestRadius, 10); } else if (randGeoFeature < 12) { // create a forest circle (TODO) if (--forestCircleCounter < 0) { if (radius > 5) { featuresToPlaceOnMap.Add(new FeatureCenterPair( new MapCoor(tempCenter), FeatureTypes.FOREST_CIRCLE)); forestCircleCounter = forestCircleFrequency; } else { forestCircleCounter = 0; } } } else { // Place a chest walkLevelGrid[(Mathf.Abs((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'c'; } break; case (ContinentType.GLACIER): if (randGeoFeature < 5) { // Place a penguin salesman walkLevelGrid[(Mathf.Abs((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = '1'; } else if (randGeoFeature < 10) { // Place an igloo walkLevelGrid[(Mathf.Abs((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'e'; } else if (randGeoFeature > 11) { // Place a chest walkLevelGrid[(Mathf.Abs((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'c'; } break; case (ContinentType.MOUNTAIN): if (randGeoFeature < 5) { // Place a mouuntain walkLevelGrid[Mathf.Abs(((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'm'; } else if (randGeoFeature > 11) { // Place a chest walkLevelGrid[(Mathf.Abs((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'c'; } break; case (ContinentType.DESERT): if (randGeoFeature < 4) { // Place a pyramid walkLevelGrid[((int)tempCenter.x) % mapWidth, ((int)tempCenter.y) % mapHeight] = '^'; } else if (randGeoFeature < 11) { // Place a cactus walkLevelGrid[((int)tempCenter.x) % mapWidth, ((int)tempCenter.y) % mapHeight] = '*'; } else if (randGeoFeature > 11) { // Place a chest walkLevelGrid[(Mathf.Abs((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'c'; } break; case (ContinentType.VOLCANO): if (!castlePlaced && circleNum > 3) { castlePlaced = true; featuresToPlaceOnMap.Add(new FeatureCenterPair(new MapCoor((int)center.x + 4, (int)center.y - 4), FeatureTypes.CASTLE)); } else if (randGeoFeature < 5) { // Place a mouuntain walkLevelGrid[Mathf.Abs(((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'm'; } else if (randGeoFeature > 11) { // Place a chest walkLevelGrid[(Mathf.Abs((int)tempCenter.x) % mapWidth), Mathf.Abs(((int)tempCenter.y) % mapHeight)] = 'c'; } break; } // Features that are only added with the last land circle if (circleNum == complexity - 1) { switch (continentType) { case (ContinentType.GRASSLAND): if (numAirshipSalesmenPlaced++ < numAirshipSalesmen) { MapCoor placeToPutAirship = new MapCoor((int)tempCenter.x, (int)tempCenter.y); int leftOrRight = UnityEngine.Random.Range(-1, 2); if (leftOrRight == 0) { leftOrRight++; } while (GetTile(placeToPutAirship, true) != '\0') { placeToPutAirship.x += leftOrRight; } placeToPutAirship.x -= leftOrRight; if (leftOrRight < 0) { featuresToPlaceOnMap.Add(new FeatureCenterPair(placeToPutAirship, FeatureTypes.AIRSHIP_SALESMAN)); } else { featuresToPlaceOnMap.Add(new FeatureCenterPair(placeToPutAirship, FeatureTypes.AIRSHIP_SALESMAN, true)); } } break; default: break; } } // Decide where the next circle is // tempCenter is the next circle's center. curveAngle += UnityEngine.Random.Range(-3.14f / 6, 3.14f / 6); int whichCircleToBuildOffOf = UnityEngine.Random.Range(0, 3); if (whichCircleToBuildOffOf != 0) { // Create a circle on the perimeter of a random circle that has already been built // I haven't tested how well this actually works. Vector2 randCenter = circleCenters[UnityEngine.Random.Range(0, circleCenters.Count)]; int tempCurvAngle = UnityEngine.Random.Range(0, 360); tempCenter = new Vector2(randCenter.x + radius * Mathf.Cos(tempCurvAngle) * 1.2f, randCenter.y + radius * Mathf.Sin(tempCurvAngle) * 1.2f); } else { // Create a circle in the direction the ccontinent is generally going towards newCenter = new Vector2(newCenter.x + radius * Mathf.Cos(curveAngle), newCenter.y + radius * Mathf.Sin(curveAngle)); tempCenter = newCenter; } // The next circle is smaller. largestRadius = Mathf.RoundToInt(radius * .8f); } }
void CreateContinent(Vector2 center, int largestRadius, int complexity, ContinentType continentType, bool hasCoast = true) { Vector2 newCenter = center; Vector2 tempCenter = center; float curveAngle = 0; // The continents generally twist inwards // if the center is high on the map if (center.y > groundGrid.GetLength(1) / 2) { curveAngle = 270 + UnityEngine.Random.Range(-3.14f / 2, 3.14f / 2); } else { //if the center is low on the map curveAngle = 90 + UnityEngine.Random.Range(-3.14f / 2, 3.14f / 2); } curveAngle = UnityEngine.Random.Range(0, 360); char groundType = 'g'; switch (continentType) { case (ContinentType.STARTING_AREA): if (GameManager.gm.leader == null) { GameManager.gm.GetComponent <HeroPartyManager>().AddKnight(center); walkLevelGrid[(int)center.x + 5, (int)center.y] = 'a'; walkLevelGrid[(int)center.x - 5, (int)center.y] = 'c'; walkLevelGrid[(int)center.x - 6, (int)center.y] = 'c'; } break; case (ContinentType.MOUNTAINOUS): groundType = 'r'; // TODO break; } List <Vector2> circleCenters = new List <Vector2>(); for (int circleNum = 0; circleNum < complexity; circleNum++) { CreateCircle(new MapCoor((int)tempCenter.x, (int)tempCenter.y), largestRadius, groundType, hasCoast); circleCenters.Add(tempCenter); int radius = largestRadius; // Create geographical features particular to the continentType; // this is where the majority of the environmental features will be implemented switch (continentType) { case (ContinentType.STARTING_AREA): int randGeoFeature = UnityEngine.Random.Range(0, 12); if (randGeoFeature < 6) { // create a forest CreateForest(tempCenter, largestRadius, 10); } else if (randGeoFeature < 9) { // create a forest circle (TODO) if (--forestCircleCounter < 0) { if (radius > 5) { featuresToPlaceOnMap.Add(new FeatureCenterPair(new MapCoor(tempCenter), FeatureTypes.FOREST_CIRCLE)); //CreateMapFeature(FeatureTypes.FOREST_CIRCLE, new MapCoor(tempCenter)); forestCircleCounter = forestCircleFrequency; } else { forestCircleCounter = 0; } } } else if (randGeoFeature < 11) { // create a mountain circle (TODO) } else { // create nothing } break; case (ContinentType.MOUNTAINOUS): // TODO: Make continent surrounded by mountains. This likely can't be done in this switch, // and will be implemented after the whole continent land mass has been created. break; } // Decide where the next circle is // tempCenter is the next circle's center. curveAngle += UnityEngine.Random.Range(-3.14f / 6, 3.14f / 6); int whichCircleToBuildOffOf = UnityEngine.Random.Range(0, 3); if (whichCircleToBuildOffOf != 0) { // Create a circle on the perimeter of a random circle that has already been built // I haven't tested how well this actually works. Vector2 randCenter = circleCenters[UnityEngine.Random.Range(0, circleCenters.Count)]; int tempCurvAngle = UnityEngine.Random.Range(0, 360); tempCenter = new Vector2(randCenter.x + radius * Mathf.Cos(tempCurvAngle) * 1.2f, randCenter.y + radius * Mathf.Sin(tempCurvAngle) * 1.2f); } else { // Create a circle in the direction the ccontinent is generally going towards newCenter = new Vector2(newCenter.x + radius * Mathf.Cos(curveAngle), newCenter.y + radius * Mathf.Sin(curveAngle)); tempCenter = newCenter; } // The next circle is smaller. largestRadius = Mathf.RoundToInt(radius * .8f); } }