Example #1
0
        public override float GetEquipmentBonusRate(CharacterItem characterItem)
        {
            if (characterItem.GetMaxDurability() <= 0)
            {
                return(1);
            }
            var durabilityRate = (float)characterItem.durability / (float)characterItem.GetMaxDurability();

            if (durabilityRate > 0.5f)
            {
                return(1f);
            }
            else if (durabilityRate > 0.3f)
            {
                return(0.75f);
            }
            else if (durabilityRate > 0.15f)
            {
                return(0.5f);
            }
            else if (durabilityRate > 0.05f)
            {
                return(0.25f);
            }
            else
            {
                return(0f);
            }
        }
        private void DecreaseEquipShieldsDurability(BaseCharacterEntity entity, float decreaseDurability)
        {
            bool          tempDestroy  = false;
            EquipWeapons  equipWeapons = entity.EquipWeapons;
            CharacterItem rightHand    = equipWeapons.rightHand;
            CharacterItem leftHand     = equipWeapons.leftHand;

            if (rightHand.GetShieldItem() != null && rightHand.GetMaxDurability() > 0)
            {
                rightHand = DecreaseDurability(rightHand, decreaseDurability, out tempDestroy);
                if (tempDestroy)
                {
                    equipWeapons.rightHand = CharacterItem.Empty;
                }
                else
                {
                    equipWeapons.rightHand = rightHand;
                }
            }
            if (leftHand.GetShieldItem() != null && leftHand.GetMaxDurability() > 0)
            {
                leftHand = DecreaseDurability(leftHand, decreaseDurability, out tempDestroy);
                if (tempDestroy)
                {
                    equipWeapons.leftHand = CharacterItem.Empty;
                }
                else
                {
                    equipWeapons.leftHand = leftHand;
                }
            }
            entity.EquipWeapons = equipWeapons;
        }
        private void DecreaseEquipItemsDurability(BaseCharacterEntity entity, float decreaseDurability)
        {
            bool tempDestroy = false;
            int  count       = entity.EquipItems.Count;

            for (int i = count - 1; i >= 0; --i)
            {
                CharacterItem equipItem = entity.EquipItems[i];
                if (equipItem.GetMaxDurability() <= 0)
                {
                    continue;
                }
                equipItem = DecreaseDurability(equipItem, decreaseDurability, out tempDestroy);
                if (tempDestroy)
                {
                    entity.EquipItems.RemoveAt(i);
                }
                else
                {
                    entity.EquipItems[i] = equipItem;
                }
            }
        }