DurationFunctionEvent.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using UnityEngine;
  2. using System.Collections;
  3. public class DurationFunctionEvent : FunctionEvent
  4. {
  5. //protected float mContinueTime = 0;
  6. //protected float mDuration;
  7. protected int mTotalFrame = 0;
  8. protected int mFrame = 0;
  9. private int effectInstanceId = 0;
  10. protected SkillHitFighterInfo mHitInfo;
  11. public SkillHitFighterInfo HitInfo
  12. {
  13. get { return mHitInfo; }
  14. set { mHitInfo = value; }
  15. }
  16. //伤害类型效果
  17. public bool IsHurtEvent
  18. {
  19. get { return mData.buffType == BattleBuffType.Hurt; }
  20. }
  21. //增益类型效果
  22. public bool IsEnhanceEvent
  23. {
  24. get { return mData.buffType == BattleBuffType.Enhance; }
  25. }
  26. //减益效果类型
  27. public bool IsNegativeEvent
  28. {
  29. get { return mData.buffType == BattleBuffType.Negative; }
  30. }
  31. //特殊效果类型
  32. public bool IsSpecialEvent
  33. {
  34. get { return mData.buffType == BattleBuffType.Special; }
  35. }
  36. //治疗效果类型
  37. public bool IsHealEvent
  38. {
  39. get { return mData.buffType == BattleBuffType.Heal; }
  40. }
  41. public DurationFunctionEvent(BuffFunctionData data):base(data)
  42. {
  43. //mDuration = data.duration;
  44. mTotalFrame = (int)(data.duration * Constants.frame_to_time);
  45. }
  46. public override void Enter(Fighter fighter)
  47. {
  48. if(Data.effectId > 0)
  49. effectInstanceId = EffectManager.Instance.PlayEffect(Data.effectId, fighter, fighter);
  50. if(!string.IsNullOrEmpty(Data.icon))
  51. {
  52. bool debuff = (Data.buffType == BattleBuffType.Negative || Data.buffType == BattleBuffType.SpecialNegative);
  53. }
  54. }
  55. public override void Exit(Fighter fighter)
  56. {
  57. if (effectInstanceId > 0)
  58. {
  59. EffectManager.Instance.RemoveEffectByInstanceID(effectInstanceId);
  60. effectInstanceId = 0;
  61. }
  62. if (Data.endeffectId > 0)
  63. EffectManager.Instance.PlayEffect(Data.endeffectId, fighter, fighter);
  64. }
  65. public virtual void Update(float deltaTime)
  66. {
  67. //mContinueTime += deltaTime;
  68. mFrame++;
  69. }
  70. public virtual bool Expired(Fighter figher)
  71. {
  72. //return mContinueTime >= mDuration;
  73. return mFrame >= mTotalFrame;
  74. }
  75. public void ResetData(BuffFunctionData data)
  76. {
  77. mData = data;
  78. }
  79. public void ResetDuration(float duration)
  80. {
  81. //if(mDuration - mContinueTime < duration)
  82. //{
  83. // //DebugHelper.Log(Data.functionType + " resetduration");
  84. // mDuration = duration;
  85. // mContinueTime = 0;
  86. //}
  87. int frame =(int) (duration * Constants.frame_to_time);
  88. if(mTotalFrame - mFrame < frame)
  89. {
  90. mTotalFrame = frame;
  91. mFrame = 0;
  92. }
  93. }
  94. }