Exemplo n.º 1
0
        public void RemoveItem(Item item)
        {
            _items.Remove(item);
            Vector3 charPos   = transform.position;
            Vector3 dropPoint = transform.position;

            RaycastHit hit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit, 45f, LayerMask.GetMask("Terrain")))
            {
                charPos.y = hit.point.y;
                dropPoint = charPos + (hit.point - charPos).normalized;
            }
            else
            {
                dropPoint = charPos + transform.forward;
                charPos.y = hit.point.y;
                dropPoint = charPos + transform.forward;
            }
            dropPoint.y = 0;

            ObtainableObject o = Instantiate(_obtainableObjectPrefab, dropPoint, Quaternion.identity);

            o._item = item;
        }
Exemplo n.º 2
0
        private void Interact(TargetableObject obj)
        {
            switch (obj.TargetableObjectType)
            {
            case TargetableObject.TargetableObjectTypes.Obtainable:
                try {
                    ObtainableObject obtObj = obj.GetComponent <ObtainableObject>();
                    _inventoryController.AddItem(obtObj.GetItem());
                    Destroy(obj.gameObject);
                }
                catch (InventoryController.InventoryFullException e) {
                    //Trigger object animation here
                }
                break;

            default:
                break;
            }
        }