示例#1
0
        /// <summary>
        /// Generates the item.
        /// </summary>
        /// <returns>The item.</returns>
        public Item GenerateItem()
        {
            Item generatedItem = null;

            // 如果拼写物品是装备
            if (spellItemType == SpellItemType.Equipment)
            {
                // 获取装备类型
                EquipmentType equipmentType = (EquipmentType)attachInfo_1;

                // 根据玩家探索到的关卡确定装备等级
                int equipmentGrade = (Player.mainPlayer.maxUnlockLevelIndex - 1) / 5 + 1;

                // 没有10级的装备,最后开出来的都是9级装备
                if (equipmentGrade == 10)
                {
                    equipmentGrade = 9;
                }

                EquipmentModel equipmentModel = GameManager.Instance.gameDataCenter.allEquipmentModels.Find(delegate(EquipmentModel obj)
                {
                    if (equipmentType == EquipmentType.Weapon)
                    {
                        return(obj.equipmentGrade == equipmentGrade &&
                               obj.equipmentType == equipmentType &&
                               obj.weaponType == (WeaponType)attachInfo_2);
                    }
                    else
                    {
                        return(obj.equipmentGrade == equipmentGrade &&
                               obj.equipmentType == equipmentType);
                    }
                });

                generatedItem = Item.NewItemWith(equipmentModel.itemId, 1);

                (generatedItem as Equipment).SetToGoldQuality();
            }
            else
            {
                generatedItem = Item.NewItemWith(attachInfo_1, 1);
            }


            return(generatedItem);
        }
示例#2
0
        /// <summary>
        /// 获取所有游戏物品中的武器类物品
        /// </summary>
        public static List <Equipment> GetAllEquipments()
        {
            List <EquipmentModel> allItemModels = GameManager.Instance.gameDataCenter.allEquipmentModels;

            List <Equipment> allEquipment = new List <Equipment> ();

            for (int i = 0; i < allItemModels.Count; i++)
            {
                EquipmentModel itemModel = allItemModels [i];

                if (itemModel.itemType == ItemType.Equipment)
                {
                    Equipment equipment = new Equipment(itemModel, 1);
                    allEquipment.Add(equipment);
                }
            }
            return(allEquipment);
        }
