public override void OnTick(MarryRoom room)
        {
            try 
            {
                if(room != null)
                {
                    room.KickAllPlayer();

                    using(PlayerBussiness db = new PlayerBussiness())
                    {
                        db.DisposeMarryRoomInfo(room.Info.ID);
                    }

                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.GroomID);
                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.BrideID);

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

                    MarryRoomMgr.RemoveMarryRoom(room);

                    GSPacketIn pkg = new GSPacketIn((short)ePackageType.MARRY_ROOM_DISPOSE);
                    pkg.WriteInt(room.Info.ID);
                    WorldMgr.MarryScene.SendToALL(pkg);

                    room.StopTimer();
                }
            }
            catch(Exception ex)
            {
                if (log.IsErrorEnabled)
                    log.Error("OnTick",ex);
            }
        }
Beispiel #2
0
        public GSPacketIn SendMarryRoomInfoUpdateToScenePlayers(MarryRoom room)
        {
            GSPacketIn gSPacketIn = new GSPacketIn(255);
            bool       flag       = room != null;

            gSPacketIn.WriteBoolean(flag);
            if (flag)
            {
                gSPacketIn.WriteInt(room.Info.ID);
                gSPacketIn.WriteBoolean(room.Info.IsHymeneal);
                gSPacketIn.WriteString(room.Info.Name);
                gSPacketIn.WriteBoolean(!(room.Info.Pwd == ""));
                gSPacketIn.WriteInt(room.Info.MapIndex);
                gSPacketIn.WriteInt(room.Info.AvailTime);
                gSPacketIn.WriteInt(room.Count);
                gSPacketIn.WriteInt(room.Info.PlayerID);
                gSPacketIn.WriteString(room.Info.PlayerName);
                gSPacketIn.WriteInt(room.Info.GroomID);
                gSPacketIn.WriteString(room.Info.GroomName);
                gSPacketIn.WriteInt(room.Info.BrideID);
                gSPacketIn.WriteString(room.Info.BrideName);
                gSPacketIn.WriteDateTime(room.Info.BeginTime);
                gSPacketIn.WriteByte((byte)room.RoomState);
                gSPacketIn.WriteString(room.Info.RoomIntroduction);
            }
            this.SendToScenePlayer(gSPacketIn);
            return(gSPacketIn);
        }
 public override void OnTick(MarryRoom room)
 {
     try
     {
         if (room != null)
         {
             room.KickAllPlayer();
             using (PlayerBussiness playerBussiness = new PlayerBussiness())
             {
                 playerBussiness.DisposeMarryRoomInfo(room.Info.ID);
             }
             GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.GroomID);
             GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.BrideID);
             GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.GroomID, false, room.Info);
             GameServer.Instance.LoginServer.SendMarryRoomInfoToPlayer(room.Info.BrideID, false, room.Info);
             MarryRoomMgr.RemoveMarryRoom(room);
             GSPacketIn gSPacketIn = new GSPacketIn(254);
             gSPacketIn.WriteInt(room.Info.ID);
             WorldMgr.MarryScene.SendToALL(gSPacketIn);
             room.StopTimer();
         }
     }
     catch (Exception exception)
     {
         if (TankMarryLogicProcessor.log.IsErrorEnabled)
         {
             TankMarryLogicProcessor.log.Error("OnTick", exception);
         }
     }
 }
Beispiel #4
0
        public GSPacketIn SendMarryRoomInfoUpdateToScenePlayers(MarryRoom room)
        {
            GSPacketIn pkg    = new GSPacketIn((short)ePackageType.MARRY_ROOM_UPDATE);
            bool       result = room != null;

            pkg.WriteBoolean(result);
            if (result)
            {
                pkg.WriteInt(room.Info.ID);
                pkg.WriteBoolean(room.Info.IsHymeneal);
                pkg.WriteString(room.Info.Name);
                pkg.WriteBoolean(room.Info.Pwd == "" ? false : true);
                pkg.WriteInt(room.Info.MapIndex);
                pkg.WriteInt(room.Info.AvailTime);
                pkg.WriteInt(room.Count);
                pkg.WriteInt(room.Info.PlayerID);
                pkg.WriteString(room.Info.PlayerName);
                pkg.WriteInt(room.Info.GroomID);
                pkg.WriteString(room.Info.GroomName);
                pkg.WriteInt(room.Info.BrideID);
                pkg.WriteString(room.Info.BrideName);
                pkg.WriteDateTime(room.Info.BeginTime);
                pkg.WriteByte((byte)room.RoomState);
                pkg.WriteString(room.Info.RoomIntroduction);
            }

            SendToScenePlayer(pkg);
            return(pkg);
        }
