Ejemplo n.º 1
0
        public virtual Item GetEquip(GameObject target, int itemType)
        {
            CharacterEquipment equipment = this.RequireEquipment(target);
            int uuid = equipment.GetEquip(itemType);

            if (uuid != 0)
            {
                return(this.itemsCatalogue[uuid]);
            }
            return(null);
        }
Ejemplo n.º 2
0
        // EQUIPMENT: -----------------------------------------------------------------------------

        public virtual bool CanEquipItem(GameObject target, int uuid, int itemType)
        {
            CharacterEquipment equipment = this.RequireEquipment(target);

            return(
                equipment.CanEquip(uuid) &&
                this.itemsCatalogue[uuid].equipable &&
                (this.itemsCatalogue[uuid].itemTypes & (1 << itemType)) > 0 &&
                this.itemsCatalogue[uuid].conditionsEquip.Check(target)
                );
        }
        // INITIALIZERS: --------------------------------------------------------------------------

        private void OnEnable()
        {
            if (target == null || serializedObject == null)
            {
                return;
            }
            if (DATABASE_INVENTORY == null)
            {
                DATABASE_INVENTORY = DatabaseInventory.Load();
            }
            this.equipment = (CharacterEquipment)this.target;
        }
Ejemplo n.º 4
0
        public virtual bool Unequip(GameObject target, int uuid)
        {
            CharacterEquipment equipment = this.RequireEquipment(target);

            if (equipment.UnequipItem(uuid))
            {
                if (this.eventOnUnequip != null)
                {
                    this.eventOnUnequip.Invoke(target, uuid);
                }
                if (this.eventChangePlayerInventory != null)
                {
                    this.eventChangePlayerInventory.Invoke();
                }
                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public virtual bool UnequipTypes(GameObject target, int itemTypes)
        {
            CharacterEquipment equipment = this.RequireEquipment(target);

            int[] unequipped = equipment.UnequipTypes(itemTypes);

            for (int i = 0; i < unequipped.Length; ++i)
            {
                if (this.eventOnUnequip != null)
                {
                    this.eventOnUnequip.Invoke(target, unequipped[i]);
                }
                if (this.eventChangePlayerInventory != null)
                {
                    this.eventChangePlayerInventory.Invoke();
                }
            }

            return(unequipped.Length > 0);
        }
        public bool Equip(GameObject target, int uuid, int itemType)
        {
            if (this.CanEquipItem(target, uuid, itemType))
            {
                CharacterEquipment equipment = this.RequireEquipment(target);
                if (equipment.CanEquip(uuid) && equipment.EquipItem(uuid, itemType))
                {
                    if (this.eventOnEquip != null)
                    {
                        this.eventOnEquip.Invoke(target, uuid);
                    }
                    if (this.eventChangePlayerInventory != null)
                    {
                        this.eventChangePlayerInventory.Invoke();
                    }
                    return(true);
                }

                return(false);
            }

            return(false);
        }
Ejemplo n.º 7
0
        protected virtual CharacterEquipment RequireEquipment(GameObject target)
        {
            if (target == null)
            {
                return(null);
            }
            CharacterEquipment equipment = target.GetComponent <CharacterEquipment>();

            if (equipment == null)
            {
                if (HookPlayer.Instance != null && target == HookPlayer.Instance.gameObject)
                {
                    equipment = target.AddComponent <PlayerEquipment>();
                    Debug.LogWarning(WARN_PLYR + " " + WARN_SOLT, target);
                }
                else
                {
                    equipment = target.AddComponent <CharacterEquipment>();
                    Debug.LogWarning(WARN_CHAR + " " + WARN_SOLT, target);
                }
            }

            return(equipment);
        }
Ejemplo n.º 8
0
        public virtual bool HasEquipedTypes(GameObject target, int itemTypes)
        {
            CharacterEquipment equipment = this.RequireEquipment(target);

            return(equipment != null && equipment.HasEquipTypes(itemTypes));
        }
Ejemplo n.º 9
0
        public virtual int HasEquiped(GameObject target, int uuid)
        {
            CharacterEquipment equipment = this.RequireEquipment(target);

            return(equipment != null ? equipment.HasEquip(uuid) : 0);
        }