Exemplo n.º 1
0
    void Update()
    {
        // !!! TODO if/else seems to be causing a lag between closing inventory & being able to fire gun
        if (Input.GetButtonDown(InputAxis.PlayerControl.INVENTORY))
        {
            UIManager.instance.ToggleScreen(ScreenName.Inventory, null, CharacterInstance);
        }
        else
        {
            if (currentlyInteractableObjects.Count > 0 && Input.GetButtonDown(InputAxis.PlayerControl.INTERACT))
            {
                currentlyInteractableObjects[0].Interact(CharacterInstance);
                currentlyInteractableObjects.RemoveAt(0);
            }

            inputMoveAmount   = Input.GetAxis(InputAxis.PlayerControl.HORIZONTAL);
            jumpButtonPressed = Input.GetButtonDown(InputAxis.PlayerControl.JUMP);

            float equippedSwap = Input.GetAxis(InputAxis.PlayerControl.EQUIPPED_SWAP);

            if (equippedSwap != 0 && Time.time > nextWeaponSwapTime)
            {
                nextWeaponSwapTime = Time.time + weaponSwapCooldown;
                // !!! TODO swap weapon
                CharacterInstance.CycleWeapon(equippedSwap < 0);
            }
            // else if so that firing cannot occur on the same frame as swapping weapons
            else if (Input.GetButton(InputAxis.PlayerControl.FIRE))
            {
                CharacterInstance.UsePrimary();
            }
        }
    }