| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 | 
							- using System;
 
- using System.Collections.Generic;
 
- using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic;
 
- using Common.Utility.CombatEvent;
 
- using Excel2Json;
 
- using Fort23.Core;
 
- using Fort23.UTool;
 
- using GameLogic.Combat.Hero;
 
- using GameLogic.Combat.Skill;
 
- using GameLogic.Player;
 
- using UnityEngine;
 
- using Utility;
 
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
 
- using Random = System.Random;
 
- namespace GameLogic.Combat.CombatTool
 
- {
 
-     public class CombatCalculateTool : Singleton<CombatCalculateTool>
 
-     {
 
-         public Random Random = new Random();
 
-         static readonly WuXingType[] Symbiosis = new WuXingType[6]
 
-         {
 
-             WuXingType.Water, // 金生水
 
-             WuXingType.Fire, // 木生火
 
-             WuXingType.Wood, // 水生木
 
-             WuXingType.Earth, // 火生土
 
-             WuXingType.Gold, // 土生金
 
-             WuXingType.Null
 
-         };
 
-         // 相克关系表(用位表示)
 
-         static readonly WuXingType[] Restrain = new WuXingType[6]
 
-         {
 
-             WuXingType.Wood, // 金克木
 
-             WuXingType.Earth, // 木克土
 
-             WuXingType.Fire, // 水克火
 
-             WuXingType.Gold, // 火克金
 
-             WuXingType.Water, // 土克水
 
-             WuXingType.Null
 
-         };
 
-         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 float GetVlaueRatioForFloat(float value, float ration)
 
-         {
 
-             float v = (value * ration) / 100f;
 
-             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, ISkillFeatures skillFeatures,
 
-             HarmType harmType = HarmType.Null)
 
-         {
 
-             return Harm(source, target.GetMainHotPoin<CombatHeroHitPoint>(), att,
 
-                 attType, triggerData, WuXingType, skillFeatures, 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, ISkillFeatures skillFeatures,
 
-             HarmType harmType = HarmType.Default)
 
-         {
 
-             HarmReturnInfo harmReturnInfo = CObjectPool.Instance.Fetch<HarmReturnInfo>();
 
-             harmReturnInfo.yuanShiAtt = att;
 
-             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;
 
-             }
 
-             float qiangDu = 100;
 
-             SkillFeaturesData skillFeaturesData = skillFeatures as SkillFeaturesData;
 
-             if (skillFeaturesData != null)
 
-             {
 
-                 qiangDu = (skillFeaturesData.hp * 100) / skillFeaturesData.maxHp;
 
-             }
 
-             harmReturnInfo.QiangDu = qiangDu;
 
-             att = GetVlaueRatioForLong(att, qiangDu);
 
-             float wuxing = source.CurrCombatHeroInfo.GetWuXingShuXing(WuXingType);
 
-             // int index = GeWuXingTypeIndex(WuXingType);
 
-             // WuXingType kzWuXing = Restrain[index];
 
-             // float direnWuXing = target.combatHeroEntity.CurrCombatHeroInfo.GetWuXingShuXing(kzWuXing);
 
-             att = GetVlaueRatioForLong(att, wuxing);
 
-             float def =
 
-                 (target.combatHeroEntity.CurrCombatHeroInfo.defense.Value * 100.0f / source.CurrCombatHeroInfo.k);
 
-             int p1_id = (int)def;
 
-             p1_id = Math.Min(100, Math.Max(1, p1_id));
 
-             MitigationParaConfig mitigationParaConfig = ConfigComponent.Instance.Get<MitigationParaConfig>(p1_id);
 
-             float p1 = (def * mitigationParaConfig.mitigationPara) / 100f;
 
-             att = GetVlaueRatioForLong(att, 100 - p1);
 
-             harmReturnInfo.att = att;
 
-             StartInjuredEventData startInjuredEventData = StartInjuredEventData.Create();
 
-             startInjuredEventData.HarmReturnInfo = harmReturnInfo;
 
-             CombatEventManager.Instance.Dispatch(CombatEventType.StartInjured, startInjuredEventData);
 
-             if (harmReturnInfo.isInvalid)
 
-             {
 
-                 return harmReturnInfo;
 
-             }
 
-             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)
 
-         {
 
-             harmType |= HarmType.Recover;
 
-             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 void ShangSHi(WuXingType wuXingType, ShowBaiscEntity target, int vInjury)
 
-         {
 
-             switch (wuXingType)
 
-             {
 
-                 case WuXingType.Gold:
 
-                     target.CurrCombatHeroInfo.Metal_Injury += vInjury;
 
-                     break;
 
-                 case WuXingType.Wood:
 
-                     target.CurrCombatHeroInfo.Wood_Injury += vInjury;
 
-                     break;
 
-                 case WuXingType.Water:
 
-                     target.CurrCombatHeroInfo.Water_Injury += vInjury;
 
-                     break;
 
-                 case WuXingType.Fire:
 
-                     target.CurrCombatHeroInfo.Fire_Injury += vInjury;
 
-                     break;
 
-                 case WuXingType.Earth:
 
-                     target.CurrCombatHeroInfo.Earth_Injury += vInjury;
 
-                     break;
 
-             }
 
-         }
 
-         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;
 
-         }
 
-         private int GeWuXingTypeIndex(WuXingType e)
 
-         {
 
-             switch (e)
 
-             {
 
-                 case WuXingType.Gold: return 0;
 
-                 case WuXingType.Wood: return 1;
 
-                 case WuXingType.Water: return 2;
 
-                 case WuXingType.Fire: return 3;
 
-                 case WuXingType.Earth: return 4;
 
-                 default: return 5; // 无效元素
 
-             }
 
-         }
 
-         public int GetRestrained(WuXingType WuXingType, WuXingType targetWuXingType)
 
-         {
 
-             int c = 0;
 
-             if (WuXingType.HasFlag(WuXingType.Gold))
 
-             {
 
-                 if (targetWuXingType.HasFlag(WuXingType.Wood))
 
-                 {
 
-                     c++;
 
-                 }
 
-             }
 
-             if (WuXingType.HasFlag(WuXingType.Wood))
 
-             {
 
-                 if (targetWuXingType.HasFlag(WuXingType.Earth))
 
-                 {
 
-                     c++;
 
-                 }
 
-             }
 
-             if (WuXingType.HasFlag(WuXingType.Water))
 
-             {
 
-                 if (targetWuXingType.HasFlag(WuXingType.Fire))
 
-                 {
 
-                     c++;
 
-                 }
 
-             }
 
-             if (WuXingType.HasFlag(WuXingType.Fire))
 
-             {
 
-                 if (targetWuXingType.HasFlag(WuXingType.Gold))
 
-                 {
 
-                     c++;
 
-                 }
 
-             }
 
-             if (WuXingType.HasFlag(WuXingType.Earth))
 
-             {
 
-                 if (targetWuXingType.HasFlag(WuXingType.Wood))
 
-                 {
 
-                     c++;
 
-                 }
 
-             }
 
-             return c;
 
-         }
 
-         public void FaBaoPengZhuang(CombatMagicWeaponEntity a, CombatMagicWeaponEntity b)
 
-         {
 
-             CombatHeroEntity heroEntityA = a.RootMagicWeaponControl.combatHeroEntity;
 
-             CombatHeroEntity heroEntityB = b.RootMagicWeaponControl.combatHeroEntity;
 
-             int myRestrained = GetRestrained(a.WuXingType, b.WuXingType);
 
-             int targetRestrained = GetRestrained(b.WuXingType, a.WuXingType);
 
-             float lg_a = heroEntityA.CurrCombatHeroInfo.GetWuXingShuXing(a.WuXingType);
 
-             float lg_b = heroEntityB.CurrCombatHeroInfo.GetWuXingShuXing(b.WuXingType);
 
-             int c = myRestrained - targetRestrained;
 
-             long myHp = (long)(a.HpBl);
 
-             long targetHp = (long)(b.HpBl);
 
-             float p2 = 100;
 
-             if (c < 0) //a被压制
 
-             {
 
-                 p2 = Mathf.Max(100, Mathf.Min(200, 30 + lg_b - lg_a));
 
-                 targetHp = (long)(targetHp * p2);
 
-             }
 
-             else if (c > 0)
 
-             {
 
-                 p2 = Mathf.Max(100, Mathf.Min(200, 30 + lg_a - lg_b));
 
-                 myHp = (long)(myHp * p2);
 
-             }
 
-             if (myHp > targetHp)
 
-             {
 
-                 myHp -= targetHp;
 
-                 a.HpBl = myHp;
 
-             }
 
-             else if (myHp < targetHp)
 
-             {
 
-                 targetHp -= myHp;
 
-                 b.HpBl = targetHp;
 
-             }
 
-             else if (myHp == targetHp)
 
-             {
 
-                 a.HpBl = 0;
 
-                 b.HpBl = 0;
 
-             }
 
-         }
 
-         public void GongFaPengZhuang(SkillFeaturesData a, SkillFeaturesData b, CombatHeroEntity heroEntityA,
 
-             CombatHeroEntity heroEntityB)
 
-         {
 
-             int myRestrained = GetRestrained(a.WuXingType, b.WuXingType);
 
-             int targetRestrained = GetRestrained(b.WuXingType, a.WuXingType);
 
-             float lg_a = heroEntityA.CurrCombatHeroInfo.GetWuXingShuXing(a.WuXingType);
 
-             float lg_b = heroEntityB.CurrCombatHeroInfo.GetWuXingShuXing(b.WuXingType);
 
-             int c = myRestrained - targetRestrained;
 
-             long myHp = (long)(a.hp);
 
-             long targetHp = (long)(b.hp);
 
-             a.pengZhuangHp=myHp;
 
-             b.pengZhuangHp=targetHp;
 
-             float p2 = 100;
 
-             if (c < 0) //a被压制
 
-             {
 
-                 p2 = Mathf.Max(100, Mathf.Min(200, 130 + lg_b - lg_a));
 
-                 targetHp = GetVlaueRatioForLong(targetHp, p2);
 
-             }
 
-             else if (c > 0)
 
-             {
 
-                 p2 = Mathf.Max(100, Mathf.Min(200, 130 + lg_a - lg_b));
 
-                 myHp = GetVlaueRatioForLong(myHp, p2);
 
-             }
 
-             if (myHp > targetHp)
 
-             {
 
-                 myHp -= targetHp;
 
-                 a.hp = myHp;
 
-                 b.hp = 0;
 
-             }
 
-             else if (myHp < targetHp)
 
-             {
 
-                 targetHp -= myHp;
 
-                 b.hp = targetHp;
 
-                 a.hp = 0;
 
-             }
 
-             else if (myHp == targetHp)
 
-             {
 
-                 a.hp = 0;
 
-                 b.hp = 0;
 
-             }
 
-             GongFaPengZhuangFinishEventData gongFaPengZhu = GongFaPengZhuangFinishEventData.Create();
 
-             gongFaPengZhu.a = a;
 
-             gongFaPengZhu.b = b;
 
-             CombatEventManager.Instance.Dispatch(CombatEventType.GongFaPengZhuangFinish, gongFaPengZhu,false);
 
-             CombatEventManager.Instance.Dispatch(CombatEventType.GongFaPengZhuangFinish2, gongFaPengZhu);
 
-         }
 
-         /// <summary>
 
-         /// 是否相生
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public bool IsSymbiosis(WuXingType a, WuXingType b)
 
-         {
 
-             int index = GeWuXingTypeIndex(a);
 
-             if (index < 0)
 
-             {
 
-                 return false;
 
-             }
 
-             return (b & Symbiosis[index]) != 0;
 
-         }
 
-         /// <summary>
 
-         /// 是否相克制
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public bool IsRestrain(WuXingType a, WuXingType b)
 
-         {
 
-             int index = GeWuXingTypeIndex(a);
 
-             if (index < 0)
 
-             {
 
-                 return false;
 
-             }
 
-             return (b & Restrain[index]) != 0;
 
-         }
 
-         public Color GetColor(WuXingType wuXingType)
 
-         {
 
-             switch ((int)wuXingType)
 
-             {
 
-                 case 1:
 
-                     return new Color(1f, 0.98f, 0.09f);
 
-                     break;
 
-                 case 2:
 
-                     return new Color(0.19f, 0.51f, 1f);
 
-                     break;
 
-                 case 4:
 
-                     return new Color(0.17f, 1f, 0.35f);
 
-                     break;
 
-                 case 8:
 
-                     return new Color(1f, 0.19f, 0.04f);
 
-                     break;
 
-                 case 16:
 
-                     return new Color(1f, 0.65f, 0.17f);
 
-                     break;
 
-             }
 
-             return Color.white;
 
-         }
 
-         public Color GetColor(int wuXingType)
 
-         {
 
-             switch ((int)wuXingType)
 
-             {
 
-                 case 1:
 
-                     return new Color(1f, 0.98f, 0.09f);
 
-                     break;
 
-                 case 2:
 
-                     return new Color(0.19f, 0.51f, 1f);
 
-                     break;
 
-                 case 3:
 
-                     return new Color(0.17f, 1f, 0.35f);
 
-                     break;
 
-                 case 4:
 
-                     return new Color(1f, 0.19f, 0.04f);
 
-                     break;
 
-                 case 5:
 
-                     return new Color(1f, 0.65f, 0.17f);
 
-                     break;
 
-             }
 
-             return Color.white;
 
-         }
 
-     }
 
- }
 
 
  |