using System; using System.Collections.Generic; using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic; using Excel2Json; using Fort23.Core; using GameLogic.Combat.Hero; using Utility; using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface; namespace GameLogic.Combat.CombatTool { public class CombatCalculateTool : Singleton { public Random Random = new Random(); public CombatCalculateTool() { Random = new Random(System.DateTime.Now.Millisecond); } public int GetOdd() { return Random.Next(0, 100); } public int GetOdd(int min, int max) { return Random.Next(min, max); } public long GetVlaueRatioForLong(long value, float ration) { long v = (value * (long)(ration * 100)) / 10000; return v; } public HarmReturnInfo Harm(CombatHeroEntity source, CombatHeroEntity target, long att, AttType attType, TriggerData triggerData, HarmType harmType = HarmType.Null) { return Harm(source, target.GetMainHotPoin(), att, attType, triggerData, harmType); } /// /// 造成伤害 /// n /// 攻击方 /// 被攻击方 /// 伤害值 public HarmReturnInfo Harm(CombatHeroEntity source, CombatHeroHitPoint target, long att, AttType attType, TriggerData triggerData, HarmType harmType = HarmType.Default) { HarmReturnInfo harmReturnInfo = CObjectPool.Instance.Fetch(); harmReturnInfo.source = source; harmReturnInfo.target = target; harmReturnInfo.att = att; harmReturnInfo.attType = attType; harmReturnInfo.harmType = harmType; harmReturnInfo.triggerData = triggerData; if (target.combatHeroEntity.isDie) { return harmReturnInfo; } if (target.combatHeroEntity.CombatAIBasic.stateControl.CurrStateName.Equals(CombatHeroStateType.rolling)) { harmReturnInfo.isMiss = true; return harmReturnInfo; } att = att - target.combatHeroEntity.CurrCombatHeroInfo.defense.Value; int odd = GetOdd(0, 100); if (odd <= source.CurrCombatHeroInfo.crit + 5) { harmReturnInfo.harmType |= HarmType.BaoJi; att += GetVlaueRatioForLong(att, source.CurrCombatHeroInfo.critDamage.Value); } harmReturnInfo.att = att; target.combatHeroEntity.HeroHurt(harmReturnInfo); return harmReturnInfo; } public HarmReturnInfo Recover(CombatHeroEntity source, CombatHeroHitPoint target, long att, AttType attType, HarmType harmType, TriggerData triggerData) { HarmReturnInfo harmReturnInfo = new HarmReturnInfo(); harmReturnInfo.source = source; harmReturnInfo.target = target; harmReturnInfo.att = att; harmReturnInfo.attType = attType; harmReturnInfo.harmType = harmType; harmReturnInfo.triggerData = triggerData; if (target.combatHeroEntity.isDie) { return harmReturnInfo; } target.combatHeroEntity.Recover(harmReturnInfo); return harmReturnInfo; } public ILifetCycleHitPoint[] GetMinHpHero(ILifetCycleHitPoint[] allLifetCycleHitPoints, int count) { if (allLifetCycleHitPoints == null) { return null; } BetterList findHero = new BetterList(); findHero.AddRange(allLifetCycleHitPoints); int currCount = Math.Min(allLifetCycleHitPoints.Length, count); ILifetCycleHitPoint[] minHpHero = new ILifetCycleHitPoint[currCount]; for (int k = 0; k < currCount; k++) { CombatHeroEntity lifetCycleHitPoint = null; int index = 0; if (findHero.Count <= 0) { return minHpHero; } lifetCycleHitPoint = findHero[0].IfLifeCycle.This(); for (int j = 0; j < findHero.Count; j++) { CombatHeroEntity lifetCycleHitPoint2 = findHero[j].IfLifeCycle.This(); if (lifetCycleHitPoint2.HpBl < lifetCycleHitPoint.HpBl) { lifetCycleHitPoint = lifetCycleHitPoint2; index = j; } } ILifetCycleHitPoint currFindHitPoint = lifetCycleHitPoint.GetMainHotPoin(true); minHpHero[k] = currFindHitPoint; findHero.RemoveAt(index); } return minHpHero; } } }