コード例 #1
0
        private TimeSpan GetStartTime(int sceneId)
        {
            KuaFuBossSceneInfo sceneItem = null;
            TimeSpan           startTime = TimeSpan.MinValue;
            DateTime           now       = TimeUtil.NowDateTime();

            lock (this.RuntimeData.Mutex)
            {
                if (!this.RuntimeData.SceneDataDict.TryGetValue(sceneId, out sceneItem))
                {
                    goto IL_153;
                }
            }
            lock (this.RuntimeData.Mutex)
            {
                for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                {
                    if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpStartSecs && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                    {
                        startTime = TimeSpan.FromSeconds(sceneItem.SecondsOfDay[i]);
                        break;
                    }
                }
            }
IL_153:
            if (startTime < TimeSpan.Zero)
            {
                startTime = now.TimeOfDay;
            }
            return(startTime);
        }
コード例 #2
0
        private int CheckCondition(GameClient client, ref KuaFuBossSceneInfo sceneItem, ref KuaFuBossGameStates state)
        {
            int result = 0;

            sceneItem = null;
            if (!this.IsGongNengOpened(client, true))
            {
                result = -13;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    if (!this.RuntimeData.LevelRangeSceneIdDict.TryGetValue(new RangeKey(Global.GetUnionLevel(client, false)), out sceneItem))
                    {
                        return(-12);
                    }
                }
                result = -2001;
                DateTime now = TimeUtil.NowDateTime();
                lock (this.RuntimeData.Mutex)
                {
                    for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                    {
                        if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpStartSecs && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                        {
                            if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpStartSecs)
                            {
                                state  = KuaFuBossGameStates.None;
                                result = -2001;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpEndSecs)
                            {
                                state  = KuaFuBossGameStates.SignUp;
                                result = 1;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i])
                            {
                                state  = KuaFuBossGameStates.Wait;
                                result = 1;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i + 1])
                            {
                                state  = KuaFuBossGameStates.Start;
                                result = 1;
                            }
                            else
                            {
                                state  = KuaFuBossGameStates.None;
                                result = -2001;
                            }
                            break;
                        }
                    }
                }
            }
            return(result);
        }
