예제 #1
0
        public async Task JoinAsync(LocalGameServer gameServer)
        {
            var joinResult = await gameServer.JoinAsync(this);

            if (joinResult.IsSuccessful)
                await InitializeAsync(joinResult.SpawnPosition, gameServer.UnderlyingGameServer);
            else
                throw new InvalidOperationException("Failed to join game server");
        }
        public async Task InitializeAsync()
        {
            var storage = new InMemoryChunkStorage(SampleChunks.MapMetadata);
            await storage.SaveAsync(new Point(0, 0), SampleChunks.Chunk1.Clone());
            await storage.SaveAsync(new Point(-1, 0), SampleChunks.Chunk2.Clone());
            await storage.SaveAsync(new Point(-1, -1), SampleChunks.Chunk3.Clone());

            var map = new Map(storage);
            await map.GetAsync(Point.Zero);

            _gameServer = new GameServer(map);
            LocalServer = new LocalGameServer(_gameServer);
        }
 public LocalGameClientViewModel(LocalGameServer gameServer)
 {
     _server = gameServer;
 }