예제 #1
0
    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);
    }
예제 #2
0
    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));
    }
예제 #3
0
    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());
        }
    }
예제 #4
0
    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);
    }
예제 #5
0
 public static void Despawn(SpacePlanet planet)
 {
     planet.gameObject.SetActive(false);
 }