public bool StatePossibility(SkillFunction HS, BattleRoleData source, BattleRoleData target) { if (AllRandomSetClass.PercentIdentify(StatePossibilityBuff)) { if (HS.ThisSkillAim == SkillAim.Self) { Success = true; return(Success); } if (HS.ThisSkillAim == SkillAim.Friend) { Success = true; return(Success); } } float rate = AllRandomSetClass.SimplePercentToDecimal (StatePossibilityBuff - target.ThisBasicRoleProperty().ReadRA(stateTag)); rate = Mathf.Clamp(rate, 0.05f, 0.95f); if (UnityEngine.Random.Range(0, 1f) < rate) { Success = true; return(Success); } Success = false; return(Success); }
public void addHp(int val, bool useSpecial = false) { if (useSpecial) { isEvoHappen = false; if (isCriDmg) { float c = AllRandomSetClass.SimplePercentToDecimal(_unit.ThisBasicRoleProperty().CRIDmg + 100); val = (int)(val * c); } if (isFault) { val = 0; } showHealAnimation(val); CurrentHp += val; } else { isCriDmg = isEvoHappen = isFault = false; showHealAnimation(val); CurrentHp += val; } if (CurrentHp >= _unit.ThisBasicRoleProperty()._role.ReadCurrentRoleRA((int)AttributeData.Hp)) { CurrentHp = _unit.ThisBasicRoleProperty()._role.ReadCurrentRoleRA((int)AttributeData.Hp); } HpText.text = "" + CurrentHp; checkHpFull(); }
/// <summary> /// 状态造成的伤害计算 /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> public override int dmgCaused(BattleRoleData source, BattleRoleData target) { int basicVal; if (!UseSourceAToDmg) { basicVal = ExtraDmg.DATA; if (ExtraDmg.dataTag == NumberData.DataType.percent) { basicVal = (int)(target.HpController.MaxHp * ExtraDmg.DECIMAL); } } else { float _decimal = AllRandomSetClass.SimplePercentToDecimal(UsePercent); float val = 0; if (stateKind == SkillKind.Elemental) { val = source.ThisBasicRoleProperty()._role.at *_decimal; } else if (stateKind == SkillKind.Physical) { val = source.ThisBasicRoleProperty()._role.mt *_decimal; } else if (stateKind == SkillKind.Arcane) { val = (source.ThisBasicRoleProperty()._role.mt + source.ThisBasicRoleProperty()._role.at) * _decimal; } basicVal = (int)val; } return(basicVal); }
public RoleBarChart ExpandByRBCPercent(RoleBarChart percentArray) { HP = (int)(HP * AllRandomSetClass.SimplePercentToDecimal(percentArray.HP)); MP = (int)(MP * AllRandomSetClass.SimplePercentToDecimal(percentArray.MP)); TP = (int)(TP * AllRandomSetClass.SimplePercentToDecimal(percentArray.TP)); return(this); }
public void CheckRaceEffect() { #region heroSide List <BattleRoleData> humans = BM.Remaining_SRL.FindAll(x => { return(x.HeroProperty._hero._heroRace == Race.Human); }); if (humans.Count > 1) { int count = humans.Count; selfRALChange.Add(5 * count, AttributeData.AT); selfRALChange.Add(5 * count, AttributeData.MT); if (count % 2 == 0) { BM.heroToEnemyDmg_event += (x) => { return((int)(x * AllRandomSetClass.SimplePercentToDecimal(100 + count / 2 * 5))); }; } } // List <BattleRoleData> elfs = BM.Remaining_SRL.FindAll(x => { return(x.HeroProperty._hero._heroRace == Race.Elf); }); if (elfs.Count > 1) { int count = elfs.Count; selfRALChange.Add(5 * count, AttributeData.AT); selfRALChange.Add(5 * count, AttributeData.MT); if (count % 2 == 0) { selfRALChange.Add(count, AttributeData.Crit); selfRALChange.Add(count, AttributeData.Evo); } } // List <BattleRoleData> dragonborns = BM.Remaining_SRL.FindAll(x => { return(x.HeroProperty._hero._heroRace == Race.Dragonborn); }); if (dragonborns.Count > 1) { int count = dragonborns.Count; selfRALChange.Add(5 * count, AttributeData.AT); selfRALChange.Add(5 * count, AttributeData.MT); if (count % 2 == 0) { BM.enemyToHeroDmg_event += (x) => { return((int)(x * AllRandomSetClass.SimplePercentToDecimal(100 - count / 2 * 5))); }; } } #endregion #region enemySide //for(int i=0;i<) #endregion }
/// <summary> /// 状态造成的属性影响计算 /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> public override RoleAttributeList ralCaused(BattleRoleData source, BattleRoleData target) { RoleAttributeList ral = new RoleAttributeList(); //RoleAttributeList sourceRal = source.ThisBasicRoleProperty()._role.ThisRoleAttributes.Clone; RoleAttributeList targetRal = source.ThisBasicRoleProperty()._role.ThisRoleAttributes.Clone; for (int i = 0; i < AllChangesInRAL.Count; i++) { ChangeInRAL c = AllChangesInRAL[i]; int d = c.ChangeData.DATA; if (!c.IsForRD) { if (c.UseDataType == ChangeInRAL.DataOrigin.normal) { if (c.ChangeData.dataTag == NumberData.DataType.percent) { d = (int)(targetRal.read(c.ADTag) * c.ChangeData.DECIMAL); } } else if (c.UseDataType == ChangeInRAL.DataOrigin.otherAtb) { int ori = targetRal.read(c.OtherAtb); d = (int)(ori * AllRandomSetClass.SimplePercentToDecimal(c.UsePercent)); } else if (c.UseDataType == ChangeInRAL.DataOrigin.armor) { RoleAttributeList _ral = getRALFromEquip(c.UsePos, source, target).Clone; d = _ral.read(c.ADTag); } ral.Add(d, c.ADTag); } else { if (c.UseDataType == ChangeInRAL.DataOrigin.normal) { if (c.ChangeData.dataTag == NumberData.DataType.percent) { d = (int)(targetRal.read(c.STag) * c.ChangeData.DECIMAL); } } else if (c.UseDataType == ChangeInRAL.DataOrigin.otherAtb) { int ori = targetRal.read(c.OtherAtb); d = (int)(ori * AllRandomSetClass.SimplePercentToDecimal(c.UsePercent)); } else if (c.UseDataType == ChangeInRAL.DataOrigin.armor) { RoleAttributeList _ral = getRALFromEquip(c.UsePos, source, target).Clone; d = _ral.read(c.STag); } ral.Add(d, c.STag); } } return(ral); }
public int ExpectResult;//期望最终浮动 public void CheckThisSkillCauseExpect(SkillFunction _skill) { int _expect = ThisBasicRoleProperty().ReadRA(AttributeData.Expect); int _expectR = _skill.ExpectR; int Ex = (int)(_expect * AllRandomSetClass.SimplePercentToDecimal(_expectR + 100)); ExpectResult = Ex; }
public bool CritHappen;//暴击-判定成功 public void CheckThisSkillCauseCrit(SkillFunction _skill) { int baseC = ThisBasicRoleProperty().ReadRA(AttributeData.Crit); int realC = (int)(baseC * AllRandomSetClass.SimplePercentToDecimal(_skill.CritR + 100)); float Rate = AdolescentSet.CritFunction(realC); bool _IsCrit = UnityEngine.Random.Range(0, 1f) < Rate; CritHappen = _IsCrit; }
public int PDUsingRA_PerSkillGrade; //% #endregion public int UsingRAShow(BattleRoleData source, AttributeData tag, int LEVEL, int SkillGrade) { int bc1 = (int)(AllRandomSetClass.SimplePercentToDecimal(BCPerformDataUsingRA + PDUsingRA_PerSkillGrade * SkillGrade + PDUsingRA_PerLevel * LEVEL) * source.ThisBasicRoleProperty().ReadRA(tag));//计算受source属性影响值 return(bc1); }
public RoleAttributeList GetRALUpByGoddess(RoleAttributeList baseRAL) { RoleAttributeList ral = RoleAttributeList.zero; float rate = AllRandomSetClass.SimplePercentToDecimal(GP.heroAttiUp); ral.AT = (int)(baseRAL.AT * rate); ral.AD = (int)(baseRAL.AD * rate); ral.MT = (int)(baseRAL.MT * rate); ral.MD = (int)(baseRAL.MD * rate); return(ral); }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target) { source.playMoveTowardAnimation(target.unit_model.position); yield return(new WaitForSeconds(moveTowardAndBackTime)); source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_attack, false); SLEffectManager.Instance.playCommonEffectSlash(target.transform.position); yield return(new WaitForSeconds(SDConstants.AnimTime_ATTACK - hitTime)); int damage = dmgCaused(source, target); #region 计算技能状态 source.SkillCheck(this, target); IsCausedCritDmg = source.CritHappen; IsCausedMiss = !source.AccurHappen; IsCausedFault = source.FaultHappen; if (IsCausedCritDmg) { float criD = AllRandomSetClass.SimplePercentToDecimal (source.ThisBasicRoleProperty().CRIDmg + 100); damage = (int)(damage * criD); } int NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); #endregion damage += NowExpect; #region 输技能状态 target.HpController.isCriDmg = IsCausedCritDmg; target.HpController.isEvoHappen = IsCausedMiss; target.HpController.isFault = IsCausedFault; #endregion damage = (int)(damage * AllRandomSetClass.SimplePercentToDecimal(100 + target.PhysModify)); Debug.Log(source.name + " slash cause " + damage + " damage to " + target.name); target.HpController.getDamage(damage, SkillKind.Physical); yield return(new WaitForSeconds(hitTime)); //yield return new WaitForSeconds(skillLastTime); source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_idle, true); source.playMoveBackAnimation(); yield return(new WaitForSeconds(moveTowardAndBackTime)); StartCoroutine(IEWaitForEnd(source)); }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target, NumberData _val, bool useSpecial = false) { source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_cast, false); SLEffectManager.Instance.playCommonEffectCast(source.transform.position); yield return(new WaitForSeconds(castLastTime)); int val = _val.DATA; if (_val.dataTag == NumberData.DataType.percent) { val = (int)(target.HpController.MaxHp * _val.DECIMAL); } if (useSpecial) { #region 计算技能状态 source.SkillCheck(this, target); IsCausedCritDmg = source.CritHappen; IsCausedMiss = !source.AccurHappen; IsCausedFault = source.FaultHappen; float criD = 1; if (IsCausedCritDmg) { criD = AllRandomSetClass.SimplePercentToDecimal (source.ThisBasicRoleProperty().CRIDmg + 100); } int NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); #endregion val = (int)(val * criD); val += NowExpect; #region 输技能状态 target.HpController.isCriDmg = IsCausedCritDmg; target.HpController.isEvoHappen = IsCausedMiss; target.HpController.isFault = IsCausedFault; #endregion } SLEffectManager.Instance.playCommonEffectLocalBarChartAdd(target.transform.position); yield return(new WaitForSeconds(effectLastTime)); Debug.Log(source.name + " heal cause " + val + " to " + target.name); target.HpController.addHp(val); yield return(new WaitForSeconds(skillLastTime)); StartCoroutine(IEWaitForShortEnd(source)); }
public bool StatePossibility(BattleRoleData target) { if (AimAtSelf) { Success = AllRandomSetClass.PercentIdentify(StatePossibilityBuff); return(Success); } float rate = AllRandomSetClass.SimplePercentToDecimal (StatePossibilityBuff - target.ThisBasicRoleProperty().ReadRA(stateTag)); rate = Mathf.Clamp(rate, 0.05f, 0.95f); if (UnityEngine.Random.Range(0, 1f) < rate) { Success = true; } return(Success); }
/// <summary> /// 全战斗属性百分比增减+-()% /// </summary> /// <param name="ForwardRA">原属性</param> /// <param name="Percent">增加或减少的百分比</param> /// <returns></returns> public static RoleAttributeList RAChangeInPercent(RoleAttributeList ForwardRA, int Percent) { float Decimal = AllRandomSetClass.SimplePercentToDecimal(Percent); RoleAttributeList RA = ForwardRA; for (int i = 0; i < (int)AttributeData.End; i++) { AttributeData Tag = (AttributeData)i; RA.Add((int)(RA.read(Tag) * Decimal), Tag); } for (int i = 0; i < (int)StateTag.End; i++) { StateTag Tag = (StateTag)i; RA.Add((int)(RA.read(Tag) * Decimal), Tag); } return(RA); }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target, NumberData _val) { source.playMoveTowardAnimation(target.unit_model.position); yield return(new WaitForSeconds(moveTowardAndBackTime)); // source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_attack, false); SLEffectManager.Instance.playCommonEffectSlash(target.transform.position); yield return(new WaitForSeconds(SDConstants.AnimTime_ATTACK - hitTime)); // float r = 0; if (_val.dataTag == NumberData.DataType.integer) { r = AllRandomSetClass.SimplePercentToDecimal(_val.DATA); } else { r = _val.DECIMAL; } //目标敌人级别越高成功率越低 int level = target.ThisBasicRoleProperty().LEVEL; for (int i = 0; i < level; i++) { r *= 0.8f; } // if (UnityEngine.Random.Range(0, 1) < r)//捕获成功 { SDDataManager.Instance.AddSlave(target.ThisBasicRoleProperty().ID); target.HpController.FadeAndDisappear(); } source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_idle, true); source.playMoveBackAnimation(); yield return(new WaitForSeconds(moveTowardAndBackTime)); StartCoroutine(IEWaitForEnd(source)); }
public bool AccurHappen;//精准·闪避-判定成功 public void CheckThisSkillCauseAccur(SkillFunction _skill, BattleRoleData _targetUnit) { if (_targetUnit.IsEnemy == IsEnemy) { AccurHappen = true; } else { BasicRoleProperty _target = _targetUnit.ThisBasicRoleProperty(); int baseA = ThisBasicRoleProperty().ReadRA(AttributeData.Accur); int realA = (int)(baseA * AllRandomSetClass.SimplePercentToDecimal(_skill.AccuracyR + 100)); int Evo = _target.ReadRA(AttributeData.Evo); float Rate = AdolescentSet.AccurFunction(realA, Evo); float t = UnityEngine.Random.Range(0, 1f); bool _IsAccur = t < Rate; AccurHappen = _IsAccur; Debug.Log("精准度计算:" + _IsAccur + " || " + t + " " + Rate + "--evo:" + Evo + "--accur:" + realA + "--baseAccur:" + baseA + "--skillAccuracyR:" + _skill.AccuracyR); } }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target, int dmgVal) { source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_cast, false); SLEffectManager.Instance.playCommonEffectCast(source.transform.position); yield return(new WaitForSeconds(castLastTime)); source.playBulletCastAnimation(bullet, source.unit_model.position, target.unit_model.position); yield return(new WaitForSeconds(bulletLastTime)); #region 计算技能状态 source.SkillCheck(this, target); IsCausedCritDmg = source.CritHappen; IsCausedMiss = !source.AccurHappen; IsCausedFault = source.FaultHappen; float criD = 1; if (IsCausedCritDmg) { criD = AllRandomSetClass.SimplePercentToDecimal (source.ThisBasicRoleProperty().CRIDmg + 100); } int NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); #endregion dmgVal = (int)(dmgVal * criD); dmgVal += NowExpect; Debug.Log(source.name + "shoot cause" + dmgVal + " damage to " + target.name); //source.unit_character_model.CurrentCharacterModel.ChangeModelAnim(SDConstants.AnimName_IDLE, true); #region 输技能状态 target.HpController.isCriDmg = IsCausedCritDmg; target.HpController.isEvoHappen = IsCausedMiss; target.HpController.isFault = IsCausedFault; #endregion dmgVal = (int)(dmgVal * AllRandomSetClass.SimplePercentToDecimal(100 + target.PhysModify)); target.HpController.getDamage(dmgVal, _skillKind); yield return(new WaitForSeconds(skillLastTime)); StartCoroutine(IEWaitForEnd(source)); }
public void AddPerc(int figure, StateTag tag) { AllResistData[(int)tag] = (int)(AllResistData[(int)tag] * AllRandomSetClass.SimplePercentToDecimal(100 + figure)); }
//数值修改逻辑 /// <summary> /// 伤害计算逻辑 /// </summary> /// <param name="dmg">伤害量(默认正号)</param> /// <param name="kind">伤害类型(不同防御力)</param> /// <param name="canReduce">能否被减伤</param> public void getDamage(int dmg, SkillKind kind, bool canReduce = true) { if (_unit.IsDead) { return; } if (SDGameManager.Instance.DEBUG_GODLIKE && _characterType == SDConstants.CharacterType.Hero) { dmg = 0; } if (canReduce) { float DmgR = AllRandomSetClass.SimplePercentToDecimal (Mathf.Abs(100 - _unit.ThisBasicRoleProperty().DmgReduction)); dmg = (int)(dmg * DmgR); } //配置额外伤害加成 dmg = _unit.IsEnemy ? _unit.BM.heroToEnemyDmg(dmg) : _unit.BM.enemyToHeroDmg(dmg); //Debug.Log(name + "是否被击中 闪避" + isEvoHappen + " " + "失误" + isFault); if (CurrentShieldHp > 0) { if (isEvoHappen || isFault) { dmg = 0; } //打破护盾 if (dmg >= CurrentShieldHp) { CurrentShieldHp = 0; checkShieldFull(); checkHpFull(); } else { CurrentShieldHp -= dmg; checkShieldFull(); } } else { int def = 0; if (kind == SkillKind.Physical) { def = _unit.ThisBasicRoleProperty()._role.ad; } else if (kind == SkillKind.Elemental) { def = _unit.ThisBasicRoleProperty()._role.md; } else if (kind == SkillKind.Arcane) { def = _unit.ThisBasicRoleProperty()._role.ad / 2 + _unit.ThisBasicRoleProperty()._role.md / 2; } dmg -= def; dmg = Mathf.Max(dmg, SDConstants.MinDamageCount); //添加Buff类建筑的影响 dmg = BattleGroupStateController.setNormalDmgByPlayerData(dmg, kind, _unit); if (isEvoHappen || isFault) { dmg = 0; } showDamageAnimation(dmg); //检测是否死亡 if (dmg >= CurrentHp) { _unit.IsDead = true; CurrentHp = 0; _unit.playDieAnimation(); } else { CurrentHp -= dmg; if (receiveExtraDamage) { getExtraDamage(currentExtraDamage); } else { _unit.playHurtAnimation(); } } checkHpFull(); } // _unit.CheckStatesWithTag_beAtked(); }
public void AddPerc(int percent, AttributeData tag) { AllAttributeData[(int)tag] = (int)(AllAttributeData[(int)tag] * AllRandomSetClass.SimplePercentToDecimal(100 + percent)); }
public IEnumerator IEStartSkill(BattleRoleData source, BattleRoleData target , int physicalVal, int elementalVal, int arcaneVal) { source.unit_character_model.CurrentCharacterModel.ChangeModelAnim (source.unit_character_model.CurrentCharacterModel.anim_cast, false); SLEffectManager.Instance.playCommonEffectCast(source.transform.position); yield return(new WaitForSeconds(castLastTime)); source.playBulletCastAnimation(bullet, source.unit_model.position, target.unit_model.position); yield return(new WaitForSeconds(bulletLastTime)); int d0 = physicalVal; int d1 = elementalVal; int d2 = arcaneVal; #region 计算技能状态 source.SkillCheck(this, target); IsCausedCritDmg = source.CritHappen; IsCausedMiss = !source.AccurHappen; IsCausedFault = source.FaultHappen; if (IsCausedCritDmg) { float criD = AllRandomSetClass.SimplePercentToDecimal (source.ThisBasicRoleProperty().CRIDmg + 100); d0 = (int)(d0 * criD); d1 = (int)(d1 * criD); d2 = (int)(d2 * criD); } #endregion #region Expect int NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); d0 += NowExpect; NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); d1 += NowExpect; NowExpect = (int)(UnityEngine.Random.Range(-1f, 1f) * source.ExpectResult); d2 += NowExpect; #endregion #region 输技能状态 target.HpController.isCriDmg = IsCausedCritDmg; target.HpController.isEvoHappen = IsCausedMiss; target.HpController.isFault = IsCausedFault; #endregion float DECIMAL = AllRandomSetClass.SimplePercentToDecimal(100 + target.PhysModify); d0 = (int)(d0 * DECIMAL); d1 = (int)(d1 * DECIMAL); d2 = (int)(d2 * DECIMAL); Debug.Log(source.name + " slash cause " + d0 + " physical damage " + d1 + " elemental damage " + d2 + " arcane damage" + " to " + target.name); target.HpController.getDamage(d0, SkillKind.Physical); target.HpController.getDamage(d1, SkillKind.Elemental); target.HpController.getDamage(d2, SkillKind.Arcane); yield return(new WaitForSeconds(skillLastTime)); StartCoroutine(IEWaitForEnd(source)); }