/// <summary> /// 技能使用 /// </summary> /// <param name="param"></param> public virtual void OnUse(UseSkillParam param) { this.m_log.Debug("OnUse:" + this.m_unskillId); UseSkillEvent useSkillEvent = new UseSkillEvent(); useSkillEvent.DurationTime = 1f; useSkillEvent.UseSkillParam = param; Singleton <ActEventManager> .singleton.AddEvent(useSkillEvent); }
void OnSkill(int i, InputAction.CallbackContext context) { if (context.phase == InputActionPhase.Performed) { UseSkillEvent.Invoke(i); } if (context.phase == InputActionPhase.Canceled) { CancelSkillEvent.Invoke(i); } }
public static void EventHandler(string script) { var e = new UseSkillEvent(script); switch (script) { case BEFORE_USE_SKILL: BeforeUseSkill(e); break; case AFTER_USE_SKILL: AfterUseSkill(e); break; default: break; } }
public void PublishSkillUsed(EventReceiver receiver, NebulaObject target, PlayerSkill skill, bool success, string message, Hashtable result) { if (skill.IsEmpty) { return; } if (!(nebulaObject)) { return; } if (false == nebulaObject.IsPlayer()) { if (receiver == EventReceiver.OwnerAndSubscriber) { receiver = EventReceiver.ItemSubscriber; } else if (receiver == EventReceiver.ItemOwner) { return; } } skillUseIndex++; if (skillUseIndex == int.MaxValue) { skillUseIndex = 1; } Hashtable data = new Hashtable { { (int)SPC.IsOn, skill.isOn }, { (int)SPC.Data, skill.data.GetInfo() }, { (int)SPC.Source, nebulaObject.Id }, { (int)SPC.SourceType, nebulaObject.Type }, { (int)SPC.Target, target.Id }, { (int)SPC.TargetType, target.Type }, { (int)SPC.IsSuccess, success }, { (int)SPC.Message, message }, { (int)SPC.Info, result }, { (int)SPC.Index, skillUseIndex } }; SendParameters sendParameters = new SendParameters { Unreliable = false, ChannelId = Settings.ItemEventChannel }; UseSkillEvent evt = new UseSkillEvent { Properties = data }; EventData evtData = new EventData((byte)EventCode.UseSkill, evt); var msg = new ItemEventMessage(nebulaObject as Item, evtData, sendParameters); switch (receiver) { case EventReceiver.ItemOwner: ReceiveEvent(evtData, sendParameters); break; case EventReceiver.ItemSubscriber: (nebulaObject as Item).EventChannel.Publish(msg); break; case EventReceiver.OwnerAndSubscriber: ReceiveEvent(evtData, sendParameters); (nebulaObject as Item).EventChannel.Publish(msg); break; } }