JSGMonsterCardModule.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using CommonAI.Data;
  2. using CommonAI.ZoneServer.JSGModule;
  3. using CommonLang.Log;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using XmdsCommon.JSGModule;
  10. using XmdsCommon.JSGModule.Interface;
  11. using XmdsCommon.Plugin;
  12. using XmdsCommonServer.Plugin;
  13. using CommonAI.Zone.Formula;
  14. using XmdsCommonServer.XLS.Data;
  15. using XmdsCommonServer.Plugin.CardSkill;
  16. using CommonAI.Zone.Helper;
  17. namespace XmdsCommonSkill.Plugin.CardSkill
  18. {
  19. /** 怪物受击,攒卡牌珠技能模块 */
  20. public class JSGMonsterCardModule : JSGCardModuleBase
  21. {
  22. //protected static Logger log = LoggerFactory.GetLogger("JSGPlayerCardModule");
  23. //技能触发数据
  24. private CardSkillData mTriggerSkill;
  25. public JSGMonsterCardModule(XmdsVirtual owner)
  26. {
  27. }
  28. protected override bool OnInit(XmdsVirtual owner, bool notifyClient)
  29. {
  30. if(mCardData == null)
  31. {
  32. mCardData = new JSGMonsterCardData();
  33. }
  34. mTriggerSkill = null;
  35. IJSGCardSkill cardSkill = owner.SkillHelper.GetPlayerSkillById(XmdsComSrvData.BOSS_CARD_SKILLID) as IJSGCardSkill;
  36. if(cardSkill == null)
  37. {
  38. log.Error("JSGMonsterCardModule找不到怪物卡牌技能数据:" + this.mOwner.mUnit.Info.ID);
  39. return false;
  40. }
  41. mTriggerSkill = new CardSkillData(XmdsComSrvData.BOSS_CARD_SKILLID, CardType.Max);
  42. mTriggerSkill.skilLv = 0;
  43. mTriggerSkill.skill = cardSkill;
  44. this.ReSet(true, notifyClient);
  45. return true;
  46. }
  47. protected override void ReSet(bool IsInit, bool notifyClient)
  48. {
  49. base.ReSet(IsInit, notifyClient);
  50. if(!IsInit)
  51. {
  52. this.mCardData.ReSet(this.mOwner);
  53. }
  54. }
  55. public override void OnHitDamage(XmdsVirtual attacker, AttackSource source, int damage, DamageType damageType)
  56. {
  57. if(mTriggerSkill == null || attacker == null || this.mOwner == null || !attacker.IsPlayerUnit() || source.FromSkillType != XmdsSkillType.cardSkill
  58. || mNextGetCardTime > CommonLang.CUtils.localTimeMS || !JSGModule.RandomPrecent(this.mCardCfg.rate))
  59. {
  60. return;
  61. }
  62. this.mNextGetCardTime = CommonLang.CUtils.localTimeMS + this.mCardCfg.interval;
  63. int cardIndex = this.mOwner.mUnit.RandomN.Next() % ((int)CardType.Max);
  64. #if JSG_CARD_TEST
  65. log.Warn("----boss获得卡牌: " + (CardType)cardIndex);
  66. #endif
  67. CardTriggerResult result = mCardData.AddCard(this.mOwner, new GenCardData((CardType)cardIndex, 1));
  68. if(result == null)
  69. {
  70. return;
  71. }
  72. //result.type = CardType.ZhuQue;
  73. #if JSG_CARD_TEST
  74. log.Warn("----boss触发卡牌技能: " + result.type);
  75. #endif
  76. mCardData.SendTriggerInfo(this.mOwner, result, mTriggerSkill.skillId, result.cardData);
  77. mTriggerSkill.type = result.type;
  78. //改成延时触发
  79. //mTriggerSkill.skill.TriggerCardSkill(this.mOwner, attacker, source, mTriggerSkill, result.sameNums);
  80. base.mTriggerSkillDelay.init(mTriggerSkill.skill, this.mOwner, attacker, source, mTriggerSkill, result.sameNums);
  81. }
  82. }
  83. }