/// <summary> /// 重铸装备【50%概率灰色,30%概率蓝色,20%概率金色】 /// </summary> public void RebuildEquipment() { int randomSeed = Random.Range(0, 100); // 非暗金装备重铸时装备品质重新随机,暗金装备重铸后仍是暗金装备 if (quality != EquipmentQuality.Purple && quality != EquipmentQuality.Gold) { if (randomSeed < 65) { quality = EquipmentQuality.Gray; } else if (randomSeed < 95) { quality = EquipmentQuality.Blue; } else if (randomSeed < 100) { quality = EquipmentQuality.Gold; } } ResetPropertiesByQuality(quality); }
public Equipment(string name, string description, string sprite, int hp, int mp, int atk, int def, int level, EquipmentQuality quality, EquipmentType equipmentType) { this.Name = name; this.Description = description; this.Sprite = sprite; this.Hp = hp; this.Mp = mp; this.ATK = atk; this.DEF = def; this.Level = level; this.Quality = quality; this.equipmentType = equipmentType; }
/// <summary> /// 根据指定品质初始化装备 /// </summary> /// <param name="quality">Quality.</param> public void ResetPropertiesByQuality(EquipmentQuality quality) { this.quality = quality; // 装备先重置到空属性 ResetEquipmentToEmptyProperty(); this.maxHealthGain = oriMaxHealthGain; this.maxManaGain = oriMaxManaGain; this.attackGain = oriAttackGain; this.magicAttackGain = oriMagicAttackGain; this.armorGain = oriArmorGain; this.magicResistGain = oriMagicResistGain; this.armorDecreaseGain = oriArmorDecreaseGain; this.magicResistDecreaseGain = oriMagicResistDecreaseGain; this.moveSpeedGain = oriMoveSpeedGain; this.critGain = oriCritGain; this.dodgeGain = oriDodgeGain; this.critHurtScalerGain = oriCritHurtScalerGain; this.physicalHurtScalerGain = oriPhysicalHurtScalerGain; this.magicalHurtScalerGain = oriMagicalHurtScalerGain; this.extraGoldGain = oriExtraGoldGain; this.extraExperienceGain = oriExtraExperienceGain; this.healthRecoveryGain = oriHealthRecoveryGain; this.magicRecoveryGain = oriMagicRecoveryGain; float gainScaler = 1; switch (quality) { case EquipmentQuality.Gray: gainScaler = Random.Range(1.0f, 1.2f); // 灰色品质的属性浮动在1.0-1.2 this.price = oriPrice; break; case EquipmentQuality.Blue: gainScaler = Random.Range(1.2f, 1.3f); // 蓝色品质的属性浮动在1.2-1.3 this.price = oriPrice * 2; break; case EquipmentQuality.Gold: // 特殊金色装备属性不浮动,普通金色装备属性浮动30%-40% if (equipmentGrade >= 10) { gainScaler = 1.0f; this.price = oriPrice; } else { gainScaler = Random.Range(1.3f, 1.4f); this.price = oriPrice * 3; } break; case EquipmentQuality.Purple: gainScaler = 1.0f; // 紫色装备属性不浮动 this.price = oriPrice; break; } this.maxHealthGain = (int)(maxHealthGain * gainScaler); this.maxManaGain = (int)(maxManaGain * gainScaler); this.attackGain = (int)(attackGain * gainScaler); this.magicAttackGain = (int)(magicAttackGain * gainScaler); this.armorGain = (int)(armorGain * gainScaler); this.magicResistGain = (int)(magicResistGain * gainScaler); this.armorDecreaseGain = (int)(armorDecreaseGain * gainScaler); this.magicResistDecreaseGain = (int)(magicResistDecreaseGain * gainScaler); this.moveSpeedGain = (int)(moveSpeedGain * gainScaler); this.critGain = critGain * gainScaler; this.dodgeGain = dodgeGain * gainScaler; this.critHurtScalerGain = critHurtScalerGain * gainScaler; this.physicalHurtScalerGain = physicalHurtScalerGain * gainScaler; this.magicalHurtScalerGain = magicalHurtScalerGain * gainScaler; this.extraGoldGain = (int)(extraGoldGain * gainScaler); this.extraExperienceGain = (int)(extraExperienceGain * gainScaler); this.healthRecoveryGain = (int)(healthRecoveryGain * gainScaler); this.magicRecoveryGain = (int)(magicRecoveryGain * gainScaler); switch (quality) { case EquipmentQuality.Gray: break; case EquipmentQuality.Blue: int randomSeed = Random.Range(0, specProperties.Count); PropertySet ps = specProperties[randomSeed]; InitSpecificProperty(ps); break; case EquipmentQuality.Gold: case EquipmentQuality.Purple: for (int i = 0; i < specProperties.Count; i++) { ps = specProperties[i]; InitSpecificProperty(ps); } break; } InitDescription(); }
/// <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(); }
public override void InitializeWithAttachedInfo(int mapIndex, MapAttachedInfoTile attachedInfo) { this.mapIndex = mapIndex; transform.position = attachedInfo.position; isGoldTreasureBox = false; if (KVPair.ContainsKey("type", attachedInfo.properties)) { string type = KVPair.GetPropertyStringWithKey("type", attachedInfo.properties); isGoldTreasureBox = type == "1"; } int rewardItemId = 0; if (!isGoldTreasureBox) { mapItemRenderer.sprite = normalTbSprite; treasureType = TreasureType.NormalTreasureBox; } else { mapItemRenderer.sprite = specialTbSprite; treasureType = TreasureType.GoldTreasureBox; } if (KVPair.ContainsKey("dropID", attachedInfo.properties)) { rewardItemId = int.Parse(KVPair.GetPropertyStringWithKey("dropID", attachedInfo.properties)); } else { rewardItemId = GetRandomItemIdFromGameLevelData(); } if (isGoldTreasureBox && MapEventsRecord.IsMapEventTriggered(mapIndex, attachedInfo.position)) { AddToPool(ExploreManager.Instance.newMapGenerator.mapEventsPool); } rewardItem = Item.NewItemWith(rewardItemId, 1); if (rewardItem.itemType == ItemType.Equipment) { Equipment eqp = rewardItem as Equipment; int randomSeed = Random.Range(0, 100); int graySeed = 0; int blueSeed = 0; // 物品品质概率 switch (Player.mainPlayer.luckInOpenTreasure) { case 0: graySeed = 65 - Player.mainPlayer.extraLuckInOpenTreasure; blueSeed = 95 - Player.mainPlayer.extraLuckInOpenTreasure; break; case 1: graySeed = 60 - Player.mainPlayer.extraLuckInOpenTreasure; blueSeed = 90 - Player.mainPlayer.extraLuckInOpenTreasure; break; } EquipmentQuality quality = EquipmentQuality.Gray; // 如果不是金色宝箱,则随机一种品质 if (!isGoldTreasureBox) { if (randomSeed < graySeed) { quality = EquipmentQuality.Gray; } else if (randomSeed < blueSeed) { quality = EquipmentQuality.Blue; } else { quality = EquipmentQuality.Gold; } } else { quality = EquipmentQuality.Gold; } eqp.ResetPropertiesByQuality(quality); } CheckIsWordTriggeredAndShow(); bc2d.enabled = true; //mapItemAnimator.gameObject.SetActive (false); mapItemRenderer.enabled = true; int sortingOrder = -(int)transform.position.y; SetSortingOrder(sortingOrder); //SetAnimationSortingOrder (sortingOrder); }
/// <summary> /// 玩家战斗胜利逻辑 /// </summary> /// <param name="monsterTransArray">Monster trans array.</param> public void BattlePlayerWin(Transform[] monsterTransArray) { // 如果没有传入敌人,直接返回 if (monsterTransArray.Length <= 0) { return; } // 记录击败的怪物数 Player.mainPlayer.totaldefeatMonsterCount++; // 重置角色骨骼动画速率 battlePlayerCtr.SetRoleAnimTimeScale(1.0f); battleMonsterCtr.SetRoleAnimTimeScale(1.0f); Transform trans = monsterTransArray [0]; BattleMonsterController bmCtr = trans.GetComponent <BattleMonsterController> (); Monster monster = trans.GetComponent <Monster> (); MapWalkableEvent walkableEvent = trans.GetComponent <MapWalkableEvent> (); Player player = Player.mainPlayer; // 执行战斗结束的回调 FightEndCallBacks(); // 重置所有技能产生的属性变化 battlePlayerCtr.agent.ClearPropertyChangesFromSkill(); // 重置角色属性【按照脱离战斗时持有装备的正常情况重新计算一遍人物属性】 battlePlayerCtr.agent.ResetBattleAgentProperties(false); // 怪物清空所有技能产生的属性变化 battleMonsterCtr.agent.ClearPropertyChangesFromSkill(); // 怪物重置属性 battleMonsterCtr.agent.ResetBattleAgentProperties(false); // 玩家位置修正到标准位置【整数点位置】 battlePlayerCtr.FixPositionToStandard(); // 玩家等待当前动作结束 battlePlayerCtr.ResetToWaitAfterCurrentRoleAnimEnd(); Vector3 monsterPos = trans.position; walkableEvent.RefreshWalkableInfoWhenQuit(true); MapMonster mm = bmCtr.GetComponent <MapMonster> (); if (mm != null) { // 生成奖励物品 Item rewardItem = mm.GenerateRewardItem(); if (rewardItem != null) { newMapGenerator.SetUpRewardInMap(rewardItem, trans.position); } if (mm.pairEventPos != -Vector3.one) { newMapGenerator.ChangeMapEventStatusAtPosition(mm.pairEventPos); } if (monster.isBoss) { MapEventsRecord.AddEventTriggeredRecord(mm.mapIndex, mm.oriPos); } } // 目前npc不参与战斗,下面的代码后续扩展可用 MapNPC mn = bmCtr.GetComponent <MapNPC> (); if (mn != null) { Item rewardItem = Item.NewItemWith(mn.fightReward.rewardValue, 1); if (rewardItem != null) { if (rewardItem.itemType == ItemType.Equipment) { Equipment eqp = rewardItem as Equipment; EquipmentQuality quality = (EquipmentQuality)mn.fightReward.attachValue; eqp.ResetPropertiesByQuality(quality); } newMapGenerator.SetUpRewardInMap(rewardItem, trans.position); } } // 开启屏幕行走点击 EnableExploreInteractivity(); // 标记不在战斗 battlePlayerCtr.isInFight = false; // 标记不再地图事件中 battlePlayerCtr.isInEvent = false; // 角色包围盒开启 battlePlayerCtr.boxCollider.enabled = true; // 清除敌方信息 battlePlayerCtr.enemy = null; //更新玩家金钱 int goldGain = monster.rewardGold + player.extraGold; player.totalGold += goldGain; GameManager.Instance.soundManager.PlayAudioClip(CommonData.goldAudioName); expUICtr.SetUpGoldGainTintHUD(goldGain); player.experience += monster.rewardExperience + player.extraExperience; //更新玩家经验值 bool isLevelUp = player.LevelUpIfExperienceEnough(); //判断是否升级 newMapGenerator.allMonstersInMap.Remove(mm); if (isLevelUp) { PlayLevelUpAnim();// 升级时播放升级动画 DisableExploreInteractivity(); expUICtr.ShowLevelUpPlane(); } else { MapWalkableEventsStartAction(); } // 更新角色状态栏 battlePlayerCtr.UpdateStatusPlane(); }