Beispiel #1
0
        public void Initialize()
        {
            // getting game world from server
            JoinResult initInfo = m_client.Join();

            m_ownGuid   = initInfo.PlayerGuid; // assigned by server unique own identifier to identify player
            m_gameWorld = new ClientGameWorld(initInfo.LogicalSize);

            foreach (var staticObject in initInfo.StaticObjects)
            {
                m_gameWorld.AddStaticObject(staticObject);
            }

            m_gameWorldXna = new GameWorldXna(m_game, m_gameWorld, new Rectangle(0, 0, m_game.Graphics.PreferredBackBufferWidth, m_game.Graphics.PreferredBackBufferHeight));
            m_gameWorldXna.Initialize();

            m_infoPanel = new InfoPanel(m_game, m_gameWorldXna);

            #region Create plane, controller and set camera
            m_ownPlane            = XWingPlane.BasicConfiguration(new Vector(m_gameWorld.Size.Width / 2.0, m_gameWorld.Size.Height / 2.0));
            m_ownPlane.PlayerGuid = m_ownGuid;

            m_gameWorld.AddPlaneController(new LocalPlaneController(m_ownPlane));

            m_gameWorldXna.CenterOfViewGameObject = m_ownPlane;
            m_gameWorldXna.ForceSetCameraOnCenterOfView();
            #endregion

            m_synchronizer = new ObjectsSynchronizer(m_client, m_gameWorld, m_ownGuid, m_ownPlane);

            m_gameWorld.AddGameObject(m_ownPlane); // Add after subscribing of GameWorld events

            m_infoPanel.PlaneInfoPanel.Plane = m_ownPlane;
            m_infoPanel.Initialize();
        }
Beispiel #2
0
    private void EnterPlayingState()
    {
        GameDebug.Assert(_gameWorld == null && Game.Instance.levelManager.IsCurrentLevelLoaded());

        _gameWorld = new GameWorld("ClientWorld");

        _gameWorld.RegisterSceneEntities();

        m_resourceSystem = new BundledResourceManager(_gameWorld, "BundledResources/Client");

        _clientGameWorld = new ClientGameWorld(_gameWorld, _networkClient, _networkStatisticsClient, m_resourceSystem);

        m_LocalPlayer = _clientGameWorld.RegisterLocalPlayer(_networkClient.clientId);

        _networkClient.QueueEvent((ushort)GameNetworkEvents.EventType.PlayerReady, true, (ref NetworkWriter data) => { });
    }
Beispiel #3
0
    void EnterPlayingState()
    {
        GameDebug.Assert(m_clientWorld == null && Game.game.levelManager.IsCurrentLevelLoaded());

        m_GameWorld.RegisterSceneEntities();

        m_resourceSystem = new BundledResourceManager("BundledResources/Client");

        m_clientWorld = new ClientGameWorld(m_GameWorld, m_NetworkClient, m_NetworkStatistics, m_resourceSystem);
        m_clientWorld.PredictionEnabled = m_predictionEnabled;

        m_LocalPlayer = m_clientWorld.RegisterLocalPlayer(m_NetworkClient.clientId);

        m_NetworkClient.QueueEvent((ushort)GameNetworkEvents.EventType.PlayerReady, true, (ref NetworkWriter data) => {});

        m_ClientState = ClientState.Playing;
    }
Beispiel #4
0
        public ObjectsSynchronizer(GameServiceClient client, ClientGameWorld world, Guid ownGuid, Plane ownPlane)
        {
            m_ownGuid     = ownGuid;
            m_ownPlane    = ownPlane;
            m_client      = client;
            m_clientWorld = world;

            m_isFirstUpdate = true;
            m_maxId         = -1;
            m_commitQueue   = new List <GameObject>();

            m_updateEvent       = new AutoResetEvent(false);
            m_workerThread      = new Thread(DoUpdateWork);
            m_workerThread.Name = "ObjectsSynchronizer worker";
            m_workerThread.Start();

            m_deleteIdsQueue = new List <Tuple <DateTime, int> >();

            world.GameObjectStatusChanged += GameObjectStatusChanged;
        }