Пример #1
0
	public void clear()
	{
		config=null;
		data=null;
		isUsing=false;
		needRelease=false;
	}
Пример #2
0
    protected void removeEventListener(TriggerConfigData config, int index, TriggerFuncData data)
    {
        SList <TriggerEventRegistData> list = _eventActiveDic.get(data.id);

        if (list == null)
        {
            return;
        }

        TriggerEventRegistData[] values = list.getValues();

        for (int i = list.size() - 1; i >= 0; --i)
        {
            if (values[i].config.id == config.id)
            {
                TriggerEventRegistData eData = list.remove(i);

                if (eData.isUsing)
                {
                    eData.needRelease = true;
                }
                else
                {
                    _eventRegistDataPool.back(eData);
                }
            }
        }
    }
Пример #3
0
    protected void addEventListener(TriggerConfigData config, int index, TriggerFuncData data)
    {
        SList <TriggerEventRegistData> list = _eventActiveDic.computeIfAbsent(data.id, k => new SList <TriggerEventRegistData>());

        TriggerEventRegistData eData = _eventRegistDataPool.getOne();

        eData.config   = config;
        eData.index    = index;
        eData.data     = data;
        eData.priority = config.priority;

        if (list.isEmpty())
        {
            list.add(eData);
        }
        else
        {
            TriggerEventRegistData[] values = list.getValues();
            int idx = Array.BinarySearch(values, 0, list.size(), eData, _comparer);

            if (idx >= 0)
            {
                list.insert(idx, eData);
            }
            else
            {
                list.insert(-idx + 1, eData);
            }
        }
    }
Пример #4
0
        //一定有TriggerConfigData的触发器
        //使用Buff创建的Trigger(也可以传递null)
        public ITriggerItem CreateTrigger(int npcId, int trCfgNum, RtBufData buf)
        {
            TriggerConfigData cfg = triggerLoader.get(trCfgNum);

            Utils.Assert(cfg == null, "Create Trigger is fail because of trigger configure num = " + trCfgNum);
            return(CreateTrigger(cfg.tEvent, npcId, trCfgNum, buf));
        }
Пример #5
0
        /// <summary>
        /// 初始化Trigger的Num
        /// 如果不替换UniqueId,则可以填-1
        /// </summary>
        /// <param name="triggerId">Trigger identifier.</param>
        public void Init(TriggerConfigData config, int uniqueId)
        {
            cfg = config;
            if (uniqueId > 0)
            {
                TriggerId = uniqueId;
            }
            if (cfg != null)
            {
                switch (config.tEnd)
                {
                case TriEnd.Recount:
                    workOnEnd = null;
                    break;

                case TriEnd.Rm_Buff_Trigger:
                    workOnEnd = new RmBuffWithTrigger();
                    break;

                case TriEnd.Rm_Buff_Layer:
                    workOnEnd = null;
                    break;

                case TriEnd.Rm_Trigger:
                    workOnEnd = new RmTrigger();
                    break;
                }
            }
        }
Пример #6
0
    public TriggerInfo AddTriggerInfo(TriggerConfigData data)
    {
        triggerIndexId++;
        TriggerInfo triggerInfo = new TriggerInfo(triggerIndexId);

        triggerInfo.triggerGroup = this;
        triggerInfo.skillInfo    = this.skillInfo;
        triggerInfo.charInfo     = this.skillInfo.charInfo;
        triggerInfo.LoadDataWithConfig(data);
        triggerInfos.Add(triggerInfo);
        return(triggerInfo);
    }
Пример #7
0
    public void LoadDataWithSkill(SkillInfo skillInfo)
    {
        //Debug.Log("LoadDataWithSkill");
        this.skillInfo = skillInfo;
        this.charInfo  = skillInfo.charInfo;
        List <D_SkillEvent> datas = GetSkillAllEvents(skillInfo.triggerId);

        foreach (D_SkillEvent data in datas)
        {
            TriggerConfigData configData = new TriggerConfigData();
            configData.SetInfo(data);
            TriggerInfo trigger = AddTriggerInfo(configData);
        }
    }
Пример #8
0
        public void cast(ServerNPC castor, IEnumerable <ServerNPC> targets, TriggerConfigData triCfg)
        {
                        #if DEBUG
            Utils.Assert(castor == null, "TriggerCastor can't cask if castor is null.");
            Utils.Assert(targets == null, "TriggerCastor can't cask if target is null.");
            Utils.Assert(triCfg == null, "TriggerCastor can't cask if TriggerConfigData is null.");
                        #endif

            RtSkData skill = new RtSkData(triCfg.SkillID, -1);
            targets = filtor(targets, triCfg);
            container.Clear();
            EfCastor.Cast(castor, targets, skill, container, false);
            dispatchMsg(container, skill);
        }