Beispiel #5
0
 public static MarryRoom[] GetAllMarryRoom()
 {
     MarryRoom[] list = null;
     _locker.AcquireReaderLock();
     try
     {
         list = new MarryRoom[_Rooms.Count];
         _Rooms.Values.CopyTo(list, 0);
     }
     finally
     {
         _locker.ReleaseReaderLock();
     }
     return list == null ? new MarryRoom[0] : list;
 }
 public override void OnGameData(MarryRoom room, GamePlayer player, GSPacketIn packet)
 {
     MarryCmdType type = (MarryCmdType)packet.ReadByte();
     try
     {
         IMarryCommandHandler handleCommand = _commandMgr.LoadCommandHandler((int)type);
         if (handleCommand != null)
         {
             handleCommand.HandleCommand(this, player, packet);
         }
         else
         {
             log.Error(string.Format("IP: {0}", player.Client.TcpEndpoint));
         }
     }
     catch(Exception e)
     {
         log.Error(string.Format("IP:{1}, OnGameData is Error: {0}", e.ToString(),player.Client.TcpEndpoint));
     }
 }
        public override void OnGameData(MarryRoom room, GamePlayer player, GSPacketIn packet)
        {
            MarryCmdType code = (MarryCmdType)packet.ReadByte();

            try
            {
                IMarryCommandHandler marryCommandHandler = this._commandMgr.LoadCommandHandler((int)code);
                if (marryCommandHandler != null)
                {
                    marryCommandHandler.HandleCommand(this, player, packet);
                }
                else
                {
                    TankMarryLogicProcessor.log.Error(string.Format("IP: {0}", player.Client.TcpEndpoint));
                }
            }
            catch (Exception ex)
            {
                TankMarryLogicProcessor.log.Error(string.Format("IP:{1}, OnGameData is Error: {0}", ex.ToString(), player.Client.TcpEndpoint));
            }
        }
Beispiel #8
0
        public override void OnGameData(MarryRoom room, GamePlayer player, GSPacketIn packet)
        {
            MarryCmdType type = (MarryCmdType)packet.ReadByte();

            try
            {
                IMarryCommandHandler handleCommand = _commandMgr.LoadCommandHandler((int)type);
                if (handleCommand != null)
                {
                    handleCommand.HandleCommand(this, player, packet);
                }
                else
                {
                    log.Error(string.Format("IP: {0}", player.Client.TcpEndpoint));
                }
            }
            catch (Exception e)
            {
                log.Error(string.Format("IP:{1}, OnGameData is Error: {0}", e.ToString(), player.Client.TcpEndpoint));
            }
        }
