示例#1
0
    void Start()
    {
        universe          = (Universe)GameObject.Find("GameManager").GetComponent(typeof(Universe));
        cellCoordPosition = gameObject.GetComponent <CellCoordPosition>();
        shadowManager     = gameObject.GetComponent <ShadowManager>();
        for (int i = 0; i < numOfPlanets; i++)
        {
            int         randomIndex = Random.Range(0, planets.Count);
            GameObject  planet      = planets[randomIndex];
            PrefabCoord planetCoord = new PrefabCoord();
            planetCoord.prefab = planet;


            planetCoord.GlobalX = (long)Random.Range(-maxGlobalDistance, maxGlobalDistance);
            planetCoord.GlobalY = (long)Random.Range(-maxGlobalDistance, maxGlobalDistance);
            planetCoord.GlobalZ = 0;
            planetCoord.LocalX  = Random.Range(-cellCoordPosition.GetCellSize(), cellCoordPosition.GetCellSize());
            planetCoord.LocalY  = Random.Range(-cellCoordPosition.GetCellSize(), cellCoordPosition.GetCellSize());
            planetCoord.LocalZ  = 0;

            planetCoord.GlobalX += (long)cellCoordPosition.GetGlobalPos().x;
            planetCoord.GlobalY += (long)cellCoordPosition.GetGlobalPos().y;
            planetCoord.GlobalZ += (long)cellCoordPosition.GetGlobalPos().z;
            planetCoord.LocalX  += cellCoordPosition.GetLocalPos().x;
            planetCoord.LocalY  += cellCoordPosition.GetLocalPos().y;
            planetCoord.LocalZ  += cellCoordPosition.GetLocalPos().z;
            GameObject instantiatedPlanet = universe.InstatntiateUniverseObject(planetCoord);
            instantiatedPlanets.Add(instantiatedPlanet);
            shadowManager.planet[i] = instantiatedPlanet;
        }
        shadowManager.Init(numOfPlanets);
    }
示例#2
0
    void Start()
    {
        universe          = (Universe)GameObject.Find("GameManager").GetComponent(typeof(Universe));
        cellCoordPosition = gameObject.GetComponent <CellCoordPosition>();
        shadowManager     = gameObject.GetComponent <ShadowManager>();
        int i = 0;

        foreach (PrefabCoord planet in planets)
        {
            planet.GlobalX += (long)cellCoordPosition.GetGlobalPos().x;
            planet.GlobalY += (long)cellCoordPosition.GetGlobalPos().y;
            planet.GlobalZ += (long)cellCoordPosition.GetGlobalPos().z;
            planet.LocalX  += cellCoordPosition.GetLocalPos().x;
            planet.LocalY  += cellCoordPosition.GetLocalPos().y;
            planet.LocalZ  += cellCoordPosition.GetLocalPos().z;
            GameObject instantiatedPlanet = universe.InstatntiateUniverseObject(planet);
            instantiatedPlanets.Add(instantiatedPlanet);
            shadowManager.planet[i] = instantiatedPlanet;
            i++;
        }
        shadowManager.Init(i);
    }