Exemple #1
0
        public ConfigLoader(ObjectLocations objectLocations)
        {
            this._objectLocations = objectLocations;

            LoadDewrito();
            //LoadServerJSON(); //Doesnt appear to be required
            LoadVotingJSON();
        }
Exemple #2
0
    void PopulateWorld()
    {
        for (int i = 0; i < worldData.Length; i++)
        {
            int index = 0;
            int forestTreeCountdown = 0;
            objectLocations[i] = new ObjectLocations(gridSize);
            for (int x = 0; x < gridSize; x++)
            {
                for (int y = 0; y < gridSize; y++)
                {
                    Vector3 position = worldData[i].mesh.vertices[worldData[i].mesh.triangles[index * 6]];
                    float   height   = position.magnitude;

                    objectLocations[i].position[x, y] = position;
                    objectLocations[i].height[x, y]   = height;

                    if (height >= 100.82f &&
                        height <= 100.99f &&
                        position.y <= 70.0f &&
                        position.y >= -70.0f)
                    {
                        if (forestTreeCountdown <= 0)
                        {
                            bool spawn = true;
                            for (int k = 0; k < forestLocations.Count; k++)
                            {
                                if (Vector3.Distance(objectLocations[i].position[x, y], forestLocations[k].obj.transform.position) <= 30.0f)
                                {
                                    spawn = false;
                                }
                            }
                            if (spawn)
                            {
                                GameObject obj = Instantiate(forestTreeHolderOriginal, objectLocations[i].position[x, y], Quaternion.identity);
                                obj.transform.SetParent(forestTreeHolder.transform);
                                forestLocations.Add(new SpawnLocation(x, y, i, obj));
                                forestTreeCountdown            = (int)Random.Range(20.0f, 50.0f);
                                objectLocations[i].space[x, y] = true;
                            }
                        }
                        forestTreeCountdown--;
                    }

                    index++;
                }
            }
        }
    }