// TODO: input system
        private void HandleInGameInput()
        {
            // jumping
            if (Input.GetKeyDown(KeyCode.Space))
            {
                m_PlayerMovement.TryToJump();
            }

            // flying
            if (Input.GetKeyDown(KeyCode.Z))
            {
                m_PlayerMovement.ToggleFlying();
            }

            // drop item
            if (Input.GetKeyDown(KeyCode.Q))
            {
                if (!inventorySystem.IsHandNullOrEmpty)
                {
                    Transform cameraTransform = MouseLook.cameraTransform;
                    inventorySystem.DropItem(inventorySystem.HandSlot, cameraTransform.position + cameraTransform.forward, 1, droppedItemVelocity);
                }
            }

            // flashlight
            if (Input.GetKeyDown(KeyCode.F))
            {
                flashlightController.NextFlashLightMode();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// On inventory update event callback
        /// </summary>
        /// <param name="op">Operation (ADD, SET, REMOVE...)</param>
        /// <param name="key">inventory item position</param>
        /// <param name="item">item data</param>
        private void OnInventoryUpdate(SyncIDictionary <Vector2Byte, ItemData> .Operation op, Vector2Byte key, ItemData item)
        {
            switch (op)
            {
            case SyncIDictionary <Vector2Byte, ItemData> .Operation.OP_ADD:
            case SyncIDictionary <Vector2Byte, ItemData> .Operation.OP_SET:
                InventorySystem.Instance.OnInventoryUpdate(key, item);
                break;

            case SyncIDictionary <Vector2Byte, ItemData> .Operation.OP_REMOVE:
                InventorySystem.DropItem(key);
                break;
            }
        }
Exemplo n.º 3
0
    void Update()
    {
        //TIRAR OBJETO
        if (Input.GetKeyDown("q"))
        {
            _inventory.DropItem(_slot);
        }
        //USAR OBJETO
        if (Input.GetMouseButtonDown(0))
        {
            _itemSelected = _inventory.CheckItems(_inventory.strSlots[_slot]);
            //USARLO
            if (_itemSelected != null)
            {
                int i = _itemSelected.GetComponent <ItemControler>().Type;
                if (i >= 2)
                {
                    if (i == 2)
                    {
                        Instantiate(piedraPrefab, PM.Players[0].transform.position, PM.Players[0].transform.rotation);
                    }
                    if (i == 4)
                    {
                        for (int j = 0; j < PM.Enemies.Count; j++)
                        {
                            var dist = (PM.Enemies[j].transform.position - PM.Players[0].transform.position).magnitude;
                            if (dist >= 6 && dist < 10)
                            {
                                PM.Enemies[j].GetComponent <Animator>().SetBool("Attract", true);
                            }

                            if (dist < 6)
                            {
                                PM.Enemies[j].GetComponent <Animator>().SetBool("Distract", true);
                            }
                        }
                    }
                    _inventory.RemoveItem(_slot);
                }
                if (i == 0)
                {
                    _lighter = GameObject.Find("Players").transform.GetChild(0).transform.Find("Linterna(Clone)").gameObject;
                    _lighter.SetActive(lighter);
                    lighter = !lighter;
                }

                if (i == 1)
                {
                    _radio = GameObject.Find("Players").transform.GetChild(0).transform.Find("Radio(Clone)").gameObject;
                    _radio.GetComponent <Radio>().On = !_radio.GetComponent <Radio>().On;
                }
            }
            Debug.Log(blueLight);
        }

        if (Input.GetMouseButtonDown(1))
        {
            _itemSelected = _inventory.CheckItems(_inventory.strSlots[_slot]);
            //USARLO
            if (_itemSelected != null)
            {
                int i = _itemSelected.GetComponent <ItemControler>().Type;

                if (i == 0 && lighter == false)
                {
                    ChangeColor(blueLight);
                    _lighter.transform.GetChild(0).gameObject.SetActive(blueLight);
                    blueLight = !blueLight;
                }
            }
            Debug.Log(blueLight);
        }

        //MOVER SLOT
        if (Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            if (_slot > 0)
            {
                _slot--;
                _inventory.HighlightSlot(_slot);
            }
        }


        //MOVER SLOT
        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            if (_slot < _inventory.slots.Length - 1)
            {
                _slot++;
                _inventory.HighlightSlot(_slot);
            }
        }
    }