Beispiel #1
0
        private void Run()
        {
            while (_running)
            {
                try
                {
                    //calculate a time delta here for map updates
                    prevTicks  = ticks;
                    ticks      = DateTime.Now.Ticks;
                    _deltaTime = (ticks - prevTicks) / 10000000.0;

                    for (int i = 0; i < _serverMaps.Count; i++)
                    {
                        ServerMap map = _serverMaps.ElementAt(i).Value;
                        map.Update((float)_deltaTime);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Stop();
                }
            }

            while (_gameClients.Count > 0)
            {
                _gameClients[0].Disconnect();
            }
            _databaseConnection.Close();
        }
Beispiel #2
0
        private GameClient(TcpClient tcpClient, int playerID)
        {
            Server.Instance.AddGameClient(this);

            _tcpClient        = tcpClient;
            _networkStream    = _tcpClient.GetStream();
            _clientIP         = ((IPEndPoint)_tcpClient.Client.RemoteEndPoint).Address.ToString();
            _sendTimer        = 0f;
            _sendingPackets   = false;
            _recievingPackets = false;

            _disconnecting   = false;
            _disconnectTimer = 5f;

            _mapChanged = false;
            _serverMap  = null;

            _mapPlayer = Server.Instance.GetDatabaseConnection().RetrievePlayerQuery(playerID);
            _mapPlayer.OnEventTrigger    += OnEventTrigger;
            _mapPlayer.OnShowMessage     += OnShowMessage;
            _mapPlayer.OnChangeMap       += OnChangeMap;
            _mapPlayer.OnSendMessage     += OnSendMessage;
            _mapPlayer.OnRequestTrade    += OnRequestTrade;
            _mapPlayer.OnStartTrade      += OnStartTrade;
            _mapPlayer.OnAcceptTrade     += OnAcceptTrade;
            _mapPlayer.OnEndTrade        += OnEndTrade;
            _mapPlayer.OnAddTradeItem    += OnAddTradeItem;
            _mapPlayer.OnRemoveTradeItem += OnRemoveTradeItem;
            _mapPlayer.OnShowShop        += OnShowShop;
            _mapPlayer.OnStartBanking    += OnStartBanking;
            _mapPlayer.OnShowWorkbench   += OnShowWorkbench;

            _serverCommands = new List <ServerCommand>();
            _messagePackets = new List <MessagePacket>();
        }
Beispiel #3
0
 public void SetServerMap(ServerMap serverMap)
 {
     _serverMap  = serverMap;
     _mapChanged = true;
 }
Beispiel #4
0
 public EventInterpreter(ServerMap serverMap)
 {
     _serverMap        = serverMap;
     _triggeringEvents = new List <TriggeringEvent>();
 }