Exemplo n.º 1
0
        public void StartGameLoop(IApiClient client, SetupState setupState, SetupController setupController)
        {
            if (RoundState != null && RoundState.IsRoundStarted)
            {
                System.Console.WriteLine("Game is already started");
                client.ErrorOccured("Game is already started");
                return;
            }

            RoundState = new RoundState();
            RoundState.IsRoundStarted = true;

            client.RoundStarted();

            //bool success = true;
            Task.Factory.StartNew(() =>
            {
                InitializeAttackerInfo(setupState);
                while (!IsRoundOver(setupState) && RoundState.IsRoundStarted)
                {
                    IsAttackerInRange(client, setupState);
                    AttackerMove(client, setupState);
                    //AttackerRecievedDamage(client);

                    Task.Delay(300).Wait();
                }

                StopShooting(client);
                RoundState.IsRoundStarted = false;
                client.RoundFinished();
                EndOfGame(client);
            });
        }
        public void StartGameLoop(IApiClient client, SetupState setupState, SetupController setupController)
        {
            if (RoundState != null && RoundState.IsRoundStarted)
            {
                System.Console.WriteLine("Game is already started");
                client.ErrorOccured("Game is already started");
                return;
            }

            RoundState = new RoundState();
            RoundState.IsRoundStarted = true;

            client.RoundStarted();

            //bool success = true;
            Task.Factory.StartNew(() =>
            {
                InitializeAttackerInfo(setupState);
                while (!IsRoundOver(setupState)&&RoundState.IsRoundStarted)
                {
                    IsAttackerInRange(client, setupState);
                    AttackerMove(client, setupState);
                    //AttackerRecievedDamage(client);

                    Task.Delay(300).Wait();
                }

                StopShooting(client);
                RoundState.IsRoundStarted = false;
                client.RoundFinished();
                EndOfGame(client);
            });
        }
 public void ConnectDefender(IApiClient client, SetupController setupController)
 {
     if (!IsGameRoomCreated())
     {
         client.ErrorOccured("Trying connect defender before room was created");
         return;
     }
     client.DefenderConnected();
     GameRoomState.IsDefenderConnected = true;
     if (GameRoomState.IsAttackerConnected && GameRoomState.IsDefenderConnected)
     {
         setupController.BeginFirstRoundSetup(client);
     }
 }
 public void ConnectDefender(IApiClient client, SetupController setupController)
 {
     if (!IsGameRoomCreated())
     {
         client.ErrorOccured("Trying connect defender before room was created");
         return;
     }
     client.DefenderConnected();
     GameRoomState.IsDefenderConnected = true;
     if (GameRoomState.IsAttackerConnected && GameRoomState.IsDefenderConnected)
     {
         setupController.BeginFirstRoundSetup(client);
     }
 }
 public void CreateGameRoom(IApiClient client, SetupController setupController)
 {
     GameRoomState = new GameRoomState();
     client.GameRoomCreated();
 }
 public void CreateGameRoom(IApiClient client, SetupController setupController)
 {
     GameRoomState = new GameRoomState();
     client.GameRoomCreated();
 }