Esempio n. 1
0
        private async Task <IGameWorld> CreateWorld()
        {
            _worldMaker = new WorldMaker()
                          .SetWorldSize(1000, 1000);

            return(await _worldMaker.Create(this));
        }
Esempio n. 2
0
        private async void CreateNetworkWorld()
        {
            _worldMaker = new NetworkWorldMaker(_networkManager);

            var world = await _worldMaker
                        .Create(this);

            var gameScreen = new GameScreen(world, _networkManager);

            var player = gameScreen.AddPlayer(new Entity(SteamClient.SteamId), true);

            var newPlayerPacket = new NewPlayerPacket
            {
                SteamId = player.EntityId,
                HeadId  = 1,
                X       = (int)player.X,
                Y       = (int)player.Y
            };

            var package = _networkManager.MessagePackager.Package(newPlayerPacket);

            _networkManager.SendMessage(package);

            foreach (var netPlayer in ((NetworkWorldMaker)_worldMaker).PlayersToAdd)
            {
                gameScreen.AddPlayer(new Entity(netPlayer.SteamId)
                {
                    X = netPlayer.X,
                    Y = netPlayer.Y
                });
            }

            ScreenManager.AddScreen(gameScreen);
            ScreenManager.ChangeScreen(gameScreen.Name);
        }