示例#3
0
            public void LoadAllItemsWithFullDataString(string fullItemDataString)
            {
                string[] seperateItemDataArray = fullItemDataString.Split(new string[] { "\n" }, StringSplitOptions.None);


                for (int i = 2; i < seperateItemDataArray.Length; i++)
                {
                    string equipmentDataString = seperateItemDataArray [i].Replace("\r", "");

                    string[] equipmentDataArray = equipmentDataString.Split(new char[] { ',' }, StringSplitOptions.None);

                    int dataLength = equipmentDataArray.Length;


                    EquipmentModel em = new EquipmentModel();

                    newItemModels.Add(em);

                    em.itemId = FromStringToInt16(equipmentDataArray [0]);

                    em.itemName = equipmentDataArray [1];

                    em.itemType = ItemType.Equipment;

                    em.equipmentType = (EquipmentType)(FromStringToInt16(equipmentDataArray [2]));

                    em.spriteName = equipmentDataArray [4];

                    em.equipmentGrade = FromStringToInt16(equipmentDataArray [6]);

                    em.price = FromStringToInt16(equipmentDataArray [7]);

                    em.defaultQuality = (EquipmentDefaultQuality)FromStringToInt16(equipmentDataArray [8]);

                    if (!IsSpecialProperty(equipmentDataArray [9]))
                    {
                        em.maxHealthGain = FromStringToInt16(equipmentDataArray [9]);
                    }
                    else
                    {
                        int maxHealthGain = FromStringToInt16(equipmentDataArray [9].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.MaxHealth, maxHealthGain));
                    }
                    if (!IsSpecialProperty(equipmentDataArray [10]))
                    {
                        em.maxManaGain = FromStringToInt16(equipmentDataArray [10]);
                    }
                    else
                    {
                        int maxManaGain = FromStringToInt16(equipmentDataArray [10].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.MaxMana, maxManaGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [11]))
                    {
                        em.attackGain = FromStringToInt16(equipmentDataArray [11]);
                    }
                    else
                    {
                        int attackGain = FromStringToInt16(equipmentDataArray [11].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.Attack, attackGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [12]))
                    {
                        em.magicAttackGain = FromStringToInt16(equipmentDataArray [12]);
                    }
                    else
                    {
                        int magicAttackGain = FromStringToInt16(equipmentDataArray [12].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.MagicAttack, magicAttackGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [13]))
                    {
                        em.armorGain = FromStringToInt16(equipmentDataArray [13]);
                    }
                    else
                    {
                        int armorGain = FromStringToInt16(equipmentDataArray [13].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.Armor, armorGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [14]))
                    {
                        em.magicResistGain = FromStringToInt16(equipmentDataArray [14]);
                    }
                    else
                    {
                        int magicResistGain = FromStringToInt16(equipmentDataArray [14].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.MagicResist, magicResistGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [15]))
                    {
                        em.armorDecreaseGain = FromStringToInt16(equipmentDataArray [15]);
                    }
                    else
                    {
                        int armorDecreaseGain = FromStringToInt16(equipmentDataArray [15].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.ArmorDecrease, armorDecreaseGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [16]))
                    {
                        em.magicResistDecreaseGain = FromStringToInt16(equipmentDataArray [16]);
                    }
                    else
                    {
                        int magicResistDecreaseGain = FromStringToInt16(equipmentDataArray [16].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.MagicResistDecrease, magicResistDecreaseGain));
                    }


                    em.attackSpeed = FromStringToAttackSpeed(equipmentDataArray [17]);


                    if (!IsSpecialProperty(equipmentDataArray [18]))
                    {
                        em.moveSpeedGain = FromStringToInt16(equipmentDataArray [18]);
                    }
                    else
                    {
                        int moveSpeedGain = FromStringToInt16(equipmentDataArray [18].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.MoveSpeed, moveSpeedGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [19]))
                    {
                        em.critGain = FromStringToSingle(equipmentDataArray [19]);
                    }
                    else
                    {
                        float critGain = FromStringToSingle(equipmentDataArray [19].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.Crit, critGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [20]))
                    {
                        em.dodgeGain = FromStringToSingle(equipmentDataArray [20]);
                    }
                    else
                    {
                        float dodgeGain = FromStringToSingle(equipmentDataArray [20].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.Dodge, dodgeGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [21]))
                    {
                        em.critHurtScalerGain = FromStringToSingle(equipmentDataArray [21]);
                    }
                    else
                    {
                        float critHurtScalerGain = FromStringToSingle(equipmentDataArray [21].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.CritHurtScaler, critHurtScalerGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [24]))
                    {
                        em.extraGoldGain = FromStringToInt16(equipmentDataArray [24]);
                    }
                    else
                    {
                        int extraGoldGain = FromStringToInt16(equipmentDataArray [24].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.ExtraGold, extraGoldGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [25]))
                    {
                        em.extraExperienceGain = FromStringToInt16(equipmentDataArray [25]);
                    }
                    else
                    {
                        int extraExperienceGain = FromStringToInt16(equipmentDataArray [25].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.ExtraExperience, extraExperienceGain));
                    }

                    if (!IsSpecialProperty(equipmentDataArray [26]))
                    {
                        em.healthRecoveryGain = FromStringToInt16(equipmentDataArray [26]);
                    }
                    else
                    {
                        int healthRecoveryGain = FromStringToInt16(equipmentDataArray [26].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.HealthRecovery, healthRecoveryGain));
                    }
                    if (!IsSpecialProperty(equipmentDataArray [27]))
                    {
                        em.magicRecoveryGain = FromStringToInt16(equipmentDataArray [27]);
                    }
                    else
                    {
                        int magicRecoveryGain = FromStringToInt16(equipmentDataArray [27].Remove(0, 1));
                        em.specProperties.Add(new PropertySet(PropertyType.MagicRecovery, magicRecoveryGain));
                    }

                    em.weaponType = (WeaponType)FromStringToInt16(equipmentDataArray [28]);
                }
            }
