Exemplo n.º 1
0
        public bool InitConfig()
        {
            bool   success  = true;
            string fileName = "";

            lock (this.RuntimeData.Mutex)
            {
                try
                {
                    Dictionary <int, WanMoXiaGuMonsterConfigInfo> dict = new Dictionary <int, WanMoXiaGuMonsterConfigInfo>();
                    fileName = Global.GameResPath("Config/WanMoXiaGu.xml");
                    XElement xml = CheckHelper.LoadXml(fileName, true);
                    if (null == xml)
                    {
                        return(false);
                    }
                    foreach (XElement xmlItem in xml.Elements())
                    {
                        if (xmlItem != null)
                        {
                            WanMoXiaGuMonsterConfigInfo config = new WanMoXiaGuMonsterConfigInfo();
                            config.ID                 = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "ID", "0"));
                            config.MonsterID          = ConfigHelper.GetElementAttributeValueIntArray(xmlItem, "MonstersID", null);
                            config.MonstersNum        = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MonstersNum", "0"));
                            config.BeginNum           = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "BeginNum", "0"));
                            config.EndNum             = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "EndNum", "0"));
                            this.RuntimeData.BeginNum = Math.Min(this.RuntimeData.BeginNum, config.BeginNum);
                            this.RuntimeData.EndNum   = Math.Max(this.RuntimeData.EndNum, config.EndNum);
                            string[] pts = Global.GetDefAttributeStr(xmlItem, "Site", "0,0").Split(new char[]
                            {
                                '|'
                            });
                            config.Site = new List <int>();
                            foreach (string pt in pts)
                            {
                                config.Site.AddRange(ConfigHelper.String2IntList(pt, ','));
                            }
                            config.Props       = Global.GetDefAttributeStr(xmlItem, "Props", "");
                            config.Intro       = Global.GetDefAttributeStr(xmlItem, "Intro", "");
                            config.RecoverTime = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "RecoverTime", "0"));
                            config.RecoverNum  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "RecoverNum", "0"));
                            config.Decorations = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "Decorations", "0"));
                            dict.Add(config.ID, config);
                        }
                    }
                    this.RuntimeData.MonsterOrderConfigList = dict;
                    this.RuntimeData.AwardList = ConfigHelper.ParserIntArrayList(GameManager.systemParamsList.GetParamValueByName("WanMoXiaGuAward"), true, '|', ',');
                    double[] arr = GameManager.systemParamsList.GetParamValueDoubleArrayByName("WanMoXiaGuCall", ',');
                    this.RuntimeData.BossMonsterID  = (int)arr[0];
                    this.RuntimeData.WanMoXiaGuCall = arr[1];
                }
                catch (Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex, true);
                }
            }
            return(success);
        }
Exemplo n.º 2
0
        public void CreateMonster(WanMoXiaGuScene scene, object tag)
        {
            CopyMap copyMap = scene.CopyMapInfo;
            GameMap gameMap = null;

            if (GameManager.MapMgr.DictMaps.TryGetValue(scene.MapID, out gameMap))
            {
                WanMoXiaGuMonsterConfigInfo waveConfig = tag as WanMoXiaGuMonsterConfigInfo;
                if (waveConfig != null)
                {
                    for (int i = 0; i < waveConfig.MonstersNum; i++)
                    {
                        int monsterID = waveConfig.MonsterID[i];
                        int gridX     = waveConfig.Site[i * 2] / gameMap.MapGridWidth;
                        int gridY     = waveConfig.Site[i * 2 + 1] / gameMap.MapGridHeight;
                        GameManager.MonsterZoneMgr.AddDynamicMonsters(scene.MapID, monsterID, scene.CopyMapInfo.CopyMapID, 1, gridX, gridY, 0, 0, SceneUIClasses.WanMoXiaGu, waveConfig, null);
                    }
                    scene.ScoreData.MonsterCount = waveConfig.MonstersNum;
                    GameManager.ClientMgr.BroadSpecialCopyMapMessage <WanMoXiaGuScoreData>(1266, scene.ScoreData, scene.CopyMapInfo);
                }
            }
        }