/* * bool VerifyDistance(Vector3 positionToCheck, int index) * { * float closestPlanet = float.MaxValue; * float distance; * for(int x = 0; x < generatedObjects.Count; ++x) * { * distance = (generatedObjects[x].transform.position - positionToCheck).magnitude; * if(x != index) * { * if( distance < planetsTooClose ) * { * Debug.Log("planets too close"); * return false; * } * if(distance < closestPlanet) * { * closestPlanet = distance; * } * } * } * //Debug.Log(closestPlanet > connectionRadius); * return closestPlanet > connectionRadius; * } * * bool TooManyLegs() * { * int twoCount = 0; * for(int x = 0; x < generatedObjects.Count; ++x) * { * if(generatedObjects[x].GetComponent<Planet>().connections.Count <= 2) * { * //Debug.Log(generatedObjects[x].name + " is a leg"); * twoCount++; * } * } * //Debug.Log(twoCount); * //Debug.Log(twoCount >= legMax); * return twoCount >= legMax; * } */ public void RegenerateMap() { foreach (Transform child in gameObject.transform) { Destroy(child.gameObject); } int xy = (int)Mathf.Floor(Mathf.Sqrt(numPlanets)); graph = GraphGenerator.Build(xy, xy, xStep, yStep, xRandRange, yRandRange, buildChance); GeneratePlanets(); GenerateConnections(); //CenterCamera(); GameManager.instance.setPlanets(generatedObjects); }