Пример #9
0
    /** 开启trigger */
    public void openTrigger(int id)
    {
        TriggerConfigData config = _configDic.get(id);

        if (config == null)
        {
            throwError("未找到trigger配置", id);
            return;
        }

        if (_openDic.contains(id))
        {
            warnLog("trigger已开启", id);
            return;
        }

        _openDic.put(id, config);


        TriggerFuncData[] events = config.events;
        TriggerFuncData   evt;
        TriggerInstance   instance;

        for (int i = 0; i < events.Length; i++)
        {
            evt = events[i];

            if (evt.id == TriggerEventType.OnInterval)
            {
                instance = getInstance(id);

                TriggerIntervalData iData = _intervalPool.getOne();

                TriggerArg one = _argPool.getOne();
                one.instance  = instance;
                iData.current = iData.delay = getInt(evt.args[0], one);
                _argPool.back(one);

                iData.instance = instance;

                instance.intervalDic.add(iData);
                _timerIntervalDic.add(iData);
            }
            else
            {
                addEventListener(config, i, events[i]);
            }
        }
    }
Пример #10
0
    private TriggerInstance doCreateInstance(int id)
    {
        TriggerConfigData config = _configDic.get(id);

        if (config == null)
        {
            warnLog("不该找不到配置", id);
            return(null);
        }

        TriggerInstance one = _instancePool.getOne();

        one.config = config;
        initInstance(one);
        return(one);
    }
Пример #11
0
        /// <summary>
        /// 筛选,将死亡的,概率上不通过的都去除
        /// </summary>
        /// <param name="targets">Targets.</param>
        /// <param name="triCfg">Tri cfg.</param>
        IEnumerable <ServerNPC> filtor(IEnumerable <ServerNPC> targets, TriggerConfigData triCfg)
        {
            List <ServerNPC> valid = new List <ServerNPC>();

            foreach (ServerNPC bnpc in targets)
            {
                if (bnpc.data.rtData.curHp > 0)
                {
                    bool happend = PseudoRandom.getInstance().happen(triCfg.Prob);
                    if (happend)
                    {
                        valid.Add(bnpc);
                    }
                }
            }
            return(valid.AsEnumerable <ServerNPC>());
        }
Пример #12
0
        ITriggerItem CreateNewTrigger(WarMsg_Type care, int trCfgNum)
        {
            ITriggerItem imp     = null;
            Type         created = null;

            if (Worker.TryGetValue(care, out created))
            {
                imp = (ITriggerItem)Activator.CreateInstance(created);
                TriggerConfigData cfg = null;
                if (trCfgNum > 0)
                {
                    cfg = triggerLoader.get(trCfgNum);
                }

                ((Trigger)imp).Init(cfg, allocIdx++);
            }
            return(imp);
        }
Пример #13
0
    /** 关闭trigger */
    public void closeTrigger(int id)
    {
        TriggerConfigData config = _openDic.remove(id);

        if (config == null)
        {
            warnLog("trigger已关闭", id);
            return;
        }

        TriggerFuncData[] events = config.events;
        TriggerFuncData   evt;
        TriggerInstance   instance;

        for (int i = 0; i < events.Length; i++)
        {
            evt = events[i];

            if (evt.id == TriggerEventType.OnInterval)
            {
                instance = getInstance(id);

                TriggerIntervalData[] keys1 = instance.intervalDic.getKeys();
                TriggerIntervalData   k1;

                for (int i1 = keys1.Length - 1; i1 >= 0; --i1)
                {
                    if ((k1 = keys1[i1]) != null)
                    {
                        _timerIntervalDic.remove(k1);
                        keys1[i1] = null;

                        _intervalPool.back(k1);
                    }
                }

                instance.intervalDic.justClearSize();
            }
            else
            {
                removeEventListener(config, i, evt);
            }
        }
    }
Пример #14
0
    /// <summary>
    /// 复制(潜拷贝)
    /// </summary>
    protected override void toShadowCopy(BaseData data)
    {
        if (!(data is TriggerConfigData))
        {
            return;
        }

        TriggerConfigData mData = (TriggerConfigData)data;

        this.id         = mData.id;
        this.name       = mData.name;
        this.groupType  = mData.groupType;
        this.groupID    = mData.groupID;
        this.isOpen     = mData.isOpen;
        this.priority   = mData.priority;
        this.events     = mData.events;
        this.conditions = mData.conditions;
        this.actions    = mData.actions;
    }
