//if worldobject doesn't exist, create one //if item is not skinned mesh, set item to the equip location //if item is skinned mesh, replace the default mesh and material with the items //set attached-to the equip location public void AttachTo(EquipLocation e) { if (!world_object) { CreateWorldObject(Vector3.zero); } BodyPart bone = player.bones [e.GetHashCode()]; if (type != ItemType.SkinnedArmour) { world_object.transform.parent = bone.transform; world_object.transform.localPosition = Vector3.zero; world_object.transform.localRotation = Quaternion.Euler(0, 0, 0); } else { SkinnedMeshRenderer renderer = bone.transform.GetComponent <SkinnedMeshRenderer> (); renderer.sharedMesh = world_object.GetComponent <MeshFilter> ().mesh; renderer.material = world_object.GetComponent <MeshRenderer> ().material; GameObject.Destroy(world_object); } attached_to = e; }
public void DropSelected() { if (_currentlySelectedLocation == EquipLocation.None) { return; } //Gets the item EquipableItem item = GetItemInSlot(_currentlySelectedLocation); //Drops the item GameObject.FindGameObjectWithTag("Player").GetComponent <ItemDropper>().DropItem(item, 1); //Closes the tooltip ItemTooltip tooltip = GameObject.FindObjectOfType <ItemTooltip>(); if (tooltip) { tooltip.Close(); } //Removes the item RemoveItem(_currentlySelectedLocation); //Sets the selected to none _currentlySelectedLocation = EquipLocation.None; }
public PaperdollDialogItem(PacketAPI api, Rectangle location, EOPaperdollDialog parent, EIFRecord info, EquipLocation locationEnum) : base(null, null, parent) { m_api = api; SetInfo(location, info); EquipLoc = locationEnum; }
// Get follower references to set up equipment slots and assign index numbers to each slot private void RegisterEquipment() { Inventory playerInventory = Inventory.GetPlayerInventory(); // Equipment followerEquipment = Equipment.GetEntityEquipment("Follower"); FollowerManager followerManager = GameObject.FindWithTag("LevelManager").GetComponent <FollowerManager>(); GameObject followerGO; if (!followerManager.GetActiveFollowerObject(out followerGO)) { return; } Equipment followerEquipment = followerGO.GetComponent <Equipment>(); equipmentSlots ??= GetComponentsInChildren <EquipmentSlotUI>(); Dictionary <EquipLocation, int> equipSlotLookup = new Dictionary <EquipLocation, int>(); foreach (var slot in equipmentSlots) { EquipLocation equipLocation = slot.GetEquipLocation(); if (equipSlotLookup.ContainsKey(equipLocation)) { equipSlotLookup[equipLocation]++; } else { equipSlotLookup[equipLocation] = 0; } slot.Setup(playerInventory, followerEquipment, equipSlotLookup[equipLocation]); } }
public PaperdollDialogItem(PacketAPI api, Rectangle location, EOPaperdollDialog parent, ItemRecord info, EquipLocation locationEnum) : base(null, null, parent) { m_api = api; SetInfo(location, info); EquipLoc = locationEnum; }
public void OnPointerClick(PointerEventData eventData) { //Get the players inventory and equipment Inventory playerInventory = GameObject.FindGameObjectWithTag("Player").GetComponent <Inventory>(); Equipment playerEquipment = GameObject.FindGameObjectWithTag("Player").GetComponent <Equipment>(); //Get the slot ui InventorySlotUI inventorySlot = GetComponentInParent <InventorySlotUI>(); ActionSlotUI actionSlot = GetComponentInParent <ActionSlotUI>(); //if this is an inventory slot if (inventorySlot) { int indexOfItem = inventorySlot._index; playerInventory.SelectItem(indexOfItem); } //if this is an action slot else if (actionSlot) { int indexOfItem = actionSlot._index; playerInventory.SelectItem(indexOfItem); } //if it is neither a inventory or a action slot then we are an equipment slot else { EquipmentSlotUI equipmentSlot = GetComponentInParent <EquipmentSlotUI>(); EquipLocation location = equipmentSlot.EquipLocation; playerEquipment.Select(location); } }
public virtual void Equip(Transform t, EquipLocation equipLocation, EquipType equipType) { switch (equipLocation) { case EquipLocation.Left: foreach (Transform child in leftEquip) { Destroy(child.gameObject); } t.transform.SetParent(leftEquip); break; case EquipLocation.Right: foreach (Transform child in rightEquip) { Destroy(child.gameObject); } t.transform.SetParent(rightEquip); break; default: throw new ArgumentOutOfRangeException(); } animator.SetFloat(_weaponTypeHash, (float)equipType); t.transform.localScale = Vector3.one; t.transform.localPosition = Vector3.zero; t.transform.localRotation = Quaternion.identity; }
// Handles equipping via right click from inventory public int TryAddItem(InventoryItem item) { // Check if it's an equipable item EquipableItem equipableItem = item as EquipableItem; if (equipableItem == null) { return(-1); } // Get location and check number of slots. If 1, add or swap items EquipLocation equipLocation = equipableItem.GetAllowedEquipLocation(); if (!equippedItems.ContainsKey(equipLocation)) { return(-1); } if (equippedItems[equipLocation].Length == 1) { return(0); } // Otherwise check for empty slot. Don't swap if all slots for equip type are full int index = FindEmptySlot(equipLocation); if (index >= 0) { return(index); } return(-1); }
public override bool Equals(object obj) { return(obj switch { string s => (s == Location), EquipLocation l => (l.Location == Location), _ => false });
public void RemoveItem(EquipLocation slot) { equippedItems.Remove(slot); if (equipmentUpdated != null) { equipmentUpdated(); } }
/// <summary> /// Return the item in the given equip location. /// </summary> public EquipableItem GetItemInSlot(EquipLocation equipLocation) //장비창에서 equpLocation을 인자로 받는다. { if (!equippedItems.ContainsKey(equipLocation)) //equippedItems라는 Dictionary에 있는 key값에 equipLocation이 없다면. { return(null); // null return } return(equippedItems[equipLocation]);//해당 키가 있는 item return }
public ItemInfo[] this[ItemType itemType, EquipLocation equipLocation] { get { return(base[new ArrayKey { ItemType = itemType, EquipLocation = equipLocation }]); } set { base[new ArrayKey { ItemType = itemType, EquipLocation = equipLocation }] = value; } }
/// <summary> /// Remove the item for the given slot. /// </summary> public void RemoveItem(EquipLocation slot) { if (!_equippedItems.ContainsKey(slot)) { return; } _equippedItems[slot] = null; }
public void AddItem(EquipLocation slot, EquipableItem item) { //Add the item to a slot Debug.Assert(item.GetAllowedEquipLocation() == slot); _equippedItems[slot] = item; EquipmentUpdated?.Invoke(); }
// PUBLIC public bool CanEquip(EquipLocation equipLocation, Equipment equipment) { if (equipLocation != allowedEquipLocation) { return(false); } return(equipCondition.Check(equipment.GetComponents <IPredicateEvaluator>())); }
public EquipableItem GetItemInSlot(EquipLocation equipLocation) { if (!equippedItems.ContainsKey(equipLocation)) { return(null); } return(equippedItems[equipLocation]); }
/// <summary> /// Return the items in the given equip location. /// </summary> public EquipableItem GetItemInSlot(EquipLocation equipLocation, int index) { if (equippedItems[equipLocation] == null) { return(null); } return(equippedItems[equipLocation][index]); }
public EquipableItem GetItemInSlot(EquipLocation equipLocation) { //Check if we have the EquipLocation if (!_equippedItems.ContainsKey(equipLocation)) { return(null); } return(_equippedItems[equipLocation]); }
public void SetAllowedEquipLocation(EquipLocation newLocation) { if (allowedEquipLocation == newLocation) { return; } SetUndo("Change Equip Location"); allowedEquipLocation = newLocation; Dirty(); }
///////////////////////////// PUBLIC METHODS //////////////////////////////////////////// /// <summary> /// returns the item in the request equipment slot /// </summary> /// <param name="location"></param> /// <returns></returns> public EquipableItem GetItemInSlot(EquipLocation location) { //Check if the sent location is valid if (!m_EquippedItems.ContainsKey(location)) { return(null); } return(m_EquippedItems[location]); }
/// <summary> /// Add an item to the given equip location. Do not attempt to equip to /// an incompatible slot. /// </summary> public void AddItem(EquipLocation slot, EquipableItem item) { Debug.Assert(item.CanEquip(slot, this)); equippedItems[slot] = item; if (equipmentUpdated != null) { equipmentUpdated(); } }
public static EquipLocation EquipLocation(this RdlActor actor) { EquipLocation equipLoc = Radiance.EquipLocation.None; string loc = actor.Properties.GetValue <string>("EquipLocation"); if (!String.IsNullOrEmpty(loc)) { equipLoc = (EquipLocation)Enum.Parse(typeof(EquipLocation), loc, true); } return(equipLoc); }
public WeaponTemplate(int id, string name, EquipLocation location, BaseSkill skill, float accuracy, float armorMultiplier, float penetrationMultiplier, float requiredStrength) : base(id, name, location) { RelatedSkill = skill; Accuracy = accuracy; ArmorMultiplier = armorMultiplier; WoundMultiplier = penetrationMultiplier; RequiredStrength = requiredStrength; }
/// <summary> /// Add an item to the given equip location. Do not attempt to equip to /// an incompatible slot. /// </summary> public void AddItem(EquipLocation slot, EquipableItem item) { Debug.Assert(item.GetAllowedEquipLocation() == slot); equippedItems[slot] = item; if (equipmentUpdated != null) { equipmentUpdated(); } }
private void BattleSetup(CharacterClass enemyName) { // Find and activate player PlayerController playerController = playerGO.GetComponent <PlayerController>(); playerHealth = playerGO.GetComponent <Health>(); playerMana = playerGO.GetComponent <Mana>(); playerEquipment = playerGO.GetComponent <Equipment>(); playerHUD.SetActive(true); playerAtkButtons.SetActive(true); questList.onQuestUpdated += QuestCompleteCheck; // Spawn starting equipment foreach (EquipableItem equipableItem in startingGear) { int equipIndex = playerEquipment.TryAddItem(equipableItem); if (equipIndex >= 0) { EquipLocation equipLocation = equipableItem.GetAllowedEquipLocation(); playerEquipment.AddItem(equipLocation, equipableItem, equipIndex); } } playerHealth.RecalculateMaxHealth(); playerMana.RecalculateMaxMana(); // Spawn enemy enemyGO = SpawnNewEnemy(enemyName); enemyGO.transform.SetAsFirstSibling(); // Assign opponent to scripts enemyGO.GetComponent <CombatEffects>().SetTarget(playerGO); enemyGO.GetComponent <EnemyAI>().SetTarget(playerController); playerController.SetEnemy(enemyGO.GetComponent <EnemyController>()); playerGO.GetComponent <CombatEffects>().SetTarget(enemyGO); bool isStartingSetup = (battleCounter == 0); if (isStartingSetup) { foreach (Transform item in playerAtkButtons.transform) { atkButtons.Add(item.GetComponent <AtkIconScript>()); item.gameObject.SetActive(false); item.GetComponent <Button>().onClick.AddListener(() => { AtkSkillUsed(item); }); } } // Activate battle coTutorial = StartCoroutine(BeginBattle(isStartingSetup)); }
private int FindEmptySlot(EquipLocation equip) { int equipSlots = equippedItems[equip].Length; for (int i = 0; i < equipSlots; i++) { if (equippedItems[equip][i] == null) { return(i); } } return(-1); }
/// <summary> /// Attempts to add item to the request equipment slot /// </summary> /// <param name="item"></param> /// <param name="location"></param> public void AddItem(EquipableItem item, EquipLocation location) { //Check if the item can go into the requested slot Debug.Assert(item.GetAllowedEquipLocation() == location); //Equip the item m_EquippedItems[location] = item; if (equipmentUpdated != null) { equipmentUpdated(); } }
public MeleeWeaponTemplate(int id, string name, EquipLocation location, BaseSkill skill, float accuracy, float armorMultiplier, float penetrationMultiplier, float requiredStrength, float strengthMultiplier, float extraDamage, float parryMod, float extraAttacks) : base(id, name, location, skill, accuracy, armorMultiplier, penetrationMultiplier, requiredStrength) { StrengthMultiplier = strengthMultiplier; ExtraDamage = extraDamage; ParryModifier = parryMod; ExtraAttacks = extraAttacks; }
public EquipableItem GetRandomEquipableItem(EquipLocation location) { var itemTypeValues = new List <ItemType>(); foreach (var itemType in _itemTypes.Values) { if (itemType.Slot == location) { itemTypeValues.Add(itemType); } } return((EquipableItem)itemTypeValues[Random.Range(0, itemTypeValues.Count)].NewItem()); }
/// <summary> /// Add an item to the given equip location. Do not attempt to equip to /// an incompatible slot. /// </summary> public void AddItem(EquipLocation slot, EquipableItem item) { if (_equippedItems == null || !_equippedItems.ContainsKey(slot)) { return; } Debug.Assert(item.GetAllowedEquipLocation() == slot); _equippedItems[slot] = item; var eventMediator = Object.FindObjectOfType <EventMediator>(); eventMediator.Broadcast(GlobalHelper.EquipmentUpdated, this); }
public int GetIndexOfType(EquipLocation location) { int index = -1; //Find the index of the EquipLocation passed in for (int i = 0; i < _equippedItems.Count; i++) { if (_equippedItems[location]) { index = 1; } } return(index); }
private static Rectangle _getEquipLocRectangle(EquipLocation loc) { Rectangle itemArea; switch (loc) { case EquipLocation.Boots: itemArea = new Rectangle(87, 220, 56, 54); break; case EquipLocation.Accessory: itemArea = new Rectangle(55, 250, 23, 23); break; case EquipLocation.Gloves: itemArea = new Rectangle(22, 188, 56, 54); break; case EquipLocation.Belt: itemArea = new Rectangle(87, 188, 56, 23); break; case EquipLocation.Armor: itemArea = new Rectangle(86, 82, 56, 98); break; case EquipLocation.Necklace: itemArea = new Rectangle(152, 51, 56, 23); break; case EquipLocation.Hat: itemArea = new Rectangle(87, 21, 56, 54); break; case EquipLocation.Shield: itemArea = new Rectangle(152, 82, 56, 98); break; case EquipLocation.Weapon: itemArea = new Rectangle(22, 82, 56, 98); break; case EquipLocation.Ring1: itemArea = new Rectangle(152, 190, 23, 23); break; case EquipLocation.Ring2: itemArea = new Rectangle(185, 190, 23, 23); break; case EquipLocation.Armlet1: itemArea = new Rectangle(152, 220, 23, 23); break; case EquipLocation.Armlet2: itemArea = new Rectangle(185, 220, 23, 23); break; case EquipLocation.Bracer1: itemArea = new Rectangle(152, 250, 23, 23); break; case EquipLocation.Bracer2: itemArea = new Rectangle(185, 250, 23, 23); break; default: throw new ArgumentOutOfRangeException("loc", "That is not a valid equipment location"); } return itemArea; }
public void SetItem(EquipLocation loc, ItemRecord info) { PaperdollDialogItem itemToUpdate = (PaperdollDialogItem)children.Find(_ctrl => { PaperdollDialogItem item = _ctrl as PaperdollDialogItem; if (item == null) return false; return item.EquipLoc == loc; }); if (itemToUpdate != null) itemToUpdate.SetInfo(_getEquipLocRectangle(loc), info); }