public void Equip_Item_by_Type_Does_Not_Change_If_Equip_Again()
    {
        //ARRANGE
        IEquippable inventory = Substitute.For <IEquippable>();
        Item        item1     = new Item(ItemType.Gun);
        Item        item2     = new Item(ItemType.Gun);

        inventory.ItemEquippedByType(ItemType.Gun).Returns(item1);


        //ACT
        inventory.Equip(item1);
        inventory.Equip(item2);

        //ASSERT
        Assert.AreEqual(item1, inventory.ItemEquippedByType(ItemType.Gun));
    }
Ejemplo n.º 2
0
 public void Equip(IEquippable <Item> item)
 {
     try
     {
         if (Check.IsEquippableByMage(item) == true &&
             CheckMultiCast.ChechEquippability(this, item) == true)
         {
             base.Equip(item);
             ResetCharacterToDefault(500);
             BuffFromIntellect();
         }
         else
         {
             throw new InvalidOperationException();
         }
     }
     catch (InvalidOperationException) { }
 }
Ejemplo n.º 3
0
    private void RaycastToEquip()
    {
        RaycastHit2D[] hits = Physics2D.RaycastAll(mousePosition, Vector2.zero);

        IEquippable itemFound = null;

        if (hits != null)
        {
            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.gameObject.tag == "Equippable")
                {
                    itemFound = hit.collider.gameObject.GetComponent <IEquippable>();
                    break;
                }
            }

            if (itemFound != null)
            {
                if (hovering != itemFound)
                {
                    if (hovering != null)
                    {
                        hovering.OnRayExit();
                    }
                    hovering = itemFound;
                    hovering.OnRayEnter();
                }

                if (Input.GetMouseButtonDown(0))
                {
                    EquipItem(itemFound);
                }
            }
            else
            {
                if (hovering != null)
                {
                    hovering.OnRayExit();
                    hovering = null;
                }
            }
        }
    }
Ejemplo n.º 4
0
        private void CheckQueuedSwitch()
        {
            if (_queuedWeaponSwitchIndex >= 0)
            {
                IEquippable cur = GetCurrentWeapon();
                if (cur != null)
                {
                    // check that current weapon is okay
                    if (!cur.CanSwitchAway())
                    {
                        return;
                    }
                    cur.SetEquipped(false);
                }

                _currentWeaponIndex      = _queuedWeaponSwitchIndex;
                _queuedWeaponSwitchIndex = -1;
                cur = GetCurrentWeapon();
                cur.SetEquipped(true);
            }
        }
Ejemplo n.º 5
0
        public override Option <ICommand> HandleKeyInput(int key)
        {
            switch (key)
            {
            case Terminal.TK_A:
                if (!_usable)
                {
                    Game.MessageHandler.AddMessage($"Cannot apply {_item}.");
                    return(Option.None <ICommand>());
                }

                IAction         action = ((IUsable)_item).ApplySkill;
                TargettingState state  = new TargettingState(Game.Player, action.Area, returnTarget =>
                {
                    Item usable = Game.Player.Inventory.Split(_item, 1);
                    Game.StateHandler.PopState();
                    return(new ApplyCommand(Game.Player, usable as IUsable, returnTarget));
                });
                Game.StateHandler.PushState(state);
                return(Option.None <ICommand>());

            case Terminal.TK_C:
            case Terminal.TK_T:
                return(Option.None <ICommand>());

            case Terminal.TK_W:
                if (!_equippable)
                {
                    Game.MessageHandler.AddMessage($"Cannot equip {_item}.");
                    return(Option.None <ICommand>());
                }

                Item        split     = Game.Player.Inventory.Split(_item, 1);
                IEquippable equipable = split as IEquippable;
                return(Option.Some <ICommand>(new EquipCommand(Game.Player, equipable)));

            default:
                return(Option.None <ICommand>());
            }
        }
Ejemplo n.º 6
0
    public void Equip(IEquippable equipment, bool playSound = true)
    {
        // First, unequip any existing items if they are equipped
        IEquippable equippedItem;

        if (equippedItems.TryGetValue(equipment.EquipmentSlot, out equippedItem))
        {
            equippedItem.Unequip(body.PartParts);
        }

        // Now equip item
        equipment.Equip(body.PartParts);

        // Sometimes we don't want to play the equip sound, such as when npc's equip items
        if (playSound)
        {
            equipment.PickupSound.PlaySoundAtPoint(transform.position);
        }

        equippedItems[equipment.EquipmentSlot] = equipment;
        return;
    }