Beispiel #9
0
        public override void OnTick(MarryRoom room)
        {
            try
            {
                if (room != null)
                {
                    room.KickAllPlayer();

                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        db.DisposeMarryRoomInfo(room.Info.ID);
                    }

                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.GroomID);
                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(room.Info.BrideID);

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

                    MarryRoomMgr.RemoveMarryRoom(room);

                    GSPacketIn pkg = new GSPacketIn((short)ePackageType.MARRY_ROOM_DISPOSE);
                    pkg.WriteInt(room.Info.ID);
                    WorldMgr.MarryScene.SendToALL(pkg);

                    room.StopTimer();
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("OnTick", ex);
                }
            }
        }
        public GSPacketIn SendMarryRoomInfo(GamePlayer player, MarryRoom room)
        {
            GSPacketIn pkg = new GSPacketIn((byte)ePackageType.MARRY_ROOM_CREATE, player.PlayerCharacter.ID);
            bool result = room != null;
            pkg.WriteBoolean(result);
            if (result)
            {
                pkg.WriteInt(room.Info.ID);
                pkg.WriteBoolean(room.Info.IsHymeneal);
                pkg.WriteString(room.Info.Name);
                pkg.WriteBoolean(room.Info.Pwd == "" ? false : true);
                pkg.WriteInt(room.Info.MapIndex);
                pkg.WriteInt(room.Info.AvailTime);
                pkg.WriteInt(room.Count);
                pkg.WriteInt(room.Info.PlayerID);
                pkg.WriteString(room.Info.PlayerName);
                pkg.WriteInt(room.Info.GroomID);
                pkg.WriteString(room.Info.GroomName);
                pkg.WriteInt(room.Info.BrideID);
                pkg.WriteString(room.Info.BrideName);
                pkg.WriteDateTime(room.Info.BeginTime);
                pkg.WriteByte((byte)room.RoomState);
                pkg.WriteString(room.Info.RoomIntroduction);
            }

            SendTCP(pkg);
            return pkg;
        }
Beispiel #11
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;
        }
Beispiel #12
0
 public static void RemoveMarryRoom(MarryRoom room)
 {
     _locker.AcquireReaderLock();
     try
     {
         if(_Rooms.Keys.Contains(room.Info.ID))
         {
             _Rooms.Remove(room.Info.ID);
         }
     }
     finally
     {
         _locker.ReleaseReaderLock();
     }
 }
Beispiel #13
0
 public GSPacketIn SendMarryRoomInfo(Game.Server.GameObjects.GamePlayer player, Game.Server.SceneMarryRooms.MarryRoom room)
 {
     throw new NotImplementedException();
 }
Beispiel #14
0
        /// <summary>
        /// This function saves the character and sends a message to all others
        /// that the player has quit the game!
        /// </summary>
        /// <param name="forced">true if Quit can not be prevented!</param>
        public virtual bool Quit()
        {
            try
            {
                //TODO: 新的这种退出办法的问题?
                //      1、经验值不能立刻扣除。
                //      2、退出游戏的逻辑放在房间里面。
                try
                {
                    if (CurrentRoom != null)
                    {
                        CurrentRoom.RemovePlayerUnsafe(this);
                        CurrentRoom = null;
                    }
                    else
                    {
                        RoomMgr.WaitingRoom.RemovePlayer(this);
                    }

                    if (_currentMarryRoom != null)
                    {
                        _currentMarryRoom.RemovePlayer(this);
                        _currentMarryRoom = null;
                    }
                }
                catch (Exception ex)
                {
                    log.Error("Player exit Game Error!", ex);
                }

                m_character.State = 0;
                SaveIntoDatabase();
            }
            catch (Exception ex)
            {
                log.Error("Player exit Error!!!", ex);
            }
            finally
            {
                WorldMgr.RemovePlayer(m_character.ID);
            }
            return true;
        }
 public virtual void OnGameData(MarryRoom game, GamePlayer player, GSPacketIn packet)
 {
 }
Beispiel #16
0
 public virtual void OnGameData(MarryRoom game, Game.Server.GameObjects.GamePlayer player, GSPacketIn packet)
 {
 }
Beispiel #17
0
 public virtual void OnTick(MarryRoom room)
 {
 }
Beispiel #18
0
        public static MarryRoom CreateMarryRoomFromDB(MarryRoomInfo roomInfo,int timeLeft)
        {
            MarryRoom room = null;
            _locker.AcquireWriterLock();
            try
            {
                room = new MarryRoom(roomInfo, _processor);
                if (room != null)
                {
                    _Rooms.Add(room.Info.ID,room);

                    room.BeginTimer(60 * 1000 * timeLeft);
                    return room;
                }
            }
            finally
            {
                _locker.ReleaseWriterLock();
            }

            return null;
        }