Exemple #1
0
    private void Update()
    {
        if (currentInputMode == InputMode.Play)
        {
            if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
            {
                farmerMovement.move(Vector3.up);
            }

            if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
            {
                farmerMovement.move(Vector3.down);
            }

            if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
            {
                farmerMovement.move(Vector3.left);
            }

            if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
            {
                farmerMovement.move(Vector3.right);
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                useItem.useEquippedItem();
            }

            if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.LeftControl))
            {
                playerInventory.dropInventoryItem();
            }

            if (!Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D) &&
                !Input.GetKey(KeyCode.UpArrow) && !Input.GetKey(KeyCode.DownArrow) && !Input.GetKey(KeyCode.LeftArrow) && !Input.GetKey(KeyCode.RightArrow))
            {
                farmerMovement.stopDustMaker();
            }
        }
        else if (currentInputMode == InputMode.RecipeMenu)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                foodManager.toggleRecipePanel();
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                foodManager.executeSelectedAction();
            }

            if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
            {
                foodManager.adjustSelectedRecipeIndex(1);
            }
            else if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
            {
                foodManager.adjustSelectedRecipeIndex(-1);
            }
        }
        else if (currentInputMode == InputMode.ShopMenu)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                shopManager.toggleShopPanel();
            }

            if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
            {
                shopManager.moveSelector(-1);
            }
            else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
            {
                shopManager.moveSelector(1);
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                shopManager.makeSelection();
            }
        }
        else if (currentInputMode == InputMode.GameOver)
        {
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                SceneManager.LoadScene("MainMenu");
            }
        }
    }