예제 #1
0
        /// <summary>
        /// 加载缓存项
        /// </summary>
        public static void LoadBossAICachingItems(SystemXmlItems systemBossAI)
        {
            Dictionary <string, List <BossAIItem> > bossAICachingDict = new Dictionary <string, List <BossAIItem> >();

            foreach (var key in systemBossAI.SystemXmlItemDict.Keys)
            {
                SystemXmlItem systemXmlItem = systemBossAI.SystemXmlItemDict[(int)key];
                BossAIItem    bossAIItem    = ParseBossAICachingItem(systemXmlItem);
                if (null == bossAIItem) //解析出错
                {
                    continue;
                }

                string strKey = string.Format("{0}_{1}", bossAIItem.AIID, bossAIItem.TriggerType);

                List <BossAIItem> bossAIItemList = null;
                if (!bossAICachingDict.TryGetValue(strKey, out bossAIItemList))
                {
                    bossAIItemList            = new List <BossAIItem>();
                    bossAICachingDict[strKey] = bossAIItemList;
                }

                bossAIItemList.Add(bossAIItem);
            }

            _BossAICachingDict = bossAICachingDict;
        }
예제 #2
0
        private static BossAIItem ParseBossAICachingItem(SystemXmlItem systemXmlItem)
        {
            BossAIItem bossAIItem = new BossAIItem
            {
                ID          = systemXmlItem.GetIntValue("ID", -1),
                AIID        = systemXmlItem.GetIntValue("AIID", -1),
                TriggerNum  = systemXmlItem.GetIntValue("TriggerNum", -1),
                TriggerCD   = systemXmlItem.GetIntValue("TriggerCD", -1),
                TriggerType = systemXmlItem.GetIntValue("TriggerType", -1),
                Desc        = systemXmlItem.GetStringValue("Description")
            };

            bossAIItem.Condition = BossAICachingMgr.ParseCondition(bossAIItem.ID, bossAIItem.TriggerType, systemXmlItem.GetStringValue("Condition"));
            BossAIItem result;

            if (null == bossAIItem.Condition)
            {
                result = null;
            }
            else
            {
                result = bossAIItem;
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// 从xml项中解析Boss AI缓存项
        /// </summary>
        /// <param name="systemXmlItem"></param>
        private static BossAIItem ParseBossAICachingItem(SystemXmlItem systemXmlItem)
        {
            BossAIItem bossAIItem = new BossAIItem()
            {
                ID          = systemXmlItem.GetIntValue("ID"),
                AIID        = systemXmlItem.GetIntValue("AIID"),
                TriggerNum  = systemXmlItem.GetIntValue("TriggerNum"),
                TriggerCD   = systemXmlItem.GetIntValue("TriggerCD"),
                TriggerType = systemXmlItem.GetIntValue("TriggerType"),
                Desc        = systemXmlItem.GetStringValue("Description"),
            };

            bossAIItem.Condition = ParseCondition(bossAIItem.ID, bossAIItem.TriggerType, systemXmlItem.GetStringValue("Condition"));
            if (null == bossAIItem.Condition)
            {
                return(null);
            }

            return(bossAIItem);
        }
예제 #4
0
        public void processEvent(EventObject eventObject)
        {
            //System.Diagnostics.Debug.WriteLine(string.Format("Boss AI Event Listener, EventType={0}", (EventTypes)eventObject.getEventType()));

            List <BossAIItem> bossAIItemList        = null;
            Monster           monster               = null;
            GameClient        gameClient            = null;
            List <BossAIItem> allDeadBossAIItemList = null;

            List <BossAIItem> execBossAIItemList = new List <BossAIItem>();

            if (eventObject.getEventType() == (int)EventTypes.MonsterBirthOn)
            {
                monster = (eventObject as MonsterBirthOnEventObject).getMonster();
                int AIID = monster.MonsterInfo.AIID;

                if (AIID > 0)
                {
                    bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, (int)BossAITriggerTypes.BirthOn);
                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (!monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    continue; //如果不能执行,则跳过
                                }


                                monster.RecBossAI(bossAIItemList[i]);
                                execBossAIItemList.Add(bossAIItemList[i]);
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == (int)EventTypes.MonsterDead)
            {
                monster    = (eventObject as MonsterDeadEventObject).getMonster();
                gameClient = (eventObject as MonsterDeadEventObject).getAttacker();

                int AIID = monster.MonsterInfo.AIID;

                if (AIID > 0)
                {
                    bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, (int)BossAITriggerTypes.Dead);

                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (!monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    continue; //如果不能执行
                                }

                                monster.RecBossAI(bossAIItemList[i]);
                                execBossAIItemList.Add(bossAIItemList[i]);
                            }
                        }
                    }

                    allDeadBossAIItemList = BossAICachingMgr.FindCachingItem(AIID, (int)BossAITriggerTypes.DeadAll);
                    if (null != allDeadBossAIItemList)
                    {
                        for (int i = 0; i < allDeadBossAIItemList.Count; i++)
                        {
                            if (!monster.CanExecBossAI(allDeadBossAIItemList[i]))
                            {
                                continue; //如果不能执行
                            }

                            bool       toContinue    = false;
                            List <int> monsterIDList = (allDeadBossAIItemList[i].Condition as AllDeadCondition).MonsterIDList;
                            for (int j = 0; j < monsterIDList.Count; j++)
                            {
                                List <object> findMonsters = GameManager.MonsterMgr.FindMonsterByExtensionID(monster.CurrentCopyMapID, monsterIDList[j]);
                                if (findMonsters.Count > 0)
                                {
                                    toContinue = true;
                                    break;
                                }
                            }

                            if (toContinue)
                            {
                                continue;
                            }

                            monster.RecBossAI(allDeadBossAIItemList[i]);
                            execBossAIItemList.Add(allDeadBossAIItemList[i]);
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == (int)EventTypes.MonsterInjured)
            {
                monster    = (eventObject as MonsterInjuredEventObject).getMonster();
                gameClient = (eventObject as MonsterInjuredEventObject).getAttacker();

                int AIID = monster.MonsterInfo.AIID;

                if (AIID > 0)
                {
                    bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, (int)BossAITriggerTypes.Injured);

                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (!monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    continue; //如果不能执行
                                }

                                monster.RecBossAI(bossAIItemList[i]);
                                execBossAIItemList.Add(bossAIItemList[i]);
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == (int)EventTypes.MonsterAttacked)
            {
                monster = (eventObject as MonsterAttackedEventObject).getMonster();

                int AIID = monster.MonsterInfo.AIID;

                if (AIID > 0)
                {
                    bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, (int)BossAITriggerTypes.Attacked);

                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (!monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    continue; //如果不能执行
                                }

                                monster.RecBossAI(bossAIItemList[i]);
                                execBossAIItemList.Add(bossAIItemList[i]);
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == (int)EventTypes.MonsterBlooadChanged)
            {
                monster = (eventObject as MonsterBlooadChangedEventObject).getMonster();
                int AIID = monster.MonsterInfo.AIID;

                if (AIID > 0)
                {
                    bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, (int)BossAITriggerTypes.BloodChanged);

                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (!monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    continue; //如果不能执行
                                }

                                double currentLifeVPercent = monster.VLife / monster.MonsterInfo.VLifeMax;
                                bool   canExecActions      = (currentLifeVPercent >= (bossAIItemList[i].Condition as BloodChangedCondition).MinLifePercent && currentLifeVPercent <= (bossAIItemList[i].Condition as BloodChangedCondition).MaxLifePercent);

                                if (canExecActions)
                                {
                                    monster.RecBossAI(bossAIItemList[i]);
                                    execBossAIItemList.Add(bossAIItemList[i]);
                                }
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == (int)EventTypes.MonsterLivingTime)
            {
                monster = (eventObject as MonsterLivingTimeEventObject).getMonster();
                int AIID = monster.MonsterInfo.AIID;

                if (AIID > 0)
                {
                    bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, (int)BossAITriggerTypes.LivingTime);

                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (!monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    continue; //如果不能执行
                                }

                                bool canExecActions = monster.GetMonsterLivingTicks() >= ((bossAIItemList[i].Condition as LivingTimeCondition).LivingMinutes * 60 * 1000);
                                if (canExecActions)
                                {
                                    monster.RecBossAI(bossAIItemList[i]);
                                    execBossAIItemList.Add(bossAIItemList[i]);
                                }
                            }
                        }
                    }
                }
            }

            if (null != execBossAIItemList)
            {
                for (int i = 0; i < execBossAIItemList.Count; i++)
                {
                    BossAIItem             bossAIItem          = execBossAIItemList[i];
                    List <MagicActionItem> magicActionItemList = null;
                    if (GameManager.SystemMagicActionMgr.BossAIActionsDict.TryGetValue(bossAIItem.ID, out magicActionItemList) && null != magicActionItemList)
                    {
                        for (int j = 0; j < magicActionItemList.Count; j++)
                        {
                            MagicAction.ProcessAction(monster, gameClient, magicActionItemList[j].MagicActionID, magicActionItemList[j].MagicActionParams);

                            //向地图中的用户广播特殊提示信息
                            if (!string.IsNullOrEmpty(bossAIItem.Desc))
                            {
                                GameManager.ClientMgr.BroadSpecialHintText(monster.CurrentMapCode, monster.CurrentCopyMapID, bossAIItem.Desc);
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        public void processEvent(EventObject eventObject)
        {
            Monster           monster            = null;
            GameClient        gameClient         = null;
            List <BossAIItem> execBossAIItemList = new List <BossAIItem>();

            if (eventObject.getEventType() == 16)
            {
                monster = (eventObject as MonsterBirthOnEventObject).getMonster();
                int AIID = monster.MonsterInfo.AIID;
                if (AIID > 0)
                {
                    List <BossAIItem> bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, 0);
                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    monster.RecBossAI(bossAIItemList[i]);
                                    execBossAIItemList.Add(bossAIItemList[i]);
                                }
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == 11)
            {
                monster    = (eventObject as MonsterDeadEventObject).getMonster();
                gameClient = (eventObject as MonsterDeadEventObject).getAttacker();
                int AIID = monster.MonsterInfo.AIID;
                if (AIID > 0)
                {
                    List <BossAIItem> bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, 3);
                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    monster.RecBossAI(bossAIItemList[i]);
                                    execBossAIItemList.Add(bossAIItemList[i]);
                                }
                            }
                        }
                    }
                    List <BossAIItem> allDeadBossAIItemList = BossAICachingMgr.FindCachingItem(AIID, 5);
                    if (null != allDeadBossAIItemList)
                    {
                        for (int i = 0; i < allDeadBossAIItemList.Count; i++)
                        {
                            if (monster.CanExecBossAI(allDeadBossAIItemList[i]))
                            {
                                bool       toContinue    = false;
                                List <int> monsterIDList = (allDeadBossAIItemList[i].Condition as AllDeadCondition).MonsterIDList;
                                for (int j = 0; j < monsterIDList.Count; j++)
                                {
                                    List <object> findMonsters = GameManager.MonsterMgr.FindMonsterByExtensionID(monster.CurrentCopyMapID, monsterIDList[j]);
                                    if (findMonsters.Count > 0)
                                    {
                                        toContinue = true;
                                        break;
                                    }
                                }
                                if (!toContinue)
                                {
                                    monster.RecBossAI(allDeadBossAIItemList[i]);
                                    execBossAIItemList.Add(allDeadBossAIItemList[i]);
                                }
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == 17)
            {
                monster    = (eventObject as MonsterInjuredEventObject).getMonster();
                gameClient = (eventObject as MonsterInjuredEventObject).getAttacker();
                int AIID = monster.MonsterInfo.AIID;
                if (AIID > 0)
                {
                    List <BossAIItem> bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, 2);
                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    monster.RecBossAI(bossAIItemList[i]);
                                    execBossAIItemList.Add(bossAIItemList[i]);
                                }
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == 19)
            {
                monster = (eventObject as MonsterAttackedEventObject).getMonster();
                int AIID = monster.MonsterInfo.AIID;
                if (AIID > 0)
                {
                    List <BossAIItem> bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, 4);
                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    monster.RecBossAI(bossAIItemList[i]);
                                    execBossAIItemList.Add(bossAIItemList[i]);
                                }
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == 18)
            {
                monster = (eventObject as MonsterBlooadChangedEventObject).getMonster();
                int AIID = monster.MonsterInfo.AIID;
                if (AIID > 0)
                {
                    List <BossAIItem> bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, 1);
                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    double currentLifeVPercent = monster.VLife / monster.MonsterInfo.VLifeMax;
                                    bool   canExecActions      = currentLifeVPercent >= (bossAIItemList[i].Condition as BloodChangedCondition).MinLifePercent && currentLifeVPercent <= (bossAIItemList[i].Condition as BloodChangedCondition).MaxLifePercent;
                                    if (canExecActions)
                                    {
                                        monster.RecBossAI(bossAIItemList[i]);
                                        execBossAIItemList.Add(bossAIItemList[i]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (eventObject.getEventType() == 20)
            {
                monster = (eventObject as MonsterLivingTimeEventObject).getMonster();
                int AIID = monster.MonsterInfo.AIID;
                if (AIID > 0)
                {
                    List <BossAIItem> bossAIItemList = BossAICachingMgr.FindCachingItem(AIID, 6);
                    if (null != bossAIItemList)
                    {
                        lock (monster.TriggerMutex)
                        {
                            for (int i = 0; i < bossAIItemList.Count; i++)
                            {
                                if (monster.CanExecBossAI(bossAIItemList[i]))
                                {
                                    bool canExecActions = monster.GetMonsterLivingTicks() >= (bossAIItemList[i].Condition as LivingTimeCondition).LivingMinutes * 60L * 1000L;
                                    if (canExecActions)
                                    {
                                        monster.RecBossAI(bossAIItemList[i]);
                                        execBossAIItemList.Add(bossAIItemList[i]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (null != execBossAIItemList)
            {
                for (int i = 0; i < execBossAIItemList.Count; i++)
                {
                    BossAIItem             bossAIItem          = execBossAIItemList[i];
                    List <MagicActionItem> magicActionItemList = null;
                    if (GameManager.SystemMagicActionMgr.BossAIActionsDict.TryGetValue(bossAIItem.ID, out magicActionItemList) && null != magicActionItemList)
                    {
                        for (int j = 0; j < magicActionItemList.Count; j++)
                        {
                            MagicAction.ProcessAction(monster, gameClient, magicActionItemList[j].MagicActionID, magicActionItemList[j].MagicActionParams, -1, -1, 0, 1, -1, 0, 0, -1, 0, false, false, 1.0, 1, 0.0);
                            if (!string.IsNullOrEmpty(bossAIItem.Desc))
                            {
                                GameManager.ClientMgr.BroadSpecialHintText(monster.CurrentMapCode, monster.CurrentCopyMapID, bossAIItem.Desc);
                            }
                        }
                    }
                }
            }
        }