Esempio n. 1
0
        public Player GetPlayerByClassIndex(char indx)
        {
            switch (indx)
            {
            case '1':
                playerBuilder = new PZshnik();
                break;

            case '2':
                playerBuilder = new Lvasuk();
                break;

            case '3':
                playerBuilder = new Animeshnik();
                break;

            case '4':
                playerBuilder = new DeadInside();
                break;

            default: playerBuilder = new PZshnik(); break;
            }
            ConfiguratePlayer();
            return(playerBuilder.GetPlayer());
        }
Esempio n. 2
0
        public virtual async Task StartListener()
        {
            while (true)
            {
                TcpClient client = server.AcceptTcpClient();

                while (true)
                {
                    await Task.Delay(2);

                    if (client.GetStream().CanRead&& client.Available >= 8)
                    {
                        //byte[] buffer = new byte[client.Available];
                        var dir   = new Director();
                        var build = new PlayerBuilder();
                        dir.Construct(build, client);
                        //client.GetStream().Read(buffer, 0, client.Available);
                        //int userId = BitConverter.ToInt32(buffer, 4);
                        //Server.User user = App.Inst.UserRepo.Users.FirstOrDefault(x => x.Id == userId);//Reikia suziureti id
                        //if (user != null)
                        //{
                        //    user.Client = client;
                        //}
                        //else
                        //{
                        //    user = App.Inst.UserRepo.AddUser(new User(userId));
                        //    user.Client = client;
                        //}
                        //Console.WriteLine("Client " + user.Id.ToString() + "connected.");
                        //Arena.AddPlayer(new Player(user));
                        Arena.AddPlayer(build.GetPlayer());

                        break;
                    }
                }
            }
        }
Esempio n. 3
0
 public Player GetPlayer()
 {
     return(playerBuilder.GetPlayer());
 }
Esempio n. 4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            //HubConnection connection = new HubConnectionBuilder()
            //    .WithUrl("https://margesignalr20201107074704.azurewebsites.net/margechat")
            //    .Build();

            ConnectionProxy connectionProxy = new ConnectionProxy();

            var player = new PlayerBuilder();

            player.BuildPlayerName();
            player.BuildPlayerColor();
            player.BuildPlayerPos();

            var enemy = new EnemyBuilder();

            enemy.BuildPlayerName();
            enemy.BuildPlayerColor();
            enemy.BuildPlayerPos();
            enemy.passConnection(connectionProxy);

            var   darkenBoard = new Darken();
            Board board       = new Board(darkenBoard);
            BoardCoordinatesViewModel chatViewModel = BoardCoordinatesViewModel.CreateConnectedViewModel(connectionProxy, player.GetPlayer(), enemy.GetEnemy(), board);

            MainWindow window = new MainWindow
            {
                DataContext = new MainViewModel(chatViewModel, board)
            };

            window.Show();

            NeutralTileFactory factory = new NeutralTileFactory();

            for (int i = 0; i < 5; i++)
            {
                AbstractNeutralTile tile = factory.GetNeutralTile("Darkest");
                tile.Display(connectionProxy);
            }

            for (int i = 0; i < 5; i++)
            {
                AbstractNeutralTile tile = factory.GetNeutralTile("Lightest");
                tile.Display(connectionProxy);
            }
        }