private IEnumerator GameOver() { AudioManager.Instance.SetPlaying("PlayerExplosion", true); DestroyObjectsInScene(); yield return(new WaitForSeconds(3f)); AudioManager.Instance.Set("BackgroundMusic", 1.0f, 0.1f); AudioManager.Instance.SetPlaying("GameOver", true); yield return(new WaitForSeconds(2f)); AudioManager.Instance.Set("BackgroundMusic", 1.0f, 0.45f); gameOverPanel.SetActive(true); EventSystem.current.SetSelectedGameObject(GameObject.Find("RestartButton"), new BaseEventData(EventSystem.current)); OnGameOver?.Invoke(); // Adds a new highscore with a randomized char name/id string[] alphabet = new string[26] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; string randomName = ""; for (int i = 0; i < UnityEngine.Random.Range(2, 6); i++) { randomName = randomName + alphabet[UnityEngine.Random.Range(0, alphabet.Length)]; } HighscoreTable.Instance.AddHighscoreEntry(score, randomName); scoreText.text = $"{scoreText.text}: <color=#00ffffff>{randomName}"; }
private void onGameOverExecuteLogic() { if (r_BoardManager.IsAllCellsUncovered() && OnGameOver != null) { OnGameOver.Invoke(); } }
public void EndGame(bool victory) { if (gameEnded) { return; // Dont end twice } gameEnded = true; OnEndOfGame?.Invoke(); if (victory) { OnVictory?.Invoke(); } else { OnGameOver?.Invoke(); } TimeManager.Instance.ChangeTimescale(0f); if (endOfGame != null) { StopCoroutine(endOfGame); endOfGame = null; } endOfGame = StartCoroutine(ResetGame()); }
//Check the Distance between two Vectors private bool CheckDistance() { //if(Vector2.Distance(paintHead, playerHead) < distanceToCheck) if (playerUpPivot.position.y > pivotUp.position.y) { //Win Conditions here //Check if the player Win the Last CheckPoint if (lastPaintPail == true) { GameManager.instance.inLastCheckPoint = true; } OnGameOver?.Invoke(false); if (inCheckMode == true) { OnScoreIncrease?.Invoke(true, 1); inCheckMode = false; } return(true); } else { //Lose Conditions here OnGameOver?.Invoke(true); if (inCheckMode == true) { OnScoreIncrease?.Invoke(false, 0); inCheckMode = false; } return(false); } }
public void executeGameover() { gamestate = Gamestate.gameOver; //Debug.LogWarning("executeGameover"); if (gamesPlayedCounter != null) { gamesPlayedCounter.increase(1); //log the number of played games } valueManager.instance.saveAllMinMaxValues(); //save min and max values for all values for the statistics tab if (HighScoreNameLinkerGroup.instance != null) { HighScoreNameLinkerGroup.instance.generateLinks(); } CardStack.instance.resetCardStack(); //reset the card stack CardStack.instance.clearFollowUpStack(); saveGameState(); string currentSceneName = SceneManager.GetActiveScene().name; OnGameOver.Invoke(); SceneManager.LoadScene(currentSceneName); //reload the scene for a clean startup of the game }
// Update is called once per frame void Update() { //Debug.LogWarning("UPDATE : " + currState); if (GameState.PAUSE == currState || GameState.GAME_OVER == currState || GameState.DYING == currState) { return; } // if (player?.position.z > zMaxDistance) // { // OnPlayerReachLimit?.Invoke(zMaxDistance); // } if (player == null) { //game conditions if (GameFlow.LifeCount > 0) { currState = GameState.DYING; GameFlow.LifeCount--; OnPlayerReachLimit?.Invoke(zMaxDistance); OnDie?.Invoke(); Debug.LogWarning("DYING : " + GameFlow.LifeCount); } else { currState = GameState.GAME_OVER; OnGameOver?.Invoke(); } } }
private void BlockEndMoveHandler(Tetromino tetromino) { if (CanAddToGrid(tetromino)) { tetromino.FinishMove(); tetromino.OnBlockEndMove -= BlockEndMoveHandler; _spawner.Remove(tetromino); AddTetrominoToGrid(tetromino); // TODO i deleted destroyed tetromino after adding to grid then need think about what do with tetromino after add and HOW add // TODO made clearing after ending adding to grid animation TryClearFullLinesAndColumns(); // TODO create new tetrominoes after ending animation of clearing _spawner.TryCreateTetrominoes(); if (!CanAddAtLeastOneLiveTetrominoToGrid()) { OnGameOver?.Invoke(); } } else { tetromino.Reset(); } }
private void OnGameOver(OnGameOver obj) { _btnSkins.SetActive(true); _btnSkins.transform.DOMoveX(_BtnSkinInitPlace, 0.3f); _btnVibro.SetActive(true); _btnVibro.transform.DOMoveX(_BtnVibroInitPlace, 0.3f); }
public DinoGame(Scene targetScene) { m_DinoCharacter = targetScene.GetComponentInChildren <DinoCharacter>(); m_DinoCharacter.OnHit += () => OnGameOver?.Invoke(); OnGameOver += () => m_DinoCharacter.State = DinoState.Dead; m_DinoLevel = targetScene.GetComponentInChildren <DinoLevel>(); // in would be nice to load/unload related scenes implicitly // with attribute like [BindScene(k_InGameUISceneName)] App.Services.Get <ISceneService>() .Load <IDinoInGameUI>( k_InGameUISceneName, (scene, ui) => { OnStart += ui.Reset; m_DinoLevel.OnScoreGained += ui.AddPoints; }); OnStart += () => { m_DinoCharacter.State = DinoState.WaitingForStart; m_DinoLevel.Reset(); m_DinoLevel.SetLevelActive(true); m_DinoCharacter.State = DinoState.Grounded; m_DinoCharacter.SetFrozen(false); }; }
private void Win() { state = State.Won; WinScreen.SetActive(true); OnGameOver.Invoke(true); SaveData.GetInstance().SetMaxLevelReached(nextLevel); }
public void TriggerGameOver() { Debug.Log("Triggering game over"); isGameOver = true; nextLevelToLoad = ""; OnGameOver?.Invoke(); }
public void FinishEvent() { Player.NormalizeInfluences(); //FIXME - fora de lugar // Subscribe this to an event if (Turn < maxTurns) { StartEvent(); } else { //Finish game List <Player> players = new List <Player>(FindObjectsOfType <Player>()); // Supremacy victory - turns count expired float power1 = players[0].Power.Total(); float power2 = players[1].Power.Total(); if (power1 > power2) { OnGameOver?.Invoke(players[0]); } else { OnGameOver?.Invoke(players[1]); } Debug.Log("Game is finished"); } OnEventEnd?.Invoke(); }
public void gameOver() { Debug.Log("game over"); isGameOver = true; OnGameOver?.Invoke(); PlayfabData.updatePlayerStats(score); }
private void EndGame() { if (GameOver || processColision) { return; } Pacman.Stop(); Ghosts.ForEach(x => x.Stop()); if (LifeCount > 0) { LifeCount--; WaitAndCall(((int)TIME_TO_RESET * 1000), InitiateGame); } else { OnGameOver?.Invoke(); GameOver = true; UnityEngine.Debug.LogWarning("GAME OVER"); } OnDie?.Invoke(); processColision = true; }
public override void GameOver() { if (OnGameOver != null) { OnGameOver.Invoke(); } }
private void OnTimeAdvance() { if (TimeManager.Instance.CurrentDate.CompareTo(TimeManager.Instance.EndDate) >= 0) { OnGameOver?.Invoke(); } }
/// <summary> /// This is the function to call the OnGameOver event /// </summary> /// <param name="winnerID"></param> public void InvokOnGameOver(int winnerID) { // WinnerID (0 = player1; 1 = player2; 2 = tie) switch (winnerID) { case 0: lastWinningPlayer = "1"; player1Score++; break; case 1: lastWinningPlayer = "2"; player2Score++; break; case 2: lastWinningPlayer = "TIE"; ties++; break; default: throw new InvalidOperationException(); } isGameOver = true; OnGameOver?.Invoke(); }
public static void OnGameOverInvoke(object sender = null) { if (OnGameOver != null) { OnGameOver.Invoke(null, EventArgs.Empty); } }
private void BackgroundWorkCompleted(object sender, RunWorkerCompletedEventArgs e) { if (!e.Cancelled) { _lastSearch = (SearchResult)e.Result; if (_lastSearch.BestMove >= 0 && CurrentState.IsValidMove(_lastSearch.BestMove)) { bool growthHappened = CurrentState.MakeMove(_lastSearch.BestMove); MoveHistory.Add(_lastSearch.BestMove); if (growthHappened) { MoveHistory.Add(Constants.AllGrowMove); } OnMoveMade?.Invoke(growthHappened); if (CurrentState.State == GameState.GameOver) { OnGameOver?.Invoke(CurrentState.Winner, CurrentState.Winner == Player.Draw ? VictoryType.InfiniteEruption : VictoryType.AntipodePathCreation); } else { ComputerPlay(); } } else { // If an engine doesn't find a move, then he adjourns the game CurrentState.Winner = CurrentState.Player == Player.One ? Player.Two : Player.One; OnGameOver?.Invoke(CurrentState.Winner, _lastSearch.Timeout ? VictoryType.OpponentTimeout : VictoryType.ArenaAdjudication); } } }
private void UpdateGridFull(bool wasFull, bool isFull) { if (settings.noScrolling == false) { // Timer stuff if (wasFull == false && isFull) { timeBeforeGameOverMax = LAST_CHANCE_DURATION; timeBeforeGameOverCurrent = timeBeforeGameOverMax; } else if (isFull && !grid.IsFrozen) { float factor = isSpeeding ? 2 : 1; timeBeforeGameOverCurrent -= (DeltaTime * factor); if (timeBeforeGameOverCurrent <= 0) { // :( Log.Warning(" GAME OVER for " + player); SetGameOver(); OnGameOver.Raise(this); } } } }
public static void Send_Over(int teamid, bool win) { OnGameOver xmsg = new OnGameOver(); xmsg.m_iTeamID = teamid; xmsg.m_iWin = win; byte[] msgBytes; using (MemoryStream stream = new MemoryStream()) { ProtoBuf.Serializer.Serialize(stream, xmsg); msgBytes = stream.ToArray(); } OnGame ongame = new OnGame(); ongame.gameData = msgBytes; ongame.m_iRoomID = Network.Myplayer.m_iRoomID; ongame.m_iTableID = Network.gameInfo_sitdown.m_iTableID; ongame.m_icmd = (int)GameID.Die; ongame.gameDataLength = msgBytes.Length; byte[] res; using (MemoryStream stream = new MemoryStream()) { ProtoBuf.Serializer.Serialize(stream, ongame); res = stream.ToArray(); } ClientHeader header = new ClientHeader(); header = GetHeader(MessageID.CMD_PLAYGAME, res.Length); connector.SendMsg(header, res); }
/// <summary> /// Places a chip in a specificed column at the next available row. If the column is full, then an exception is thrown. If the chip is of type /// <see cref="Chip.None"/>, then an exception is thrown. If the chip place was succesful, then the turns are switches via the <see cref="SwitchTurns"/> /// method. /// </summary> /// <param name="column">The column to place the chip in.</param> /// <param name="chip">The chip to be placed in the column.</param> public void PlaceChip(int column, Chip chip) { if (!IsColumnAvailable(column)) { throw new Exception($"The column {column} is filled in completely!"); } if (chip == Chip.None) { throw new InvalidEnumArgumentException("The chip is invalid!"); } gameBoardChips[GetNextAvailableRow(column), column] = chip; OnChipPlaced?.Invoke(this); if (IsGameOver) { UpdateScore(); OnGameOver?.Invoke(this, CurrentGameStatus); } else { SwitchTurns(); } }
private void EndGame() { gameIsOver = true; OnGameOver?.Invoke(); gameOverUI.SetActive(true); }
private void GameOver() { _gameWatch.Stop(); GameState = GameState.Lost; ShowMines(); OnGameOver?.Invoke(this, EventArgs.Empty); }
private void GameManager_OnGameStateChange(EGameStates GameState) { switch (GameState) { case EGameStates.MAIN_MENU: OnMainMenu?.Invoke(); break; case EGameStates.CONNECTING: break; case EGameStates.RELOADING_ROUND: break; case EGameStates.LOADING_NEXTROUND: OnRoundBegin.Invoke(); break; case EGameStates.LOADING_REMATCH: break; case EGameStates.GAMEPLAY: OnGameplayBegin?.Invoke(); break; case EGameStates.ROUND_OVER: OnRoundOver.Invoke(); break; case EGameStates.GAME_OVER: OnGameOver.Invoke(); break; } }
private void PlayerController_OnPlayerDies() { GameStateData gameState = GetGameStateData(); sectionService.Points = 0; sectionService.Level = 1; OnGameOver?.Invoke(this, gameState); }
public void GameOver() { IsGameOver = true; OnGameOver.Invoke(); gameOverUI.SetActive(true); Time.timeScale = 0f; }
// Ends the game /// <summary> /// Ends the game. /// </summary> public void EndGame() { if (!GameOver) { GameOver = true; OnGameOver?.Invoke(); } }
private void Death() { isDead = true; playerShooting.DisableEffects(); anim.SetTrigger("Die"); SoundController.Instance.PlayAudio(TypeAudio.PlayerDeath); OnGameOver?.Invoke(); }
public void GameOver() { currentGameState = GameState.Over; OnGameOver?.Invoke(); intersceneManagerInstance.GetQuestsIntersceneManagement.CheckForFinishedQuests(questCheckingManager.GetTavelledDistance, questCheckingManager.GetNumberOfKilledEnemies, questCheckingManager.GetNumberOfBarellRoll); playerUI.OpenQuestsFrames(intersceneManagerInstance.GetQuestsIntersceneManagement.GetCurrentQuests); }