/// <summary> /// Handles the pause between games timer finishing /// </summary> void HandlePauseBetweenGamesTimerFinished() { // update the progress bar updateProgressBar(); // check whether we need to move onto the next game if (gameCounter == GameConstants.MaxGames) { // if new game, need to reset game count gameCounter = 0; // and move to the next difficult combination difficultyIndex++; } // check if all games have completed if (difficultyIndex >= difficultyList.Count) { // if yes, load statistics scene SceneManager.LoadScene("statistics"); } else { // if not, let listeners know that we are going to start a new game gameStartingEvent.Invoke(); // alternate the starting player for each game started = started == PlayerName.Player1 ? PlayerName.Player2 : PlayerName.Player1; // get the difficulty combination for this game currentDifficulties = difficultyList[difficultyIndex]; // start the new game StartGame(started, currentDifficulties); } }
private void Go_Click(object sender, RoutedEventArgs e) { List <string> names = null; names = spTextboxes.Children.OfType <TextBox>() .Where(texbox => texbox.Name.StartsWith("tbxP")) .Select(texbox => texbox.Text).ToList <string>(); GameStarting?.Invoke(names); }
void HandlePauseTimerFinishedEvent() { gamesDone++; if (gamesDone < numberOfGames) { gameStarting.Invoke(); } else { SceneManager.LoadScene("scenes/statistics"); } }
public void StartGame() { var playingPlayers = GetAllLobbyPlayers().Where(x => x.PlayerPosition != PlayerPosition.Spectator).ToList(); if (playingPlayers.Count < 2) { throw new InvalidActionException("Not enough players."); } _server.OnClientConnected -= ServerOnOnClientConnected; _server.OnClientDisonnected -= ServerOnOnClientDisonnected; // TODO: postarat se o tyto handlery foreach (var lobbyPlayer in GetAllLobbyPlayers().Where(x => x.PlayerHandler != null)) { lobbyPlayer.PlayerHandler.GameStarting(); } // Game updaters var gameUpdaters = new List <IGameUpdater>(); var localGame = new LocalGame(_hostPlayer.PlayerId); gameUpdaters.Add(localGame); foreach (var lobbyPlayer in GetAllLobbyPlayers().Where(x => x.PlayerHandler != null)) { gameUpdaters.Add(new RemoteGameUpdater(lobbyPlayer.PlayerHandler.Receiver)); } var board = new BoardFactory().CreateBoard(); var gameSettings = new GameSettings(); // Build the game manager var gameManager = new GameManager(board, gameSettings, new MultipleGameUpdater(gameUpdaters), GetAllLobbyPlayers()); gameManager.DiceRolling = new DiceRolling(gameManager); gameManager.TurnLogic = new TurnLogic(gameManager); gameManager.Start(); var hostPlayer = gameManager.Players.Find(x => x.PlayerId == _hostPlayer.PlayerId); if (hostPlayer == null) { throw new FatalGameException("Invalid host player id"); } var hostPlayerController = new LocalPlayerController(hostPlayer); localGame.SetPlayerController(hostPlayerController); GameStarting?.Invoke(localGame); }
private IEnumerator StartGameDelayed() { retriesLeft = MAX_RETRIES; GameStarting?.Invoke(this, null); yield return(new WaitUntil(() => IsUILoaded)); IsGameStarted = true; //GameTime = Time.time; Globals.CurrentStartTime = Time.time; Time.timeScale = 1f; GameStarted?.Invoke(this, null); this.RemoveCoroutine(nameof(StartGameDelayed)); }
public void Join(string playerName, string ip, int port) { if (_gameClient != null) { return; } _gameClient = new GameClient(); _gameClient.Disconnected += () => Disconnected?.Invoke(); _gameClient.LobbyException += GameClientOnLobbyException; _gameClient.SetMyPlayerId += GameClientOnSetMyPlayerId; _gameClient.LobbyPlayersUpdated += GameClientOnLobbyPlayersUpdated; _gameClient.ChatServerMessage += GameClientOnChatServerMessage; _gameClient.ChatPlayerMessage += GameClientOnChatPlayerMessage; _gameClient.GameStarting += starting => GameStarting?.Invoke(new RemoteGame(_gameClient, _myPlayerId)); _gameClient.Join(playerName, ip, port); }
private void OnGameStarting(GameStarting gameStarting) { GameStarting?.Invoke(gameStarting); }
protected virtual void OnGameStarting(GameStartingEventArgs args) { GameStarting?.Invoke(this, args); }
private void Update() { if (timerGame.Finished && gameEnd) { currentWaitTime += Time.deltaTime; if (counter < n && currentWaitTime >= waitTime) { counter++; Difficulty diff1; Difficulty diff2; if (counter < 100) { diff1 = Difficulty.Easy; diff2 = Difficulty.Easy; } else if (counter >= 100 && counter < 200) { diff1 = Difficulty.Medium; diff2 = Difficulty.Medium; } else if (counter >= 200 && counter < 300) { diff1 = Difficulty.Hard; diff2 = Difficulty.Hard; } else if (counter >= 300 && counter < 400) { diff1 = Difficulty.Medium; diff2 = Difficulty.Easy; } else if (counter >= 400 && counter < 500) { diff1 = Difficulty.Hard; diff2 = Difficulty.Easy; } else { diff1 = Difficulty.Hard; diff2 = Difficulty.Medium; } StartGame((PlayerName)(counter % 2) , diff1 , diff2); lapText.text = "Lap: " + counter + " of 600"; timerGame.Duration = GameConstants.AiThinkSeconds; timerGame.Run(); gameStarting.Invoke(); gameEnd = false; currentWaitTime = 0; } else if (counter >= n) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } } }
void OnGameStarting(bool starting, Turn turn, string opponentConnectionId, string opponentUserName) { Connection.Current.Status.OpponentDetails = (opponentUserName, opponentConnectionId); GameStarting?.Invoke(starting, turn); }
IEnumerator WaitForKinect() { Debug.Log("Waiting for Kinect"); calibrationImage.fillAmount = 0; calibrationCompletionRate.text = (Mathf.CeilToInt(calibrationImage.fillAmount * 100)).ToString() + "%"; kinectMan.ClearKinectUsers(); bool calibrateKinect = true; //kinectWaitingScreen.SetActive(true); //kinect.StartAcquiringTargetBody(); #if ENABLE_CALIBRATION yield return(new WaitUntil(() => kinectMan.IsUserDetected())); #endif while (calibrationImage.fillAmount < 1f) { #if ENABLE_CALIBRATION calibrateKinect = kinectMan.IsUserDetected(); #endif if (!calibrateKinect) { Debug.Log("Break waiting for Kinect coroutine"); //set fill to 0; //restart calibration in 0.5s; startCalibration(); calibrationImage.DOFillAmount(0.0f, 0.2f); calibrationText.text = "CALIBRATION WAS INTERRUPTED!"; yield break; } if (calibrationImage != null) { calibrationImage.fillAmount = calibrationImage.fillAmount + 0.01f; calibrationImage.color = Color.Lerp(Color.white, new Color(1.0f, 1.0f, 1.0f), calibrationImage.fillAmount); } calibrationCompletionRate.text = (Mathf.CeilToInt(calibrationImage.fillAmount * 100)).ToString() + "%"; if (calibrationText != null) { calibrationText.text = calibrationImage.fillAmount < 0.3f ? "IN PROGRESS..." : calibrationImage.fillAmount < 0.5f ? "HALFWAY THERE!" : calibrationImage.fillAmount < 0.95f ? "JUST A LITTLE MORE!" : "COMPLETED!"; } yield return(new WaitForSeconds(0.02f)); } if (calibrationImageParent != null) { calibrationImageParent.transform.DOPunchScale(new Vector3(0.1f, 0.1f), 0.5f, 5, 0.5f); } //if (calibrationText != null) // calibrationText.transform.DOLocalJump(calibrationText.transform.localPosition, 100f, 1, 0.4f); TrinaxManager.trinaxAudioManager.PlayUISFX(TrinaxAudioManager.AUDIOS.CALIBRATION_DONE, TrinaxAudioManager.AUDIOPLAYER.UI_SFX); yield return(new WaitForSeconds(1.5f)); CalibrationCanvas.DOFade(0, 0.2f).OnComplete(() => { CalibrationCanvas.blocksRaycasts = false; CalibrationCanvas.gameObject.SetActive(false); }); yield return(new WaitForSeconds(0.65f)); Debug.Log("Calibration Complete"); calibrated = true; GameStarting?.Invoke(); }