Ejemplo n.º 1
0
        public void PollNewMessages()
        {
            trace.TraceVerbose("PollNewMessages");

            if (this.Player != null)
            {
                Message msg;
                while (m_connection.TryGetMessage(out msg))
                {
                    trace.TraceVerbose("OnReceiveMessage({0})", msg);

                    bool handled = DispatchMessage(msg);

                    if (!handled)
                    {
                        this.Player.DispatchMessage(msg);
                    }
                }
            }

            if (!m_connection.IsConnected)
            {
                trace.TraceInformation("PollNewMessages, disconnected");

                OnDisconnected();
            }
        }
Ejemplo n.º 2
0
        bool IsTimeToStartTick()
        {
            VerifyAccess();
            bool r = _IsTimeToStartTick();

            trace.TraceVerbose("IsTimeToStartTick = {0}", r);
            return(r);
        }
Ejemplo n.º 3
0
        void UpdateTileLayout(Size renderSize)
        {
            var tileSize = this.TileSize;

            bool gridSizeChanged = UpdateGridSize(renderSize, tileSize);

            UpdateRenderOffset(renderSize, tileSize);

            trace.TraceVerbose("UpdateTileLayout(rs {0}, gs {1}, ts {2}) -> Off {3:F2}, Grid {4}", renderSize, this.GridSize, tileSize,
                               m_renderOffset, this.GridSize);

            InvalidateTileRender();

            if (TileLayoutChanged != null)
            {
                TileLayoutChanged(this.GridSize, tileSize);
            }

            if (gridSizeChanged)
            {
                if (this.GridSizeChanged != null)
                {
                    this.GridSizeChanged(this, this.GridSize);
                }
            }
        }
Ejemplo n.º 4
0
        void HandleMessage(MapDataTerrainsListMessage msg)
        {
            var env = m_world.GetObject <EnvironmentObject>(msg.Environment);

            trace.TraceVerbose("Received TerrainData for {0} tiles", msg.TileDataList.Count());
            env.SetTerrains(msg.TileDataList);
        }
Ejemplo n.º 5
0
        // Called from world
        void OnTurnStarted(ObjectID livingID)
        {
            turnTrace.TraceVerbose("TurnStart: {0}", livingID);

            if (m_world.IsOurTurn == false)
            {
                return;
            }

            if (this.IsAutoAdvanceTurnEnabled)
            {
                if (this.FocusedObject == null || this.FocusedObject.HasAction)
                {
                    SendProceedTurn();
                }
            }
        }
Ejemplo n.º 6
0
        // Called from User
        public void DispatchMessage(Message m)
        {
            trace.TraceVerbose("DispatchMessage({0})", m);

            var msg = (ServerMessage)m;

            Action <Player, ServerMessage> method = s_handlerMap[msg.GetType()];

            method(this, msg);
        }