Exemple #1
0
        /// <summary>
        /// 客户端进入地图
        /// </summary>
        /// <returns></returns>
        public bool ClientEnter(GameClient client)
        {
            bool ret = false;

            lock (mutex)
            {
                if (TheKingOfPKGetawardFlag.ContainsKey(client.ClientData.RoleID))
                {
                    return(true);
                }

                //当前总的在线用户数
                if (_TotalClientCount < MaxEnterNum)
                {
                    _TotalClientCount++;

                    TheKingOfPKGetawardFlag.Add(client.ClientData.RoleID, 0);

                    ret = true;
                }
            }

            ProcessTimeNotifyBattleKilledNum(true);

            string strcmd = string.Format("{0}:{1}", 0, _TotalClientCount);

            GameManager.ClientMgr.SendToClient(client, strcmd, (int)TCPGameServerCmds.CMD_SPR_ARENABATTLEKILLEDNUM);

            return(ret);
        }
Exemple #2
0
        /// <summary>
        /// 客户端离开地图
        /// </summary>
        /// <returns></returns>
        protected void ClientLeave(GameClient client)
        {
            lock (mutex)
            {
                //当前总的在线用户数
                _TotalClientCount--;

                TheKingOfPKGetawardFlag.Remove(client.ClientData.RoleID);
            }

            ProcessTimeNotifyBattleKilledNum(true);
        }
