Exemplo n.º 1
0
    //ca serait plus generique si equipe renvoyer un boolean pour dire si l'action a fonctionne ou pas, si elle na pas fonctionne ne pas supprimer lobjet par exemple
    public void Equip(AStuff <TModuleType> stuff)
    {
        //this.itemManagerGUI.ResetItemSelected();
        //envoyer lindex au lieu de stuff comme un gros degueulasse
        if (this.attribute.Level >= stuff.levelRequiered)
        {
            e_equipmentEmplacement emplacement = stuff.equipmentEmplacement;
            bool worked  = true;
            bool unequip = false;

            if (this.equipment.GetEquipmentSlot(emplacement).Equipped)
            {
                unequip = true;
            }

            if (emplacement == e_equipmentEmplacement.Both_Hand)
            {
                this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Left_Hand).UnequipInSlot(equipment.GetEquipmentSlot(e_equipmentEmplacement.Left_Hand).Item, this.equipment, this);
                this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Right_Hand).UnequipInSlot(equipment.GetEquipmentSlot(e_equipmentEmplacement.Right_Hand).Item, this.equipment, this);
            }
            else if (emplacement == e_equipmentEmplacement.Left_Hand || emplacement == e_equipmentEmplacement.Right_Hand)
            {
                this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Both_Hand).UnequipInSlot(equipment.GetEquipmentSlot(e_equipmentEmplacement.Both_Hand).Item, equipment, this);
            }

            if (unequip)
            {
                AStuff <TModuleType> equippedStuff = equipment.EquipmentSlots[((int)emplacement)].Item;

                if (equippedStuff != null && inventory.CanAddItem(equippedStuff))
                {
                    this.equipment.EquipmentSlots[((int)emplacement)].UnequipInSlot(equippedStuff, this.equipment, this);
                }
                else
                {
                    base.ModuleManager.ServiceLocator.ErrorDisplayStack.Add("You are too heavy to wear this item", e_errorDisplay.Warning);
                    worked = false;
                }
            }

            if (worked)
            {
                this.equipment.AddItemWeight(stuff);
                this.equipment.EquipmentSlots[((int)emplacement)].EquipInSlot(stuff);

                this.inventory.UnselectAll();
                this.attributeInitializer.ModifyPlayerAttributesWithEquipment(stuff, 1);
            }
        }
        else
        {
            base.ModuleManager.ServiceLocator.ErrorDisplayStack.Errors.Add(new ErrorDisplay("You can't wear this item because you don't have the level requiered to use it", e_errorDisplay.Warning));
        }
    }
Exemplo n.º 2
0
    public void Unequip(AStuff <TModuleType> stuff)
    {
        //this.itemManagerGUI.ResetItemSelected();
        e_equipmentEmplacement emplacement = stuff.equipmentEmplacement;
        bool worked = false;

        if (stuff != this.equipment.GetEquipmentSlot(emplacement).Item)
        {
            base.ModuleManager.ServiceLocator.ErrorDisplayStack.Add("You try to unequip an item that you didnt equipped", e_errorDisplay.Error);
        }
        else
        {
            if (emplacement == e_equipmentEmplacement.Both_Hand)
            {
                if (this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Right_Hand).Equipped&& this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Left_Hand).Equipped)                 // &&
                //inventory.CanAddItem(equipmentSlots[((int)e_equipmentEmplacement.Right_Hand)].item, equipmentSlots[((int)e_equipmentEmplacement.Left_Hand)].item))
                {
                    if (this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Left_Hand).Equipped)
                    {
                        this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Left_Hand).UnequipInSlot(stuff, this.equipment, this);
                    }
                    if (this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Right_Hand).Equipped)
                    {
                        this.equipment.GetEquipmentSlot(e_equipmentEmplacement.Right_Hand).UnequipInSlot(stuff, this.equipment, this);
                    }
                }
            }
            if (this.equipment.GetEquipmentSlot(emplacement).Equipped)
            {
                worked = true;
            }

            if (worked)
            {
                this.equipment.GetEquipmentSlot(emplacement).UnequipInSlot(stuff, this.equipment, this);
                this.inventory.UnselectAll();
            }
        }
    }
Exemplo n.º 3
0
 public EquipmentSlot <TModuleType> GetEquipmentSlot(e_equipmentEmplacement emplacement)
 {
     return(this.equipmentSlots[((int)emplacement)]);
 }