/// <summary> /// 属性宝石构造函数 /// </summary> /// <param name="pgModel">Pg model.</param> /// <param name="itemCount">Item count.</param> public PropertyGemstone(PropertyGemstoneModel pgModel, int itemCount) { InitBaseProperties(pgModel); this.itemType = ItemType.PropertyGemstone; this.itemCount = itemCount; this.maxHealthGainBase = pgModel.maxHealthGainBase; this.maxManaGainBase = pgModel.maxManaGainBase; this.attackGainBase = pgModel.attackGainBase; this.magicAttackGainBase = pgModel.magicAttackGainBase; this.armorGainBase = pgModel.armorGainBase; this.magicResistGainBase = pgModel.magicResistGainBase; this.armorDecreaseGainBase = pgModel.armorDecreaseGainBase; this.magicResistDecreaseGainBase = pgModel.magicResistDecreaseGainBase; this.moveSpeedGainBase = pgModel.moveSpeedGainBase; this.critGainBase = pgModel.critGainBase; this.dodgeGainBase = pgModel.dodgeGainBase; this.critHurtScalerGainBase = pgModel.critHurtScalerGainBase; this.physicalHurtScalerGainBase = pgModel.physicalHurtScalerGainBase; this.magicalHurtScalerGainBase = pgModel.magicalHurtScalerGainBase; this.extraGoldGainBase = pgModel.extraGoldGainBase; this.extraExperienceGainBase = pgModel.extraExperienceGainBase; this.healthRecoveryGainBase = pgModel.healthRecoveryGainBase; this.magicRecoveryGainBase = pgModel.magicRecoveryGainBase; this.grade = pgModel.grade; }
public void LoadAllItemsWithFullDataString(string fullItemDataString) { string[] seperateItemDataArray = fullItemDataString.Split(new string[] { "\n" }, StringSplitOptions.None); for (int i = 2; i < seperateItemDataArray.Length; i++) { string propertyGemstoneDataString = seperateItemDataArray[i].Replace("\r", ""); string[] consumablesDataArray = propertyGemstoneDataString.Split(new char[] { ',' }, StringSplitOptions.None); int dataLength = consumablesDataArray.Length; PropertyGemstoneModel propertyGemstoneModel = new PropertyGemstoneModel(); propertyGemstoneModels.Add(propertyGemstoneModel); propertyGemstoneModel.itemId = FromStringToInt16(consumablesDataArray[0]); propertyGemstoneModel.itemName = consumablesDataArray[1]; propertyGemstoneModel.spriteName = consumablesDataArray[3]; propertyGemstoneModel.itemDescription = consumablesDataArray[4]; propertyGemstoneModel.price = FromStringToInt32(consumablesDataArray[5]); propertyGemstoneModel.maxHealthGainBase = FromStringToInt16(consumablesDataArray[6]); propertyGemstoneModel.maxManaGainBase = FromStringToInt16(consumablesDataArray[7]); propertyGemstoneModel.attackGainBase = FromStringToInt16(consumablesDataArray[8]); propertyGemstoneModel.magicAttackGainBase = FromStringToInt16(consumablesDataArray[9]); propertyGemstoneModel.armorGainBase = FromStringToInt16(consumablesDataArray[10]); propertyGemstoneModel.magicResistGainBase = FromStringToInt16(consumablesDataArray[11]); propertyGemstoneModel.armorDecreaseGainBase = FromStringToInt16(consumablesDataArray[12]); propertyGemstoneModel.magicResistDecreaseGainBase = FromStringToInt16(consumablesDataArray[13]); propertyGemstoneModel.moveSpeedGainBase = FromStringToInt16(consumablesDataArray[14]); propertyGemstoneModel.critGainBase = FromStringToInt16(consumablesDataArray[15]); propertyGemstoneModel.dodgeGainBase = FromStringToInt16(consumablesDataArray[16]); propertyGemstoneModel.critHurtScalerGainBase = FromStringToInt16(consumablesDataArray[17]); propertyGemstoneModel.physicalHurtScalerGainBase = FromStringToInt16(consumablesDataArray[18]); propertyGemstoneModel.magicalHurtScalerGainBase = FromStringToInt16(consumablesDataArray[19]); propertyGemstoneModel.extraGoldGainBase = FromStringToInt16(consumablesDataArray[20]); propertyGemstoneModel.extraExperienceGainBase = FromStringToInt16(consumablesDataArray[21]); propertyGemstoneModel.healthRecoveryGainBase = FromStringToInt16(consumablesDataArray[22]); propertyGemstoneModel.magicRecoveryGainBase = FromStringToInt16(consumablesDataArray[23]); propertyGemstoneModel.grade = (GemstoneGrade)FromStringToInt16(consumablesDataArray[24]); InitDescription(propertyGemstoneModel); } }
/// <summary> /// 使用特殊物品 /// </summary> /// <returns>属性变化</returns> /// <param name="itemForSpecialOperation">进行特殊操作的物品</param> /// <param name="refreshItemDetailCallBack">使用完成后更新物品描述的回调</param> public PropertyChange UseSpecialItem(Item itemForSpecialOperation, CallBackWithItem refreshItemDetailCallBack) { PropertyChange propertyChange = new PropertyChange(); switch (specialItemType) { case SpecialItemType.TuiMoJuanZhou: if (itemForSpecialOperation is Equipment) { Equipment equipment = itemForSpecialOperation as Equipment; // 使用退魔卷轴,移除装备上的所有属性宝石 PropertyGemstone[] propertyGemstones = equipment.RemovePropertyGemstons(); // 属性宝石重新添加进背包 for (int i = 0; i < propertyGemstones.Length; i++) { Player.mainPlayer.AddItem(propertyGemstones[i]); } // 刷新装备详细信息 if (refreshItemDetailCallBack != null) { refreshItemDetailCallBack(equipment); } // 重算人物属性 propertyChange = Player.mainPlayer.ResetBattleAgentProperties(false); GameManager.Instance.soundManager.PlayAudioClip(CommonData.xiaoMoAudioName); } break; case SpecialItemType.ChongZhuShi: if (itemForSpecialOperation is Equipment) { Equipment equipment = itemForSpecialOperation as Equipment; // 重铸装备 equipment.RebuildEquipment(); // 刷新装备详细信息页面 if (refreshItemDetailCallBack != null) { refreshItemDetailCallBack(equipment); } // 重算人物属性 propertyChange = Player.mainPlayer.ResetBattleAgentProperties(false); GameManager.Instance.soundManager.PlayAudioClip(CommonData.chongzhuAudioName); } break; case SpecialItemType.YinShenYuPai: int oriFadeStepLeft = ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft; // 人物隐身20步 ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft = Mathf.Max(oriFadeStepLeft, 20); GameManager.Instance.soundManager.PlayAudioClip(CommonData.yinShenAudioName); // 如果原来人物没有隐身,则播放隐身特效动画 if (oriFadeStepLeft == 0) { ExploreManager.Instance.battlePlayerCtr.SetEffectAnim(CommonData.yinShenEffectName, null, 0, 0); } break; case SpecialItemType.DianJinFuShi: if (itemForSpecialOperation is Equipment) { Equipment equipment = itemForSpecialOperation as Equipment; // 将装备重铸为金色品质 equipment.SetToGoldQuality(); // 刷新装备详细信息页面 if (refreshItemDetailCallBack != null) { refreshItemDetailCallBack(equipment); } // 重算人物属性 propertyChange = Player.mainPlayer.ResetBattleAgentProperties(false); GameManager.Instance.soundManager.PlayAudioClip(CommonData.dianjinAudioName); } break; case SpecialItemType.TieYaoShi: case SpecialItemType.TongYaoShi: case SpecialItemType.JinYaoShi: case SpecialItemType.WanNengYaoShi: case SpecialItemType.QiaoZhen: break; case SpecialItemType.QianDai: // 钱袋开出500金币 Player.mainPlayer.totalGold += 500; GameManager.Instance.soundManager.PlayAudioClip(CommonData.goldAudioName); break; case SpecialItemType.ShenMiYaoJi: // 神秘药剂增加2个技能点 Player.mainPlayer.skillNumLeft += 2; GameManager.Instance.soundManager.PlayAudioClip(CommonData.drinkAudioName); break; case SpecialItemType.ShenMiMianJu: // 神秘面具隐身30步 oriFadeStepLeft = ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft; ExploreManager.Instance.battlePlayerCtr.fadeStepsLeft = Mathf.Max(oriFadeStepLeft, 30); if (oriFadeStepLeft == 0) { ExploreManager.Instance.battlePlayerCtr.SetEffectAnim(CommonData.yinShenEffectName, null, 0, 0); } GameManager.Instance.soundManager.PlayAudioClip(CommonData.yinShenAudioName); break; case SpecialItemType.JingYanZhiShu: // 经验之书直接升一级 Player.mainPlayer.agentLevel++; ExploreManager.Instance.expUICtr.ShowLevelUpPlane(); GameManager.Instance.soundManager.PlayAudioClip(CommonData.levelUpAudioName); break; case SpecialItemType.BaoXiang: // 宝箱开出1-3个高级宝石 int gemstoneCount = Random.Range(1, 4); List <PropertyGemstoneModel> allHighGradeGemstones = GameManager.Instance.gameDataCenter.allPropertyGemstoneModels.FindAll(delegate(PropertyGemstoneModel obj) { return(obj.grade == GemstoneGrade.High); }); for (int i = 0; i < gemstoneCount; i++) { int randomSeed = Random.Range(0, allHighGradeGemstones.Count); PropertyGemstoneModel propertyGemstoneModel = allHighGradeGemstones[randomSeed]; PropertyGemstone propertyGemstone = new PropertyGemstone(propertyGemstoneModel, 1); Player.mainPlayer.AddItem(propertyGemstone); } GameManager.Instance.soundManager.PlayAudioClip(CommonData.gemstoneAudioName); break; case SpecialItemType.CaoYao: // 草药回复40%生命 Player.mainPlayer.health += Mathf.RoundToInt(Player.mainPlayer.maxHealth * 0.4f); GameManager.Instance.soundManager.PlayAudioClip(CommonData.eatAudoiName); break; case SpecialItemType.QuSanChangDi: case SpecialItemType.QuSanLingDang: // 消灭地图上30%的怪物 ExploreManager.Instance.newMapGenerator.SomeMonstersToPool(0.3f); break; case SpecialItemType.HuoBa: case SpecialItemType.YouDeng: // 环境变亮 ExploreManager.Instance.newMapGenerator.SetUpExploreMask(1); break; case SpecialItemType.KaiGuan: ExploreManager.Instance.newMapGenerator.AllTrapsOff(); break; case SpecialItemType.SiYeCao: // 四叶草提升开宝箱是开出好装备的概率 Player.mainPlayer.luckInOpenTreasure = 1; //GameManager.Instance.persistDataManager.SaveCompletePlayerData(); GameManager.Instance.soundManager.PlayAudioClip(CommonData.siYeCaoAudioName); break; case SpecialItemType.XingYunYuMao: // 幸运羽毛提升怪物掉落物品的概率 Player.mainPlayer.luckInMonsterTreasure = 1; //GameManager.Instance.persistDataManager.SaveCompletePlayerData(); GameManager.Instance.soundManager.PlayAudioClip(CommonData.xingYunYuMaoAudioName); break; } return(propertyChange); }
private void InitDescription(PropertyGemstoneModel propertyGemstoneModel) { string propertyRangeString = string.Empty; if (propertyGemstoneModel.maxHealthGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.maxHealthGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.maxHealthGainBase * 1.3f)); } else if (propertyGemstoneModel.maxManaGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.maxManaGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.maxManaGainBase * 1.3f)); } else if (propertyGemstoneModel.attackGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.attackGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.attackGainBase * 1.3f)); } else if (propertyGemstoneModel.magicAttackGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.magicAttackGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.magicAttackGainBase * 1.3f)); } else if (propertyGemstoneModel.armorGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.armorGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.armorGainBase * 1.3f)); } else if (propertyGemstoneModel.magicResistGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.magicResistGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.magicResistGainBase * 1.3f)); } else if (propertyGemstoneModel.armorDecreaseGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.armorDecreaseGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.armorDecreaseGainBase * 1.3f)); } else if (propertyGemstoneModel.magicResistDecreaseGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.magicResistDecreaseGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.magicResistDecreaseGainBase * 1.3f)); } else if (propertyGemstoneModel.moveSpeedGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.moveSpeedGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.moveSpeedGainBase * 1.3f)); } else if (propertyGemstoneModel.critGainBase > 0) { propertyRangeString = string.Format("{0}%~{1}%", Mathf.RoundToInt(propertyGemstoneModel.critGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.critGainBase * 1.3f)); } else if (propertyGemstoneModel.dodgeGainBase > 0) { propertyRangeString = string.Format("{0}%~{1}%", Mathf.RoundToInt(propertyGemstoneModel.dodgeGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.dodgeGainBase * 1.3f)); } else if (propertyGemstoneModel.critHurtScalerGainBase > 0) { propertyRangeString = string.Format("{0}%~{1}%", Mathf.RoundToInt(propertyGemstoneModel.critHurtScalerGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.critHurtScalerGainBase * 1.3f)); } else if (propertyGemstoneModel.physicalHurtScalerGainBase > 0) { propertyRangeString = string.Format("{0}%~{1}%", Mathf.RoundToInt(propertyGemstoneModel.physicalHurtScalerGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.physicalHurtScalerGainBase * 1.3f)); } else if (propertyGemstoneModel.magicalHurtScalerGainBase > 0) { propertyRangeString = string.Format("{0}%~{1}%", Mathf.RoundToInt(propertyGemstoneModel.magicalHurtScalerGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.magicalHurtScalerGainBase * 1.3f)); } else if (propertyGemstoneModel.extraGoldGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.extraGoldGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.extraGoldGainBase * 1.3f)); } else if (propertyGemstoneModel.extraExperienceGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.extraExperienceGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.extraExperienceGainBase * 1.3f)); } else if (propertyGemstoneModel.healthRecoveryGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.healthRecoveryGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.healthRecoveryGainBase * 1.3f)); } else if (propertyGemstoneModel.magicRecoveryGainBase > 0) { propertyRangeString = string.Format("{0}~{1}", Mathf.RoundToInt(propertyGemstoneModel.magicRecoveryGainBase * 0.7f), Mathf.RoundToInt(propertyGemstoneModel.magicRecoveryGainBase * 1.3f)); } propertyGemstoneModel.itemDescription = propertyGemstoneModel.itemDescription.Replace("#", propertyRangeString); }
/// <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); }