Esempio n. 1
0
        public int GetBirthPoint(GameClient client, out int posX, out int posY)
        {
            int result;

            lock (this.RuntimeData.Mutex)
            {
                KuaFuBossBirthPoint birthPoint = null;
                int side = Global.GetRandomNumber(1, this.RuntimeData.MapBirthPointDict.Count);
                if (!this.RuntimeData.MapBirthPointDict.TryGetValue(side, out birthPoint))
                {
                    birthPoint = this.RuntimeData.MapBirthPointDict.First <KeyValuePair <int, KuaFuBossBirthPoint> >().Value;
                }
                posX   = birthPoint.PosX;
                posY   = birthPoint.PosY;
                result = side;
            }
            return(result);
        }
Esempio n. 2
0
        public int GetBirthPoint(GameClient client, out int posX, out int posY)
        {
            int side = 1; //client.ClientData.BattleWhichSide

            lock (RuntimeData.Mutex)
            {
                KuaFuBossBirthPoint birthPoint = null;
                side = Global.GetRandomNumber(1, RuntimeData.MapBirthPointDict.Count);
                if (!RuntimeData.MapBirthPointDict.TryGetValue(side, out birthPoint))
                {
                    birthPoint = RuntimeData.MapBirthPointDict.First().Value;
                }

                posX = birthPoint.PosX;
                posY = birthPoint.PosY;
                return(side);
            }
        }
Esempio n. 3
0
        public bool InitConfig()
        {
            bool   success  = true;
            string fileName = "";

            lock (this.RuntimeData.Mutex)
            {
                try
                {
                    this.RuntimeData.MapBirthPointDict.Clear();
                    fileName = "Config/ThroughServiceBossRebirth.xml";
                    string   fullPathFileName = Global.GameResPath(fileName);
                    XElement xml = XElement.Load(fullPathFileName);
                    IEnumerable <XElement> nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KuaFuBossBirthPoint item = new KuaFuBossBirthPoint();
                        item.ID          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "PosX");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "PosY");
                        item.BirthRadius = (int)Global.GetSafeAttributeLong(node, "BirthRadius");
                        this.RuntimeData.MapBirthPointDict[item.ID] = item;
                    }
                    this.RuntimeData.SceneDataDict.Clear();
                    this.RuntimeData.LevelRangeSceneIdDict.Clear();
                    this.RuntimeData.SceneDynMonsterDict.Clear();
                    fileName         = "Config/ThroughServiceBoss.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        KuaFuBossSceneInfo sceneItem = new KuaFuBossSceneInfo();
                        int id      = (int)Global.GetSafeAttributeLong(node, "MapCode");
                        int mapCode = (int)Global.GetSafeAttributeLong(node, "MapCode");
                        sceneItem.Id               = id;
                        sceneItem.MapCode          = mapCode;
                        sceneItem.MinLevel         = (int)Global.GetSafeAttributeLong(node, "MinLevel");
                        sceneItem.MaxLevel         = (int)Global.GetSafeAttributeLong(node, "MaxLevel");
                        sceneItem.MinZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MinZhuanSheng");
                        sceneItem.MaxZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MaxZhuanSheng");
                        sceneItem.PrepareSecs      = (int)Global.GetSafeAttributeLong(node, "PrepareSecs");
                        sceneItem.WaitingEnterSecs = (int)Global.GetSafeAttributeLong(node, "WaitingEnterSecs");
                        sceneItem.FightingSecs     = (int)Global.GetSafeAttributeLong(node, "FightingSecs");
                        sceneItem.ClearRolesSecs   = (int)Global.GetSafeAttributeLong(node, "ClearRolesSecs");
                        ConfigParser.ParseStrInt2(Global.GetSafeAttributeStr(node, "ApplyTime"), ref sceneItem.SignUpStartSecs, ref sceneItem.SignUpEndSecs, ',');
                        sceneItem.SignUpStartSecs += sceneItem.SignUpEndSecs;
                        if (!ConfigParser.ParserTimeRangeListWithDay(sceneItem.TimePoints, Global.GetSafeAttributeStr(node, "TimePoints"), true, '|', '-', ','))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("读取{0}时间配置(TimePoints)出错", fileName), null, true);
                        }
                        for (int i = 0; i < sceneItem.TimePoints.Count; i++)
                        {
                            TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds);
                            sceneItem.SecondsOfDay.Add(ts.TotalSeconds);
                        }
                        GameMap gameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(mapCode, out gameMap))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("地图配置中缺少{0}所需的地图:{1}", fileName, mapCode), null, true);
                        }
                        RangeKey range = new RangeKey(Global.GetUnionLevel(sceneItem.MinZhuanSheng, sceneItem.MinLevel, false), Global.GetUnionLevel(sceneItem.MaxZhuanSheng, sceneItem.MaxLevel, false), null);
                        this.RuntimeData.LevelRangeSceneIdDict[range] = sceneItem;
                        this.RuntimeData.SceneDataDict[id]            = sceneItem;
                    }
                    fileName         = "Config/ThroughServiceBossMonster.xml";
                    fullPathFileName = Global.GameResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (XElement node in nodes)
                    {
                        BattleDynamicMonsterItem item2 = new BattleDynamicMonsterItem();
                        item2.Id            = (int)Global.GetSafeAttributeLong(node, "ID");
                        item2.MapCode       = (int)Global.GetSafeAttributeLong(node, "CodeID");
                        item2.MonsterID     = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item2.PosX          = (int)Global.GetSafeAttributeLong(node, "X");
                        item2.PosY          = (int)Global.GetSafeAttributeLong(node, "Y");
                        item2.DelayBirthMs  = (int)Global.GetSafeAttributeLong(node, "Time");
                        item2.PursuitRadius = (int)Global.GetSafeAttributeLong(node, "PursuitRadius");
                        item2.Num           = (int)Global.GetSafeAttributeLong(node, "Num");
                        item2.Radius        = (int)Global.GetSafeAttributeLong(node, "Radius");
                        List <BattleDynamicMonsterItem> itemList = null;
                        if (!this.RuntimeData.SceneDynMonsterDict.TryGetValue(item2.MapCode, out itemList))
                        {
                            itemList = new List <BattleDynamicMonsterItem>();
                            this.RuntimeData.SceneDynMonsterDict[item2.MapCode] = itemList;
                        }
                        itemList.Add(item2);
                    }
                }
                catch (Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex, true);
                }
            }
            return(success);
        }