Esempio n. 1
0
            public void LoadAllItemsWithFullDataString(string fullItemDataString)
            {
                string[] seperateItemDataArray = fullItemDataString.Split(new string[] { "\n" }, StringSplitOptions.None);


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

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

                    int dataLength = skillScrollDataArray.Length;

                    SkillScrollModel skillScrollModel = new SkillScrollModel();

                    skillScrollModels.Add(skillScrollModel);

                    skillScrollModel.itemId = FromStringToInt16(skillScrollDataArray[0]);

                    skillScrollModel.itemName = skillScrollDataArray[1];

                    skillScrollModel.spriteName = skillScrollDataArray[4];

                    skillScrollModel.itemDescription = skillScrollDataArray[5].Replace('+', ',');

                    skillScrollModel.price = FromStringToInt32(skillScrollDataArray[6]);

                    skillScrollModel.skillId = FromStringToInt16(skillScrollDataArray[7]);
                }
            }
Esempio n. 2
0
        /// <summary>
        /// 技能卷轴构造函数
        /// </summary>
        /// <param name="skillScrollModel">Skill scroll model.</param>
        /// <param name="itemCount">Item count.</param>
        public SkillScroll(SkillScrollModel skillScrollModel, int itemCount)
        {
            InitBaseProperties(skillScrollModel);

            this.itemType = ItemType.SkillScroll;

            this.itemCount = itemCount;

            this.skillId = skillScrollModel.skillId;
        }
Esempio n. 3
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);
        }