コード例 #3
0
ファイル: KuaFuBossManager.cs プロジェクト: chenchungit/ky
        public bool ProcessGetKuaFuBossStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                KuaFuBossSceneInfo  sceneItem = null;
                KuaFuBossGameStates timeState = KuaFuBossGameStates.None;
                int result  = (int)KuaFuBossGameStates.None;
                int groupId = 0;
                RuntimeData.RoleId2JoinGroup.TryGetValue(client.ClientData.RoleID, out groupId);

                CheckCondition(client, ref sceneItem, ref timeState);
                if (groupId > 0)
                {
                    if (timeState >= KuaFuBossGameStates.SignUp && timeState <= KuaFuBossGameStates.Wait)
                    {
                        int state = YongZheZhanChangClient.getInstance().GetKuaFuRoleState(client.ClientData.RoleID);
                        if (state >= (int)KuaFuRoleStates.SignUp)
                        {
                            result = (int)KuaFuBossGameStates.Wait;
                        }
                        else
                        {
                            result = (int)KuaFuBossGameStates.NotJoin;
                        }
                    }
                    else if (timeState == KuaFuBossGameStates.Start)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.ContainsKey(client.ClientData.RoleID))
                        {
                            result = (int)KuaFuBossGameStates.Start;
                        }
                    }
                }
                else
                {
                    if (timeState == KuaFuBossGameStates.SignUp)
                    {
                        result = (int)KuaFuBossGameStates.SignUp;
                    }
                    else if (timeState == KuaFuBossGameStates.Wait || timeState == KuaFuBossGameStates.Start)
                    {
                        // 未参加本次活动
                        result = (int)KuaFuBossGameStates.NotJoin;
                    }
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
コード例 #4
0
ファイル: KuaFuBossManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 罗兰城战攻防竞价申请指令处理
        /// </summary>
        /// <param name="client"></param>
        /// <param name="nID"></param>
        /// <param name="bytes"></param>
        /// <param name="cmdParams"></param>
        /// <returns></returns>
        public bool ProcessKuaFuBossJoinCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result = StdErrorCode.Error_Success_No_Info;

                do
                {
                    KuaFuBossSceneInfo  sceneItem = null;
                    KuaFuBossGameStates state     = KuaFuBossGameStates.None;
                    if (!CheckMap(client))
                    {
                        result = StdErrorCode.Error_Denied_In_Current_Map;
                    }
                    else
                    {
                        result = CheckCondition(client, ref sceneItem, ref state);
                    }

                    if (state != KuaFuBossGameStates.SignUp)
                    {
                        result = StdErrorCode.Error_Not_In_valid_Time; //非报名时间
                    }
                    else if (RuntimeData.RoleId2JoinGroup.ContainsKey(client.ClientData.RoleID))
                    {
                        result = StdErrorCode.Error_Operation_Denied; // 已经报名了
                    }

                    if (result >= 0)
                    {
                        int gropuId = sceneItem.Id;
                        result = YongZheZhanChangClient.getInstance().YongZheZhanChangSignUp(client.strUserID, client.ClientData.RoleID, client.ClientData.ZoneID,
                                                                                             (int)GameTypes.KuaFuBoss, gropuId, client.ClientData.CombatForce);
                        if (result > 0)
                        {
                            RuntimeData.RoleId2JoinGroup[client.ClientData.RoleID] = gropuId;
                            client.ClientData.SignUpGameType = (int)GameTypes.KuaFuBoss;
                        }
                    }
                } while (false);

                //发送结果给客户端
                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
コード例 #5
0
 public bool ProcessKuaFuBossJoinCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         KuaFuBossSceneInfo  sceneItem = null;
         KuaFuBossGameStates state     = KuaFuBossGameStates.None;
         int result;
         if (!this.CheckMap(client))
         {
             result = -21;
         }
         else
         {
             result = this.CheckCondition(client, ref sceneItem, ref state);
         }
         if (state != KuaFuBossGameStates.SignUp)
         {
             result = -2001;
         }
         else if (this.RuntimeData.RoleId2JoinGroup.ContainsKey(client.ClientData.RoleID))
         {
             result = -12;
         }
         if (result >= 0)
         {
             int gropuId = sceneItem.Id;
             result = YongZheZhanChangClient.getInstance().YongZheZhanChangSignUp(client.strUserID, client.ClientData.RoleID, client.ClientData.ZoneID, 6, gropuId, client.ClientData.CombatForce);
             if (result > 0)
             {
                 this.RuntimeData.RoleId2JoinGroup[client.ClientData.RoleID] = gropuId;
                 client.ClientData.SignUpGameType = 6;
             }
         }
         client.sendCmd <int>(nID, result, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
コード例 #6
0
ファイル: KuaFuBossManager.cs プロジェクト: chenchungit/ky
        private TimeSpan GetStartTime(int sceneId)
        {
            int result = 0;
            KuaFuBossSceneInfo sceneItem = null;
            TimeSpan           startTime = TimeSpan.MinValue;
            DateTime           now       = TimeUtil.NowDateTime();

            do
            {
                lock (RuntimeData.Mutex)
                {
                    if (!RuntimeData.SceneDataDict.TryGetValue(sceneId, out sceneItem))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }
                }

                result = StdErrorCode.Error_Not_In_valid_Time;
                lock (RuntimeData.Mutex)
                {
                    for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                    {
                        if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                            now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                            now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                        {
                            startTime = TimeSpan.FromSeconds(sceneItem.SecondsOfDay[i]);
                            break;
                        }
                    }
                }
            } while (false);

            if (startTime < TimeSpan.Zero)
            {
                startTime = now.TimeOfDay;
            }

            return(startTime);
        }
コード例 #7
0
        public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            bool result;

            if (sceneType == SceneUIClasses.KuaFuBoss)
            {
                int            fuBenSeqId = copyMap.FuBenSeqID;
                int            mapCode    = copyMap.MapCode;
                int            roleId     = client.ClientData.RoleID;
                int            gameId     = (int)Global.GetClientKuaFuServerLoginData(client).GameId;
                DateTime       now        = TimeUtil.NowDateTime();
                KuaFuBossScene scene      = null;
                lock (this.RuntimeData.Mutex)
                {
                    if (!this.SceneDict.TryGetValue(fuBenSeqId, out scene))
                    {
                        KuaFuBossSceneInfo        sceneInfo = null;
                        YongZheZhanChangFuBenData fuBenData;
                        if (!this.RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData))
                        {
                            LogManager.WriteLog(LogTypes.Error, "跨服Boss没有为副本找到对应的跨服副本数据,GameID:" + gameId, null, true);
                        }
                        if (!this.RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo))
                        {
                            LogManager.WriteLog(LogTypes.Error, "跨服Boss没有为副本找到对应的档位数据,ID:" + fuBenData.GroupIndex, null, true);
                        }
                        scene         = new KuaFuBossScene();
                        scene.CopyMap = copyMap;
                        scene.CleanAllInfo();
                        scene.GameId         = gameId;
                        scene.m_nMapCode     = mapCode;
                        scene.CopyMapId      = copyMap.CopyMapID;
                        scene.FuBenSeqId     = fuBenSeqId;
                        scene.m_nPlarerCount = 1;
                        scene.SceneInfo      = sceneInfo;
                        DateTime startTime = now.Date.Add(this.GetStartTime(sceneInfo.Id));
                        scene.StartTimeTicks             = startTime.Ticks / 10000L;
                        scene.GameStatisticalData.GameId = gameId;
                        this.SceneDict[fuBenSeqId]       = scene;
                        List <BattleDynamicMonsterItem> dynMonsterList;
                        if (this.RuntimeData.SceneDynMonsterDict.TryGetValue(mapCode, out dynMonsterList))
                        {
                            scene.DynMonsterList = dynMonsterList;
                        }
                    }
                    else
                    {
                        scene.m_nPlarerCount++;
                    }
                    copyMap.IsKuaFuCopy = true;
                    copyMap.SetRemoveTicks(TimeUtil.NOW() + (long)(scene.SceneInfo.TotalSecs * 1000));
                }
                GameMap gameMap = null;
                if (GameManager.MapMgr.DictMaps.TryGetValue(copyMap.MapCode, out gameMap))
                {
                    scene.MapGridWidth  = gameMap.MapGridWidth;
                    scene.MapGridHeight = gameMap.MapGridHeight;
                }
                YongZheZhanChangClient.getInstance().GameFuBenRoleChangeState(roleId, 5, 0, 0);
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
コード例 #8
0
 public bool ProcessKuaFuBossEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         KuaFuBossSceneInfo  sceneItem = null;
         KuaFuBossGameStates state     = KuaFuBossGameStates.None;
         int result = 0;
         if (!this.CheckMap(client))
         {
             result = -21;
         }
         else
         {
             result = this.CheckCondition(client, ref sceneItem, ref state);
         }
         if (state == KuaFuBossGameStates.Start)
         {
             KuaFuServerLoginData kuaFuServerLoginData = null;
             lock (this.RuntimeData.Mutex)
             {
                 if (this.RuntimeData.RoleIdKuaFuLoginDataDict.TryGetValue(client.ClientData.RoleID, out kuaFuServerLoginData))
                 {
                     KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                     if (null != clientKuaFuServerLoginData)
                     {
                         clientKuaFuServerLoginData.RoleId     = kuaFuServerLoginData.RoleId;
                         clientKuaFuServerLoginData.GameId     = kuaFuServerLoginData.GameId;
                         clientKuaFuServerLoginData.GameType   = kuaFuServerLoginData.GameType;
                         clientKuaFuServerLoginData.EndTicks   = kuaFuServerLoginData.EndTicks;
                         clientKuaFuServerLoginData.ServerId   = kuaFuServerLoginData.ServerId;
                         clientKuaFuServerLoginData.ServerIp   = kuaFuServerLoginData.ServerIp;
                         clientKuaFuServerLoginData.ServerPort = kuaFuServerLoginData.ServerPort;
                         clientKuaFuServerLoginData.FuBenSeqId = kuaFuServerLoginData.FuBenSeqId;
                     }
                 }
                 else
                 {
                     result = -11000;
                 }
             }
             if (result >= 0)
             {
                 result = YongZheZhanChangClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.EnterGame, false);
                 if (result >= 0)
                 {
                     GlobalNew.RecordSwitchKuaFuServerLog(client);
                     client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                 }
                 else
                 {
                     Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                 }
             }
         }
         else
         {
             result = -2001;
         }
         client.sendCmd <int>(nID, result, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
コード例 #9
0
        private void TimerProc(object sender, EventArgs e)
        {
            bool     notifyPrepareGame = false;
            bool     notifyEnterGame   = false;
            DateTime now = TimeUtil.NowDateTime();

            lock (this.RuntimeData.Mutex)
            {
                bool bInActiveTime           = false;
                KuaFuBossSceneInfo sceneItem = this.RuntimeData.SceneDataDict.Values.FirstOrDefault <KuaFuBossSceneInfo>();
                for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                {
                    if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - (double)sceneItem.SignUpStartSecs && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                    {
                        double secs = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds;
                        bInActiveTime = true;
                        if (!this.RuntimeData.PrepareGame)
                        {
                            if (secs > 0.0 && secs < (double)(sceneItem.SignUpEndSecs / 2))
                            {
                                LogManager.WriteLog(LogTypes.Error, "报名截止5分钟时间过半,通知跨服中心开始分配所有报名玩家的活动场次", null, true);
                                this.RuntimeData.PrepareGame = true;
                                notifyPrepareGame            = true;
                                break;
                            }
                        }
                        else if (secs < 0.0)
                        {
                            LogManager.WriteLog(LogTypes.Error, "报名截止状态结束,可以通知已分配到场次的玩家进入游戏了", null, true);
                            notifyEnterGame = true;
                            this.RuntimeData.PrepareGame = false;
                            break;
                        }
                    }
                }
                if (!bInActiveTime)
                {
                    if (this.RuntimeData.RoleIdKuaFuLoginDataDict.Count > 0)
                    {
                        this.RuntimeData.RoleIdKuaFuLoginDataDict.Clear();
                    }
                    if (this.RuntimeData.RoleId2JoinGroup.Count > 0)
                    {
                        this.RuntimeData.RoleId2JoinGroup.Clear();
                    }
                }
            }
            if (notifyPrepareGame)
            {
                LogManager.WriteLog(LogTypes.Error, "通知跨服中心开始分配所有报名玩家的活动场次", null, true);
                string cmd = string.Format("{0} {1} {2}", "GameState", 2, 6);
                YongZheZhanChangClient.getInstance().ExecuteCommand(cmd);
            }
            if (notifyEnterGame)
            {
                lock (this.RuntimeData.Mutex)
                {
                    foreach (KuaFuServerLoginData kuaFuServerLoginData in this.RuntimeData.RoleIdKuaFuLoginDataDict.Values)
                    {
                        this.RuntimeData.NotifyRoleEnterDict.Add(kuaFuServerLoginData.RoleId, kuaFuServerLoginData);
                    }
                }
            }
            List <KuaFuServerLoginData> list = null;

            lock (this.RuntimeData.Mutex)
            {
                int count = this.RuntimeData.NotifyRoleEnterDict.Count;
                if (count > 0)
                {
                    list = new List <KuaFuServerLoginData>();
                    KuaFuServerLoginData kuaFuServerLoginData = this.RuntimeData.NotifyRoleEnterDict.First <KeyValuePair <int, KuaFuServerLoginData> >().Value;
                    foreach (KeyValuePair <int, KuaFuServerLoginData> kv in this.RuntimeData.NotifyRoleEnterDict)
                    {
                        if (kv.Key % 15 == kuaFuServerLoginData.RoleId % 15)
                        {
                            list.Add(kv.Value);
                        }
                    }
                    foreach (KuaFuServerLoginData data in list)
                    {
                        this.RuntimeData.NotifyRoleEnterDict.Remove(data.RoleId);
                    }
                }
            }
            if (null != list)
            {
                foreach (KuaFuServerLoginData kuaFuServerLoginData in list)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(kuaFuServerLoginData.RoleId);
                    if (null != client)
                    {
                        client.sendCmd <int>(1121, 1, false);
                    }
                }
            }
        }