Пример #15
0
    public void LoadDataWithConfig(TriggerConfigData data)
    {
        int index = 0;

        foreach (ConfigData condition in data.conditions)
        {
            index++;
            TriggerCondInfo condInfo = new TriggerCondInfo(index);
            condInfo.triggerInfo = this;
            condInfo.LoadDataWithConfig(condition);
            condInfos.Add(condInfo);
        }
        index = 0;
        foreach (ConfigData effect in data.effects)
        {
            index++;
            TriggerEffectInfo effectInfo = new TriggerEffectInfo(index);
            effectInfo.triggerInfo = this;
            effectInfo.LoadDataWithConfig(effect);
            effectInfos.Add(effectInfo);
        }
    }
Пример #16
0
 public void clear()
 {
     config = null;
 }
Пример #17
0
    /// <summary>
    /// 是否数据一致
    /// </summary>
    protected override bool toDataEquals(BaseData data)
    {
        TriggerConfigData mData = (TriggerConfigData)data;

        if (this.id != mData.id)
        {
            return(false);
        }

        if (this.name != mData.name)
        {
            return(false);
        }

        if (this.groupType != mData.groupType)
        {
            return(false);
        }

        if (this.groupID != mData.groupID)
        {
            return(false);
        }

        if (this.isOpen != mData.isOpen)
        {
            return(false);
        }

        if (this.priority != mData.priority)
        {
            return(false);
        }

        if (mData.events != null)
        {
            if (this.events == null)
            {
                return(false);
            }
            if (this.events.Length != mData.events.Length)
            {
                return(false);
            }
            TriggerFuncData[] eventsT = this.events;
            TriggerFuncData[] eventsR = mData.events;
            int eventsLen             = eventsT.Length;
            for (int eventsI = 0; eventsI < eventsLen; ++eventsI)
            {
                TriggerFuncData eventsU = eventsT[eventsI];
                TriggerFuncData eventsV = eventsR[eventsI];
                if (eventsV != null)
                {
                    if (eventsU == null)
                    {
                        return(false);
                    }
                    if (!eventsU.dataEquals(eventsV))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (eventsU != null)
                    {
                        return(false);
                    }
                }
            }
        }
        else
        {
            if (this.events != null)
            {
                return(false);
            }
        }

        if (mData.conditions != null)
        {
            if (this.conditions == null)
            {
                return(false);
            }
            if (this.conditions.Length != mData.conditions.Length)
            {
                return(false);
            }
            TriggerFuncData[] conditionsT = this.conditions;
            TriggerFuncData[] conditionsR = mData.conditions;
            int conditionsLen             = conditionsT.Length;
            for (int conditionsI = 0; conditionsI < conditionsLen; ++conditionsI)
            {
                TriggerFuncData conditionsU = conditionsT[conditionsI];
                TriggerFuncData conditionsV = conditionsR[conditionsI];
                if (conditionsV != null)
                {
                    if (conditionsU == null)
                    {
                        return(false);
                    }
                    if (!conditionsU.dataEquals(conditionsV))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (conditionsU != null)
                    {
                        return(false);
                    }
                }
            }
        }
        else
        {
            if (this.conditions != null)
            {
                return(false);
            }
        }

        if (mData.actions != null)
        {
            if (this.actions == null)
            {
                return(false);
            }
            if (this.actions.Length != mData.actions.Length)
            {
                return(false);
            }
            TriggerFuncData[] actionsT = this.actions;
            TriggerFuncData[] actionsR = mData.actions;
            int actionsLen             = actionsT.Length;
            for (int actionsI = 0; actionsI < actionsLen; ++actionsI)
            {
                TriggerFuncData actionsU = actionsT[actionsI];
                TriggerFuncData actionsV = actionsR[actionsI];
                if (actionsV != null)
                {
                    if (actionsU == null)
                    {
                        return(false);
                    }
                    if (!actionsU.dataEquals(actionsV))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (actionsU != null)
                    {
                        return(false);
                    }
                }
            }
        }
        else
        {
            if (this.actions != null)
            {
                return(false);
            }
        }

        return(true);
    }
