예제 #1
0
        public GameScreen(IGameWorld gameWorld, INetworkManager networkManager) : base("GameScreen")
        {
            GameWorld      = gameWorld;
            NetworkManager = networkManager;

            PacketManager.Initialize(networkManager);

            var gameScreenUserInterface = new GameScreenUserInterface();

            _interfaceController = new GameScreenUserInterfaceController(gameScreenUserInterface);
            UserInterface        = new MyraUserInterface(gameScreenUserInterface);

            _bluePrintManager = new BluePrintManager(this);

            var updateResolver = new CameraBoundsUpdateResolver(_camera);

            _gameRenderer = new GameRenderer(
                new PlayerRenderer(),
                new WorldRenderer(),
                new LightMapRenderer(),
                updateResolver);

            _playerCreator = new PlayerCreator(
                GameWorld,
                _interfaceController,
                _camera,
                updateResolver);
        }
예제 #2
0
        public Form1(IPlayerCreator playerCreator,IBoardState initialBoard)
        {
            this.initialBoard = initialBoard;
            squaresData = new Dictionary<int, SquareData>();
            this.playerCreator = playerCreator;

            InitializeComponent();
            depthCombo.SelectedIndex = 3;
        }
 public Morabaraba(IBoard board, IPlayerCreator creator)
 {
     CurrentBoard = board;   //init.InitializeBoard(p1Pos,p2Pos);
     this.creator = creator; //new PlayerCreator(ColorType.Colour.Dark,12-p1Pos.Count,12-p2Pos.Count);
     p1           = creator.GetPlayerOne();
     p2           = creator.GetPlayerTwo();
     turn         = true;
     removing     = false;
 }
 public Morabaraba(int unplaced, int unplaced2)
 {
     init         = new GameBoardInitialisor();
     CurrentBoard = init.InitializeBoard();
     creator      = new PlayerCreator(unplaced, unplaced2);
     p1           = creator.GetPlayerOne();
     p2           = creator.GetPlayerTwo();
     turn         = true;
     removing     = false;
 }
예제 #5
0
        public async Task Connect(Form form)
        {
            if (ClientPlayer == null)
            {
                State        = new ConnectingState();
                ClientPlayer = new Player();
                HttpResponseMessage response = await client.PostAsJsonAsync(playersData, ClientPlayer);

                playerCreator          = new PlayerFactory().CreatePlayer(); //PlayerCreatorHandler.GetPlayerCreator();
                enemyCreator           = new EnemyFactory().CreatePlayer();  //PlayerCreatorHandler.GetEnemyCreator();
                currentlyOnlinePlayers = new List <Player>();

                PlayerPlacedBombs = new List <Bomb>();
                enemyPlacedBombs  = new List <Bomb>();

                enemyPlayerModels      = new Dictionary <int, PictureBox>();
                PlayerPlacedBombModels = new Dictionary <int, PictureBox>();
                enemyPlacedBombModels  = new Dictionary <int, PictureBox>();
                if (response.IsSuccessStatusCode)
                {
                    State = new ConnectedState();
#pragma warning disable CS0618 // Type or member is obsolete
                    ClientPlayer = await JsonConvert.DeserializeObjectAsync <Player>(await response.Content.ReadAsStringAsync());

#pragma warning restore CS0618 // Type or member is obsolete
                    ConnectionEstablished = true;

                    ClientPlayerBox = playerCreator.CreatePlayerModel(ClientPlayer);
                    form.Controls.Add(ClientPlayerBox);
                    roomWalls = new List <Wall>();


                    //response = await client.GetAsync(wallsData);

                    HttpResponseMessage wallsResponse = await client.GetAsync(wallsData);


                    if (wallsResponse.IsSuccessStatusCode)
                    {
#pragma warning disable CS0618 // Type or member is obsolete
                        roomWalls = await JsonConvert.DeserializeObjectAsync <List <Wall> >(await wallsResponse.Content.ReadAsStringAsync());

#pragma warning restore CS0618 // Type or member is obsolete
                        if (roomWalls.Count > 0)
                        {
                            await TryTogetMap(form);
                        }
                        else
                        {
                            await TryToCreateMap(form);
                        }
                    }
                }
            }
        }
 public Morabaraba(ICommand command)
 {
     this.command = command;
     init         = new GameBoardInitialisor();
     CurrentBoard = init.InitializeBoard();
     creator      = new PlayerCreator();
     p1           = creator.GetPlayerOne();
     p2           = creator.GetPlayerTwo();
     turn         = true;
     removing     = false;
 }
예제 #7
0
        private void CreatePlayersInGame()
        {
            if (game == null)
            {
                throw new Exception("Creating players requires a game!!! ");
            }

            playerCreator = PlayerCreatorFactory.Create(game);

            game.players = playerCreator.CreateNew(1);
        }
예제 #8
0
        public MainViewModel(
            IPlayerCreator playerCreator,
            IPlayRoundService playRoundService)
        {
            _playerCreator    = playerCreator;
            _playRoundService = playRoundService;

            _communityCards = new ObservableCollection <Card>();

            var deck = new Deck();

            deck.Shuffle();

            var players = InitializePlayers();
        }
예제 #9
0
 public Engine
     (IPlayerCreator playerCreator,
     IGameController gameController,
     IRegistration player,
     IWriter writer,
     IReader reader,
     IApplicationInterface applicationInterface)
 {
     this.playerCreator        = playerCreator;
     this.gameController       = gameController;
     this.player               = player;
     this.Reader               = reader;
     this.applicationInterface = applicationInterface;
     this.Writer               = writer;
 }
예제 #10
0
        public async Task Disconnect(Form form)
        {
            State = new DisconnectingState();
            ConnectionEstablished = false;
            if (ClientPlayer != null)
            {
                HttpResponseMessage response = await client.DeleteAsync(playersData + ClientPlayer.id);

                if (response.IsSuccessStatusCode)
                {
                    ClientPlayer  = null;
                    playerCreator = null;
                    enemyCreator  = null;
                    form.Controls.Remove(ClientPlayerBox);

                    //foreach(Player p in currentlyOnlinePlayers)
                    //{
                    //    form.Controls.Remove(enemyPlayerModels[p.id]);
                    //}

                    foreach (KeyValuePair <int, PictureBox> p in enemyPlayerModels)
                    {
                        form.Controls.Remove(p.Value);
                    }
                    foreach (KeyValuePair <int, PictureBox> p in PlayerPlacedBombModels)
                    {
                        form.Controls.Remove(p.Value);
                    }
                    foreach (KeyValuePair <int, PictureBox> p in enemyPlacedBombModels)
                    {
                        form.Controls.Remove(p.Value);
                    }

                    currentlyOnlinePlayers = null;
                    PlayerPlacedBombs      = null;
                    enemyPlacedBombs       = null;
                    enemyPlayerModels      = null;
                    PlayerPlacedBombModels = null;
                    enemyPlacedBombModels  = null;
                    State = new DisconnectedState();
                    //form.Controls.Remove()
                }
            }
        }
예제 #11
0
 public LocationManager(IMapWorker mapWorker, IPlayerCreator playerCreator)
 {
     _mapWorker     = mapWorker;
     _playerCreator = playerCreator;
 }