Ejemplo n.º 7
0
 public void Equip(IEquippable <Item> item)
 {
     try
     {
         if (CheckMultiCast.ChechEquippability(this, item) == true)
         {
             if (this.equippment[item.SlotCompatibility] != null)
             {
                 this.equippment[item.SlotCompatibility].UnEquip(this);
                 backpack.Change(this.equippment[item.SlotCompatibility], item, this);
             }
             else
             {
                 item.Equip(this);
             }
         }
         else
         {
             throw new InvalidOperationException();
         }
     }
     catch (InvalidOperationException) { }
 }
Ejemplo n.º 8
0
 //Equip a item/weapon
 public string Equip(IEquippable thing, Player player, bool remove)
 {
     return(backpack.Equip(thing, player, remove));
 }
Ejemplo n.º 9
0
 public string Equip(IEquippable thing, Player player, bool remove)
 {
     return(inventory.Equip(thing, player, remove));
 }
Ejemplo n.º 10
0
 public void EquipHelmet(IEquippable helmet)
 {
     HelmetSlot.Unequip();
     HelmetSlot = helmet;
     HelmetSlot.Equip();
 }
Ejemplo n.º 11
0
        private void EquipItem()
        {
            //verify that there are equippables
            if (!mainCharacter.Equippables.Any())
            {
                //no equippables
                Console.WriteLine("\r\n *** There are no items in the inventory.\r\n *** Please create a weapon or armor.");
                return;
            }
            //member class variables
            Program pro = new Program();

            //display selection
            Console.WriteLine("\r\nEQUIP AN ITEM");
            pro.PrintLine();

            Console.WriteLine("\r\nAVAILABLE INVENTORY");
            pro.PrintLine();

            //index counter
            int counter = 0;

            //print items
            foreach (IEquippable item in mainCharacter.Equippables)
            {
                if (item is Weapon)
                {
                    Console.WriteLine(counter + ". [WEAPON] attack: " + item.Attack);
                }

                if (item is Helmet)
                {
                    Console.WriteLine(counter + ". [ARMOR - HELMET] defense: " + item.Defense);
                }

                if (item is Chestpiece)
                {
                    Console.WriteLine(counter + ". [ARMOR - CHESTPIECE] defense: " + item.Defense);
                }

                //update counter
                counter++;
            }

            //enter item number to equip
            Console.WriteLine("\r\nEnter the number for the item you would like to equip:");

            //capture user input
            String userSelection = Console.ReadLine();
            int    userSelectionInt;

            //validate number
            while (!int.TryParse(userSelection, out userSelectionInt) || userSelectionInt > counter - 1 || userSelectionInt < 0)
            {
                //error not on list
                Console.WriteLine("\r\nOnly enter numbers from the list.\r\nEnter the number for the item you would like to equip:");
                userSelection = Console.ReadLine();
            }

            //remove new item from inventory
            IEquippable choosenItem = mainCharacter.Equippables[userSelectionInt];

            mainCharacter.Equippables.Remove(choosenItem);

            //check type
            if (choosenItem is Weapon)
            {
                //remove current equipped weapon
                if (mainCharacter.CurrentWeapon != null)
                {
                    //move it back to inventory
                    mainCharacter.Equippables.Add(mainCharacter.CurrentWeapon);
                }
                //add choosen item to equipped weapon
                choosenItem.Equip(mainCharacter);
            }
            else if (choosenItem is Helmet)
            {
                //remove current helmet from dictionary
                if (mainCharacter.Armors != null && mainCharacter.Armors.ContainsKey("helmet"))
                {
                    //assign to variable
                    Armor removedItem;
                    mainCharacter.Armors.TryGetValue("helmet", out removedItem);

                    //remove and add to inventory
                    mainCharacter.Armors.Remove("helmet");

                    //add it back to inventory as helmet
                    Helmet newHelmet = (Helmet)removedItem;
                    mainCharacter.Equippables.Add(newHelmet);
                }
                //add choose item to dictionary
                Armor newArmor = (Armor)choosenItem;
                newArmor.Equip(mainCharacter);
            }
            else if (choosenItem is Chestpiece)
            {
                //remove current chestpiece from dictionary
                if (mainCharacter.Armors != null && mainCharacter.Armors.ContainsKey("chestpiece"))
                {
                    //assign to variable
                    Armor removedItem;
                    mainCharacter.Armors.TryGetValue("chestpiece", out removedItem);

                    //remove and add to inventory
                    mainCharacter.Armors.Remove("chestpiece");

                    //add it back to inventory as chestpiece
                    Chestpiece newChestpiece = (Chestpiece)removedItem;
                    mainCharacter.Equippables.Add(newChestpiece);
                }
                //add choose item to dictionary
                Armor newArmor = (Armor)choosenItem;
                newArmor.Equip(mainCharacter);
            }

            //display change to user
            Console.WriteLine("\r\n-----USER UPDATED-----");
        }