示例#4
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public Equipment(EquipmentModel equipmentModel, int itemCount)
        {
            this.itemType  = ItemType.Equipment;
            this.itemCount = itemCount;

            // 初始化物品基本属性
            InitBaseProperties(equipmentModel);

            // 初始化装备属性(默认初始化为灰色装备)
            this.oriMaxHealthGain = equipmentModel.maxHealthGain;
            this.oriMaxManaGain   = equipmentModel.maxManaGain;

            this.oriAttackGain      = equipmentModel.attackGain;
            this.oriMagicAttackGain = equipmentModel.magicAttackGain;

            this.oriArmorGain               = equipmentModel.armorGain;
            this.oriMagicResistGain         = equipmentModel.magicResistGain;
            this.oriArmorDecreaseGain       = equipmentModel.armorDecreaseGain;
            this.oriMagicResistDecreaseGain = equipmentModel.magicResistDecreaseGain;

            this.attackSpeed      = (AttackSpeed)equipmentModel.attackSpeed;
            this.oriMoveSpeedGain = equipmentModel.moveSpeedGain;

            this.oriCritGain  = equipmentModel.critGain;
            this.oriDodgeGain = equipmentModel.dodgeGain;

            this.oriCritHurtScalerGain     = equipmentModel.critHurtScalerGain;
            this.oriPhysicalHurtScalerGain = equipmentModel.physicalHurtScalerGain;
            this.oriMagicalHurtScalerGain  = equipmentModel.magicalHurtScalerGain;

            this.oriExtraGoldGain       = equipmentModel.extraGoldGain;
            this.oriExtraExperienceGain = equipmentModel.extraExperienceGain;

            this.oriHealthRecoveryGain = equipmentModel.healthRecoveryGain;
            this.oriMagicRecoveryGain  = equipmentModel.magicRecoveryGain;

            // 基础价格
            this.oriPrice = equipmentModel.price;
            // 实际价格【根据品质会在基础价格上有一定浮动】
            this.price = equipmentModel.price;
            // 默认品质【初始化生成时默认的品质】
            this.defaultQuality = equipmentModel.defaultQuality;

            // 装备类型
            this.equipmentType = (EquipmentType)(equipmentModel.equipmentType);
            // 装备等级
            this.equipmentGrade = equipmentModel.equipmentGrade;
            // 附加属性集
            this.specProperties = equipmentModel.specProperties;

            // 按照默认属性初始化装备
            switch (defaultQuality)
            {
            case EquipmentDefaultQuality.Random:
                RebuildEquipment();
                break;

            case EquipmentDefaultQuality.Gold:
                quality = EquipmentQuality.Gold;
                ResetPropertiesByQuality(quality);
                break;

            case EquipmentDefaultQuality.Purple:
                quality = EquipmentQuality.Purple;
                ResetPropertiesByQuality(quality);
                break;

            case EquipmentDefaultQuality.Gray:
                quality = EquipmentQuality.Gray;
                ResetPropertiesByQuality(quality);
                break;
            }

            // 武器类型【该数据仅对于武器有用】
            this.weaponType = equipmentModel.weaponType;
            // 镶嵌的宝石集合
            attachedPropertyGemstones = new List <PropertyGemstone>();
            // 初始化装备描述【属性转化为实际描述】
            InitDescription();
        }
示例#5
0
        /// <summary>
        /// 通过物品id和数量初始化物品
        /// 【0-299】装备
        /// 【300-399】消耗品
        /// 【400-499】属性宝石
        /// 【500-599】技能卷轴
        /// 【600-699】特殊物品
        /// </summary>
        public static Item NewItemWith(int itemId, int itemCount)
        {
            Item newItem = null;

            // 逻辑上相同:寻找数据模型->使用数据模型创建新物品

            if (itemId < 300)
            {
                EquipmentModel equipmentModel = GameManager.Instance.gameDataCenter.allEquipmentModels.Find(delegate(EquipmentModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (equipmentModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new Equipment(equipmentModel, itemCount);
            }
            else if (itemId >= 300 && itemId < 400)
            {
                ConsumablesModel cm = GameManager.Instance.gameDataCenter.allConsumablesModels.Find(delegate(ConsumablesModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (cm == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new Consumables(cm, itemCount);
            }
            else if (itemId >= 400 && itemId < 500)
            {
                PropertyGemstoneModel propertyGemstoneModel = GameManager.Instance.gameDataCenter.allPropertyGemstoneModels.Find(delegate(PropertyGemstoneModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (propertyGemstoneModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new PropertyGemstone(propertyGemstoneModel, itemCount);
            }
            else if (itemId >= 500 && itemId < 600)
            {
                SkillScrollModel skillScrollModel = GameManager.Instance.gameDataCenter.allSkillScrollModels.Find(delegate(SkillScrollModel obj)
                {
                    return(obj.itemId == itemId);
                });

                if (skillScrollModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }

                newItem = new SkillScroll(skillScrollModel, itemCount);
            }
            else if (itemId >= 600 && itemId < 700)
            {
                SpecialItemModel specialItemModel = GameManager.Instance.gameDataCenter.allSpecialItemModels.Find(delegate(SpecialItemModel obj)
                {
                    return(obj.itemId == itemId);
                });
                if (specialItemModel == null)
                {
                    string error = string.Format("未找到id为{0}的物品", itemId);
                    Debug.LogError(error);
                }
                newItem = new SpecialItem(specialItemModel, itemCount);
            }

            return(newItem);
        }