public void RegistarPlanetToData(SpacePlanet X) { //Make A new Planet Planet N = new Planet(X.PlanetID); for (int i = 0; i < X.NumberFarms; i++) { N.AddBuilding(new Farm()); } for (int i = 0; i < X.NumberMines; i++) { N.AddBuilding(new Mine()); } for (int i = 0; i < X.NumberSmelters; i++) { N.AddBuilding(new Smelter()); } for (int i = 0; i < X.NumberFactories; i++) { N.AddBuilding(new Factory()); } for (int i = 0; i < X.NumberCitiesAndLevel.Count; i++) { for (int J = 0; J < X.NumberCitiesAndLevel[i]; J++) { N.AddBuilding(new City(i + 1)); } } DataManager.Data.LoadPlanet(N); }
SpacePlanet GeneratePlanet() { float angle = Random.Range(0, Mathf.PI * 2); float distance = Random.Range(5f, Distance); tmpV3.x = -Mathf.Sin(angle); tmpV3.y = Mathf.Cos(angle); return(SpacePlanet.Spawn(tmpV3.normalized * distance)); }
void ResetGame() { for (int i = 0; i < planets.Count; i++) { SpacePlanet.Despawn(planets[i]); } planets.Clear(); int planetCount = Random.Range(MinPlanets, MaxPlanets); for (int i = 0; i < planetCount; i++) { planets.Add(GeneratePlanet()); } }
public static SpacePlanet Spawn(Vector3 position) { tmpPlanet = null; for (int i = 0; i < pool.Count; i++) { if (!pool[i].isActiveAndEnabled) { tmpPlanet = pool[i]; tmpPlanet.gameObject.SetActive(true); break; } } if (tmpPlanet == null) { tmpPlanet = Instantiate(PrefabManager.Current.PlanetPrefab); pool.Add(tmpPlanet); } tmpPlanet.transform.position = position; tmpPlanet.world = null; return(tmpPlanet); }
public static void Despawn(SpacePlanet planet) { planet.gameObject.SetActive(false); }