BuffData.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public enum BattleBuffType
  5. {
  6. None = 0,
  7. Hurt = 1, //伤害
  8. Enhance = 2, //增益
  9. Negative = 3, //减益
  10. Special = 4, //特殊
  11. Heal = 5, //治疗
  12. SpecialNegative = 6, //特殊减益
  13. }
  14. public enum BuffHitType
  15. {
  16. Perfect_Dodge = 1, //可完美闪避
  17. Dodge = 2, //可普通闪避
  18. Resist = 4, //可抵抗
  19. Critical = 8, //可暴击
  20. }
  21. public enum Buff_Function_Type
  22. {
  23. Body_Size_Change_Value = 1, // 体型变大/体型变小
  24. Phyx_Damage_Change_Percent = 2, // 物理伤害加成/减免百分比
  25. Magic_Damage_Change_Percent = 3, // 魔法伤害加成/减免百分比
  26. Fixed_Damage_Change_Value = 4, // 固定伤害数值
  27. STR_Change_Percent = 10, // 降低/提升一定比例的STR
  28. STR_Change_Value = 11, // 降低/提升一定数值的STR
  29. INT_Change_Percent = 12, // 降低/提升一定比例的INT
  30. INT_Change_Value = 13, // 降低/提升一定数值的INT
  31. AGI_Change_Percent = 14, // 降低/提升一定比例的AGI
  32. AGI_Change_Value = 15, // 降低/提升一定数值的AGI
  33. Change_MaxHP_Percent = 16, // 降低/提升一定比例的HP
  34. Change_MaxHP_Value = 17, // 降低/提升一定数值的HP
  35. SP_Change_Percent = 18, // 造成以target来源属性为比例的回蓝
  36. SP_Change_Value = 19, // 降低/提升一定数值的SP
  37. Phyx_Defense_Change_Percent = 20, // 降低/提升一定比例的物防
  38. Phyx_Defense_Change_Value = 21, // 降低/提升一定数值的物防
  39. Magic_Defense_Change_Percent = 22, // 降低/提升一定比例的魔防
  40. Magic_Defense_Change_Value = 23, // 降低/提升一定数值的魔防
  41. Invincible = 24, // 无敌
  42. Immunity = 25, // 免疫
  43. Vertigo = 26, // 眩晕
  44. Silence = 27, // 沉默
  45. Forget = 28, // 遗忘
  46. Confusion = 29, // 混乱
  47. Fear = 30, // 恐惧
  48. Frozen = 31, // 冰冻
  49. Heal_Change_Percent = 32, // 治疗增幅/降幅百分比
  50. Sleep = 33, // 睡眠
  51. Stiff = 34, // 石化
  52. Curse = 35, // 诅咒
  53. Poison = 36, // 中毒
  54. Break = 37, // 打断
  55. Forbid_NormalSkill = 38, // 禁止普攻
  56. Clean = 39, // 净化
  57. Disperse = 40, // 驱散
  58. Sneer = 41, // 嘲讽
  59. Heal_Target_HP_Change_Percent = 42, // 治疗目标一定比例的HP
  60. Heal_Target_HP_Change_Value = 43, // 治疗目标一定数值的HP
  61. Summon_Monster = 44, // 召唤一定数量的怪物
  62. Shield_AbsortAttack_Change_Percent = 45, // 一个数值为DEF%的吸收伤害护盾
  63. ChangeHP_FromAttr_Percent = 46, //给目标加一个以来源数值为比例的治疗buff
  64. Shield_AbsortAttack_Fixed_Change_Value = 47, // 一个固定值吸收伤害的护盾
  65. LUK_Change_Value = 48, // 降低/提升固定值的LUK
  66. LUK_Change_Percent = 49, // 降低/提升 一定比例的LUK
  67. AttackCD_Change_Percent = 50, // 降低/提升 一定比例的攻击间隔
  68. AttackCD_Change_Value = 51, // 降低/提升 固定值的间隔
  69. Ten_Change_Percent = 52, // 降低/提升 一定比例的韧性
  70. Ten_Change_Value = 53, // 降低/提升 固定值的韧性
  71. Crit_Change_Percent = 54, // 降低/提升 暴击率百分比
  72. Crit_Change_Value = 55, // 降低/提升 固定值的暴击率
  73. RageStatus = 56, // 狂暴状态
  74. Damage_Change_Percent = 57, // 伤害百分比
  75. ChangeSkill = 58, // 替换技能
  76. Attack_Change_Percent = 59, // 提升/降低 一定比例的物理攻击百分比
  77. Attack_Change_Value = 60, // 提升/降低 一定数值的物理攻击力
  78. MagicAttack_Change_Percent = 61, // 提升/降低 一定比例的魔防攻击百分比
  79. MagicAttack_Change_Value = 62, // 提升/降低 一定数值的魔防攻击力
  80. ChangeSkillSpeed = 63, // 加速/减速技能效果
  81. Change_FromNature__Damage_Percent = 64, // 提升/降低 一定比例源于对应属性的伤害
  82. Change_ToNature_Damage_Percent = 65, // 提升/降低 一定比例面向对应属性的伤害
  83. AttackSpeed_Change_Percent = 66, // 提升/降低 一定比例的攻速百分比
  84. Add_Function_Point_Value = 67, // 获得效果点数值
  85. Deduct_Function_Point_Value = 68, // 扣除点数额外加成
  86. ChangeBuff_Using_Function_Point = 69, // 拥有点数额外加成
  87. Hit_Change_Percent = 70, // 降低/提升一定比例的命中
  88. Hit_Change_Value = 71, // 降低/提升一定数值的命中
  89. Dodge_Change_Percent = 72, // 降低/提升一定比例的闪避
  90. Dodge_Change_Value = 73, // 降低/提升一定数值的闪避
  91. Add_Hurt_From_Caster_Attr = 74, // 造成以自身来源属性为比例的伤害
  92. Add_Hurt_From_Target_Attr = 75, // 造成以目标来源属性为比例的伤害
  93. IgnorePhysicDefense_Change_Value = 76, // 提升/降低一定数值的忽视物防
  94. IgnoreMagicDefense_Change_Value = 77, // 提升/降低一定数值的忽视魔防
  95. Add_Duration_Hurt = 78, // 造成固定值的持续伤害
  96. PhysicDamagePercent_Change_Value = 79, // 提升一定数值的物伤加成百分比
  97. MagicDamagePercent_Change_Value = 80, // 提升一定数值的魔法伤害加成百分比
  98. CritDamagePercent_Change_Value = 81, // 提升/降低一定数值的暴击伤害百分比
  99. PhysicDamageReflectPercent_Change_Value = 82, // 提升/降低一定数值的物理伤害反射百分比
  100. MagicDamageReflectPercent_Change_Value = 83, // 提升/降低一定数值的魔法伤害反射百分比
  101. AntiPhysicDamagePercent_Change_Value = 84, // 提升/降低一定数值的抗物伤加成百分比
  102. AntiMagicDamagePercent_Change_Value = 85, // 提升/降低一定数值的抗魔伤加成百分比
  103. Hurt_Change_Value_From_Caster_STR = 86, // 造成以自身的力量为比例的持续伤害
  104. Hurt_Change_Value_From_Caster_AGI = 87, // 造成以自身的敏捷为比例的持续伤害
  105. Hurt_Change_Value_From_Caster_INT = 88, // 造成以自身的智力为比例的持续伤害
  106. Hurt_Change_Value_From_Caster_VIT = 89, // 造成以自身的体质为比例的持续伤害
  107. Hurt_Change_Value_From_Caster_DEX = 90, // 造成以自身的灵巧为比例的持续伤害
  108. Hurt_Change_Value_From_Caster_LUK = 91, // 造成以自身的幸运为比例的持续伤害
  109. Hurt_Change_Value_From_Caster_HP = 92, // 造成以自身的生命为比例的持续伤害
  110. Hurt_Change_Value_From_Caster_SP = 93, // 造成以自身的蓝量为比例的持续伤害
  111. Hurt_Change_Value_From_Caster_Attack = 94, // 造成以自身的物攻为比例的持续伤害
  112. Hurt_Change_Value_From_Caster_MagicAttack = 95, // 造成以自身的魔攻为比例的持续伤害
  113. Hurt_Change_Value_From_Caster_Defense = 96, // 造成以自身的物防为比例的持续伤害
  114. Hurt_Change_Value_From_Caster_MagicDefense = 97, // 造成以自身的魔防为比例的持续伤害
  115. Hurt_Change_Value_From_Caster_Hit = 98, // 造成以自身的命中为比例的持续伤害
  116. Hurt_Change_Value_From_Caster_Dodge = 99, // 造成以自身的闪避为比例的持续伤害
  117. Hurt_Change_Value_From_Caster_Crit = 100, // 造成以自身的暴击为比例的持续伤害
  118. Hurt_Change_Value_From_Caster_Ten = 101, // 造成以自身的韧性为比例的持续伤害
  119. Hurt_Change_Value_From_Caster_AttackSpeed = 102, //造成以自身的攻击速度为比例的持续伤害
  120. Hurt_Change_Value_From_Caster_MaxHp = 103, // 造成以自身的最大血量为比例的持续伤害
  121. Hurt_Change_Value_From_Caster_MaxSP = 104, // 造成以自身的最大蓝量为比例的持续伤害
  122. Shield_AbsortAttack_Change_Percent_From_Caster = 105, //以caster属性来源为比例的护盾
  123. Heal_Change_Percent_From_Caster = 106, //以caster属性来源为比例的治疗
  124. Heal_Change_Percent_From_Target = 107, //以自身属性来源为比例的治疗
  125. Add_SP_From_Caster = 109, //造成以caster来源属性为比例的回蓝
  126. Hurt_Change_Value_From_Target_HP = 110, // 造成以目标的当前生命为比例的持续伤害
  127. Hurt_Change_Value_From_Target_MaxHP = 111, // 造成以目标的当前生命为比例的持续伤害
  128. PassiveSkill_Trigger = 112, // 被动技能触发效果
  129. Nature_None_Change_Value = 113,
  130. Nature_Water_Change_Value = 114,
  131. Nature_Ground_Change_Value = 115,
  132. Nature_Fire_Change_Value = 116,
  133. Nature_Wind_Change_Value = 117,
  134. Nature_Saint_Change_Value = 118,
  135. Nature_Dark_Change_Value = 119,
  136. Nature_Read_Change_Value = 120,
  137. AntiNature_None_Change_Value = 121,
  138. AntiNature_Water_Change_Value = 122,
  139. AntiNature_Ground_Change_Value = 123,
  140. AntiNature_Fire_Change_Value = 124,
  141. AntiNature_Wind_Change_Value = 125,
  142. AntiNature_Saint_Change_Value = 126,
  143. AntiNature_Dark_Change_Value = 127,
  144. AntiNature_Read_Change_Value = 128,
  145. ChangeHP_From_CasterAttr_Percent = 129, //给caster加一个以来源数值为比例的治疗buff
  146. //---------------------------------------------new
  147. Hurt_Targert_SuckBlood = 130, //回复自身造成目标伤害的比例
  148. Attack_Change_ByTargetAttr = 131, //根据目标属性 提升降低目标物理攻击
  149. MagicAttack_Change_ByTargetAttr = 132, //根据目标属性 提升降低目标魔法攻击
  150. AttackDefense_Change_ByTargetAttr = 133, //根据目标属性 提升降低目标物理防御
  151. MagicDefense_Change_ByTargetAttr = 134, //根据目标属性 提升降低目标魔法防御
  152. Attack_Change_BySourceAttr = 135, //根据施法者属性 提升降低目标物理攻击
  153. MagicAttack_Change_BySourceAttr = 136, //根据施法者属性 提升降低目标魔法攻击
  154. AttackDefense_Change_BySourceAttr = 137, //根据施法者属性 提升降低目标物理防御
  155. MagicDefense_Change_BySourceAttr = 138, //根据施法者属性 提升降低目标魔法防御
  156. Attack_Change_ByTargetCostHpPercent = 139, //根据目标损失血量比例 增加自身攻击
  157. MagicAttack_Change_ByTargetCostHpPercent = 140, //根据目标损失血量比例 增加自身攻击
  158. Attack_Change_BySourceCostHpPercent = 141, //根据施法者损失血量比例 增加自身攻击
  159. MagicAttack_Change_BySourceCostHpPercent = 142, //根据施法者损失血量比例 增加自身攻击
  160. Attack_Change_ByTargetCurHpPercent = 143, //根据目标血量比例 增加自身攻击
  161. MagicAttack_Change_ByTargetCurHpPercent = 144, //根据目标血量比例 增加自身攻击
  162. Attack_Change_BySourceCurHpPercent = 145, //根据施法者血量比例 增加自身攻击
  163. MagicAttack_Change_BySourceCurHpPercent = 146, //根据施法者血量比例 增加自身攻击
  164. Reflect_Hurt_ByTargetAttr = 150, //反弹自身受到傷害给 源伤害 更具目標屬性比例
  165. Reflect_Hurt_BySourceAttr = 151, //反弹自身受到傷害给 源伤害 更具施法者屬性比例
  166. Reflect_Fix_Hurt = 152, //自身受到伤害,反弹固定伤害
  167. Hurt_Attack_SuckDamage = 153, //受到物理伤害吸收护盾
  168. Hurt_MagicAttack_SuckDamage = 154, //受到魔法伤害吸收护盾
  169. Change_Hit_Value = 155, //增加 降低 命中
  170. Change_Doge_Value = 156, //增加 降低 闪避
  171. Change_Crit_Value = 157, //增加 降低 暴击
  172. Change_Ten_Value = 158, //增加 降低 抗暴
  173. //tick
  174. Target_Hurt_FixVal_ByTargetCostHp = 147, //根据目标损失血量 造成目标伤害
  175. Target_Hurt_FixVal_BySourceCostHp = 148, //根据施法者损失血量 造成目标伤害
  176. Target_Hurt_FixVal_BySourceTargetAttrDiff = 149, //根据目标与施法者属性差的比例伤害 造成目标伤害
  177. //----------------------------------------------------------------------
  178. Bullet_BeHurt_Change_Percent = 1000, // 子弹 伤害百分比
  179. Bullet_BeHurt_Change_Value = 10001, // 子弹 伤害数值
  180. }
  181. /// <summary>
  182. /// 概率触发buff结构
  183. /// </summary>
  184. public class TriggerBuffData
  185. {
  186. private int mBuffId;
  187. private float mTriggerRatio;
  188. private BuffTriggerType mTriggerType;
  189. private BuffTriggerCasterType mCasterType;
  190. private float mCD;
  191. private float mLastTriggerTime = 0;
  192. private int mCDFrame = 0;
  193. private int mBuffLevel = 1;
  194. //RunParam
  195. private int mLastTriggerFrame = 0;
  196. private int mTriggeredNum = 0;
  197. private Fix64 mTriggerFrame = Fix64.Zero;
  198. private Fix64 mCurFrame = Fix64.Zero;
  199. public int BuffLevel
  200. {
  201. get { return mBuffLevel; }
  202. set { mBuffLevel = value; }
  203. }
  204. public int BuffId
  205. {
  206. get { return mBuffId; }
  207. }
  208. public float TriggerRatio
  209. {
  210. get { return mTriggerRatio; }
  211. }
  212. public float CD
  213. {
  214. get { return mCD; }
  215. }
  216. public BuffTriggerType TriggerType
  217. {
  218. get { return mTriggerType; }
  219. }
  220. public BuffTriggerCasterType CasterType
  221. {
  222. get { return mCasterType; }
  223. }
  224. public float LastTriggerTime
  225. {
  226. get { return mLastTriggerTime; }
  227. set { mLastTriggerTime = value; }
  228. }
  229. public int LastTriggerFrame
  230. {
  231. get { return mLastTriggerFrame; }
  232. }
  233. private int mCheckVal;
  234. public int CheckVal
  235. {
  236. get { return mCheckVal; }
  237. set { mCheckVal = value; }
  238. }
  239. private string mFunParamStr;
  240. public string FunParamStr
  241. {
  242. get { return mFunParamStr; }
  243. }
  244. private int mExtendParam = 0;
  245. public TriggerBuffData(int id,float ratio,float cd,BuffTriggerType type, BuffTriggerCasterType casterType,string extendParam,string funParam = null)
  246. {
  247. mBuffId = id;
  248. mTriggerRatio = ratio;
  249. mCD = cd;
  250. mTriggerType = type;
  251. mCasterType = casterType;
  252. mCDFrame =(int) (mCD * Constants.frame_to_time);
  253. mFunParamStr = funParam;
  254. if (!string.IsNullOrEmpty(extendParam))
  255. {
  256. int.TryParse(extendParam, out mExtendParam);
  257. if(type == BuffTriggerType.Trigger_FixedTime)
  258. {
  259. mTriggerFrame = (Fix64)mExtendParam * (Fix64)Constants.frame_to_time;
  260. }
  261. }
  262. }
  263. public bool CanTrigger(int frame)
  264. {
  265. if(mLastTriggerFrame != 0)
  266. if (frame - mLastTriggerFrame < mCDFrame) return false;
  267. return CanExcut();
  268. }
  269. public bool CanExcut()
  270. {
  271. float randomValue = BattleMgr.Instance.Battle.RandomValue(true);
  272. return randomValue < mTriggerRatio;
  273. }
  274. public bool CanCheckCondition(Fighter fighter)
  275. {
  276. if(TriggerType == BuffTriggerType.Trigger_Negative_Fun)
  277. {
  278. return fighter.NegativeBuffCnt >= mExtendParam;
  279. }
  280. else if(TriggerType == BuffTriggerType.Trigger_HP_Lower)
  281. {
  282. bool IsTrigger = (SDouble)fighter.Life / fighter.MaxLife * 100 < mExtendParam;
  283. return IsTrigger;
  284. }else if(TriggerType == BuffTriggerType.Trigger_Accumulative_TakeDamage)
  285. {
  286. return fighter.TotalTakeDamage >= mExtendParam && mLastTriggerFrame == 0; //只能执行一次
  287. }else if(TriggerType == BuffTriggerType.Trigger_Multi_Accumulative_TakeDamage)
  288. {
  289. return fighter.TotalTakeDamage >= (mExtendParam * (mTriggeredNum +1));
  290. }
  291. else if (TriggerType == BuffTriggerType.Trigger_Multi_Accumulative_TakeDamage_Precent)
  292. {
  293. int nMaxSetpHp = (int)(fighter.MaxLife * mExtendParam * 0.01f);
  294. return fighter.TotalTakeDamage >= (nMaxSetpHp * (mTriggeredNum + 1));
  295. }
  296. else if (TriggerType == BuffTriggerType.Trigger_Accumulative_TakeDamage_Precent)
  297. {
  298. int nMaxSetpHp = (int)(fighter.MaxLife * mExtendParam * 0.01f);
  299. return fighter.TotalTakeDamage >= nMaxSetpHp && mLastTriggerFrame == 0; //只能执行一次
  300. }
  301. return true;
  302. }
  303. public void DoTrigger(Fighter pFighter, int curFrame)
  304. {
  305. pFighter.CastBuff(null, BuffId, BuffLevel);
  306. mLastTriggerFrame = curFrame;
  307. mTriggeredNum++;
  308. }
  309. public void DoUpdateTrigger(Fighter pFighter, int curFrame)
  310. {
  311. if (TriggerType == BuffTriggerType.Trigger_FixedTime)
  312. {
  313. if(mCurFrame == mTriggerFrame)
  314. {
  315. if(CanExcut())
  316. DoTrigger(pFighter, curFrame);
  317. mCurFrame = Fix64.Zero;
  318. return;
  319. }
  320. mCurFrame += 1;
  321. }
  322. }
  323. public void ResetData()
  324. {
  325. mCurFrame = Fix64.Zero;
  326. mLastTriggerFrame = 0;
  327. mTriggeredNum = 0;
  328. }
  329. }
  330. public class BuffFunctionData
  331. {
  332. public int id;
  333. public BattleBuffType buffType;
  334. public Buff_Function_Type functionType;
  335. public bool canHurtStop; //是否可以伤害打断
  336. public bool forbidMove; //是否影响动作
  337. public bool forbidNormalAttack; //禁止普攻
  338. public bool forbidSkill; //禁止技能释放
  339. public bool canIgnoreDodge; //是否可以闪避
  340. public float intervalTime; //间隔时长
  341. public int[] fromAttr; //来源属性
  342. public string icon; //图标
  343. public int effectId; //特效id
  344. public int endeffectId; //结束特效id
  345. public string word; //文字
  346. public string extendParam;
  347. private int mTargetType = 0; //作用目标类型: 1 施法者, 2 目标
  348. public int TargetType
  349. {
  350. get { return mTargetType; }
  351. set { mTargetType = value; }
  352. }
  353. private int mGroup = 0;
  354. public int Group
  355. {
  356. get { return mGroup; }
  357. }
  358. private float mVal;
  359. private float mDuration;
  360. private float mIncVal;
  361. private float mIncDur;
  362. private int mSkillLv = 1;
  363. public int SkillLv
  364. {
  365. get { return mSkillLv; }
  366. }
  367. //是否为瞬发效果
  368. public bool IsInstantFunc
  369. {
  370. get { return duration <= 0; }
  371. }
  372. public float IncVal
  373. {
  374. get { return mIncVal; }
  375. }
  376. public float value
  377. {
  378. get
  379. {
  380. return mVal + (mSkillLv - 1) * mIncVal;
  381. }
  382. }
  383. public float duration
  384. {
  385. get
  386. {
  387. return mDuration + (mSkillLv - 1) * mIncDur;
  388. }
  389. }
  390. public float BaseValue
  391. {
  392. get { return mVal; }
  393. }
  394. public float BaseDuration
  395. {
  396. get { return mDuration; }
  397. }
  398. public BuffFunctionData(int id, float val, float incVal, float duration, float incDur, int[] fromAttr, float intervalTime,string extendParam)
  399. {
  400. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.FunctionCfgName);
  401. if (dic == null) return;
  402. this.id = id;
  403. this.mVal = val;
  404. this.mIncVal = incVal;
  405. this.mDuration = duration;
  406. this.mIncDur = incDur;
  407. this.fromAttr = fromAttr;
  408. this.intervalTime = intervalTime;
  409. this.extendParam = extendParam;
  410. int temp;
  411. if (dic.ContainsKey("FunctionType"))
  412. {
  413. int.TryParse(dic["FunctionType"], out temp);
  414. functionType = (Buff_Function_Type)temp;
  415. }
  416. if(dic.ContainsKey("BuffType"))
  417. {
  418. int.TryParse(dic["BuffType"], out temp);
  419. this.buffType = (BattleBuffType)temp;
  420. }
  421. if(dic.ContainsKey("HurtStop"))
  422. {
  423. int.TryParse(dic["HurtStop"], out temp);
  424. this.canHurtStop = temp > 0;
  425. }
  426. if(dic.ContainsKey("ForbidMove"))
  427. {
  428. int.TryParse(dic["ForbidMove"], out temp);
  429. this.forbidMove = temp > 0;
  430. }
  431. if(dic.ContainsKey("ForbidAttack"))
  432. {
  433. int.TryParse(dic["ForbidAttack"], out temp);
  434. this.forbidNormalAttack = temp > 0;
  435. }
  436. if(dic.ContainsKey("ForbidSkill"))
  437. {
  438. int.TryParse(dic["ForbidSkill"], out temp);
  439. this.forbidSkill = temp > 0;
  440. }
  441. if(dic.ContainsKey("Dodge"))
  442. {
  443. int.TryParse(dic["Dodge"], out temp);
  444. this.canIgnoreDodge = temp > 0;
  445. }
  446. if(dic.ContainsKey("Icon"))
  447. {
  448. icon = dic["Icon"];
  449. }
  450. if(dic.ContainsKey("Effect"))
  451. {
  452. int.TryParse(dic["Effect"], out effectId);
  453. }
  454. if (dic.ContainsKey("EndEffect"))
  455. {
  456. int.TryParse(dic["EndEffect"], out endeffectId);
  457. }
  458. if (dic.ContainsKey("Word"))
  459. {
  460. word = dic["Word"];
  461. }
  462. if(dic.ContainsKey("Group"))
  463. {
  464. int.TryParse(dic["Group"], out mGroup);
  465. }
  466. }
  467. public void SetLevel(int skillLevel)
  468. {
  469. mSkillLv = skillLevel;
  470. }
  471. public void Dispose()
  472. {
  473. }
  474. }
  475. public class TriggerMarkParam
  476. {
  477. public int markId;
  478. public int markVal;
  479. public int markTargetType;
  480. public TriggerMarkParam(int id, int val, int targetType)
  481. {
  482. this.markId = id;
  483. this.markVal = val;
  484. this.markTargetType = targetType;
  485. }
  486. }
  487. public struct TargetFilterRule
  488. {
  489. public FilterTeamType teamType;
  490. public FilterActorType actorType;
  491. public FilterParamType paramType;
  492. public int paramVal;
  493. public int extendParam1;
  494. public int extendParam2;
  495. public TargetFilterRule(int teamType,int actorType, int paramType,int paramVal,int extendParam1,int extendParam2)
  496. {
  497. this.teamType = (FilterTeamType)teamType;
  498. this.actorType = (FilterActorType)actorType;
  499. this.paramType = (FilterParamType)paramType;
  500. this.paramVal = paramVal;
  501. this.extendParam1 = extendParam1;
  502. this.extendParam2 = extendParam2;
  503. }
  504. public TargetFilterRule(int teamType,int actorType)
  505. {
  506. this.teamType = (FilterTeamType)teamType;
  507. this.actorType = (FilterActorType)actorType;
  508. this.paramType = FilterParamType.Param_Type_None;
  509. this.paramVal = 0;
  510. this.extendParam1 = 0;
  511. this.extendParam2 = 0;
  512. }
  513. public TargetFilterRule(int teamType,int actorType,int paramType,int paramVal)
  514. {
  515. this.teamType = (FilterTeamType)teamType;
  516. this.actorType = (FilterActorType)actorType;
  517. this.paramType = (FilterParamType)paramType;
  518. this.paramVal = paramVal;
  519. this.extendParam1 = 0;
  520. this.extendParam2 = 0;
  521. }
  522. }
  523. public class BuffData
  524. {
  525. public int buffID;
  526. public string buffDescription;
  527. public string icon;
  528. public int totalFrame;
  529. public Target_Select_Rule funTargetType;
  530. public TargetFilterRule filterRule;
  531. public float rate;
  532. public int sortValue;
  533. public int hitType;
  534. public Damage_Type damageType; //伤害类型
  535. public bool ignoreMultiHurt; //是否忽略多段伤害
  536. public float multiHurtIntervalTime;
  537. public int multiHurtCnt;
  538. public string extendFunStr;
  539. public List<ValType> extendBuffs = null;
  540. public bool removeFunAfterStop = false;
  541. public int cloneBossId = 0;
  542. public TriggerMarkParam markData = null;
  543. public List<ValType> markExtendList = null;
  544. protected SkillActionFrameEvent[] mBuffActionFrameEvents;
  545. private List<BuffFunctionData> mBuffFunList = new List<BuffFunctionData>();
  546. public List<BuffFunctionData> BuffFunList
  547. {
  548. get { return mBuffFunList; }
  549. }
  550. public SkillActionFrameEvent[] ActionFrameEvents
  551. {
  552. get { return mBuffActionFrameEvents; }
  553. }
  554. public SkillActionFrameEvent SingFrameEvent = null;
  555. public BuffData(int id, int gender, ProfessionType jobType, int jobStage, int jobBranch)
  556. {
  557. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id, Config.BuffCfgName);
  558. if (dic == null)
  559. {
  560. DebugHelper.LogWarning(string.Format("{0} buff 在buff配表中不存在", id));
  561. mBuffActionFrameEvents = new SkillActionFrameEvent[0];
  562. return;
  563. }
  564. this.buffID = id;
  565. if(dic.ContainsKey("Desc"))
  566. {
  567. buffDescription = dic["Desc"];
  568. }
  569. if(dic.ContainsKey("Icon"))
  570. {
  571. icon = dic["Icon"];
  572. }
  573. int temp;
  574. if (dic.ContainsKey("TargetType"))
  575. {
  576. int.TryParse(dic["TargetType"], out temp);
  577. funTargetType = (Target_Select_Rule)temp;
  578. }
  579. if(dic.ContainsKey("FilterType"))
  580. {
  581. string filterTypeStr = dic["FilterType"];
  582. if(!string.IsNullOrEmpty(filterTypeStr))
  583. {
  584. int[] iVals = StringUtil.split2Int(filterTypeStr, ';');
  585. if(iVals.Length == 2)
  586. {
  587. filterRule = new TargetFilterRule(iVals[0], iVals[1]);
  588. }else if(iVals.Length == 4)
  589. {
  590. filterRule = new TargetFilterRule(iVals[0], iVals[1], iVals[2], iVals[3]);
  591. }else if(iVals.Length == 6)
  592. {
  593. filterRule = new TargetFilterRule(iVals[0], iVals[1], iVals[2], iVals[4], iVals[5], iVals[6]);
  594. }
  595. }
  596. }
  597. if (dic.ContainsKey("HitType"))
  598. {
  599. int.TryParse(dic["HitType"], out hitType);
  600. }
  601. if (dic.ContainsKey("Effectiveness"))
  602. {
  603. float.TryParse(dic["Effectiveness"], out rate);
  604. rate = rate / 10000.0f;
  605. }
  606. if(dic.ContainsKey("DamageType"))
  607. {
  608. int.TryParse(dic["DamageType"], out temp);
  609. damageType = (Damage_Type)temp;
  610. }
  611. if(dic.ContainsKey("IgnoreMultiHurt"))
  612. {
  613. int.TryParse(dic["IgnoreMultiHurt"], out temp);
  614. ignoreMultiHurt = temp > 0;
  615. }
  616. if (dic.ContainsKey("Function"))
  617. {
  618. SetFunData(dic["Function"]);
  619. }
  620. if(dic.ContainsKey("ExtendFunction"))
  621. {
  622. extendFunStr = dic["ExtendFunction"];
  623. }
  624. if (dic.ContainsKey("RemoveFunWhenStop"))
  625. {
  626. int.TryParse(dic["RemoveFunWhenStop"], out temp);
  627. removeFunAfterStop = temp > 0;
  628. }
  629. if(!string.IsNullOrEmpty(extendFunStr))
  630. {
  631. extendBuffs = new List<ValType>();
  632. string[] extendFunList = StringUtil.split(extendFunStr, ';');
  633. for (int idx = 0; idx < extendFunList.Length; idx++)
  634. {
  635. int[] funVals = StringUtil.split2Int(extendFunList[idx], ':');
  636. if(funVals.Length >= 2)
  637. {
  638. ValType valType = new ValType(funVals[1], funVals[0]);
  639. extendBuffs.Add(valType);
  640. }
  641. }
  642. }
  643. if(dic.ContainsKey("Mark"))
  644. {
  645. var tempStr = dic["Mark"];
  646. if(!string.IsNullOrEmpty(tempStr))
  647. {
  648. string[] tempStrList = tempStr.Split(':');
  649. if(tempStrList.Length == 3)
  650. {
  651. int markId, val, targetType;
  652. int.TryParse(tempStrList[0], out markId);
  653. int.TryParse(tempStrList[1], out val);
  654. int.TryParse(tempStrList[2], out targetType);
  655. if(markId > 0)
  656. markData = new TriggerMarkParam(markId,val,targetType);
  657. }
  658. }
  659. }
  660. if(markData!=null)
  661. {
  662. if(dic.ContainsKey("MarkExtend"))
  663. {
  664. var tempStr = dic["MarkExtend"];
  665. if (!string.IsNullOrEmpty(tempStr))
  666. {
  667. markExtendList = new List<ValType>();
  668. string[] tempStrList = tempStr.Split(';');
  669. for(int idx =0; idx < tempStrList.Length;idx++)
  670. {
  671. var str = tempStrList[idx];
  672. string[] tempStrList2 = str.Split(':');
  673. if(tempStrList2.Length == 2)
  674. {
  675. int layer = 0, buffId = 0;
  676. int.TryParse(tempStrList2[0], out layer);
  677. int.TryParse(tempStrList2[1], out buffId);
  678. ValType val = new ValType(layer, buffId);
  679. markExtendList.Add(val);
  680. }
  681. }
  682. }
  683. }
  684. }
  685. LoadEventsData(gender,(int)jobType,jobStage,jobBranch);
  686. }
  687. public void SetFunData(string funStr)
  688. {
  689. if (string.IsNullOrEmpty(funStr)) return;
  690. string[] funStrList = funStr.Split(';');
  691. mBuffFunList = new List<BuffFunctionData>(funStrList.Length);
  692. for (int idx = 0; idx < funStrList.Length; idx++)
  693. {
  694. string[] funTemp = funStrList[idx].Split(':');
  695. if (funTemp.Length < 2) continue;
  696. int funId = 0;
  697. float funVal = 0;
  698. float funIncVal = 0;
  699. float funDuration = 0;
  700. float funIncDuration = 0;
  701. int[] fromAttr = new int[1];
  702. fromAttr[0] = 0;
  703. float intervalTime = 0;
  704. int targetType = 0;
  705. string extendParam = null;
  706. if (funTemp.Length > 1)
  707. {
  708. float[] funValList = StringUtil.split2Float(funTemp[1], '_');
  709. if (funValList.Length > 0)
  710. funVal = funValList[0];
  711. if (funValList.Length > 1)
  712. funIncVal = funValList[1];
  713. }
  714. if (funTemp.Length > 2)
  715. {
  716. float[] funDurList = StringUtil.split2Float(funTemp[2], '_');
  717. if (funDurList.Length > 0)
  718. funDuration = funDurList[0];
  719. if (funDurList.Length > 1)
  720. funIncDuration = funDurList[1];
  721. }
  722. if (funTemp.Length > 3)
  723. {
  724. fromAttr = StringUtil.split2Int(funTemp[3], '_');
  725. }
  726. if (funTemp.Length > 4)
  727. {
  728. float.TryParse(funTemp[4], out intervalTime);
  729. }
  730. if (funTemp.Length > 5)
  731. {
  732. int.TryParse(funTemp[5], out targetType);
  733. }
  734. if (funTemp.Length > 6)
  735. {
  736. extendParam = funTemp[6];
  737. }
  738. if (int.TryParse(funTemp[0], out funId))
  739. {
  740. BuffFunctionData fun = new BuffFunctionData(funId, funVal, funIncVal, funDuration, funIncDuration, fromAttr, intervalTime, extendParam);
  741. fun.TargetType = targetType;
  742. BuffFunList.Add(fun);
  743. }
  744. }
  745. }
  746. void LoadEventsData(int gender, int jobType, int jobStage, int jobBranch)
  747. {
  748. bool calc = false;
  749. SkillActionFrameEvent hitFE = null;
  750. try
  751. {
  752. ActionEventData aeData = SkillActionEventCfgMgr.Instance.GetActionEventData(buffID,gender,jobType,jobStage,jobBranch);
  753. if (aeData == null)
  754. {
  755. DebugHelper.LogError("LoadEventsData:中没有buffID = " + buffID);
  756. mBuffActionFrameEvents = new SkillActionFrameEvent[0];
  757. return;
  758. }
  759. totalFrame = aeData.TotalFrame;
  760. //totalTime = aeData.TotalFrame / Constants.frame_to_time;
  761. List<ActionEventParam> aeParams = aeData.ActionEventList;
  762. if (aeParams == null || aeParams.Count == 0) return;
  763. List<SkillActionFrameEvent> eventList = new List<SkillActionFrameEvent>(aeParams.Count);
  764. for (int idx = 0; idx < aeParams.Count; idx++)
  765. {
  766. ActionEventParam aep = aeParams[idx];
  767. SkillActionFrameEvent frameEventData = new SkillActionFrameEvent(this.buffID);
  768. frameEventData.initStartTime = (Fix64)aep.startFrame / (Fix64)Constants.frame_to_time;
  769. frameEventData.initEndTime = (Fix64)aep.endFrame / (Fix64)Constants.frame_to_time;
  770. frameEventData.initStartFrame = aep.startFrame;
  771. frameEventData.initEndFrame = aep.endFrame;
  772. frameEventData.bAffectBySing = aep.bAffectBySing;
  773. frameEventData.eventType = (SkillActionFrameEventType)aep.eventType;
  774. frameEventData.name = frameEventData.initStartFrame.ToString() + "," + ((int)frameEventData.eventType).ToString();
  775. frameEventData.paramerters = aep.frameParams.ToArray();
  776. eventList.Add(frameEventData);
  777. if (frameEventData.eventType == SkillActionFrameEventType.FE_Skill_Sing)
  778. {
  779. SingFrameEvent = frameEventData;
  780. }
  781. if(frameEventData.eventType == SkillActionFrameEventType.FE_Hit ||
  782. frameEventData.eventType == SkillActionFrameEventType.FE_Bullet)
  783. {
  784. if (hitFE != null && !calc)
  785. {
  786. multiHurtIntervalTime = (frameEventData.initStartFrame - hitFE.initStartFrame) / Constants.frame_to_time;
  787. calc = true;
  788. }
  789. else
  790. {
  791. hitFE = frameEventData;
  792. }
  793. multiHurtCnt++;
  794. }
  795. }
  796. CommonUtil.SortList(eventList, (a, b) => (int)(a.startTime * Constants.frame_to_time) - (int)(b.startTime * Constants.frame_to_time));
  797. mBuffActionFrameEvents = eventList.ToArray();
  798. }
  799. catch (System.Exception e)
  800. {
  801. DebugHelper.LogError("加载buff {0} 的动作帧事件失败:{1}", buffID, e.Message);
  802. mBuffActionFrameEvents = new SkillActionFrameEvent[0];
  803. }
  804. }
  805. private int mBuffLevel = 1;
  806. public int BuffLevel
  807. {
  808. get { return mBuffLevel; }
  809. }
  810. public void SetLevel(int skillLv)
  811. {
  812. mBuffLevel = skillLv;
  813. if (BuffFunList == null) return;
  814. for(int idx =0; idx < BuffFunList.Count;idx++)
  815. {
  816. BuffFunctionData funData = BuffFunList[idx];
  817. funData.SetLevel(skillLv);
  818. }
  819. }
  820. public void Dispose()
  821. {
  822. //清理buff的帧事件数据
  823. if (mBuffActionFrameEvents != null)
  824. {
  825. for (int i = 0; i < mBuffActionFrameEvents.Length; ++i)
  826. {
  827. if (mBuffActionFrameEvents[i] != null)
  828. {
  829. mBuffActionFrameEvents[i].Dispose();
  830. mBuffActionFrameEvents[i] = null;
  831. }
  832. }
  833. mBuffActionFrameEvents = null;
  834. }
  835. }
  836. }