Пример #1
0
    //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;
    }
Пример #2
0
        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;
 }
Пример #4
0
        // 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;
		}
Пример #6
0
        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);
            }
        }
Пример #7
0
        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;
        }
Пример #8
0
        // 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);
        }
Пример #9
0
 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();
     }
 }
Пример #11
0
        /// <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
        }
Пример #12
0
 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; }
 }
Пример #13
0
        /// <summary>
        /// Remove the item for the given slot.
        /// </summary>
        public void RemoveItem(EquipLocation slot)
        {
            if (!_equippedItems.ContainsKey(slot))
            {
                return;
            }

            _equippedItems[slot] = null;
        }
Пример #14
0
        public void AddItem(EquipLocation slot, EquipableItem item)
        {
            //Add the item to a slot
            Debug.Assert(item.GetAllowedEquipLocation() == slot);

            _equippedItems[slot] = item;

            EquipmentUpdated?.Invoke();
        }
Пример #15
0
        // 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]);
        }
Пример #17
0
        /// <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]);
        }
Пример #18
0
        public EquipableItem GetItemInSlot(EquipLocation equipLocation)
        {
            //Check if we have the EquipLocation
            if (!_equippedItems.ContainsKey(equipLocation))
            {
                return(null);
            }

            return(_equippedItems[equipLocation]);
        }
Пример #19
0
 public void SetAllowedEquipLocation(EquipLocation newLocation)
 {
     if (allowedEquipLocation == newLocation)
     {
         return;
     }
     SetUndo("Change Equip Location");
     allowedEquipLocation = newLocation;
     Dirty();
 }
Пример #20
0
        ///////////////////////////// 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]);
        }
Пример #21
0
        /// <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();
            }
        }
Пример #22
0
        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);
        }
Пример #23
0
 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;
 }
Пример #24
0
        /// <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));
        }
Пример #26
0
        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);
        }
Пример #27
0
        /// <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();
            }
        }
Пример #28
0
 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;
 }
Пример #29
0
        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());
        }
Пример #30
0
        /// <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);
        }
Пример #31
0
        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);
        }
Пример #32
0
		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;
		}
Пример #33
0
		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);
		}