Example #1
0
        private void ProcessDJFightAwards(DJRoomData djRoomData)
        {
            DJRoomRolesData djRoomRolesData = this.FindRoomRolesData(djRoomData.RoomID);

            if (null != djRoomRolesData)
            {
                DJRoomRolesPoint djRoomRolesPoint = new DJRoomRolesPoint
                {
                    RoomID     = djRoomData.RoomID,
                    RoomName   = djRoomData.RoomName,
                    RolePoints = new List <DJRoomRolePoint>()
                };
                lock (djRoomRolesData)
                {
                    int loseTeam        = this.GetLoseTeam(djRoomRolesData);
                    int team1AvgDJPoint = this.GetTeamAvgDJPoint(djRoomRolesData.Team1);
                    int team2AvgDJPoint = this.GetTeamAvgDJPoint(djRoomRolesData.Team2);
                    for (int i = 0; i < djRoomRolesData.Team1.Count; i++)
                    {
                        djRoomRolesPoint.RolePoints.Add(new DJRoomRolePoint
                        {
                            RoleID     = djRoomRolesData.Team1[i].RoleID,
                            RoleName   = djRoomRolesData.Team1[i].RoleName,
                            FightPoint = ((loseTeam > 0) ? this.GetTeamRolePoint(djRoomRolesData.Team1[i], team2AvgDJPoint, loseTeam != 1) : 0)
                        });
                    }
                    for (int i = 0; i < djRoomRolesData.Team2.Count; i++)
                    {
                        djRoomRolesPoint.RolePoints.Add(new DJRoomRolePoint
                        {
                            RoleID     = djRoomRolesData.Team2[i].RoleID,
                            RoleName   = djRoomRolesData.Team2[i].RoleName,
                            FightPoint = ((loseTeam > 0) ? this.GetTeamRolePoint(djRoomRolesData.Team1[i], team1AvgDJPoint, loseTeam != 2) : 0)
                        });
                    }
                }
                for (int i = 0; i < djRoomRolesPoint.RolePoints.Count; i++)
                {
                    if (djRoomRolesPoint.RolePoints[i].FightPoint != 0)
                    {
                        GameManager.DBCmdMgr.AddDBCmd(10023, string.Format("{0}:{1}", djRoomRolesPoint.RolePoints[i].RoleID, djRoomRolesPoint.RolePoints[i].FightPoint), null, 0);
                    }
                }
                GameManager.ClientMgr.NotifyDianJiangRoomRolesPoint(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, djRoomRolesPoint);
            }
        }
Example #2
0
        /// <summary>
        /// 处理点将台结束时的奖励
        /// </summary>
        private void ProcessDJFightAwards(DJRoomData djRoomData)
        {
            DJRoomRolesData djRoomRolesData = FindRoomRolesData(djRoomData.RoomID);

            if (null == djRoomRolesData)
            {
                return;
            }

            DJRoomRolesPoint djRoomRolesPoint = new DJRoomRolesPoint()
            {
                RoomID     = djRoomData.RoomID,
                RoomName   = djRoomData.RoomName,
                RolePoints = new List <DJRoomRolePoint>(),
            };

            lock (djRoomRolesData)
            {
                int loseTeam = GetLoseTeam(djRoomRolesData);
                //if (0 == loseTeam) return;

                //获取队伍1的积分平均值
                int team1AvgDJPoint = GetTeamAvgDJPoint(djRoomRolesData.Team1);

                //获取队伍2的积分平均值
                int team2AvgDJPoint = GetTeamAvgDJPoint(djRoomRolesData.Team2);

                for (int i = 0; i < djRoomRolesData.Team1.Count; i++)
                {
                    djRoomRolesPoint.RolePoints.Add(new DJRoomRolePoint()
                    {
                        RoleID     = djRoomRolesData.Team1[i].RoleID,
                        RoleName   = djRoomRolesData.Team1[i].RoleName,
                        FightPoint = loseTeam > 0 ? GetTeamRolePoint(djRoomRolesData.Team1[i], team2AvgDJPoint, (loseTeam != 1)) : 0,
                    });
                }

                for (int i = 0; i < djRoomRolesData.Team2.Count; i++)
                {
                    djRoomRolesPoint.RolePoints.Add(new DJRoomRolePoint()
                    {
                        RoleID     = djRoomRolesData.Team2[i].RoleID,
                        RoleName   = djRoomRolesData.Team2[i].RoleName,
                        FightPoint = loseTeam > 0 ? GetTeamRolePoint(djRoomRolesData.Team1[i], team1AvgDJPoint, (loseTeam != 2)) : 0,
                    });
                }
            }

            //写入数据库中...
            for (int i = 0; i < djRoomRolesPoint.RolePoints.Count; i++)
            {
                if (djRoomRolesPoint.RolePoints[i].FightPoint != 0)
                {
                    GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_DB_ADDDJPOINT,
                                                  string.Format("{0}:{1}", djRoomRolesPoint.RolePoints[i].RoleID, djRoomRolesPoint.RolePoints[i].FightPoint),
                                                  null, GameManager.LocalServerIdForNotImplement);
                }
            }

            //发送给客户端(参战者,以及所有的观众)
            // 发送点将台房间的战斗结果
            GameManager.ClientMgr.NotifyDianJiangRoomRolesPoint(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, djRoomRolesPoint);
        }