public void EquipItem(Item it) { IEquipable equipable = it as IEquipable; equipable.Equip(); string itemType = it.GetItemType(); Debug.Log(itemType); if (itemType == "Weapon" || itemType == "PickAxe") { Weapon weapon = (Weapon)it; WeaponHands weaponHands = weapon.weaponHands; attackPoint.localPosition = weapon.attackPointOffset; if (weaponHands == WeaponHands.OneHand) { playerAnimator.SetLayerWeight(1, 1f); playerAnimator.SetLayerWeight(2, 0f); } if (weaponHands == WeaponHands.TwoHand) { playerAnimator.SetLayerWeight(1, 0f); playerAnimator.SetLayerWeight(2, 1f); } } }
public void equip(IEquipable i, FightableC c) { int index = 0; Item it = null; if (!i.Equals(null) && !s.Equals(null)) { if (i is Equipment) { it = i as Equipment; } else if (i is MagicalEquipment) { it = i as MagicalEquipment; } if (i.CanBeEquiped(c.Stats)) { index = getPosFromPartType(i.getPartType()); } else { throw new EquipmentRequirementsNotMetException("You don't meet the requirements needed to use that equipment"); } } else { throw new System.ArgumentException("Params can't be null"); } }
private void Pickup() { Debug.Log("Pickup Called"); //Only check this layer for equipment triggers LayerMask equipable_mask = LayerMask.GetMask("Equip Trigger"); ContactFilter2D equip_filter = new ContactFilter2D { useTriggers = true }; equip_filter.SetLayerMask(equipable_mask); Collider2D[] results = new Collider2D[1]; //just using the circle collider for pickup collision detection for now //to avoid having to iterate over all attached colliders and check each Collider2D collider = gameObject.GetComponent <CircleCollider2D>(); //check if player collider is touching another collider in filter //results should only be null or have equipable objects as they will all be on own layer if (collider.OverlapCollider(equip_filter, results) > 0) { if (results != null) { //call Equip() on the first object in results IEquipable equipment = results[0].GetComponentInParent <IEquipable>(); equipment.Equip(transform.Find("Equipment Slot")); } } }
private void InteractWithItemObject(ItemObject itemObject) { Debug.Assert(itemObject.Item != null); IUsable usable = itemObject.Item as IUsable; IPickupable pickupable = itemObject.Item as IPickupable; IEquipable equipable = itemObject.Item as IEquipable; IStackable stackable = itemObject.Item as IStackable; if (usable != null) { usable.OnUse(_stats, itemObject); } else if (pickupable != null) { if (equipable != null && equipable.IsDurable && _equipment.EquipmentTable[equipable.EquipmentType].IsEmpty) { equipable.OnEquip(_equipment, _stats); } else if (stackable != null) { stackable.OnStack(_inventory); } else { pickupable.OnPutInInventory(_inventory); } pickupable.OnRemoveFromGround(itemObject); } }
private void LeftClickItemIcon(object[] eventParams) { Debug.Assert(eventParams.Length == 1 && eventParams[0] is ItemIcon); ItemIcon itemIcon = (ItemIcon)eventParams[0]; SlotPosition slotPosition = itemIcon.Position; IPickupable pickupable = itemIcon.Item as IPickupable; IEquipable equipable = itemIcon.Item as IEquipable; if (_airItem.IsEmpty) { if (itemIcon.IsEquipmentIcon) { equipable.OnUnequip(_equipment, _stats); } else if (itemIcon.Item is IStackable) { EventManager.TriggerEvent(EventName.OPEN_SPLIT_SCREEN, eventParams); return; } else { pickupable.OnRemoveFromInventory(_inventory, slotPosition); } pickupable.OnPutInAir(_airItem, slotPosition); } else { IPickupable pickupableAir = _airItem.Item as IPickupable; if (slotPosition.RowIndex == EquipmentSlot.EQUIPMENT_SLOT_ROW_INDEX) { IEquipable equipableAir = _airItem.Item as IEquipable; if (equipableAir == null) { Debug.Log("Not equipable"); return; } if ((Equipment.EquipmentType)slotPosition.SlotIndex != equipableAir.EquipmentType) { Debug.Log("Not the same equipment type"); return; } if (equipable.IsDurable == false) { Debug.Log("Not durable"); } equipable.OnUnequip(_equipment, _stats); pickupableAir.OnRemoveFromAir(_airItem); equipableAir.OnEquip(_equipment, _stats); pickupable.OnPutInAir(_airItem, slotPosition); } else { pickupable.OnRemoveFromInventory(_inventory, slotPosition); pickupableAir.OnRemoveFromAir(_airItem); pickupableAir.OnPutInInventory(_inventory, slotPosition); pickupable.OnPutInAir(_airItem, slotPosition); } } }
/* * Swaps handItem and pocketItem * Sometimes, people like to put their hands into their pockets. * Assumes that pocket exists */ public void PocketItem(int eeiHand) { int eeiPocket = eeiHand + 1; IEquipable equipable = equipmentEquipableItemArray[eeiPocket]; equipmentEquipableItemArray[eeiPocket] = equipmentEquipableItemArray[eeiHand]; equipmentEquipableItemArray[eeiHand] = equipable; }
public void TerminateBoomerang() { if (currentItem != null) { currentItem = null; boomerang = null; } }
public void AddEquipment(IEquipable E) { if (Inventory.Contains((Item)E)) { Inventory.Remove((Item)E); } HeldItems.Add(E); }
public void TerminateBow() { if (currentItem != null) { currentItem = null; bow = null; } }
public void TerminateBomb() { if (currentItem != null) { currentItem = null; bomb = null; } }
private void AddStats(IEquipable itemToWear) { this.Health += itemToWear.HealthBonus; this.MaxHealth += itemToWear.HealthBonus; this.Mana += itemToWear.ManaBonus; this.MaxMana += itemToWear.ManaBonus; this.Attack += itemToWear.AttackBonus; this.Defence += itemToWear.DefenceBonus; }
private void UnequipItemNoDurability(object[] eventParams) { Debug.Assert(eventParams.Length == 1 && eventParams[0] is Item); IPickupable pickupable = eventParams[0] as IPickupable; IEquipable equipable = eventParams[0] as IEquipable; equipable.OnUnequip(_equipment, _stats); pickupable.OnPutInInventory(_inventory); }
private void RemoveStats(IEquipable itemToRemove) { this.Health -= itemToRemove.HealthBonus; this.MaxHealth -= itemToRemove.HealthBonus; this.Mana -= itemToRemove.ManaBonus; this.MaxMana -= itemToRemove.ManaBonus; this.Attack -= itemToRemove.AttackBonus; this.Defence -= itemToRemove.DefenceBonus; }
public void Equip(Player player, IEquipable item) { if (player.Armor != null) { player.Backpack.Add(player.Armor); } Console.WriteLine($"\t you equipped {item.Name} with {Defence} defence!"); player.Armor = (Armor)item; player.Defence = Defence; }
public void Equip(Player player, IEquipable weapon) { if (player.Weapon.Name != "Fists") { player.Backpack.Add(player.Weapon); } Console.WriteLine($"\t you equipped {Name} with {Damage} Damage!"); player.Weapon = (Weapon)weapon; player.Damage = Damage; }
// Wear item // Wear all // Wear all.item protected virtual bool DoWear(string rawParameters, params CommandParameter[] parameters) { if (parameters.Length == 0) { Send("Wear, wield, or hold what?"); } else if (parameters[0].IsAll) { CommandParameter whatParameter = parameters[0]; // We have to clone list because it'll be modified when wearing an item IReadOnlyCollection <IEquipable> list; // list must be cloned because it'll be modified when wearing an item if (!string.IsNullOrWhiteSpace(whatParameter.Value)) // get all.item { list = new ReadOnlyCollection <IEquipable>(FindHelpers.FindAllByName(Content.Where(CanSee).OfType <IEquipable>(), whatParameter).ToList()); } else // get all { list = new ReadOnlyCollection <IEquipable>(Content.Where(CanSee).OfType <IEquipable>().ToList()); } if (list.Any()) { foreach (IEquipable item in list) { WearItem(item, false); } RecomputeAttributes(); } else { Send(StringHelpers.ItemInventoryNotFound); // TODO: better wording } } else { IItem item = FindHelpers.FindByName(Content.Where(CanSee), parameters[0]); if (item == null) { Send(StringHelpers.ItemInventoryNotFound); } else { IEquipable equipable = item as IEquipable; if (equipable == null) { Send("It cannot be equiped."); } else { WearItem(equipable, true); RecomputeAttributes(); } } } return(true); }
public InventoryManager(Player player) { inventory = new HashSet <Type>(); this.player = player; equippedItem = null; rupeeCount = 1; keyCount = 0; bombCount = 0; }
public void UseBoomerang() { if (currentItem == null) { if (inventory.Contains(typeof(Boomerang))) { boomerang = new Boomerang(player); currentItem = boomerang; } } }
public void UseBow() { if (currentItem == null) { if (inventory.Contains(typeof(Bow))) { bow = new Bow(player); currentItem = bow; } } }
public void UseBomb() { if (currentItem == null) { if (inventory.Contains(typeof(Bomb)) && bombCount > 0) { bomb = new Bomb(player); currentItem = bomb; bombCount -= 1; } } }
void ChangeEquipment(string name) { for (uint i = 0; i < playerData.equipables.Count; i++) { IEquipable equipment = playerData.equipables[(int)i]; if (equipment.equipName == name) { playerData.currentEquipable = equipment; break; } } }
public void equip(IEquipable newEquipment) { string targetSlot = newEquipment.targetSlot(); if (this.peekEquipmentSlot(targetSlot) != null) { this.unequip(targetSlot); } this.myEquipment[targetSlot] = newEquipment; newEquipment.onEquip(this); }
public static void objetoSiguiente(Personaje personaje) { IEquipable itemEnMano = inventario.First(); //Creo que First no lo popea de la lista itemEnMano.Apagar(personaje); inventario.RemoveAt(0); //Por eso hago esto inventario.Add(itemEnMano); IEquipable nuevoItemEnMano = inventario.First(); personaje.setItemEnMano(nuevoItemEnMano); nuevoItemEnMano.Encender(personaje); }
public IEquipable Unequip(IEquipable.EquipmentType equipmentType) { IEquipable item = _equipment[equipmentType]; if (item != null) { AddCharacteristics(-item.Strength, -item.Agility, -item.Intelligence); item.Owner = null; } _equipment[equipmentType] = null; return(item); }
public void equipItem(IEquipable itemToEquip) { if (equipedWeapon != null) { equipedWeapon.ApplyEffect(this, false); addItemToBackpack(equipedWeapon); } if (itemToEquip is Weapon) { equipedWeapon = itemToEquip; itemToEquip.ApplyEffect(this, true); } }
/// <summary> /// This will get called from an object that hands out IEquipable, like for example, a tire stack /// </summary> /// <param name="equipable"></param> /// <returns>Returns wether or not the interactable was succesfully equipped</returns> public bool ReceiveInteractable(IEquipable equipable) { // We can only have one equipable if (_CurrentEquipable != null) { return(false); } _CurrentEquipable = equipable; equipable.Equip(this); equipable.GameObject.transform.parent = _PlayerInteractableLocation; equipable.GameObject.transform.position = _PlayerInteractableLocation.position; return(true); }
public bool EquipToSocket(GameObject itemToEquip) { Component comp = itemToEquip.GetComponent(typeof(IEquipable)); IEquipable equip = comp as IEquipable; if (comp && !isFilled && equip.GetEquipSlotType() == equipSlotType) { UnequipSocket(); equipedObject = itemToEquip; isFilled = true; // TODO: use equipSlotType to map skeletal stuff to model of actor so that it animates correctly } return(isFilled); }
protected override EquipPayload GetPayload() { GD.Print("WeaponSlot - GetPayload"); IEquipable equipable = currentTile.GetParentItem() as IEquipable; if (equipable != null) { return(new WeaponEquipPayload( equipable, weaponSlotTypeType )); } return(null); }
public IEquipable Equip(IEquipable item) { if (item.CanBeFit(this)) { AddCharacteristics(item.Strength, item.Agility, item.Intelligence); IEquipable prevItem = _equipment[item.Type]; _equipment[item.Type] = item; item.Owner = this; return(prevItem); } else { throw new Exception("Item can't be equiped."); } }
private void testEquipablePipe() { Dictionary <string, int> m1Stats = new Dictionary <string, int> { { BattleStats.CURRENT_HEALTH, 10 }, { BattleStats.MAX_HEALTH, 10 }, { BattleStats.SPEED, 0 } }; Dictionary <string, int> m2Stats = new Dictionary <string, int>(m1Stats); PMMob m1 = new PMMob(m1Stats); PMMob m2 = new PMMob(m2Stats); Pipe <int> speedUp = new PipeSum(new ExpireNever <Pipe <int> >(), new Flagable(), 5); speedUp.addFlag(BattleStats.SPEED); IEquipable helmOfSpeed = new EquipablePipe(EquipSlots.HELM, speedUp); m1.equip(helmOfSpeed); IEquipable e = m1.peekEquipmentSlot(EquipSlots.HELM); if (e.targetSlot() == EquipSlots.HELM) { Debug.Log("Nocab test 2.1 passed"); } else { Debug.Log("Nocab test 2.1 fail"); } if (m1.getStat(BattleStats.SPEED) == 5) { Debug.Log("Nocab test 2.2 passed"); } else { Debug.Log("Nocab test 2.2 failed"); } m1.unequip(EquipSlots.HELM); if (m1.getStat(BattleStats.SPEED) == 0) { Debug.Log("Nocab test 2.3 passed"); } else { Debug.Log("Nocab test 2.3 failed: Equipable pipe did not reset value after unequip"); } }