コード例 #1
0
        public bool OnInitGame(GameClient client)
        {
            KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
            KarenFuBenData       fuBenData;

            lock (this.RuntimeData.Mutex)
            {
                if (!this.RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData))
                {
                    fuBenData = null;
                }
                else if (fuBenData.State >= GameFuBenState.End)
                {
                    return(false);
                }
            }
            if (null == fuBenData)
            {
                if (KarenBattleManager.getInstance().GMTest)
                {
                    lock (this.RuntimeData.Mutex)
                    {
                        if (!this.RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData))
                        {
                            fuBenData            = new KarenFuBenData();
                            fuBenData.GameId     = (int)kuaFuServerLoginData.GameId;
                            fuBenData.SequenceId = GameCoreInterface.getinstance().GetNewFuBenSeqId();
                            this.RuntimeData.FuBenItemData[fuBenData.GameId] = fuBenData;
                        }
                    }
                }
                else
                {
                    KarenFuBenData newFuBenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData((int)kuaFuServerLoginData.GameId);
                    if (newFuBenData == null || newFuBenData.State == GameFuBenState.End)
                    {
                        LogManager.WriteLog(LogTypes.Error, ("获取不到有效的副本数据," + newFuBenData == null) ? "fuBenData == null" : "fuBenData.State == GameFuBenState.End", null, true);
                        return(false);
                    }
                    lock (this.RuntimeData.Mutex)
                    {
                        if (!this.RuntimeData.FuBenItemData.TryGetValue((int)kuaFuServerLoginData.GameId, out fuBenData))
                        {
                            fuBenData            = newFuBenData;
                            fuBenData.SequenceId = GameCoreInterface.getinstance().GetNewFuBenSeqId();
                            this.RuntimeData.FuBenItemData[fuBenData.GameId] = fuBenData;
                        }
                    }
                }
            }
            if (KarenBattleManager.getInstance().GMTest)
            {
                client.ClientData.BattleWhichSide = Global.GetRandomNumber(1, 5);
            }
            else
            {
                KarenFuBenRoleData kroleData = JunTuanClient.getInstance().GetKarenFuBenRoleData((int)kuaFuServerLoginData.GameId, client.ClientData.RoleID);
                if (null == kroleData)
                {
                    return(false);
                }
                client.ClientData.BattleWhichSide = kroleData.Side;
            }
            int  posX;
            int  posY;
            int  side = this.GetBirthPoint(client, out posX, out posY, true);
            bool result;

            if (side <= 0)
            {
                LogManager.WriteLog(LogTypes.Error, "无法获取有效的阵营和出生点,进入跨服失败,side=" + side, null, true);
                result = false;
            }
            else
            {
                lock (this.RuntimeData.Mutex)
                {
                    kuaFuServerLoginData.FuBenSeqId = fuBenData.SequenceId;
                    KarenBattleSceneInfo sceneInfo;
                    if (null == (sceneInfo = KarenBattleManager.getInstance().TryGetKarenBattleSceneInfo((int)kuaFuServerLoginData.GameId)))
                    {
                        return(false);
                    }
                    client.ClientData.MapCode = sceneInfo.MapCode;
                }
                client.ClientData.PosX       = posX;
                client.ClientData.PosY       = posY;
                client.ClientData.FuBenSeqID = kuaFuServerLoginData.FuBenSeqId;
                KarenBattleManager.getInstance().OnInitGame(SceneUIClasses.KarenWest, client);
                result = true;
            }
            return(result);
        }
