Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientPacketHandler"/> class.
        /// </summary>
        /// <param name="networkSender">The socket sender.</param>
        /// <param name="screenManager">The <see cref="IScreenManager"/>.</param>
        /// <param name="dynamicEntityFactory">The <see cref="IDynamicEntityFactory"/> used to serialize
        /// <see cref="DynamicEntity"/>s.</param>
        /// <exception cref="ArgumentNullException"><paramref name="dynamicEntityFactory" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="screenManager" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="networkSender" /> is <c>null</c>.</exception>
        public ClientPacketHandler(INetworkSender networkSender, IScreenManager screenManager,
                                   IDynamicEntityFactory dynamicEntityFactory)
        {
            if (dynamicEntityFactory == null)
            {
                throw new ArgumentNullException("dynamicEntityFactory");
            }
            if (screenManager == null)
            {
                throw new ArgumentNullException("screenManager");
            }
            if (networkSender == null)
            {
                throw new ArgumentNullException("networkSender");
            }

            _networkSender        = networkSender;
            _dynamicEntityFactory = dynamicEntityFactory;
            _screenManager        = screenManager;

            _peerTradeInfoHandler = new ClientPeerTradeInfoHandler(networkSender);
            _peerTradeInfoHandler.GameMessageCallback += PeerTradeInfoHandler_GameMessageCallback;

            _objGrabber = new ObjGrabber(this);
        }
Beispiel #2
0
        /// <summary>
        /// Handles the <see cref="ClientPeerTradeInfoHandler.GameMessageCallback"/> event from the <see cref="ClientPeerTradeInfoHandler"/>.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ClientPeerTradeInfoHandlerEventArgs"/> instance containing the event data.</param>
        void PeerTradeInfoHandler_GameMessageCallback(ClientPeerTradeInfoHandler sender, ClientPeerTradeInfoHandlerEventArgs e)
        {
            // Parse the GameMessage
            var msg = GameMessageCollection.CurrentLanguage.GetMessage(e.GameMessage, e.Args);

            // Display
            if (!string.IsNullOrEmpty(msg))
            {
                GameplayScreen.AppendToChatOutput(msg);
            }
        }