public override void OnEquip(vItem item)
        {
            if (meleeWeapon)
            {
                var damage       = item.GetItemAttribute(vItemAttributes.Damage);
                var staminaCost  = item.GetItemAttribute(vItemAttributes.StaminaCost);
                var defenseRate  = item.GetItemAttribute(vItemAttributes.DefenseRate);
                var defenseRange = item.GetItemAttribute(vItemAttributes.DefenseRange);
                if (damage != null)
                {
                    this.meleeWeapon.damage.damageValue = damage.value;
                }
                if (staminaCost != null)
                {
                    this.meleeWeapon.staminaCost = staminaCost.value;
                }
                if (defenseRate != null)
                {
                    this.meleeWeapon.defenseRate = defenseRate.value;
                }
                if (defenseRange != null)
                {
                    this.meleeWeapon.defenseRange = defenseRate.value;
                }
            }

            base.OnEquip(item);
        }
        public void OnEquip(vItem item)
        {
            referenceItem = item;
            isEquiped     = true;
            if (!weapon)
            {
                return;
            }

            var damage       = item.GetItemAttribute(vItemAttributes.Damage);
            var staminaCost  = item.GetItemAttribute(vItemAttributes.StaminaCost);
            var defenseRate  = item.GetItemAttribute(vItemAttributes.DefenseRate);
            var defenseRange = item.GetItemAttribute(vItemAttributes.DefenseRange);

            if (damage != null)
            {
                this.weapon.damage.damageValue = damage.value;
            }
            if (staminaCost != null)
            {
                this.weapon.staminaCost = staminaCost.value;
            }
            if (defenseRate != null)
            {
                this.weapon.defenseRate = defenseRate.value;
            }
            if (defenseRange != null)
            {
                this.weapon.defenseRange = defenseRate.value;
            }
        }
Example #3
0
        private bool CheckAmmo(ref bool isValid, ref int totalAmmo)
        {
            if (!item)
            {
                return(false);
            }
            var damageAttribute = item.GetItemAttribute(weapon.isSecundaryWeapon ? vItemAttributes.SecundaryAmmoCount : vItemAttributes.AmmoCount);

            isValid = damageAttribute != null && !damageAttribute.isBool;
            if (isValid)
            {
                totalAmmo = damageAttribute.value;
            }
            return(isValid && damageAttribute.value > 0);
        }
Example #4
0
        public override void OnEquip(vItem item)
        {
            if (!shooterWeapon)
            {
                return;
            }
            base.OnEquip(item);
            shooterWeapon.changeAmmoHandle = new vShooterWeapon.ChangeAmmoHandle(ChangeAmmo);
            shooterWeapon.checkAmmoHandle  = new vShooterWeapon.CheckAmmoHandle(CheckAmmo);
            var damageAttribute = item.GetItemAttribute(shooterWeapon.isSecundaryWeapon ? vItemAttributes.SecundaryDamage : vItemAttributes.Damage);

            if (damageAttribute != null)
            {
                shooterWeapon.maxDamage = damageAttribute.value;
            }

            if (shooterWeapon.secundaryWeapon)
            {
                var _equipments = shooterWeapon.secundaryWeapon.GetComponents <vEquipment>();
                for (int i = 0; i < _equipments.Length; i++)
                {
                    if (_equipments[i] != null)
                    {
                        _equipments[i].OnEquip(item);
                    }
                }
            }
        }
