Пример #1
0
        public static MarryRoom CreateMarryRoom(GamePlayer player, MarryRoomInfo info)
        {
            if(!player.PlayerCharacter.IsMarried)
            {
                return null;
            }

            MarryRoom room = null;
            DateTime beginTime = DateTime.Now;

            info.PlayerID = player.PlayerCharacter.ID;
            info.PlayerName = player.PlayerCharacter.NickName;
            if (player.PlayerCharacter.Sex == true)
            {
                info.GroomID = info.PlayerID;
                info.GroomName = info.PlayerName;
                info.BrideID = player.PlayerCharacter.SpouseID;
                info.BrideName = player.PlayerCharacter.SpouseName;
            }
            else
            {
                info.BrideID = info.PlayerID;
                info.BrideName = info.PlayerName;
                info.GroomID = player.PlayerCharacter.SpouseID;
                info.GroomName = player.PlayerCharacter.SpouseName;
            }

            info.BeginTime = beginTime;
            info.BreakTime = beginTime;

            using (PlayerBussiness db = new PlayerBussiness())
            {
                if (db.InsertMarryRoomInfo(info))
                {
                    room = new MarryRoom(info, _processor);
                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(info.GroomID);
                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(info.BrideID);
                    GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(info.GroomID, true, info);
                    GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(info.BrideID, true, info);
                }
            }

            if (room != null)
            {

                _locker.AcquireWriterLock();
                try
                {
                    _Rooms.Add(room.Info.ID, room);
                }
                finally
                {
                    _locker.ReleaseWriterLock();
                }

                if (room.AddPlayer(player))
                {
                    room.BeginTimer(60 * 1000 * 60 * room.Info.AvailTime);
                    return room;
                }
            }

            return null;
        }