コード例 #1
0
ファイル: MarryRoomMgr.cs プロジェクト: geniushuai/DDTank-3.0
        private static void CheckRoomStatus()
        {
            using(PlayerBussiness db = new PlayerBussiness())
            {
                MarryRoomInfo[] roomInfos = db.GetMarryRoomInfo();

                foreach(MarryRoomInfo roomInfo in roomInfos)
                {
                    //TimeSpan usedTime = roomInfo.BreakTime - roomInfo.BeginTime;
                    //int timeLeft = roomInfo.AvailTime - usedTime.Hours;
                    
                    if(roomInfo.ServerID != GameServer.Instance.Configuration.ServerID)
                    {
                        continue;
                    }

                    TimeSpan usedTime = DateTime.Now - roomInfo.BeginTime;
                    int timeLeft = roomInfo.AvailTime * 60 - (int)usedTime.TotalMinutes;

                    if (timeLeft > 0)
                    {
                        //创建房间
                        CreateMarryRoomFromDB(roomInfo, timeLeft);
                    }
                    else
                    { 
                        db.DisposeMarryRoomInfo(roomInfo.ID);
                        GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(roomInfo.GroomID);
                        GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(roomInfo.BrideID);

                        GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(roomInfo.GroomID, false, roomInfo);
                        GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(roomInfo.BrideID, false, roomInfo);

                    }

                }
            }
        }