コード例 #2
0
 public bool ProcessGetKarenBattleStateCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result    = 0;
         int westcount = 0;
         int eastcount = 0;
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
             {
                 result,
                 westcount,
                 eastcount,
                 "",
                 ""
             }), false);
             return(true);
         }
         KarenGameStates timeState = KarenGameStates.None;
         this.CheckTimeCondition(ref timeState);
         if (this.CheckCanEnterKarenBattle(client))
         {
             if (timeState == KarenGameStates.Wait)
             {
                 result = 1;
             }
             else if (timeState == KarenGameStates.Start)
             {
                 lock (this.Mutex)
                 {
                     foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict)
                     {
                         KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key);
                         if (null != fubenData)
                         {
                             JunTuanRankData rankData = this.GetJunTuanRankDataByClient(client);
                             if (null != rankData)
                             {
                                 SceneUIClasses sceneType = Global.GetMapSceneType(item.Value.MapCode);
                                 if (sceneType == SceneUIClasses.KarenWest)
                                 {
                                     westcount = fubenData.GetRoleCountWithEnter(rankData.Rank);
                                 }
                                 else
                                 {
                                     eastcount = fubenData.GetRoleCountWithEnter(rankData.Rank);
                                 }
                             }
                         }
                     }
                 }
                 result = 2;
             }
         }
         else if (timeState == KarenGameStates.Wait || timeState == KarenGameStates.Start)
         {
             JunTuanRankData RankData = this.GetJunTuanRankDataByClient(client);
             if (null != RankData)
             {
                 result = 3;
             }
             else
             {
                 result = 4;
             }
         }
         string            eastjtname = "";
         string            westjtname = "";
         List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData();
         if (null != LingDiList)
         {
             foreach (LingDiData item2 in LingDiList)
             {
                 SceneUIClasses mapType = this.ConvertCaiJiLingDiTypeToMapSceneType(item2.LingDiType);
                 if (mapType == SceneUIClasses.KarenWest)
                 {
                     westjtname = item2.JunTuanName;
                 }
                 else if (mapType == SceneUIClasses.KarenEast)
                 {
                     eastjtname = item2.JunTuanName;
                 }
             }
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
         {
             result,
             westcount,
             eastcount,
             westjtname,
             eastjtname
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
コード例 #3
0
        private void TimerProc(object sender, EventArgs e)
        {
            bool     notifyPrepareGame = false;
            bool     notifyEnterGame   = false;
            bool     notifyEndGame     = false;
            DateTime now = TimeUtil.NowDateTime();

            lock (this.Mutex)
            {
                KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>();
                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] - 120.0 && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1] + 120.0)
                    {
                        double secsPrepare = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds;
                        double secsEnd     = sceneItem.SecondsOfDay[i + 1] + 120.0 - now.TimeOfDay.TotalSeconds;
                        if (!this.PrepareGame)
                        {
                            if (secsPrepare > 0.0 && secsPrepare < 120.0)
                            {
                                this.PrepareGame  = true;
                                notifyPrepareGame = true;
                                break;
                            }
                        }
                        else if (secsPrepare < 0.0)
                        {
                            notifyEnterGame  = true;
                            this.PrepareGame = false;
                            break;
                        }
                        if (!this.EndGame)
                        {
                            if (secsEnd > 0.0 && secsEnd < 120.0)
                            {
                                this.EndGame  = true;
                                notifyEndGame = true;
                                break;
                            }
                        }
                        else if (secsEnd < 0.0)
                        {
                            this.EndGame = false;
                            break;
                        }
                    }
                }
            }
            if (notifyPrepareGame)
            {
                LogManager.WriteLog(LogTypes.Error, "阿卡伦战场活动即将开始,准备通知军团角色进入!", null, true);
                lock (this.Mutex)
                {
                    this.FactionIDVsServerIDDict.Clear();
                }
            }
            if (notifyEnterGame)
            {
                int westcount = 0;
                int eastcount = 0;
                lock (this.Mutex)
                {
                    LogManager.WriteLog(LogTypes.Error, "阿卡伦战场开启,可以通知已分配到场次的玩家进入游戏了", null, true);
                    KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>();
                    foreach (GameClient client in GameManager.ClientMgr.GetAllClients(true))
                    {
                        if (this.CheckCanEnterKarenBattle(client) && this.CheckMap(client) && this.IsGongNengOpened(client, false))
                        {
                            if (null != client)
                            {
                                client.sendCmd(1210, string.Format("{0}:{1}:{2}:{3}", new object[]
                                {
                                    1,
                                    1,
                                    westcount,
                                    eastcount
                                }), false);
                            }
                        }
                    }
                }
            }
            if (notifyEndGame)
            {
                lock (this.Mutex)
                {
                    foreach (KarenBattleSceneInfo item in this.SceneDataDict.Values)
                    {
                        KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.MapCode);
                        if (fubenData != null && fubenData.ServerId == GameManager.ServerId)
                        {
                            SceneUIClasses mapType = Global.GetMapSceneType(item.MapCode);
                            if (mapType != SceneUIClasses.KarenEast || KarenBattleManager_MapEast.getInstance().SceneDict.Count == 0)
                            {
                                if (mapType != SceneUIClasses.KarenWest || KarenBattleManager_MapWest.getInstance().SceneDict.Count == 0)
                                {
                                    int               lingDiType    = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType);
                                    LingDiData        oldLingDiData = null;
                                    List <LingDiData> LingDiList    = JunTuanClient.getInstance().GetLingDiData();
                                    if (null != LingDiList)
                                    {
                                        oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType);
                                    }
                                    RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null;
                                    LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, 0, 0, "", null);
                                    EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, 0, 0, 0);
                                }
                            }
                        }
                    }
                }
            }
            this.UpdateKuaFuMapClientCount(KarenBattleManager_MapWest.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>());
            this.UpdateKuaFuMapClientCount(KarenBattleManager_MapEast.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>());
        }