Ejemplo n.º 12
0
 public void Equip(IEquippable item)
 {
     if (item is Gun) {
         Equip ((Gun)item);
     }
 }
 private void Awake()
 {
     // create the weapons we want to assign and test
     _weaponToTest = new SwordOfSwinging(_stats);
     _helmetToTest = new FeatheryHat(_stats);
 }
Ejemplo n.º 14
0
        private static void Story02cc() //Rope non Initiative
        {
            //NEED to add logic if user has neither blunt nor sharp
            Chapter = "02cc";
            bool        Sharpbool = false;
            IEquippable sharpitem = null;

            if (storysent == false)
            {
                Console.WriteLine("You prepare to untie the rope as the creature walks into view. But without proper bait there is nothing keeping the creature drawn to the center of the room.");
                storysent = true;
                foreach (IEquippable item in Character.Inventory2)
                {
                    if (item.WeaponType == "Sharp")
                    {
                        Sharpbool = true;
                        sharpitem = item;
                    }
                }
                if (Sharpbool == true)
                {
                    Console.WriteLine($"The beast is as close to the damage zone as you think it'll ever be. You take out your {sharpitem.Name} and start working on the thick twine. It is harder then you expected and you being to worry that the creature will hear you with its gigantic" +
                                      " ears and move out of the way. You grab the rope with your free hand for leverage and begin cutting more desperately now, sweat dropping from your brow. Not yet relenting, you sneak a quick glance at the dinner and with" +
                                      " a sudden and loud snap, the rope rips from your hands.");
                    Continue(0);
                    Console.WriteLine("The massive chandelier crashes into the table near where the beast was standing, cleaving the great table in half and sending silverware and wreckage in all directions as you leap behind the piano to avoid the debris.");
                    Continue(0);
                    Console.WriteLine("It wasn't a direct hit. You sprint to attack while you still have the chance.");
                    ColorChanger(ConsoleColor.Green, "Battle Advantage!");
                    ColorChanger(ConsoleColor.Red, "3 Damage dealt to enemy.");

                    Entities ManBat = new Entities
                    {
                        Name         = "Grotesque Bat",
                        movelist     = new string[] { "Hunt", "Bite", "Overwhelm", "Bulwark" },
                        HealthPoints = 17
                    };

                    Program.isInBattle = true;
                    Program.Battle(ManBat);
                }
                else
                {
                    string BluntitemName = "";
                    foreach (IEquippable item in Character.Inventory2)
                    {
                        if (item.WeaponType == "Blunt")
                        {
                            BluntitemName = item.Name;
                        }
                    }
                    Console.WriteLine("The beast is as close to the damage zone as you think it'll ever be. You began to work on untying the rope, it would be easier if you had something sharp to work with. It’s attached to a metal bar jutting from the wall in well-tied knots. You begin to worry that the" +
                                      " creature will hear you with its gigantic ears and move out of the way. Your hands begin to ache and skin beings to peel as you use all your strength to undo the thick twine knots.");
                    Continue(0);
                    Console.Clear();
                    Console.WriteLine($"Sweat dripping from your brow, you steal a glance from the table and see that two beady eyes staring back at you. It sees you. In an act of desperation, you swing your {BluntitemName} at the metal bar as hard as you can, and" +
                                      " it goes flying, pulled up toward the ceiling. In the next instant, a loud crash fills the room, cleaving the great table in half and sending silverware and wreckage in all directions. You leap into cover to avoid getting hit. When the dust " +
                                      "clears, you see the beast lay nearby struggling to get to its feet, it wasn't a direct hit. You attack while you still have the advantage.");
                    Continue(0);
                    ColorChanger(ConsoleColor.Green, "Battle Advantage!");
                    ColorChanger(ConsoleColor.Red, "1 Damage dealt to enemy.");

                    Entities ManBat = new Entities
                    {
                        Name         = "Grotesque Bat",
                        movelist     = new string[] { "Hunt", "Bite", "Overwhelm", "Bulwark" },
                        HealthPoints = 19
                    };

                    Program.isInBattle = true;
                    Program.Battle(ManBat);
                }
                storysent = true;
            }
            else
            {
            }
        }