コード例 #10
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);
        }
コード例 #11
0
ファイル: KuaFuBossManager.cs プロジェクト: chenchungit/ky
        public bool ProcessKuaFuBossEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                KuaFuBossSceneInfo  sceneItem = null;
                KuaFuBossGameStates state     = KuaFuBossGameStates.None;
                int result = StdErrorCode.Error_Success_No_Info;

                if (!CheckMap(client))
                {
                    result = StdErrorCode.Error_Denied_In_Current_Map;
                }
                else
                {
                    result = CheckCondition(client, ref sceneItem, ref state);
                }

                if (state == KuaFuBossGameStates.Start)
                {
                    KuaFuServerLoginData kuaFuServerLoginData = null;
                    lock (RuntimeData.Mutex)
                    {
                        if (RuntimeData.RoleIdKuaFuLoginDataDict.TryGetValue(client.ClientData.RoleID, out kuaFuServerLoginData))
                        {
                            KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                            if (null != clientKuaFuServerLoginData)
                            {
                                clientKuaFuServerLoginData.RoleId     = kuaFuServerLoginData.RoleId;
                                clientKuaFuServerLoginData.GameId     = kuaFuServerLoginData.GameId;
                                clientKuaFuServerLoginData.GameType   = kuaFuServerLoginData.GameType;
                                clientKuaFuServerLoginData.EndTicks   = kuaFuServerLoginData.EndTicks;
                                clientKuaFuServerLoginData.ServerId   = kuaFuServerLoginData.ServerId;
                                clientKuaFuServerLoginData.ServerIp   = kuaFuServerLoginData.ServerIp;
                                clientKuaFuServerLoginData.ServerPort = kuaFuServerLoginData.ServerPort;
                                clientKuaFuServerLoginData.FuBenSeqId = kuaFuServerLoginData.FuBenSeqId;
                            }
                        }
                        else
                        {
                            result = StdErrorCode.Error_Server_Busy;
                        }
                    }

                    if (result >= 0)
                    {
                        result = YongZheZhanChangClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.EnterGame);
                        if (result >= 0)
                        {
                            GlobalNew.RecordSwitchKuaFuServerLog(client);
                            client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KF_SWITCH_SERVER, Global.GetClientKuaFuServerLoginData(client));
                        }
                        else
                        {
                            Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                        }
                    }
                }
                else
                {
                    result = StdErrorCode.Error_Not_In_valid_Time;
                }

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
コード例 #12
0
ファイル: KuaFuBossManager.cs プロジェクト: chenchungit/ky
        // 检查勇者战场当前处于什么时间状态
        private int CheckCondition(GameClient client, ref KuaFuBossSceneInfo sceneItem, ref KuaFuBossGameStates state)
        {
            int result = 0;

            sceneItem = null;

            do
            {
                if (!IsGongNengOpened(client, true))
                {
                    result = StdErrorCode.Error_Type_Not_Match;
                    break;
                }

                lock (RuntimeData.Mutex)
                {
                    if (!RuntimeData.LevelRangeSceneIdDict.TryGetValue(new RangeKey(Global.GetUnionLevel(client)), out sceneItem))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }
                }

                result = StdErrorCode.Error_Not_In_valid_Time;
                DateTime now = TimeUtil.NowDateTime();
                lock (RuntimeData.Mutex)
                {
                    for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                    {
                        if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                            now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                            now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                        {
                            if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs)
                            {
                                state  = KuaFuBossGameStates.None;
                                result = StdErrorCode.Error_Not_In_valid_Time;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i] - sceneItem.SignUpEndSecs)
                            {
                                state  = KuaFuBossGameStates.SignUp;
                                result = StdErrorCode.Error_Success;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i])
                            {
                                state  = KuaFuBossGameStates.Wait;
                                result = StdErrorCode.Error_Success;
                            }
                            else if (now.TimeOfDay.TotalSeconds < sceneItem.SecondsOfDay[i + 1])
                            {
                                state  = KuaFuBossGameStates.Start;
                                result = StdErrorCode.Error_Success;
                            }
                            else
                            {
                                state  = KuaFuBossGameStates.None;
                                result = StdErrorCode.Error_Not_In_valid_Time;
                            }
                            break;
                        }
                    }
                }
            } while (false);

            return(result);
        }
