コード例 #1
0
ファイル: ThemeBoss.cs プロジェクト: qiuhoude/mu_server
        public bool InitConfig()
        {
            string fileName = "";

            try
            {
                fileName = Global.GameResPath(ThemeDataConst.ThemeActivityBoss);
                XElement xml = CheckHelper.LoadXml(fileName, true);
                if (null == xml)
                {
                    return(false);
                }
                this.FromDate       = "-1";
                this.ToDate         = "-1";
                this.AwardStartDate = "-1";
                this.AwardEndDate   = "-1";
                Dictionary <int, ThemeBossConfig> bossConfigDict = new Dictionary <int, ThemeBossConfig>();
                IEnumerable <XElement>            nodes          = xml.Elements();
                foreach (XElement xmlItem in nodes)
                {
                    ThemeBossConfig config   = new ThemeBossConfig();
                    string[]        maxLevel = Global.GetDefAttributeStr(xmlItem, "MaxLevel", "0").Split(new char[]
                    {
                        '|'
                    });
                    if (maxLevel.Length >= 2)
                    {
                        config.ID            = (int)Global.GetSafeAttributeLong(xmlItem, "ID");
                        config.MonstersID    = (int)Global.GetSafeAttributeLong(xmlItem, "MonstersID");
                        config.MapCode       = (int)Global.GetSafeAttributeLong(xmlItem, "MapCode");
                        config.PosX          = (int)Global.GetSafeAttributeLong(xmlItem, "X");
                        config.PosY          = (int)Global.GetSafeAttributeLong(xmlItem, "Y");
                        config.Radius        = (int)Global.GetSafeAttributeLong(xmlItem, "Radius");
                        config.Num           = (int)Global.GetSafeAttributeLong(xmlItem, "Num");
                        config.MaxUnionLevel = Global.GetUnionLevel2(Global.SafeConvertToInt32(maxLevel[0]), Global.SafeConvertToInt32(maxLevel[1]));
                        if (!ConfigParser.ParserTimeRangeList(config.TimePoints, xmlItem.Attribute("TimePoints").Value.ToString(), true, '|', '-'))
                        {
                            throw new Exception(string.Format("读取{0}时间配置(TimePoints)出错", fileName));
                        }
                        for (int i = 0; i < config.TimePoints.Count; i++)
                        {
                            TimeSpan ts = new TimeSpan(config.TimePoints[i].Hours, config.TimePoints[i].Minutes, config.TimePoints[i].Seconds);
                            config.SecondsOfDay.Add(ts.TotalSeconds);
                        }
                        bossConfigDict[config.ID] = config;
                    }
                }
                List <int> goodsList = new List <int>();
                string     goodsStr  = GameManager.systemParamsList.GetParamValueByName("ThemeActivityBOSSGoods");
                if (!string.IsNullOrEmpty(goodsStr))
                {
                    goodsList = Array.ConvertAll <string, int>(goodsStr.Split(new char[]
                    {
                        ','
                    }), (string _x) => Global.SafeConvertToInt32(_x)).ToList <int>();
                }
                lock (ThemeBoss.Mutex)
                {
                    this.ThemeBossConfigDict = bossConfigDict;
                    this.BroadGoodsIDList    = goodsList;
                }
                this.ActivityType = 155;
                base.PredealDateTime();
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex, true);
                return(false);
            }
            return(true);
        }
コード例 #2
0
ファイル: ThemeBoss.cs プロジェクト: qiuhoude/mu_server
        public void TimerProc()
        {
            if (!GameManager.IsKuaFuServer)
            {
                if (155 == this.ActivityType && this.InActivityTime())
                {
                    DateTime now      = TimeUtil.NowDateTime();
                    long     nowTicks = now.Ticks / 10000L;
                    lock (ThemeBoss.Mutex)
                    {
                        if (Math.Abs(nowTicks - ThemeBoss.LastHeartBeatTicks) < 1000L)
                        {
                            return;
                        }
                        ThemeBoss.LastHeartBeatTicks = nowTicks;
                        this.GenerateThemeBossScene();
                    }
                    foreach (KeyValuePair <int, ThemeBossScene> scenes in this.SceneDict)
                    {
                        lock (ThemeBoss.Mutex)
                        {
                            switch (scenes.Value.State)
                            {
                            case BattleStates.NoBattle:
                                if (this.JudgeCanTriggerActivity(scenes.Value, now))
                                {
                                    if (this.GetStartEndTime(scenes.Key, out scenes.Value.StartTick, out scenes.Value.EndTick))
                                    {
                                        scenes.Value.State = BattleStates.WaitingFight;
                                    }
                                }
                                break;

                            case BattleStates.WaitingFight:
                                if (nowTicks >= scenes.Value.StartTick)
                                {
                                    ThemeBossConfig BossConfigInfo = scenes.Value.BossConfigInfo;
                                    Monster         bossSeed       = GameManager.MonsterZoneMgr.AddDynamicMonsters(scenes.Value.MapCode, BossConfigInfo.MonstersID, -1, BossConfigInfo.Num, BossConfigInfo.PosX / 100, BossConfigInfo.PosY / 100, BossConfigInfo.Radius, 0, SceneUIClasses.Normal, null, null);
                                    if (null != bossSeed)
                                    {
                                        scenes.Value.State        = BattleStates.StartFight;
                                        scenes.Value.AliveBossNum = BossConfigInfo.Num;
                                        Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.HintMsg, GLang.GetLang(4013, new object[0]), true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.HintAndBox, 0, 0, 100, 100);
                                    }
                                }
                                break;

                            case BattleStates.StartFight:
                                if (!scenes.Value.BroadCast4014 && (scenes.Value.EndTick - nowTicks) / 1000L <= 180L)
                                {
                                    Global.BroadcastRoleActionMsg(null, RoleActionsMsgTypes.HintMsg, GLang.GetLang(4014, new object[0]), true, GameInfoTypeIndexes.Hot, ShowGameInfoTypes.HintAndBox, 0, 0, 100, 100);
                                    scenes.Value.BroadCast4014 = true;
                                }
                                if (nowTicks >= scenes.Value.EndTick)
                                {
                                    scenes.Value.State = BattleStates.EndFight;
                                    List <object> monsterList = GameManager.MonsterMgr.GetObjectsByMap(scenes.Value.MapCode);
                                    foreach (object item in monsterList)
                                    {
                                        Monster monster = item as Monster;
                                        if (monster != null && monster.MonsterInfo.ExtensionID == scenes.Value.BossConfigInfo.MonstersID)
                                        {
                                            GameManager.MonsterMgr.DeadMonsterImmediately(monster);
                                        }
                                    }
                                }
                                break;

                            case BattleStates.EndFight:
                                scenes.Value.State         = BattleStates.NoBattle;
                                scenes.Value.BroadCast4014 = false;
                                scenes.Value.AliveBossNum  = 0;
                                break;
                            }
                        }
                    }
                }
            }
        }