Example #5
0
        public void OnEquip(vItem item)
        {
            if (!weapon)
            {
                return;
            }
            this.referenceItem      = item;
            isEquiped               = true;
            weapon.changeAmmoHandle = new vShooterWeapon.ChangeAmmoHandle(ChangeAmmo);
            weapon.checkAmmoHandle  = new vShooterWeapon.CheckAmmoHandle(CheckAmmo);
            var damageAttribute = item.GetItemAttribute(weapon.isSecundaryWeapon ? vItemAttributes.SecundaryDamage : vItemAttributes.Damage);

            if (damageAttribute != null)
            {
                weapon.maxDamage = damageAttribute.value;
            }
            if (weapon.secundaryWeapon)
            {
                var _equipments = weapon.secundaryWeapon.GetComponents <vIEquipment>();
                for (int i = 0; i < _equipments.Length; i++)
                {
                    if (_equipments[i] != null)
                    {
                        _equipments[i].OnEquip(item);
                    }
                }
            }
        }
        /// <summary>
        /// Use with ItemManager
        /// </summary>
        /// <param name="item"></param>
        public void AddAmmo(vItem item)
        {
            if (item.type == vItemType.Ammo)
            {
                var ammo = ammos.Find(a => a.ammoID == item.id);
                if (ammo == null)
                {
                    ammo = new vAmmo(item.name, item.id, 0);
                    ammos.Add(ammo);
                    ammo.onDestroyAmmoItem = new vAmmo.OnDestroyItem(OnDestroyAmmoItem);
                }

                ammo.ammoItems.Add(item);
            }
            else
            {
                var primaryAmmo   = item.GetItemAttribute(vItemAttributes.AmmoCount);
                var secundaryAmmo = item.GetItemAttribute(vItemAttributes.SecundaryAmmoCount);
                if (primaryAmmo != null || secundaryAmmo != null)
                {
                    var weaponReference = item.originalObject.GetComponent <vShooter.vShooterWeapon>();
                    if (weaponReference != null)
                    {
                        if (primaryAmmo != null && primaryAmmo.value > weaponReference.clipSize)
                        {
                            var extraAmmo = primaryAmmo.value - weaponReference.clipSize;
                            primaryAmmo.value -= extraAmmo;
                            ItemReference newAmmoItem = new ItemReference(weaponReference.ammoID);
                            newAmmoItem.amount = extraAmmo;
                            itemManager.AddItem(newAmmoItem, true);
                        }
                        if (secundaryAmmo != null && weaponReference.secundaryWeapon != null && secundaryAmmo.value > weaponReference.secundaryWeapon.clipSize)
                        {
                            var extraAmmo = secundaryAmmo.value - weaponReference.secundaryWeapon.clipSize;
                            secundaryAmmo.value -= extraAmmo;
                            ItemReference newAmmoItem = new ItemReference(weaponReference.secundaryWeapon.ammoID);
                            newAmmoItem.amount = extraAmmo;
                            itemManager.AddItem(newAmmoItem, true);
                        }
                    }
                }
            }
            UpdateTotalAmmo();
        }
Example #7
0
        private void CanUseItem(vItem item, ref List <bool> validateResult)
        {
            if (item.GetItemAttribute(vItemAttributes.Health) != null)
            {
                var valid = tpController.currentHealth < tpController.maxHealth;
                if (valid != canUse || !firstRun)
                {
                    canUse   = valid;
                    firstRun = true;
                    vHUDController.instance.ShowText(valid ? "Increase health" : "Can't use " + item.name + " because your health is full", 4f);
                }

                if (!valid)
                {
                    validateResult.Add(valid);
                }
            }
        }
Example #8
0
        public override void OnEquip(vItem item)
        {
            if (shooterWeapon)
            {
                shooterWeapon.changeAmmoHandle = new vShooterWeapon.ChangeAmmoHandle(ChangeAmmo);
                shooterWeapon.checkAmmoHandle  = new vShooterWeapon.CheckAmmoHandle(CheckAmmo);
                var damageAttribute = item.GetItemAttribute(shooterWeapon.isSecundaryWeapon ? vItemAttributes.SecundaryDamage : vItemAttributes.Damage);

                if (damageAttribute != null)
                {
                    shooterWeapon.maxDamage = damageAttribute.value;
                }

                if (secundaryEquipment)
                {
                    secundaryEquipment.OnEquip(item);
                }
            }
            base.OnEquip(item);
        }
Example #9
0
        private void CanUseItem(vItem item, ref List <bool> validateResult)
        {
            // search for the attribute 'Health'
            if (item.GetItemAttribute(vItemAttributes.Health) != null)
            {
                // the variable valid will identify if the currentHealth is lower than the maxHealth, allowing to use the item
                var valid = tpController.currentHealth < tpController.maxHealth;
                if (valid != canUse || !firstRun)
                {
                    canUse   = valid;
                    firstRun = true;
                    // trigger a custom text if there is a HUDController in the scene
                    vHUDController.instance.ShowText(valid ? "Increase health" : "Can't use " + item.name + " because your health is full", 4f);
                }

                if (!valid)
                {
                    validateResult.Add(valid);
                }
            }
        }