示例#1
0
 public void UpdateTreesAroundEditorCamera()
 {
     if (mainCam == null && !Application.isPlaying)
     {
         mainCam = SceneView.GetAllSceneCameras()[0];
     }
     terrain = FindObjectOfType <TerrainConstructor>();
     CheckTrees();
 }
示例#2
0
 private void Start()
 {
     mainCam = Camera.main;
     if (commonTreePool == null)
     {
         CreateTreePool();
     }
     terrain = FindObjectOfType <TerrainConstructor>();
     CheckTrees();
     StartCoroutine(CheckPlayerPosition());
 }
示例#3
0
 public void ArrangeChunks()
 {
     terrain = GetComponent <TerrainConstructor>();
     chunks  = new TerrainChunk[Data.xSize / chunkSize + 1, Data.zSize / chunkSize + 1];
     for (int x = 0; x < chunks.GetLength(0); x++)
     {
         for (int z = 0; z < chunks.GetLength(1); z++)
         {
             GameObject chunkObject = new GameObject("Chunk");
             chunks[x, z] = new TerrainChunk(chunkObject);
         }
     }
     for (int x = 0; x < Data.xSize; x++)
     {
         for (int z = 0; z < Data.zSize; z++)
         {
             //chunks[x / Data.xSize, z / Data.zSize].baseTiles.Add(Data.GetTileAtCoordinates(x, z).Transform.gameObject);
         }
     }
 }
示例#4
0
    public override void OnInspectorGUI()
    {
        TerrainConstructor terrain = (TerrainConstructor)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Generate Terrain"))
        {
            terrain.GenerateTerrain();
            EditorUtility.SetDirty(terrain);
        }
        if (GUILayout.Button("Generate Flora"))
        {
            terrain.GenerateFlora();
            EditorUtility.SetDirty(terrain);
        }
        if (GUILayout.Button("Construct Terrain"))
        {
            terrain.ClearTerrain();
            terrain.ConstructTerrain();
            EditorUtility.SetDirty(terrain);
        }
        if (GUILayout.Button("Clear All"))
        {
            terrain.ClearTerrain();
            EditorUtility.SetDirty(terrain);
        }
        if (GUILayout.Button("Save Terrain"))
        {
            TerrainSaver.SaveTerrain(terrain.terrainData, terrain.terrainFileName);
        }
        if (GUILayout.Button("Load Terrain"))
        {
            TerrainData data = TerrainSaver.LoadTerrain(terrain.terrainFileName);
            terrain.terrainData = data;
            terrain.ConstructTerrain();
        }
        serializedObject.Update();
        serializedObject.ApplyModifiedProperties();
    }
示例#5
0
    // Start is called before the first frame update
    void Start()
    {
        instance = this;

        GenerateRooms();

        ArrangeRooms();

        DrawRooms();

        Vector2Int spawnPos = DrawCorridors();

        DrawWalls();

        if (drawRoomCenters)
        {
            DrawCenters();
        }

        SpawnExit(spawnPos);

        InstantiatePlayables(spawnPos);
    }
示例#6
0
 public void Start()
 {
     terrainConstructor = TerrainConstructor.instance;
 }