/// <summary> /// 生成奖励物品 /// </summary> /// <returns>The reward item.</returns> public Item GenerateRewardItem() { Monster monster = GetComponent <Monster>(); Item rewardItem = null; if (monster.isBoss) { if (!hasReward) { return(null); } int index = 0; if (monster.monsterId % 2 == 0) { index = (Player.mainPlayer.currentLevelIndex / 5 + 1) * 1000; List <EquipmentModel> ems = GameManager.Instance.gameDataCenter.allEquipmentModels.FindAll(delegate(EquipmentModel obj) { return(obj.equipmentGrade == index); }); int randomSeed = Random.Range(0, ems.Count); rewardItem = new Equipment(ems[randomSeed], 1); } else { index = (Player.mainPlayer.currentLevelIndex / 5 + 2); if (index == 10) { index = 9; } List <EquipmentModel> ems = GameManager.Instance.gameDataCenter.allEquipmentModels.FindAll(delegate(EquipmentModel obj) { return(obj.equipmentGrade == index); }); int randomSeed = Random.Range(0, ems.Count); rewardItem = new Equipment(ems[randomSeed], 1); (rewardItem as Equipment).SetToGoldQuality(); } } else { int randomSeed = Random.Range(0, 100); int dropItemSeed = 0; switch (Player.mainPlayer.luckInMonsterTreasure) { case 0: dropItemSeed = 5 + Player.mainPlayer.extraLuckInMonsterTreasure; break; case 1: dropItemSeed = 10 + Player.mainPlayer.extraLuckInMonsterTreasure; break; } if (randomSeed >= 0 && randomSeed < dropItemSeed) { randomSeed = Random.Range(0, 10); // 掉落物品是30%的概率掉落装备 if (randomSeed <= 2) { int index = Player.mainPlayer.currentLevelIndex / 5 + 1; if (index == 10) { index = 9; } List <EquipmentModel> ems = GameManager.Instance.gameDataCenter.allEquipmentModels.FindAll(delegate(EquipmentModel obj) { return(obj.equipmentGrade == index); }); randomSeed = Random.Range(0, ems.Count); rewardItem = new Equipment(ems[randomSeed], 1); } else { int consumablesGrade = Player.mainPlayer.currentLevelIndex / 10; if (consumablesGrade >= 4) { consumablesGrade = 3; } List <ConsumablesModel> cms = GameManager.Instance.gameDataCenter.allConsumablesModels.FindAll(delegate(ConsumablesModel obj) { return(obj.consumablesGrade == consumablesGrade); }); randomSeed = Random.Range(0, cms.Count); rewardItem = new Consumables(cms[randomSeed], 1); } } else { rewardItem = null; } } return(rewardItem); }
public void SetUpItemDetail(Item item) { ClearItemDetails(); Sprite itemSprite = GameManager.Instance.gameDataCenter.GetGameItemSprite(item); itemIcon.sprite = itemSprite; itemIcon.enabled = true; itemIconBackground.enabled = true; itemName.text = item.itemName; itemIconBackground.sprite = grayEquipmentFrame; itemName.color = CommonData.grayEquipmentColor; goldIcon.enabled = true; priceText.text = (item.price / 8).ToString(); switch (item.itemType) { case ItemType.Equipment: Equipment eqp = item as Equipment; itemDescription.text = item.itemDescription; specialOperationHint.enabled = false; attachedDescription.text = eqp.attachedPropertyDescription; switch (eqp.quality) { case EquipmentQuality.Gray: itemName.color = CommonData.grayEquipmentColor; itemIconBackground.sprite = grayEquipmentFrame; break; case EquipmentQuality.Blue: itemName.color = CommonData.blueEquipmentColor; itemIconBackground.sprite = blueEquipmentFrame; break; case EquipmentQuality.Gold: itemName.color = CommonData.goldEquipmentColor; itemIconBackground.sprite = goldEquipmentFrame; break; case EquipmentQuality.Purple: itemName.color = CommonData.purpleEquipmentColor; itemIconBackground.sprite = purpleEquipmentFrame; break; } SetUpOperationButtons(!eqp.equiped, eqp.equiped, false); specialOperationContainer.gameObject.SetActive(false); attachedGemstoneDisplay.SetUpAttachedSkillDisplay(eqp.attachedPropertyGemstones); attachedGemstoneDisplay.gameObject.SetActive(true); break; case ItemType.Consumables: //Consumables cons = item as Consumables; attachedDescription.text = item.itemDescription; SetUpOperationButtons(false, false, true); specialOperationContainer.gameObject.SetActive(false); specialOperationHint.enabled = false; //attachedSkillDisplay.gameObject.SetActive (false); attachedGemstoneDisplay.gameObject.SetActive(false); break; case ItemType.SkillScroll: //SkillScroll skillScroll = item as SkillScroll; attachedDescription.text = item.itemDescription; itemDescription.text = string.Empty; //attachedSkillDisplay.gameObject.SetActive (true); // Skill attachedSkill = GameManager.Instance.gameDataCenter.allSkills.Find (delegate(Skill obj) { //return obj.skillId == skillScroll.skillId; //}); SetUpOperationButtons(false, false, true); specialOperationContainer.gameObject.SetActive(false); specialOperationHint.enabled = false; //attachedSkillDisplay.SetUpAttachedSkillDisplay(attachedSkill); attachedGemstoneDisplay.gameObject.SetActive(false); break; case ItemType.PropertyGemstone: attachedDescription.text = item.itemDescription; itemDescription.text = string.Empty; SetUpOperationButtons(false, false, false); specialOperationContainer.gameObject.SetActive(false); specialOperationHint.enabled = false; //attachedSkillDisplay.gameObject.SetActive(false); attachedGemstoneDisplay.gameObject.SetActive(false); break; case ItemType.SpecialItem: attachedDescription.text = item.itemDescription; specialOperationHint.enabled = false; SpecialItem specialItem = item as SpecialItem; switch (specialItem.specialItemType) { case SpecialItemType.TieYaoShi: case SpecialItemType.TongYaoShi: case SpecialItemType.JinYaoShi: case SpecialItemType.WanNengYaoShi: case SpecialItemType.QiaoZhen: SetUpOperationButtons(false, false, false); specialOperationContainer.gameObject.SetActive(false); break; case SpecialItemType.DianJinFuShi: case SpecialItemType.ChongZhuShi: case SpecialItemType.TuiMoJuanZhou: SetUpOperationButtons(false, false, true); specialOperationContainer.gameObject.SetActive(true); soCell.SetUpSpeicalOperationCell(null); soCell.InitSpecialOperaiton(null); specialOperationHint.enabled = true; break; default: SetUpOperationButtons(false, false, true); specialOperationContainer.gameObject.SetActive(false); break; } //attachedSkillDisplay.gameObject.SetActive(false); attachedGemstoneDisplay.gameObject.SetActive(false); break; } generalItemDetailContainer.gameObject.SetActive(true); }
/// <summary> /// 在物品详细信息页点击了使用按钮 /// </summary> public void OnUseButtonClick() { // 如果选中的物品为空,直接返回 if (currentSelectItem == null) { return; } // 标记是否清除物品详细信息【如果物品使用完成后数量为0,从背包中移除了,则清除物品的详细信息】 bool clearItemDetail = false; // 进行特殊操作物品【如点金石点的装备,重铸石重铸的装备等】 Item specialOperaitonItem = null; // 标记是否从背包中移除 bool totallyRemoved = true; // 根据当前选中物品的类型不同,区分不同的使用逻辑 switch (currentSelectItem.itemType) { // 消耗品使用逻辑 case ItemType.Consumables: Consumables consumables = currentSelectItem as Consumables; PropertyChange propertyChange = consumables.UseConsumables(null); if (consumables.itemCount > 0) { totallyRemoved = false; } bagView.SetUpPlayerStatusPlane(propertyChange); GameManager.Instance.soundManager.PlayAudioClip(consumables.audioName); break; // 技能卷轴的使用逻辑 case ItemType.SkillScroll: SkillScroll skillScroll = currentSelectItem as SkillScroll; // 检查技能是否已经学满了 if (Player.mainPlayer.CheckSkillFull()) { string skillFullHint = string.Format("只能学习{0}个技能", Player.mainPlayer.maxSkillCount); bagView.SetUpSingleTextTintHUD(skillFullHint); return; } // 检查技能是否已经学习过了 bool skillHasLearned = Player.mainPlayer.CheckSkillHasLearned(skillScroll.skillId); if (skillHasLearned) { bagView.SetUpSingleTextTintHUD("不能重复学习技能"); return; } totallyRemoved = true; propertyChange = skillScroll.UseSkillScroll(); GameManager.Instance.soundManager.PlayAudioClip(CommonData.paperAudioName); // 由于有被动技能,学习后玩家属性上可能有变化,所以学习技能后也要更新属性面板 bagView.SetUpPlayerStatusPlane(propertyChange); break; // 特殊物品的使用逻辑 case ItemType.SpecialItem: SpecialItem specialItem = currentSelectItem as SpecialItem; Item itemForSpecialOperation = bagView.itemDetail.soCell.itemInCell; specialOperaitonItem = itemForSpecialOperation; switch (specialItem.specialItemType) { case SpecialItemType.ChongZhuShi: case SpecialItemType.DianJinFuShi: if (itemForSpecialOperation == null) { return; } break; case SpecialItemType.TuiMoJuanZhou: if (itemForSpecialOperation == null) { return; } Equipment equipment = itemForSpecialOperation as Equipment; if (equipment.attachedPropertyGemstones.Count == 0) { bagView.hintHUD.SetUpSingleTextTintHUD("当前装备未镶嵌宝石"); return; } int addItemCount = 0; for (int i = 0; i < equipment.attachedPropertyGemstones.Count; i++) { PropertyGemstone propertyGemstone = equipment.attachedPropertyGemstones[i]; bool gemstoneExist = Player.mainPlayer.CheckItemExistInBag(propertyGemstone); if (!gemstoneExist) { addItemCount++; } } if (specialItem.itemCount == 1) { addItemCount--; } bool bagFull = Player.mainPlayer.allItemsInBag.Count + addItemCount >= Player.mainPlayer.maxBagCount * CommonData.singleBagItemVolume; if (bagFull) { bagView.hintHUD.SetUpSingleTextTintHUD("背包已满"); return; } break; default: break; } propertyChange = specialItem.UseSpecialItem(itemForSpecialOperation, bagView.itemDetail.SetUpItemDetail); bagView.SetUpEquipedEquipmentsPlane(); bagView.SetUpPlayerStatusPlane(propertyChange); break; } // 如果玩家正在战斗中,更新技能按钮状态 if (ExploreManager.Instance.battlePlayerCtr.isInFight) { ExploreManager.Instance.expUICtr.UpdateActiveSkillButtons(); } // 从背包中移除当前选中的物品,如果该物品完全从背包中移除了,则清空物品详细信息面板 clearItemDetail = Player.mainPlayer.RemoveItem(currentSelectItem, 1); // 更新当前背包 bagView.UpdateCurrentBagItemsPlane(); if (clearItemDetail) { bagView.ClearItemDetail(); } // 进行特殊操作的物品,特殊操作结束后显示被操作物品的信息,并在背包中将该物品的选中框高亮 if (specialOperaitonItem != null) { currentSelectItem = specialOperaitonItem; bagView.SetUpItemDetail(specialOperaitonItem); int specialOperaitonItemIndexInBag = Player.mainPlayer.GetItemIndexInBag(specialOperaitonItem); if (specialOperaitonItemIndexInBag >= 0) { int itemIndexInCurrentBag = specialOperaitonItemIndexInBag % CommonData.singleBagItemVolume; bagView.bagItemsDisplay.SetSelectionIcon(itemIndexInCurrentBag, true); } } // 非特殊操作的物品,如果使用完之后还没有从背包中完全移除,则显示物品的选中框 else if (!totallyRemoved) { int itemIndexInBag = Player.mainPlayer.GetItemIndexInBag(currentSelectItem); if (itemIndexInBag >= 0) { int itemIndexInCurrentBag = itemIndexInBag % CommonData.singleBagItemVolume; bagView.bagItemsDisplay.SetSelectionIcon(itemIndexInCurrentBag, true); } } }
// 构造函数 public PlayRecord() { Debug.Log("generate play record"); Player player = Player.mainPlayer; player.ResetBattleAgentProperties(false); this.maxExploreLevel = player.maxUnlockLevelIndex + 1 > 50 ? 50 : Player.mainPlayer.maxUnlockLevelIndex + 1; DateTime now = DateTime.Now; DateTime installDate = Convert.ToDateTime(player.currentExploreStartDateString); TimeSpan timeSpan = now.Subtract(installDate); this.totalExploreDays = timeSpan.Days + 1; LearningInfo learningInfo = LearningInfo.Instance; int learnedWordCountOfCurrentType = player.learnedWordsCountInCurrentExplore; int correctWordCountOfCurrentType = player.correctWordsCountInCurrentExplore; this.totalDefeatMonsterCount = player.totaldefeatMonsterCount; this.totalLearnedWordCount = learnedWordCountOfCurrentType; this.learnCorrectPercentageX100 = learnedWordCountOfCurrentType == 0 ? 0 : correctWordCountOfCurrentType * 100 / learnedWordCountOfCurrentType; this.maxHealth = player.maxHealth; this.maxMana = player.maxMana; this.attack = player.attack; this.magicAttack = player.magicAttack; this.armor = player.armor; this.magicResist = player.magicResist; this.armorDecrease = player.armorDecrease; this.magicResistDecrease = player.magicResistDecrease; this.dodge = player.dodge; this.crit = player.crit; this.extraGold = player.extraGold; this.extraExperience = player.extraExperience; this.healthRecovery = player.healthRecovery; this.magicRecovery = player.magicRecovery; for (int i = 0; i < player.allEquipedEquipments.Length; i++) { Equipment equipment = player.allEquipedEquipments[i]; if (equipment.itemId < 0) { continue; } this.equipedEquipments.Add(equipment); } for (int i = 0; i < player.allLearnedSkillsRecord.Count; i++) { SkillModel learnedSkill = player.allLearnedSkillsRecord[i]; if (learnedSkill.skillId <= 0) { continue; } this.learnedSkillRecords.Add(learnedSkill); } // 计算评分 this.evaluatePoint = (int)(totalDefeatMonsterCount * 0.3f) + totalLearnedWordCount * learnCorrectPercentageX100 * learnCorrectPercentageX100 / 10000; if (evaluatePoint < 100) { evaluateString = "F"; } else if (evaluatePoint >= 100 && evaluatePoint < 300) { evaluateString = "E"; } else if (evaluatePoint >= 300 && evaluatePoint < 550) { evaluateString = "D"; } else if (evaluatePoint >= 550 && evaluatePoint < 850) { evaluateString = "C"; } else if (evaluatePoint >= 850 && evaluatePoint < 1250) { evaluateString = "B"; } else if (evaluatePoint >= 1250 && evaluatePoint < 1700) { evaluateString = "A"; } else if (evaluatePoint >= 1700 && evaluatePoint < 2200) { evaluateString = "S"; } else if (evaluatePoint >= 2200 && evaluatePoint < 2750) { evaluateString = "SS"; } else if (evaluatePoint >= 2750) { evaluateString = "SSS"; } }
protected override void ExcuteActiveSkillLogic(BattleAgentController self, BattleAgentController enemy) { // 如果是玩家角色,则在每次攻击时重设攻速 if (self is BattlePlayerController) { int attackSpeedInt = 0; for (int i = 0; i < self.agent.allEquipedEquipments.Length; i++) { Equipment equipment = self.agent.allEquipedEquipments[i]; if (equipment.itemId == -1) { continue; } if (equipment.equipmentType == EquipmentType.Weapon) { attackSpeedInt = (int)equipment.attackSpeed; break; } } for (int i = 0; i < self.agent.attachedPermanentPassiveSkills.Count; i++) { PermanentPassiveSkill permanentPassiveSkill = self.agent.attachedPermanentPassiveSkills[i]; if (permanentPassiveSkill is JiSu) { attackSpeedInt++; break; } } if (attackSpeedInt > 3) { attackSpeedInt = 3; } (self.agent as Player).attackSpeed = (AttackSpeed)attackSpeedInt; } SetEffectAnims(self, enemy); // 执行攻击触发事件回调 for (int i = 0; i < self.attackTriggerExcutors.Count; i++) { TriggeredSkillExcutor excutor = self.attackTriggerExcutors[i]; excutor.triggeredCallback(self, enemy); } // 敌方执行被攻击触发事件回调 for (int i = 0; i < enemy.beAttackedTriggerExcutors.Count; i++) { TriggeredSkillExcutor excutor = enemy.beAttackedTriggerExcutors[i]; excutor.triggeredCallback(enemy, self); } //计算对方闪避率(敌方的基础闪避率 - 己方的闪避修正) float enemyDodge = enemy.agent.dodge; //判断对方是否闪避成功 if (isEffective(enemyDodge)) { enemy.AddTintTextToQueue("闪避"); return; } int actualPhysicalHurt = 0; int actualMagicalHurt = 0; if (self.agent.attack > 0) { //int oriPhysicalHurt = self.agent.attack + self.agent.armorDecrease / 4; int oriPhysicalHurt = self.agent.attack; float crit = self.agent.crit; if (isEffective(crit)) { enemy.AddTintTextToQueue("暴击"); oriPhysicalHurt = (int)(oriPhysicalHurt * self.agent.critHurtScaler); } int armorCal = enemy.agent.armor - self.agent.armorDecrease / 2; if (armorCal < -50) { armorCal = -50; } actualPhysicalHurt = (int)(oriPhysicalHurt / (armorCal / 100f + 1)); //actualPhysicalHurt = oriPhysicalHurt - enemy.agent.armor / 4; if (actualPhysicalHurt < 0) { actualPhysicalHurt = 0; } enemy.AddHurtAndShow(actualPhysicalHurt, HurtType.Physical, self.towards); } if (self.agent.magicAttack > 0) { int magicResistCal = enemy.agent.magicResist - self.agent.magicResistDecrease / 2; if (magicResistCal < -50) { magicResistCal = -50; } actualMagicalHurt = (int)(self.agent.magicAttack / (magicResistCal / 100f + 1)); if (actualMagicalHurt < 0) { actualMagicalHurt = 0; } enemy.AddHurtAndShow(actualMagicalHurt, HurtType.Magical, self.towards); } enemy.PlayShakeAnim(); self.agent.physicalHurtToEnemy = actualPhysicalHurt; self.agent.magicalHurtToEnemy = actualMagicalHurt; // 执行己方攻击命中的回调 for (int i = 0; i < self.hitTriggerExcutors.Count; i++) { TriggeredSkillExcutor excutor = self.hitTriggerExcutors[i]; excutor.triggeredCallback(self, enemy); } // 执行敌方被击中的回调 for (int i = 0; i < enemy.beHitTriggerExcutors.Count; i++) { TriggeredSkillExcutor excutor = enemy.beHitTriggerExcutors[i]; excutor.triggeredCallback(enemy, self); } }