Exemplo n.º 1
0
    private void GetPlayerInputs()
    {
        horizontal      = Input.GetAxis("Horizontal");
        vertical        = Input.GetAxis("Vertical");
        mouseHorizontal = Input.GetAxis("Mouse X");
        mouseVertical   = Input.GetAxis("Mouse Y");

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            WorldSaveSystem.SaveWorld(World.Instance.worldData);
            Application.Quit();
        }

        if (Input.GetButtonDown("Sprint"))
        {
            isSprinting = true;
        }
        if (Input.GetButtonUp("Sprint"))
        {
            isSprinting = false;
        }

        if (isGrounded && Input.GetButtonDown("Jump"))
        {
            jumpRequest = true;
        }

        if (selectedBlock.gameObject.activeSelf)
        {
            //destroy block
            if (Input.GetMouseButtonDown(0))
            {
                world.GetChunkFromPosition(selectedBlock.position).EditVoxelData(selectedBlock.position, 0);
            }

            //create and place new block
            if (Input.GetMouseButtonDown(1))
            {
                if (toolbar.slots[toolbar.slotIndex].HasItem)
                {
                    world.GetChunkFromPosition(placeBlock.position).EditVoxelData(placeBlock.position, toolbar.slots[toolbar.slotIndex].itemSlot.stack.id);
                    toolbar.slots[toolbar.slotIndex].itemSlot.UpdateAmount(1);
                }
            }
        }
    }
Exemplo n.º 2
0
    private void Update()
    {
        playerChunkPos = GetChunkCoordFromPosition(player.position);

        if (!playerChunkPos.Equals(playerLastChunkPos))
        {
            CheckViewDistance();
        }

        if (chunksToDraw.Count > 0)
        {
            chunksToDraw.Dequeue().CreateMesh();
        }

        if (!settings.enableMultiThreading)
        {
            if (!modsApplying)
            {
                ApplyModifications();
            }

            if (chunksToUpdate.Count > 0)
            {
                UpdateChunks();
            }
        }

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

        if (Input.GetKeyDown(KeyCode.F1))
        {
            WorldSaveSystem.SaveWorld(worldData);
        }
    }
Exemplo n.º 3
0
 public void QuitGame()
 {
     WorldSaveSystem.SaveWorld(World.Instance.worldData);
     Application.Quit();
 }