Ejemplo n.º 15
0
 public UnequipCommand(Actor source, IEquippable item)
 {
     Source         = source;
     _equipableItem = item;
 }
Ejemplo n.º 16
0
 public string Equip(Player player, IEquippable item)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
        //Method for equipping things
        public string Equip(IEquippable item, Player player, bool remove)
        {
            /********************************************
            *       CHANGE WEAPON
            ********************************************/
            if (item is IWeapon tempWeapon)
            {
                //If the player changes to another item of the same type, but do not unequip the first one before.
                if (!remove)
                {
                    //If weapon has never been equipped or if it has been manually unequipped
                    if (equippedWeapon.Count == 0)
                    {
                        equippedWeapon.Add(tempWeapon);
                        player.StrengthWeapon += tempWeapon.Damage;
                        //Method for updating vitals after change of weapon
                        player.MakeVitalChangeAfterEquip("Weapon");
                        if (equippedWeapon.Contains(item))
                        {
                            //Activate the "Equipped" text on the newly equipped weapon
                            item.ActivateDeactivateEquipBool(true);
                        }
                    }

                    //If a weapon is activly in the slot and is going to be replaced.
                    else
                    {
                        equippedWeapon[0].ActivateDeactivateEquipBool(false);
                        player.StrengthWeapon -= player.StrengthWeapon * 2;
                        player.MakeVitalChangeAfterEquip("Weapon");
                        equippedWeapon.RemoveAt(0);
                        equippedWeapon.Add(tempWeapon);
                        if (equippedWeapon.Contains(item))
                        {
                            item.ActivateDeactivateEquipBool(true);
                        }

                        player.StrengthWeapon += tempWeapon.Damage;
                        player.MakeVitalChangeAfterEquip("Weapon");
                    }
                }
                //Else the Item is manually unequipped
                else
                {
                    for (int i = 0; i < equippedWeapon.Count; i++)
                    {
                        bool deleted = false;
                        if (!deleted)
                        {
                            if (equippedWeapon[i].Equals(item))
                            {
                                equippedWeapon[i].ActivateDeactivateEquipBool(false);


                                player.StrengthWeapon -= player.StrengthWeapon * 2;
                                equippedWeapon.RemoveAt(i);
                                player.MakeVitalChangeAfterEquip("Weapon");
                            }
                        }
                    }
                }
            }

            /********************************************
            *       CHANGE SHOE
            ********************************************/

            //For comments, se above section for weapon
            if (item is IShoes tempShoe)
            {
                //If the player changes to another item of the same type, but do not unequip the first one before.
                if (!remove)
                {
                    if (equippedShoe.Count == 0)
                    {
                        equippedShoe.Add(tempShoe);
                        player.AgilityShoe += tempShoe.Agility;
                        player.MakeVitalChangeAfterEquip("Shoe");
                        if (equippedShoe.Contains(item))
                        {
                            item.ActivateDeactivateEquipBool(true);
                        }
                    }
                }
                //Else the Item is manually unequipped
                else
                {
                    for (int i = 0; i < equippedShoe.Count; i++)
                    {
                        bool deleted = false;
                        if (!deleted)
                        {
                            if (equippedShoe[i].Equals(item))
                            {
                                equippedShoe[i].ActivateDeactivateEquipBool(false);


                                player.AgilityShoe -= player.AgilityShoe * 2;
                                equippedShoe.RemoveAt(i);
                                player.MakeVitalChangeAfterEquip("Shoe");
                            }
                        }
                    }
                }
            }



            /********************************************
            *       CHANGE ARMOR
            ********************************************/
            //For comments, se above section for weapon
            else if (item is IArmor tempArmor)
            {
                //If the player changes to another item of the same type, but do not unequip the first one before.
                if (!remove)
                {
                    if (equippedArmor.Count == 0)
                    {
                        equippedArmor.Add(tempArmor);

                        player.AgilityArmor += tempArmor.Agility;
                        player.ArmorArmor   += tempArmor.Armor;

                        player.MakeVitalChangeAfterEquip("Armor");
                        if (equippedArmor.Contains(item))
                        {
                            item.ActivateDeactivateEquipBool(true);
                        }
                    }
                    else
                    {
                        equippedArmor[0].ActivateDeactivateEquipBool(false);

                        player.AgilityArmor -= player.AgilityArmor * 2;

                        player.ArmorArmor -= player.ArmorArmor * 2;
                        player.MakeVitalChangeAfterEquip("Armor");
                        equippedArmor.RemoveAt(0);
                        equippedArmor.Add(tempArmor);
                        if (equippedArmor.Contains(item))
                        {
                            item.ActivateDeactivateEquipBool(true);
                        }
                        player.AgilityArmor += tempArmor.Agility;

                        player.ArmorArmor += tempArmor.Armor;
                        player.MakeVitalChangeAfterEquip("Armor");
                    }
                }
                //Else the Item is manually unequipped
                else
                {
                    for (int i = 0; i < equippedArmor.Count; i++)
                    {
                        bool deleted = false;
                        if (!deleted)
                        {
                            if (equippedArmor[i].Equals(item))
                            {
                                equippedArmor[i].ActivateDeactivateEquipBool(false);
                                player.AgilityArmor -= player.AgilityArmor * 2;

                                player.ArmorArmor -= player.ArmorArmor * 2;
                                equippedArmor.RemoveAt(i);
                                player.MakeVitalChangeAfterEquip("Armor");
                            }
                        }
                    }
                }
            }

            /********************************************
            *       CHANGE AMULETT
            ********************************************/
            //For comments, se above section for weapon
            else if (item is IAmulett tempAmulett)
            {
                //If the player changes to another item of the same type, but do not unequip the first one before.
                if (!remove)
                {
                    if (equippedAmulett.Count == 0)
                    {
                        equippedAmulett.Add(tempAmulett);

                        player.AgilityAmulett  += tempAmulett.Agility;
                        player.HealthAmulett   += tempAmulett.Hp;
                        player.StrengthAmulett += tempAmulett.Strength;
                        player.MakeVitalChangeAfterEquip("Amulett");
                        if (equippedAmulett.Contains(item))
                        {
                            item.ActivateDeactivateEquipBool(true);
                        }
                    }
                    else
                    {
                        equippedAmulett[0].ActivateDeactivateEquipBool(false);

                        player.AgilityAmulett  -= player.AgilityAmulett * 2;
                        player.HealthAmulett   -= player.HealthAmulett * 2;
                        player.StrengthAmulett -= player.StrengthAmulett * 2;
                        player.MakeVitalChangeAfterEquip("Amulett");
                        equippedAmulett.RemoveAt(0);
                        equippedAmulett.Add(tempAmulett);
                        if (equippedAmulett.Contains(item))
                        {
                            item.ActivateDeactivateEquipBool(true);
                        }
                        player.AgilityAmulett  += tempAmulett.Agility;
                        player.HealthAmulett   += tempAmulett.Hp;
                        player.StrengthAmulett += tempAmulett.Strength;
                        player.MakeVitalChangeAfterEquip("Amulett");
                    }
                }
                //Else the Item is manually unequipped
                else
                {
                    for (int i = 0; i < equippedAmulett.Count; i++)
                    {
                        bool deleted = false;
                        if (!deleted)
                        {
                            if (equippedAmulett[i].Equals(item))
                            {
                                equippedAmulett[i].ActivateDeactivateEquipBool(false);
                                player.AgilityAmulett  -= player.AgilityAmulett * 2;
                                player.HealthAmulett   -= player.HealthAmulett * 2;
                                player.StrengthAmulett -= player.StrengthAmulett * 2;
                                equippedAmulett.RemoveAt(i);
                                player.MakeVitalChangeAfterEquip("Amulett");
                            }
                        }
                    }
                }
            }
            return($"{item.Name} was equipped");
        }
Ejemplo n.º 18
0
 public static bool ChechEquippability(IHero hero, IEquippable <Item> item)
 {
     return(Check.IsAlive(hero) == true &&
            Check.LevelIsHigherOrEqual(hero, item.LevelNeeded) == true);
 }