| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 | using System;using System.Collections.Generic;using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;using Excel2Json;using Fort23.Core;using GameLogic.Combat.Hero;using GameLogic.Player;using Utility;using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;namespace GameLogic.Combat.CombatTool{    public class CombatCalculateTool : Singleton<CombatCalculateTool>    {        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 int GetVlaueRatioForInt(int value, float ration)        {            int v = (value * (int)(ration * 100)) / 10000;            return v;        }        public HarmReturnInfo Harm(CombatHeroEntity source, CombatHeroEntity target, long att, AttType attType,            TriggerData triggerData,WuXingType WuXingType, HarmType harmType = HarmType.Null)        {            return Harm(source, target.GetMainHotPoin<CombatHeroHitPoint>(), att,                attType, triggerData,WuXingType, harmType);        }        /// <summary>        /// 造成伤害        /// </summary>n        /// <param name="source">攻击方</param>        /// <param name="target">被攻击方</param>        /// <param name="att">伤害值</param>        public HarmReturnInfo Harm(CombatHeroEntity source, CombatHeroHitPoint target, long att,            AttType attType, TriggerData triggerData,WuXingType WuXingType,            HarmType harmType = HarmType.Default)        {                       HarmReturnInfo harmReturnInfo = CObjectPool.Instance.Fetch<HarmReturnInfo>();            harmReturnInfo.source = source;            harmReturnInfo.target = target;            harmReturnInfo.att = att;            harmReturnInfo.attType = attType;            harmReturnInfo.WuXingType= WuXingType;            harmReturnInfo.harmType = harmType;            harmReturnInfo.triggerData = triggerData;            if (target.combatHeroEntity.isDie)            {                return harmReturnInfo;            }            if (CombatController.currActiveCombat.IsGameOver)            {                return harmReturnInfo;            }            if (target.combatHeroEntity.CombatAIBasic.stateControl.CurrStateName.Equals(CombatHeroStateType.rolling))            {                harmReturnInfo.isMiss = true;                return harmReturnInfo;            }                                harmReturnInfo.att = att;            target.combatHeroEntity.This<CombatHeroEntity>().HeroHurt(harmReturnInfo);            return harmReturnInfo;        }        public HarmReturnInfo TrueHarm(CombatHeroEntity source, CombatHeroHitPoint target, long att,            AttType attType, TriggerData triggerData,            HarmType harmType = HarmType.Default)        {            HarmReturnInfo harmReturnInfo = CObjectPool.Instance.Fetch<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.This<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.This<CombatHeroEntity>().Recover(harmReturnInfo);            return harmReturnInfo;        }        public ILifetCycleHitPoint[] GetMinHpHero(ILifetCycleHitPoint[] allLifetCycleHitPoints, int count)        {            if (allLifetCycleHitPoints == null)            {                return null;            }            BetterList<ILifetCycleHitPoint> findHero = new BetterList<ILifetCycleHitPoint>();            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<CombatHeroEntity>();                for (int j = 0; j < findHero.Count; j++)                {                    CombatHeroEntity lifetCycleHitPoint2 =                        findHero[j].IfLifeCycle.This<CombatHeroEntity>();                    if (lifetCycleHitPoint2.HpBl < lifetCycleHitPoint.HpBl)                    {                        lifetCycleHitPoint = lifetCycleHitPoint2;                        index = j;                    }                }                ILifetCycleHitPoint currFindHitPoint = lifetCycleHitPoint.GetMainHotPoin<ILifetCycleHitPoint>(true);                minHpHero[k] = currFindHitPoint;                findHero.RemoveAt(index);            }            return minHpHero;        }    }}
 |