/// <summary>
        ///     equipa o desequipa el item actual (toggle)
        /// </summary>
        public void equipSelectedItem()
        {
            if (null != SelectedItem)
            {
                InventoryObject.Categories category = InventoryObject.CategoryPerType[SelectedItem.Type];

                if (InventoryObject.Categories.Armor.Equals(category))
                {
                    //es armadura
                    if (EquippedArmor == SelectedItem)
                    {
                        EquippedArmor = null;
                    }
                    else
                    {
                        EquippedArmor = SelectedItem;
                    }
                }
                else if (InventoryObject.Categories.Tool.Equals(category))
                {
                    //es una herramienta / arma
                    if (EquippedTool == SelectedItem)
                    {
                        EquippedTool = null;
                    }
                    else
                    {
                        EquippedTool = SelectedItem;
                    }
                }
            }
        }
 /// <summary>
 ///     agrega un item a la selección de combinación
 /// </summary>
 /// <param name="selectedItem"></param>
 public void selectForCombination(InventoryObject selectedItem)
 {
     if (!this.combinationSelection.Contains(selectedItem))
     {
         combinationSelection.Add(selectedItem);
     }
     else
     {
         combinationSelection.Remove(selectedItem);
     }
 }
        /// <summary>
        ///     devuelve un item del inventario por su índice
        /// </summary>
        /// <param name="itemIndex"></param>
        /// <returns></returns>
        private InventoryObject getItemByIndex(int itemIndex)
        {
            InventoryObject result = null;

            foreach (KeyValuePair <int, InventoryObject> item in Inventory)
            {
                if (itemIndex == item.Value.InventoryIndex)
                {
                    result = item.Value;
                    break;
                }
            }

            return(result);
        }
 /// <summary>
 ///     intenta seleccionar el item previo al actual
 /// </summary>
 public void selectPreviousItem()
 {
     if (SelectedItemIndex > 1 && Inventory.Count > 1)
     {
         InventoryObject result = null;
         int             i      = SelectedItemIndex;
         while (i > 1)
         {
             i--;
             result = getItemByIndex(i);
             if (null != result)
             {
                 SelectedItemIndex = i;
                 SelectedItem      = result;
                 break;
             }
         }
     }
 }
 /// <summary>
 ///     intenta seleccionar el item siguiente al actual
 /// </summary>
 public void selectNextItem()
 {
     if (Inventory.Count > 1 && SelectedItemIndex < inventoryIndexCounter)
     {
         InventoryObject result = null;
         int             i      = SelectedItemIndex;
         while (i <= inventoryIndexCounter)
         {
             i++;
             result = getItemByIndex(i);
             if (null != result)
             {
                 SelectedItemIndex = i;
                 SelectedItem      = result;
                 break;
             }
         }
     }
 }
 /// <summary>
 ///     Método que retorna true al agregar un objeto al inventario del jugador.
 ///     Si el jugador no tiene espacio disponible en su inventario devuelve false y el objeto no se agrega.
 /// </summary>
 /// <param name="newObject"></param>
 /// <returns></returns>
 public bool addInventoryObject(InventoryObject newObject)
 {
     if (this.Inventory.Count < this.InventorySize)
     {
         inventoryIndexCounter++;
         newObject.InventoryIndex = inventoryIndexCounter;
         this.Inventory.Add(newObject.InventoryIndex, newObject);
         if (this.Inventory.Count == 1)
         {
             //primer objeto levantado -> lo pongo como seleccionado
             SelectedItem      = newObject;
             SelectedItemIndex = newObject.InventoryIndex;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        ///     método que remueve un objeto del inventario del jugador
        /// </summary>
        /// <param name="objectToRemove"></param>
        public void removeInventoryObject(InventoryObject objectToRemove)
        {
            if (null != objectToRemove)
            {
                this.Inventory.Remove(objectToRemove.InventoryIndex);
                if (EquippedTool == objectToRemove)
                {
                    EquippedTool = null;
                }
                if (SelectedItem == objectToRemove)
                {
                    SelectedItem = null;

                    if (Inventory.Count == 1)
                    {
                        SelectedItem      = Inventory.First().Value;
                        SelectedItemIndex = SelectedItem.InventoryIndex;
                    }
                    else
                    {
                        selectNextItem();
                        if (null == SelectedItem)
                        {
                            selectPreviousItem();
                        }
                    }
                }
                if (combinationSelection.Contains(objectToRemove))
                {
                    combinationSelection.Remove(objectToRemove);
                }

                //si no tengo más items, reinicio el contador de objetos
                if (0 == Inventory.Count)
                {
                    inventoryIndexCounter = 0;
                }
            }
        }
        /// <summary>
        ///     intenta consumir el objeto seleccionado. Retorna true si se consumió
        /// </summary>
        public bool consumeItem()
        {
            bool            result = false;
            InventoryObject obj    = this.SelectedItem;

            if (InventoryObject.ObjectTypes.Seed.Equals(obj.Type))
            {   //Seed
                this.Hunger = this.Hunger + 5;
                if (this.Hunger > 100)
                {
                    this.Hunger = 100;
                }
                result = true;
            }
            else if (InventoryObject.ObjectTypes.Rock.Equals(obj.Type))
            {   //Roca ?
                this.beHit(25);
                result = true;
            }
            else if (InventoryObject.ObjectTypes.AlienMeat.Equals(obj.Type))
            {   //AlienMeat!
                this.Hunger = this.Hunger + 100;
                if (this.Hunger > 100)
                {
                    this.Hunger = 100;
                }
                result = true;
            }
            else if (InventoryObject.ObjectTypes.Leaf.Equals(obj.Type))
            {   //Hoja
                this.Stamina = this.Stamina + 15;
                if (this.Stamina > 100)
                {
                    this.Stamina = 100;
                }
                result = true;
            }
            else if (InventoryObject.ObjectTypes.Water.Equals(obj.Type))
            {   //Agua
                this.Thirst = this.Thirst + 20;
                if (this.Thirst > 100)
                {
                    this.Thirst = 100;
                }
                result = true;
            }
            else if (InventoryObject.ObjectTypes.Potion.Equals(obj.Type))
            {   //Poción
                this.Thirst = this.Thirst + 50;
                if (this.Thirst > 100)
                {
                    this.Thirst = 100;
                }
                this.LifePoints = 100;
                result          = true;
            }

            if (result)
            {
                this.removeInventoryObject(obj);
            }

            return(result);
        }
 /// <summary>
 ///     método que detecta el input del usuario y realiza acciones en base a eso
 /// </summary>
 private void detectUserInput()
 {
     if (Input.buttonPressed(TgcD3dInput.MouseButtons.BUTTON_LEFT))
     {
         pickingRay.updateRay();
         testPicking();
     }
     else if (Input.keyPressed(Key.LeftArrow))
     {
         Player1.selectPreviousItem();
         soundPlayer.playActionSound(SoundPlayer.Actions.Menu_Next);
     }
     else if (Input.keyPressed(Key.Space))
     {
         soundPlayer.playActionSound(SoundPlayer.Actions.Jump);
     }
     else if (Input.keyPressed(Key.RightArrow))
     {
         Player1.selectNextItem();
         soundPlayer.playActionSound(SoundPlayer.Actions.Menu_Next);
     }
     else if (Input.keyPressed(Key.E))
     {
         if (null != Player1.SelectedItem && Player1.SelectedItem.isEquippable())
         {
             soundPlayer.playActionSound(SoundPlayer.Actions.Menu_Select);
             Player1.equipSelectedItem();
         }
         else
         {
             //intento consumir el item ya que no era equipable
             if (null != Player1.SelectedItem && Player1.consumeItem())
             {
                 soundPlayer.playActionSound(SoundPlayer.Actions.Drink);
             }
             else
             {
                 soundPlayer.playActionSound(SoundPlayer.Actions.Menu_Wrong);
             }
         }
     }
     else if (Input.keyPressed(Key.Q))
     {
         Player1.removeInventoryObject(Player1.SelectedItem);
         soundPlayer.playActionSound(SoundPlayer.Actions.Menu_Discard);
     }
     else if (Input.keyPressed(Key.Z))
     {
         Player1.selectForCombination(Player1.SelectedItem);
         soundPlayer.playActionSound(SoundPlayer.Actions.Menu_Select);
     }
     else if (Input.keyPressed(Key.C))
     {
         if (!InventoryObject.combineObjects(Player1, Player1.combinationSelection))
         {
             //falló la combinación
             soundPlayer.playActionSound(SoundPlayer.Actions.Menu_Wrong);
         }
         else
         {
             //comb ok
             soundPlayer.playActionSound(SoundPlayer.Actions.Success);
         }
     }
     else if (Input.keyPressed(Key.RightShift))
     {
         //god mode!
         if (!GodMode)
         {
             GodMode = true;
             MyCamera.WalkingSpeed = MyCamera.WalkingSpeed * 5;
             MyCamera.RunningSpeed = MyCamera.RunningSpeed * 5;
             Player1.Stamina       = 9999;
             Player1.BaseDamage    = 100;
             setTopRightText("Modo Dios Activado");
         }
         else
         {
             GodMode = false;
             MyCamera.WalkingSpeed = MyCamera.WalkingSpeed / 5;
             MyCamera.RunningSpeed = MyCamera.RunningSpeed / 5;
             Player1.Stamina       = 100;
             Player1.BaseDamage    = 1;
             setTopRightText("Modo Dios Desactivado");
         }
     }
 }