コード例 #4
0
 public bool ProcessKarenBattleEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int result = 0;
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd <int>(nID, result, false);
             return(true);
         }
         int roleID  = Global.SafeConvertToInt32(cmdParams[0]);
         int mapCode = Global.SafeConvertToInt32(cmdParams[1]);
         KarenBattleSceneInfo sceneItem = null;
         KarenGameStates      state     = KarenGameStates.None;
         int             eastcount      = 0;
         int             westcount      = 0;
         JunTuanRankData rankData       = this.GetJunTuanRankDataByClient(client);
         if (rankData == null || !this.CheckCanEnterKarenBattle(client))
         {
             result = -5;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         if (!this.CheckMap(client))
         {
             result = -21;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         result = this.CheckTimeCondition(ref state);
         if (state != KarenGameStates.Start)
         {
             result = -2001;
             client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
             {
                 result,
                 0,
                 westcount,
                 eastcount
             }), false);
             return(true);
         }
         lock (this.Mutex)
         {
             if (!this.SceneDataDict.TryGetValue(mapCode, out sceneItem))
             {
                 result = -5;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             foreach (KeyValuePair <int, KarenBattleSceneInfo> item in this.SceneDataDict)
             {
                 KarenFuBenData fbData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.Key);
                 if (null != fbData)
                 {
                     SceneUIClasses sType = Global.GetMapSceneType(item.Value.MapCode);
                     if (sType == SceneUIClasses.KarenWest)
                     {
                         westcount = fbData.GetRoleCountWithEnter(rankData.Rank);
                     }
                     else
                     {
                         eastcount = fbData.GetRoleCountWithEnter(rankData.Rank);
                     }
                 }
             }
             DateTime lastEnterTime = Global.GetRoleParamsDateTimeFromDB(client, "20019");
             if (!this.GMTest && TimeUtil.NowDateTime().Ticks - lastEnterTime.Ticks < 10000000L * (long)sceneItem.EnterCD)
             {
                 GameManager.ClientMgr.NotifyImportantMsg(client, string.Format(GLang.GetLang(2615, new object[0]), sceneItem.EnterCD), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 0);
                 result = -2007;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             KuaFuServerInfo kfserverInfo = null;
             KarenFuBenData  fubenData    = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(mapCode);
             if (fubenData == null || !KuaFuManager.getInstance().TryGetValue(fubenData.ServerId, out kfserverInfo))
             {
                 result = -11000;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             if (fubenData.GetRoleCountWithEnter(rankData.Rank) >= sceneItem.MaxEnterNum)
             {
                 result = -22;
                 client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
                 {
                     result,
                     0,
                     westcount,
                     eastcount
                 }), false);
                 return(true);
             }
             SceneUIClasses       sceneType = Global.GetMapSceneType(sceneItem.MapCode);
             KuaFuServerLoginData clientKuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
             if (null != clientKuaFuServerLoginData)
             {
                 clientKuaFuServerLoginData.RoleId     = client.ClientData.RoleID;
                 clientKuaFuServerLoginData.GameId     = (long)fubenData.GameId;
                 clientKuaFuServerLoginData.GameType   = fubenData.GameType;
                 clientKuaFuServerLoginData.EndTicks   = fubenData.EndTime.Ticks;
                 clientKuaFuServerLoginData.ServerId   = client.ServerId;
                 clientKuaFuServerLoginData.ServerIp   = kfserverInfo.Ip;
                 clientKuaFuServerLoginData.ServerPort = kfserverInfo.Port;
                 clientKuaFuServerLoginData.FuBenSeqId = 0;
             }
             if (result >= 0)
             {
                 result = JunTuanClient.getInstance().GameFuBenRoleChangeState(client.ServerId, client.ClientData.RoleID, (int)clientKuaFuServerLoginData.GameId, rankData.Rank, 4);
                 if (result >= 0)
                 {
                     GlobalNew.RecordSwitchKuaFuServerLog(client);
                     client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                 }
                 else
                 {
                     Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                 }
             }
         }
         client.sendCmd(nID, string.Format("{0}:{1}:{2}:{3}", new object[]
         {
             result,
             0,
             westcount,
             eastcount
         }), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }