예제 #1
0
        public void ConnectTwoClients()
        {
            TestHelper.RunWithWebserver(() =>
            {
                bool isFirstRecieved = false;
                bool isSecondRecieved = false;
                bool isFirstGameStart = false;
                bool isSecondGameStart = false;

                var client1 = new ClientComponent();
                var client2 = new ClientComponent();

                client1.RecievedEmpty += () =>
                {
                    isFirstRecieved = true;
                };

                client2.RecievedEmpty += () =>
                {
                    isSecondRecieved = true;
                };

                client1.BeginGame += () => {
                    isFirstGameStart = true;
                };

                client2.BeginGame += () =>
                {
                    isSecondGameStart = true;
                };

                Task.Run(() => {
                    client1.Connect();
                });

                Task.Run(() =>
                {
                    client2.Connect();
                });

                while (!(isFirstRecieved && isSecondRecieved))
                {
                    Thread.Sleep(50);
                }

                while (!(isFirstGameStart && isSecondGameStart))
                {
                    Thread.Sleep(50);
                }
            });
        }
예제 #2
0
        public void ConnectSingleClientCheckReturnData()
        {
            TestHelper.RunWithWebserver(() => {
                bool isAborted = false;

                var comp = new ClientComponent();

                comp.RecievedEmpty += () => {
                    isAborted = true;

                    return;
                };

                //comp.Connect();

                Task.Run(() => comp.Connect());

                while (!isAborted)
                {
                    Thread.Sleep(50);
                }
            });
        }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();

            this._clientComp = new ClientComponent();

            restart.Loaded += (sender, e) =>
            {
                Canvas.SetTop(restart, this.canvas.ActualHeight / 2 - restart.ActualHeight / 2);
                Canvas.SetLeft(restart, this.canvas.ActualWidth / 2 - restart.ActualWidth / 2);
            };
            //this.Loaded += MainWindow_Loaded;
        }
예제 #4
0
        public void TwoClientsOneMoveOtherShoot()
        {
            TestHelper.RunWithWebserver(() =>
            {
                bool isFirstRecieved = false;
                bool isSecondRecieved = false;
                bool isSecondReviecedEnemyMoved = false;

                var client1 = new ClientComponent();
                var client2 = new ClientComponent();

                client1.EnemyMove += (moveType) =>
                {
                    if (moveType == MoveType.MoveRight)
                    {
                        isFirstRecieved = true;
                    }
                };

                client2.EnemyShot += () =>
                {
                    isSecondRecieved = true;
                };

                client2.EnemyMove += (moveType) =>
                {
                    if (moveType == MoveType.MoveLeft)
                        isSecondReviecedEnemyMoved = true;
                };

                Task.Run(() =>
                {
                    client1.Connect();
                    Thread.Sleep(50);
                    client1.Shoot();
                    Thread.Sleep(50);
                    client1.Move(MoveType.MoveLeft);
                });

                Task.Run(() =>
                {
                    client2.Connect();
                    Thread.Sleep(50);
                    client2.Move(MoveType.MoveRight);
                });

                while (!(isFirstRecieved && isSecondRecieved && isSecondReviecedEnemyMoved))
                {
                    Thread.Sleep(50);
                }
            });
        }