using CoreGame; namespace CoreGame.Render { public class Trigger_OnDurationShoot : TriggerBase { // self.fParam1 触发计时器(开始射击时间) // self.fParam2 为上次射击时间 // self.fParam3 为累计触发次数 // triggerCfg.Param1 连续射击阈值 // triggerCfg.Param2 为触发间隔 // triggerCfg.Param3 为累计次数触发条件 // triggerCfg.Param4 为触发后是否重置次数 public override void OnEvent(TriggerSpec self, int eventId, object param1) { if (self.param1.floatVal <= 0) { self.param1.floatVal = GameTime.GetRenderTime(); } if (self.param2.floatVal <= 0) { self.param2.floatVal = GameTime.GetRenderTime(); } if (self.param3.floatVal <= 0) { self.param3.floatVal = 0; } if (GameTime.GetRenderTime() - self.param2.floatVal >= triggerCfg.param1 * 0.0001f) { //距离上次射击大于triggerCfg.Param1/10000重置,持续射击时长 self.param1.floatVal = GameTime.GetRenderTime(); } if (GameTime.GetRenderTime() - self.param1.floatVal >= triggerCfg.param2 * 0.0001f) { //持续射击大于triggerCfg.Param2激活技能 self.param3.floatVal += 1; if (self.param3.floatVal >= triggerCfg.param3) { if (OnTrigger(self, eventId, param1)) { self.param3.floatVal = 0; if (triggerCfg.param4 > 0) { self.param1.floatVal = GameTime.GetRenderTime(); self.param2.floatVal = GameTime.GetRenderTime(); } } } } self.param2.floatVal = GameTime.GetRenderTime(); } public override void Init(TriggerSpec self) { RegEntityEvent(self, ClientEvent.OnDurationShoot); } public override void UnInit(TriggerSpec self) { UnRegEntityEvent(self, ClientEvent.OnDurationShoot); } } }