Пример #1
0
 // Use this for initialization
 void Awake()
 {
     terrainManager  = ScriptableObject.CreateInstance <TerrainManager>();
     terrainSettings = ScriptableObject.CreateInstance <TerrainSettings>();
     if (gameMaster != this)
     {
         gameMaster = this;
         DontDestroyOnLoad(this);
     }
     GameObject NewTerrain = TerrainExtensions.CreateTerrain(new Vector3(0f, 0f, 0f));
 }
Пример #2
0
    // Use this for initialization
    void Awake()
    {
        terrainSettings        = ScriptableObject.CreateInstance <TerrainSettings>();
        ParticleSystemSelector = ScriptableObject.CreateInstance <ScriptableParticle>();
        terrainBiome           = ScriptableObject.CreateInstance <TerrainBiome>();
        terrainManager         = ScriptableObject.CreateInstance <TerrainManager>();
        if (gameMaster != this)
        {
            gameMaster = this;
        }
        DontDestroyOnLoad(this);

        TerrainExtensions.CreateTerrain(new Vector3(0, 0, 0));
    }
Пример #3
0
 void Update()
 {
     if (tracker == null)
     {
         tracker = GameMaster.gameMaster.TrackerObject;
     }
     if (transform.childCount >= 1)
     {
         if (tracker.transform.localPosition.x >= terrainSettings.MapSize.x - terrainSettings.EdgeDistance)
         {
             if (!Neighbors.ContainsKey(TerrainExtensions.Direction.Right))
             {
                 Vector3 Pos = new Vector3(transform.position.x + terrainSettings.MapSize.x,
                                           transform.position.y,
                                           transform.position.z);
                 if (!GameMaster.gameMaster.terrainManager.TerrainPositions.ContainsKey(Pos))
                 {
                     GameObject NewTerrain = TerrainExtensions.CreateTerrain(Pos, terrain, TerrainExtensions.Direction.Right);
                     Neighbors.Add(TerrainExtensions.Direction.Right, NewTerrain);
                     NewTerrain.GetComponent <TerrainScript>().Neighbors.Add(TerrainExtensions.Direction.Left, gameObject);
                 }
             }
         }
         if (tracker.transform.localPosition.z >= terrainSettings.MapSize.z - terrainSettings.EdgeDistance)
         {
             if (!Neighbors.ContainsKey(TerrainExtensions.Direction.UP))
             {
                 Vector3 Pos = new Vector3(transform.position.x,
                                           transform.position.y,
                                           transform.position.z + terrainSettings.MapSize.z);
                 if (!GameMaster.gameMaster.terrainManager.TerrainPositions.ContainsKey(Pos))
                 {
                     GameObject NewTerrain = TerrainExtensions.CreateTerrain(Pos, terrain, TerrainExtensions.Direction.UP);
                     Neighbors.Add(TerrainExtensions.Direction.UP, NewTerrain);
                     NewTerrain.GetComponent <TerrainScript>().Neighbors.Add(TerrainExtensions.Direction.Down, gameObject);
                 }
             }
         }
         if (tracker.transform.localPosition.x <= terrainSettings.EdgeDistance)
         {
             if (!Neighbors.ContainsKey(TerrainExtensions.Direction.Left))
             {
                 Vector3 Pos = new Vector3(transform.position.x - terrainSettings.MapSize.x,
                                           transform.position.y,
                                           transform.position.z);
                 if (!GameMaster.gameMaster.terrainManager.TerrainPositions.ContainsKey(Pos))
                 {
                     GameObject NewTerrain = TerrainExtensions.CreateTerrain(Pos, terrain, TerrainExtensions.Direction.Left);
                     Neighbors.Add(TerrainExtensions.Direction.Left, NewTerrain);
                     NewTerrain.GetComponent <TerrainScript>().Neighbors.Add(TerrainExtensions.Direction.Right, gameObject);
                 }
             }
         }
         if (tracker.transform.localPosition.z <= terrainSettings.EdgeDistance)
         {
             if (!Neighbors.ContainsKey(TerrainExtensions.Direction.Down))
             {
                 Vector3 Pos = new Vector3(transform.position.x,
                                           transform.position.y,
                                           transform.position.z - terrainSettings.MapSize.z);
                 if (!GameMaster.gameMaster.terrainManager.TerrainPositions.ContainsKey(Pos))
                 {
                     GameObject NewTerrain = TerrainExtensions.CreateTerrain(Pos, terrain, TerrainExtensions.Direction.Down);
                     Neighbors.Add(TerrainExtensions.Direction.Down, NewTerrain);
                     NewTerrain.GetComponent <TerrainScript>().Neighbors.Add(TerrainExtensions.Direction.UP, gameObject);
                 }
             }
         }
     }
 }