示例#1
0
        private void AddHandleToDic(HandlerType type, BaseEvtHandler handler)
        {
            if (!mTypeToHandlerList.TryGetValue(type, out var list))
            {
                list = new List <BaseEvtHandler>();
                mTypeToHandlerList.Add(type, list);
            }

            list.Add(handler);
        }
示例#2
0
        private void InitHandlers()
        {
            foreach (var handlerConfig in mSkillCfg.mEvtHandlerCfgs)
            {
                switch (handlerConfig.mHandlerType)
                {
                case HandlerType.none:
                    LogDC.Log("none handler cfg");
                    break;

                case HandlerType.time:
                {
                    var handler = new TimeEvtHandler();
                    AddHandleToDic(handlerConfig.mHandlerType, handler);
                    mEvthandlerList.Add(handler.SetConfig(handlerConfig).SetSkill(this));
                    break;
                }

                case HandlerType.on_cast_target:
                {
                    var handler = new CastTargetHandler();
                    AddHandleToDic(handlerConfig.mHandlerType, handler);
                    mEvthandlerList.Add(handler.SetConfig(handlerConfig).SetSkill(this));
                    break;
                }

                case HandlerType.after_create:
                {
                    var handler = new BaseEvtHandler();
                    AddHandleToDic(handlerConfig.mHandlerType, handler);
                    mEvthandlerList.Add(handler.SetConfig(handlerConfig).SetSkill(this));
                    break;
                }
                }
            }
            LogDC.LogEx("init handlers ", mTypeToHandlerList.Keys.Count, mEvthandlerList.Count);
        }