public CommunicationHandler(int port, IPlayerContainer container, INotifiable notify, IRequestable request) { // TODO: Interface ILobby

            _playerContainer = container;
            _tcpListener = new TcpListener(port);
            _tcpListener.SocketAccepted += SocketAccepted;
            _tcpListener.Start();

            _udpClient = new UdpClient(port);
            _udpClient.DataReceived += UdpClient_DataReceived;
            _udpClient.Start();

            _processor = new DataProcessor(notify, request);
            Console.WriteLine("Server started listening on port : {0}", ((IPEndPoint)_tcpListener.Socket.LocalEndPoint).Port);
        }
예제 #2
0
        private IViewFrame GetFrame(IPlayerContainer playerContainer)
        {
            //Get new frame
            var newframe = MechanicEngine.ViewPort.GetFrame(playerContainer.Player.Id, playerContainer.PreviousTile);

            if (newframe != null)
            {
                //Update currrent tile
                var currentTile = MechanicEngine.ViewPort.GetPlayerCurrentTile(playerContainer.Player.Id);

                _logger.Info(string.Format("Current player tile  X: {0}, Y: {1}", currentTile.Position.X, currentTile.Position.Y));

                if (playerContainer.PreviousTile == null || (currentTile != null && playerContainer.PreviousTile.Position != currentTile.Position))
                {
                    playerContainer.PreviousTile = currentTile;
                }

                return(newframe);
            }

            return(null);
        }
예제 #3
0
 public DomainPlayerIdentityModel(IPlayerContainer container)
 {
     Id = container.PlayerId != null ? (int)container.PlayerId : -1;
 }
예제 #4
0
        public void Awake()
        {
            this.playerContainer = ContainerInstaller.diContainer.Resolve <IPlayerContainer>();

            //       Debug.Log(playerContainer.Player.Name);
        }
예제 #5
0
 public PlayerService()
 {
     _playerContainer = new PlayerContainer();
 }