JSNextCardSkillStrengthenhModule.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using CommonAI.Data;
  2. using CommonLang.Log;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using XmdsCommonServer.XLS.Data;
  9. using XmdsCommonSkill.Plugin.CardSkill;
  10. namespace XmdsCommonServer.Plugin.CardSkill.PlayerCardSkill
  11. {
  12. //下一次卡牌技能强化
  13. public class JSNextCardSkillStrengthenhModule
  14. {
  15. protected static Logger sLog = LoggerFactory.GetLogger("JSNextCardSkillStrengthenhModule");
  16. // 本次强化效果: 可能存在多个累加
  17. private CardStrengthData[] mCardStrengthInfo = new CardStrengthData[(int)CardStrengthenType.Max + 1];
  18. //下次强化加成
  19. private List<NextCardStrengthenInfo> mStrengthenList = new List<NextCardStrengthenInfo>();
  20. //---------------------------------------------- --------------------------------------------------------------------
  21. //---------------------------------------------特殊效果数据记录--------------------------------------------------------
  22. //-------------------------------------------------------------------------------------------------------------------
  23. public void Update(XmdsVirtual player)
  24. {
  25. for (int i = mStrengthenList.Count - 1; i >= 0; i--)
  26. {
  27. NextCardStrengthenInfo data = mStrengthenList[i];
  28. if (data.validTime <= CommonLang.CUtils.localTimeMS || data.validTimes == 0)
  29. {
  30. //如果绑定buff
  31. if (data.bindBuffID > 0 && data.validTimes <= 0)
  32. {
  33. player.mUnit.removeBuff(data.bindBuffID);
  34. }
  35. mStrengthenList.RemoveAt(i);
  36. }
  37. }
  38. }
  39. public void Init()
  40. {
  41. for (int i = 0; i <= (int)CardStrengthenType.Max; i++)
  42. {
  43. if (mCardStrengthInfo[i] == null)
  44. {
  45. mCardStrengthInfo[i] = new CardStrengthData();
  46. mCardStrengthInfo[i].data = new IntIntData();
  47. }
  48. }
  49. }
  50. public void ReSet()
  51. {
  52. for (int i = 0; i <= (int)CardStrengthenType.Max; i++)
  53. {
  54. mCardStrengthInfo[i].type = CardStrengthenType.None;
  55. }
  56. this.mStrengthenList.Clear();
  57. }
  58. public NextCardStrengthenInfo AddStrength(CardType type, CardStrengthenType strenghType, int value1, int value2, int validTime, int validTimes = -1,
  59. byte needSames = 0, DamageType dmgType = DamageType.None, CardLayerRule layerRules = null)
  60. {
  61. long validEndTime = validTime + CommonLang.CUtils.localTimeMS;
  62. //this.SetAllStrengthTimeByType(strenghType, validEndTime, validTimes);
  63. NextCardStrengthenInfo data = new NextCardStrengthenInfo();
  64. data.layerRules = layerRules;
  65. data.pointCard = type;
  66. data.needSames = needSames;
  67. data.needDmgType = dmgType;
  68. data.type = strenghType;
  69. data.value1 = value1;
  70. data.value2 = value2;
  71. data.validTime = validEndTime;
  72. data.validTimes = validTimes;
  73. //data.bindBuffID = bindBuffID;
  74. do
  75. {
  76. if (data.layerRules == null) { break; }
  77. if (!data.layerRules.IsValid())
  78. {
  79. sLog.Error("AddStrength异常:" + type + ", " + strenghType + ", " + data);
  80. return null;
  81. }
  82. NextCardStrengthenInfo oldData = this.GetStrengthInfoByUniqueID(data.layerRules.uniqueID);
  83. if (oldData == null) { break; }
  84. if (data.layerRules.layerType == CardLayerType.Replace)
  85. {
  86. //针对那种多个覆盖形式的
  87. oldData.Replace(data);
  88. //System.Console.WriteLine("伤害覆盖:" + data.value2 + " -> " + oldData.value2);
  89. return oldData;
  90. }
  91. else if(data.layerRules.layerType == CardLayerType.Layers)
  92. {
  93. //针对叠层
  94. oldData.AddLayers(data);
  95. //System.Console.WriteLine("伤害叠层:" + data.value2 + " -> " + oldData.value2);
  96. return oldData;
  97. }
  98. } while (false);
  99. this.mStrengthenList.Add(data);
  100. return data;
  101. }
  102. private NextCardStrengthenInfo GetStrengthInfoByUniqueID(int uniqueID)
  103. {
  104. foreach (NextCardStrengthenInfo info in this.mStrengthenList)
  105. {
  106. if (info.layerRules != null && info.layerRules.uniqueID == uniqueID)
  107. {
  108. return info;
  109. }
  110. }
  111. return null;
  112. }
  113. //private void SetAllStrengthTimeByType(CardStrengthenType strenghType, long validTime, int validTimes)
  114. //{
  115. // 重置剩余层数的所有时间
  116. // if (strenghType != CardStrengthenType.DmgLayer)
  117. // {
  118. // return;
  119. // }
  120. // for (int i = 0; i < mStrengthenList.Count; i++)
  121. // {
  122. // NextCardStrengthenInfo data = mStrengthenList[i];
  123. // if (data.type == strenghType)
  124. // {
  125. // data.validTime = validTime;
  126. // data.validTimes = validTimes;
  127. // }
  128. // }
  129. //}
  130. //重置当前强化效果
  131. public void TriggerSkillLoadStrength(CardSkillData skillData, int sameNums)
  132. {
  133. for (int i = 1; i < (int)CardStrengthenType.Max; i++)
  134. {
  135. if (this.GetStrengthInfo(skillData.type, (CardStrengthenType)i, sameNums, skillData.dmgType, mCardStrengthInfo[i].data))
  136. {
  137. mCardStrengthInfo[i].type = (CardStrengthenType)i;
  138. }
  139. else
  140. {
  141. mCardStrengthInfo[i].type = CardStrengthenType.None;
  142. mCardStrengthInfo[i].data.ReSet();
  143. }
  144. }
  145. }
  146. public IntIntData GetStrengthInfo(CardStrengthenType strgnthenType)
  147. {
  148. return mCardStrengthInfo[(int)strgnthenType].data;
  149. }
  150. //获得强化加成效果
  151. private bool GetStrengthInfo(CardType cardType, CardStrengthenType strgnthenType, int sameNums, DamageType dmgType, IntIntData strengthenInfo)
  152. {
  153. //处理卡牌珠生成逻辑,优先处理最近的
  154. bool process = false;
  155. for (int i = mStrengthenList.Count - 1; i >= 0; i--)
  156. {
  157. NextCardStrengthenInfo data = mStrengthenList[i];
  158. if (data.pointCard != CardType.Max && data.pointCard != cardType)
  159. {
  160. continue;
  161. }
  162. else if (strgnthenType != data.type || data.validTime < CommonLang.CUtils.localTimeMS || data.validTimes == 0)
  163. {
  164. continue;
  165. }
  166. else if (data.needSames > 0 && sameNums < data.needSames)
  167. {
  168. continue;
  169. }
  170. else if (data.needDmgType != DamageType.None && data.needDmgType != dmgType)
  171. {
  172. continue;
  173. }
  174. if (data.validTimes > 0) { data.validTimes--; }
  175. //特殊模块的特殊处理
  176. process = true;
  177. if (data.layerRules != null && data.layerRules.layerType == CardLayerType.Layers)
  178. {
  179. // 仅层数叠加
  180. strengthenInfo.value1 = data.value1 * data.value2;
  181. strengthenInfo.value2 += data.value2;
  182. }
  183. else
  184. {
  185. strengthenInfo.value1 += data.value1;
  186. strengthenInfo.value2 += data.value2;
  187. }
  188. }
  189. return process;
  190. }
  191. }
  192. }