public void RemoveListener(ComponentEventName eventName, Action <IComponentEvent> handler)
 {
     if (m_ListenTable.ContainsKey(eventName))
     {
         m_ListenTable[eventName] -= handler;
     }
 }
 public void SendEvent(ComponentEventName eventName, IComponentEvent entityEvent)
 {
     if (m_ListenTable.ContainsKey(eventName))
     {
         m_RecursiveDepth++;
         if (m_RecursiveDepth > RECURSIVE_DEPTH_MAX)
         {
             throw new Exception("SendEvent Recursive Depth is Max");
         }
         if (m_ListenTable[eventName] == null)
         {
             throw new Exception("m_ListenTable[] is null " + eventName);
         }
         try
         {
             m_ListenTable[eventName]?.Invoke(entityEvent);
         }
         catch (Exception ex)
         {
             UnityEngine.Debug.LogException(ex);
             //throw ex;
         }
         finally
         {
             m_RecursiveDepth--;
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// 向当前Entity下的所有Component发送事件
 /// </summary>
 protected void SendEvent(ComponentEventName eventName, IComponentEvent entityEvent)
 {
     if (m_ComponentEventDispatcher == null)
     {
         throw new Exception("m_ComponentEventDispatcher == null");
     }
     m_ComponentEventDispatcher.SendEvent(eventName, entityEvent);
 }
Beispiel #4
0
 /// <summary>
 /// 删除监听事件
 /// </summary>
 /// <param name="eventName"></param>
 /// <param name="handler"></param>
 protected void RemoveListener(ComponentEventName eventName, Action <IComponentEvent> handler)
 {
     if (m_ComponentEventDispatcher == null)
     {
         throw new Exception("m_ComponentEventDispatcher == null");
     }
     m_ComponentEventDispatcher.RemoveListener(eventName, handler);
 }
Beispiel #5
0
    /// <summary>
    /// 向Entity发送事件
    /// </summary>
    /// <param name="entityId"></param>
    /// <param name="eventName"></param>
    /// <param name="entityEvent"></param>
    public void SendEventToEntity(uint entityId, ComponentEventName eventName, IComponentEvent entityEvent)
    {
        BaseEntity entity = GetEntityById <BaseEntity>(entityId);

        if (entity != null)
        {
            entity.SendEvent(eventName, entityEvent);
        }
    }
 public void AddListener(ComponentEventName eventName, Action <IComponentEvent> handler)
 {
     if (!m_ListenTable.ContainsKey(eventName))
     {
         m_ListenTable.Add(eventName, handler);
     }
     else
     {
         m_ListenTable[eventName] += handler;
     }
 }
Beispiel #7
0
    /// <summary>
    /// 像一类Entity发送事件
    /// </summary>
    /// <typeparam name="EntityType"></typeparam>
    /// <param name="eventName"></param>
    /// <param name="entityEvent"></param>
    public void SendEventToEntity <EntityType>(ComponentEventName eventName, IComponentEvent entityEvent) where EntityType : BaseEntity
    {
        Dictionary <ulong, BaseEntity> keyValuePairs;

        if (m_EntityTypeTable.TryGetValue(typeof(EntityType), out keyValuePairs))
        {
            foreach (var entity in keyValuePairs.Values)
            {
                entity.SendEvent(eventName, entityEvent);
            }
        }
    }
Beispiel #8
0
    public override void OnEvent(ComponentEventName eventName, IComponentEvent eventParam)
    {
        if (eventName == ComponentEventName.MSG_SKILL_HIT)
        {
            SkillHitNotification skillHitInfo = eventParam as SkillHitNotification;
            if (skillHitInfo.TargetEntity != m_Buff.BuffProperty.GetOwner())
            {
                return;
            }

            for (int iEffect = 0; iEffect < m_ReactiveVFXList.Count; iEffect++)
            {
                m_ReactiveVFXList[iEffect].OnHit(skillHitInfo.HitPoint);
            }
        }
    }
Beispiel #9
0
 public virtual void OnEvent(ComponentEventName eventName, IComponentEvent eventParam)
 {
 }
Beispiel #10
0
 /// <summary>
 /// 向Entity发送事件对象
 /// </summary>
 /// <typeparam name="EntityType"></typeparam>
 /// <param name="eventName"></param>
 /// <param name="entityEvent"></param>
 protected void SendEventToEntity <EntityType>(ComponentEventName eventName, IComponentEvent entityEvent) where EntityType : BaseEntity
 {
     m_SendEventToEntity.SendEventToEntity <EntityType>(eventName, entityEvent);
 }
Beispiel #11
0
 /// <summary>
 /// 向Entity发送事件对象
 /// </summary>
 /// <param name="entityId"></param>
 /// <param name="eventName"></param>
 /// <param name="entityEvent"></param>
 protected void SendEventToEntity(uint entityId, ComponentEventName eventName, IComponentEvent entityEvent)
 {
     m_SendEventToEntity.SendEventToEntity(entityId, eventName, entityEvent);
 }
Beispiel #12
0
 /// <summary>
 /// 发送事件
 /// </summary>
 /// <param name="eventName"></param>
 /// <param name="entityEvent"></param>
 public void SendEvent(ComponentEventName eventName, IComponentEvent entityEvent)
 {
     m_EntityEventDispatcher.SendEvent(eventName, entityEvent);
 }