Exemple #3
0
        /// <summary>
        /// 处理正在战斗的过程
        /// </summary>
        private void ProcessBattling()
        {
            if (BattlingState == BattleStates.PublishMsg) //广播血战地府的消息给在线用户
            {
                // 消息推送
                int nNow = DateTime.Now.DayOfYear;

                if (m_nPushMsgDayID != nNow)
                {
                    //Global.DayActivityTiggerPushMessage((int)SpecialActivityTypes.TheKingOfPK);

                    Global.UpdateDBGameConfigg(GameConfigNames.PKKingPushMsgDayID, nNow.ToString());

                    m_nPushMsgDayID = nNow;
                }

                //判断如果超过了最大等待时间, 先禁止进入血战地府
                long ticks = DateTime.Now.Ticks / 10000;
                if (ticks >= (StateStartTicks + (WaitingEnterSecs * 1000)))
                {
                    //向血战地府场景内的角色发送准备战斗倒计时消息
                    //发送广播消息
                    GameManager.ClientMgr.NotifyArenaBattleInviteMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, MapCode, (int)BattleCmds.Time, (int)BattleStates.WaitingFight, PrepareSecs);

                    BattlingState   = BattleStates.WaitingFight;
                    StateStartTicks = DateTime.Now.Ticks / 10000;
                }
            }
            else if (BattlingState == BattleStates.WaitingFight) //等待战斗倒计时(此时禁止新用户进入, 此时伤害无效)
            {
                //如果超过了最大倒计时时间,允许角色进入战斗伤害
                long ticks = DateTime.Now.Ticks / 10000;
                if (ticks >= (StateStartTicks + (PrepareSecs * 1000)))
                {
                    //是否允许攻击
                    AllowAttack = true;

                    //向血战地府场景内的角色发送战斗倒计时消息
                    //发送广播消息
                    GameManager.ClientMgr.NotifyArenaBattleInviteMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, MapCode, (int)BattleCmds.Time, (int)BattleStates.StartFight, FightingSecs);

                    //开始时角色的人数
                    StartRoleNum = GameManager.ClientMgr.GetMapClientsCount(MapCode);

                    EnterBattleClientCount = StartRoleNum;
                    AllKilledRoleNum       = 0;

                    BattlingState   = BattleStates.StartFight;
                    StateStartTicks = DateTime.Now.Ticks / 10000;

                    //上次阵营积分通知的时间
                    LastNotifyBattleKilledNumTicks = StateStartTicks;

                    ProcessTimeNotifyBattleKilledNum(true);
                }
            }
            else if (BattlingState == BattleStates.StartFight) //开始战斗(倒计时中)
            {
                //如果超过了最大倒计时时间,允许角色进入战斗伤害
                long ticks = DateTime.Now.Ticks / 10000;

                //战斗时间结束,停止战斗
                if (ticks >= (StateStartTicks + (FightingSecs * 1000)))
                {
                    //是否允许攻击
                    AllowAttack = false;

                    BattlingState   = BattleStates.EndFight;
                    StateStartTicks = DateTime.Now.Ticks / 10000;
                }
                //如果超过了30秒,且血战地府中只剩余一个人,同样结束战斗
                else if (ticks >= (StateStartTicks + (30 * 1 * 1000)))
                {
                    //现在角色的人数
                    // int roleNum = GameManager.ClientMgr.GetMapClientsCount(MapCode);
                    // 不能根据地图中现有的人来算,在发送死亡通知时,死亡的人可能收不到死亡消息,造成有可能继续留在地图中一段时间 ChenXiaojun
                    int roleNum = EnterBattleClientCount - AllKilledRoleNum;
                    if (GameManager.ClientMgr.GetMapClientsCount(MapCode) <= 1)
                    {
                        // 地图人数与统计剩余人数不一致时记日志 ChenXiaojun
                        int nMapRoleNum = GameManager.ClientMgr.GetMapClientsCount(MapCode);
                        if (roleNum != nMapRoleNum)
                        {
                            String strLog = String.Format("PK之王活动中地图人数({0})与统计剩余人数({1})不一致", nMapRoleNum, roleNum);
                            LogManager.WriteLog(LogTypes.Error, strLog);
                        }

                        //是否允许攻击
                        AllowAttack = false;

                        BattlingState   = BattleStates.EndFight;
                        StateStartTicks = DateTime.Now.Ticks / 10000;
                    }
                }
                else
                {
                    //定时通知在场的玩家战斗状态
                    ProcessTimeNotifyBattleKilledNum();

                    //定时给在场的玩家增加经验
                    ProcessTimeAddRoleExp();
                }
            }
            else if (BattlingState == BattleStates.EndFight) //结束战斗(此时伤害无效)
            {
                BattlingState   = BattleStates.ClearBattle;
                StateStartTicks = DateTime.Now.Ticks / 10000;

                //向血战地府场景内的角色发送战斗清场倒计时消息
                //发送广播消息
                GameManager.ClientMgr.NotifyArenaBattleInviteMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, MapCode, (int)BattleCmds.Time, (int)BattleStates.ClearBattle, ClearRolesSecs);

                //开始计算给予的奖励
                /// 处理血战地府结束时的奖励
                ProcessBattleResultAwards();
            }
            else if (BattlingState == BattleStates.ClearBattle) //清空战斗场景
            {
                //如果超过了最大倒计时时间,允许角色进入战斗伤害
                long ticks = DateTime.Now.Ticks / 10000;
                if (ticks >= (StateStartTicks + (ClearRolesSecs * 1000)))
                {
                    //强迫将所有逗留的用户强制传送出去
                    GameManager.ClientMgr.NotifyBattleLeaveMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, MapCode);

                    BattlingState   = BattleStates.NoBattle;
                    StateStartTicks = 0;

                    // 清空 [4/2/2014 LiaoWei]
                    TheKingOfPKGetawardFlag.Clear();
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 给奖励
        /// </summary>
        private void ProcessAward(GameClient client)
        {
            int nFlag;

            if (BattlingState < BattleStates.StartFight)
            {
                //开始战斗前离开不给奖励
                return;
            }
            else if (BattlingState == BattleStates.StartFight)
            {
                long ticks = DateTime.Now.Ticks / 10000;
                if (ticks < StateStartTicks + 1000) //进场1秒后退出才给奖励,防止卡时间点刷奖励
                {
                    return;
                }
            }

            lock (mutex)
            {
                if (!TheKingOfPKGetawardFlag.TryGetValue(client.ClientData.RoleID, out nFlag))
                {
                    return;
                }

                if (nFlag > 0)
                {
                    return;
                }

                TheKingOfPKGetawardFlag[client.ClientData.RoleID] = 1;
            }

            if (client.ClientData.KingOfPkCurrentPoint > TheKingOfPKTopPoint)
            {
                SetTotalPointInfo(client.ClientData.RoleName, client.ClientData.KingOfPkCurrentPoint);
            }

            // 1.成就=系数1+Min(系数2,积分)*系数3   2.经验=Min(400,转生级别*400+人物等级)*系数1+Min(系数2,积分)*系数3  2014.4.21改成 人物级别*转生级别对应比例*系数1 +Min(系数2,积分)*系数3
            // 经验=系数1*SystemParams.xml定义的ZhuanShengExpXiShu参数值+Min(系数2,积分)*系数3*SystemParams.xml定义的ZhuanShengExpXiShu参数值

            string strPkAward = GameManager.systemParamsList.GetParamValueByName("PkAward");

            string[] strChengJiu    = null;
            string[] strExp         = null;
            int      nChengjiuPoint = 0;
            long     nExp           = 0;


            if (!string.IsNullOrEmpty(strPkAward))
            {
                string[] strFild = strPkAward.Split('|');

                string strInfo = strFild[0];

                strChengJiu = strInfo.Split(',');

                strInfo = strFild[1];

                strExp = strInfo.Split(',');
            }

            nChengjiuPoint = Global.SafeConvertToInt32(strChengJiu[0]) + Global.GMin(Global.SafeConvertToInt32(strChengJiu[1]), client.ClientData.KingOfPkCurrentPoint) *
                             Global.SafeConvertToInt32(strChengJiu[2]);

            if (nChengjiuPoint > 0)
            {
                ChengJiuManager.AddChengJiuPoints(client, "角斗赛", nChengjiuPoint, true, true);
            }

            //nExp = Global.GMin(400, client.ClientData.ChangeLifeCount * 400 + client.ClientData.Level) * Global.SafeConvertToInt32(strExp[0]) +
            //            Global.GMin(Global.SafeConvertToInt32(strExp[1]), client.ClientData.KingOfPkCurrentPoint) * Global.SafeConvertToInt32(strExp[2]);

            double nRate = 0.0;

            /*if (client.ClientData.ChangeLifeCount == 0)
             *  nRate = 1;
             * else
             *  nRate = Data.ChangeLifeInfoList[client.ClientData.ChangeLifeCount].ExpProportion;*/

            nRate = Data.ChangeLifeEverydayExpRate[client.ClientData.ChangeLifeCount];

            //(int)(client.ClientData.Level * nRate * Global.SafeConvertToInt32(strExp[0]) + Global.GMin(Global.SafeConvertToInt32(strExp[1]), client.ClientData.KingOfPkCurrentPoint) * Global.SafeConvertToInt32(strExp[2]));
            nExp = (int)(Global.SafeConvertToInt32(strExp[0]) * nRate + Global.GMin(Global.SafeConvertToInt32(strExp[1]), client.ClientData.KingOfPkCurrentPoint) * Global.SafeConvertToInt32(strExp[2]) * nRate);

            double dblExperience = 1.0;
            // 合服期间奖励翻倍
            // 活动时间内
            HeFuAwardTimesActivity activity = HuodongCachingMgr.GetHeFuAwardTimesActivity();

            if (null != activity && activity.InActivityTime() && activity.activityTimes > 0.0)
            {
                dblExperience += activity.activityTimes - 1;
            }
            // 节日多倍奖励
            JieRiMultAwardActivity jieriact = HuodongCachingMgr.GetJieRiMultAwardActivity();

            if (null != jieriact)
            {
                JieRiMultConfig config = jieriact.GetConfig((int)MultActivityType.TheKingOfPK);
                if (null != config)
                {
                    dblExperience += config.GetMult();
                }
            }


            nExp = (int)(nExp * dblExperience);

            if (nExp > 0)
            {
                GameManager.ClientMgr.ProcessRoleExperience(client, nExp);
            }

            string strCmd = "";

            // 1.自己的积分 2.获得成就积分 3.获得经验
            strCmd = string.Format("{0}:{1}:{2}", client.ClientData.KingOfPkCurrentPoint, nChengjiuPoint, nExp);

            client.ClientData.KingOfPkCurrentPoint = 0;

            GameManager.ClientMgr.SendToClient(client, strCmd, (int)TCPGameServerCmds.CMD_SPR_NOTIFYTHEKINGOFPKAWARDINFO);
        }