Пример #18
0
    /// <summary>
    /// 复制(深拷贝)
    /// </summary>
    protected override void toCopy(BaseData data)
    {
        if (!(data is TriggerConfigData))
        {
            return;
        }

        TriggerConfigData mData = (TriggerConfigData)data;

        this.id = mData.id;

        this.name = mData.name;

        this.groupType = mData.groupType;

        this.groupID = mData.groupID;

        this.isOpen = mData.isOpen;

        this.priority = mData.priority;

        if (mData.events != null)
        {
            TriggerFuncData[] eventsR = mData.events;
            int eventsLen             = eventsR.Length;
            if (this.events == null || this.events.Length != eventsLen)
            {
                this.events = new TriggerFuncData[eventsLen];
            }
            TriggerFuncData[] eventsT = this.events;
            for (int eventsI = 0; eventsI < eventsLen; ++eventsI)
            {
                TriggerFuncData eventsV = eventsR[eventsI];
                TriggerFuncData eventsU;
                if (eventsV != null)
                {
                    eventsU = (TriggerFuncData)eventsV.clone();
                }
                else
                {
                    eventsU = null;
                    nullObjError("eventsU");
                }

                eventsT[eventsI] = eventsU;
            }
        }
        else
        {
            this.events = null;
            nullObjError("events");
        }

        if (mData.conditions != null)
        {
            TriggerFuncData[] conditionsR = mData.conditions;
            int conditionsLen             = conditionsR.Length;
            if (this.conditions == null || this.conditions.Length != conditionsLen)
            {
                this.conditions = new TriggerFuncData[conditionsLen];
            }
            TriggerFuncData[] conditionsT = this.conditions;
            for (int conditionsI = 0; conditionsI < conditionsLen; ++conditionsI)
            {
                TriggerFuncData conditionsV = conditionsR[conditionsI];
                TriggerFuncData conditionsU;
                if (conditionsV != null)
                {
                    conditionsU = (TriggerFuncData)conditionsV.clone();
                }
                else
                {
                    conditionsU = null;
                    nullObjError("conditionsU");
                }

                conditionsT[conditionsI] = conditionsU;
            }
        }
        else
        {
            this.conditions = null;
            nullObjError("conditions");
        }

        if (mData.actions != null)
        {
            TriggerFuncData[] actionsR = mData.actions;
            int actionsLen             = actionsR.Length;
            if (this.actions == null || this.actions.Length != actionsLen)
            {
                this.actions = new TriggerFuncData[actionsLen];
            }
            TriggerFuncData[] actionsT = this.actions;
            for (int actionsI = 0; actionsI < actionsLen; ++actionsI)
            {
                TriggerFuncData actionsV = actionsR[actionsI];
                TriggerFuncData actionsU;
                if (actionsV != null)
                {
                    actionsU = (TriggerFuncData)actionsV.clone();
                }
                else
                {
                    actionsU = null;
                    nullObjError("actionsU");
                }

                actionsT[actionsI] = actionsU;
            }
        }
        else
        {
            this.actions = null;
            nullObjError("actions");
        }
    }
Пример #19
0
        /// <summary>
        /// 创建触发器,
        /// </summary>
        private ITriggerItem CreateTrigger(WarMsg_Type care, int npcId, int trCfgNum, RtBufData buff)
        {
            int          id  = 0;
            ITriggerItem one = null;

            List <ITriggerItem> idleList = null;

            if (OnIdle.TryGetValue(care, out idleList))
            {
                one = idleList.Count > 0 ? idleList[0] : null;
                if (one == null)
                {
                    //Create the new one
                    one = CreateNewTrigger(care, trCfgNum);
                }
                else
                {
                    idleList.RemoveAt(0);
                    TriggerConfigData cfg = null;
                    if (trCfgNum > 0)
                    {
                        cfg = triggerLoader.get(trCfgNum);
                    }
                    ((Trigger)one).Init(cfg, -1);
                }
            }
            else
            {
                //Create the new one
                one = CreateNewTrigger(care, trCfgNum);
            }

            id = one.GetID();

            List <ITriggerItem> workList = null;

            if (OnWork.TryGetValue(care, out workList))
            {
                workList.Add(one);
            }
            else
            {
                workList = new List <ITriggerItem>();
                workList.Add(one);
                OnWork[care] = workList;
            }

            //挂在Npc上
            ServerNPC npc = WarServerManager.Instance.npcMgr.GetNPCByUniqueID(npcId);

            npc.addTrigger(id);

            ((Trigger)one).HangUpNpcId = npcId;

            //关联的Buff是否存在
            if (buff != null)
            {
                ((Trigger)one).HangUpBuffId = buff.ID;
                buff.TriggerID = id;
            }


            return(one);
        }