示例#1
0
    private void Start()
    {
        ChunksController = new ChunksController();
        VoxelController  = new VoxelController();

        WorldData = SaveSystem.LoadWorld("test_world");

        Vector3 spawnPosition = new Vector3(
            Settings.Get.WorldCentre,
            //Settings.Get.ChunkHeight / 2 - 50,
            TerrainAttributes.solidGroundHeight + 10,
            Settings.Get.WorldCentre);

        Player.transform.position = spawnPosition;
        playerLastCoord           = CoordConvertor.GetChunkCoord(Player.transform.position);

        LoadWorld();

        GenerateWorld();
    }
示例#2
0
    void Update()
    {
        PlayerCoord = CoordConvertor.GetChunkCoord(Player.transform.position);

        if (!PlayerCoord.Equals(playerLastCoord))
        {
            playerLastCoord = PlayerCoord;
            ChunksController.CheckViewDistance(PlayerCoord);
        }

        ChunksController.CreateNextChunk();

        if (Input.GetKeyDown(KeyCode.F3))
        {
            DebugScreen.gameObject.SetActive(!DebugScreen.gameObject.activeSelf);
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            SaveSystem.SaveWorld(WorldData);
        }
    }
示例#3
0
    public Chunk GetChunk(Vector3 pPos)
    {
        Vector3Int coord = CoordConvertor.GetChunkCoord(pPos);

        return(chunks[coord.x, coord.z]);
    }