コード例 #13
0
ファイル: KuaFuBossManager.cs プロジェクト: chenchungit/ky
        private void TimerProc(object sender, EventArgs e)
        {
            bool     notifyPrepareGame = false;
            bool     notifyEnterGame   = false;
            DateTime now = TimeUtil.NowDateTime();

            lock (RuntimeData.Mutex)
            {
                bool bInActiveTime = false;

                KuaFuBossSceneInfo sceneItem = RuntimeData.SceneDataDict.Values.FirstOrDefault();
                for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2)
                {
                    if ((int)now.DayOfWeek == sceneItem.TimePoints[i].Days &&
                        now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - sceneItem.SignUpStartSecs &&
                        now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1])
                    {
                        double secs = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds;
                        bInActiveTime = true;
                        if (!RuntimeData.PrepareGame)
                        {
                            if (secs > 0 && secs < sceneItem.SignUpEndSecs / 2)
                            {
                                LogManager.WriteLog(LogTypes.Error, "报名截止5分钟时间过半,通知跨服中心开始分配所有报名玩家的活动场次");

                                // 通知跨服中心开始准备副本
                                RuntimeData.PrepareGame = true;
                                notifyPrepareGame       = true;
                                break;
                            }
                        }
                        else
                        {
                            if (secs < 0)
                            {
                                LogManager.WriteLog(LogTypes.Error, "报名截止状态结束,可以通知已分配到场次的玩家进入游戏了");

                                // 首次到达进入时间,通知进入,并重置PrepareGame状态,然后以后的循环走上面的if
                                // 但是上面的if在本次活动期间就相当于空转
                                notifyEnterGame         = true;
                                RuntimeData.PrepareGame = false;
                                break;
                            }
                        }
                    }
                }

                if (!bInActiveTime)
                {
                    if (RuntimeData.RoleIdKuaFuLoginDataDict.Count > 0)
                    {
                        RuntimeData.RoleIdKuaFuLoginDataDict.Clear();
                    }

                    if (RuntimeData.RoleId2JoinGroup.Count > 0)
                    {
                        RuntimeData.RoleId2JoinGroup.Clear();
                    }
                }
            }

            if (notifyPrepareGame)
            {
                LogManager.WriteLog(LogTypes.Error, "通知跨服中心开始分配所有报名玩家的活动场次");

                // GameServer和KF-GameServer都会通知准备游戏,所以中心要防止状态回滚
                string cmd = string.Format("{0} {1} {2}", GameStates.CommandName, GameStates.PrepareGame, (int)GameTypes.KuaFuBoss);
                YongZheZhanChangClient.getInstance().ExecuteCommand(cmd);
            }

            if (notifyEnterGame)
            {
                lock (RuntimeData.Mutex)
                {
                    foreach (var kuaFuServerLoginData in RuntimeData.RoleIdKuaFuLoginDataDict.Values)
                    {
                        RuntimeData.NotifyRoleEnterDict.Add(kuaFuServerLoginData.RoleId, kuaFuServerLoginData);
                    }
                }
            }

            //通知报名的玩家进入活动,每次只通知一部分(按RoleID除以15的余数),防止所有玩家一起进入给服务器造成压力.
            List <KuaFuServerLoginData> list = null;

            lock (RuntimeData.Mutex)
            {
                int count = RuntimeData.NotifyRoleEnterDict.Count;
                if (count > 0)
                {
                    list = new List <KuaFuServerLoginData>();
                    KuaFuServerLoginData kuaFuServerLoginData = RuntimeData.NotifyRoleEnterDict.First().Value;
                    foreach (var kv in RuntimeData.NotifyRoleEnterDict)
                    {
                        if ((kv.Key % 15) == (kuaFuServerLoginData.RoleId % 15))
                        {
                            list.Add(kv.Value);
                        }
                    }

                    foreach (var data in list)
                    {
                        RuntimeData.NotifyRoleEnterDict.Remove(data.RoleId);
                    }
                }
            }

            if (null != list)
            {
                foreach (var kuaFuServerLoginData in list)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(kuaFuServerLoginData.RoleId);
                    if (null != client)
                    {
                        client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KUAFU_BOSS_ENTER, 1);
                    }
                }
            }
        }