public void RevealSquare(int row, int col) { if (gameOver || board[row, col].IsRevealed) { return; } board[row, col].IsRevealed = true; if (board[row, col].IsFlagged) { UnflagSquare(row, col); } if (board[row, col].IsMine) { MineRevealed.Raise(this, new SquareEventArgs(row, col)); gameOver = true; timer.Stop(); GameLost.Raise(this, EventArgs.Empty); } else { SafeSquareRevealed.Raise(this, new SquareEventArgs(row, col, board[row, col].AdjacentMines)); if (board[row, col].AdjacentMines == 0) { RevealEmptySquares(row, col); } } if (CheckGameWon()) { OnGameWon(); } }
private void LoseGame(Cell failReason) { IsGameRunning = false; foreach (var cell in cells) { if (cell.Data.Bomb && !cell.Data.Opened) { cell.Open(); } cell.UpdateAppearance(); if (cell == failReason) { cell.MakeBgRed(); } if (!cell.Data.Bomb && cell.Data.Marked) { cell.ShowMistakenMark(); } } GameLost.SafeInvoke(); }
public void LoseGame() { if (_isPlaying == true) { _isPlaying = false; } GameLost?.Invoke(); }
public void Explore() { if (InvaderDeck.IsEmpty) { SendGameEndData(); GameLost?.Invoke(); return; } _currentExplore = InvaderDeck.Dequeue(); SendExploreData(); }
private void SpawnPiece() { CurrentPiece = TetrisPiece.Spawn(this); if (CurrentPiece == null) { State = TetrisBoardState.Stopped; GameLost?.Invoke(this, EventArgs.Empty); return; } CurrentPiece.Draw(); }
private bool CheckIfGameIsEnded() { if (_map.GetCells().Any(x => x.State == CellState.Boom)) { GameLost.Raise(this, EventArgs.Empty); return(true); } if (_map.GetCells().All(x => x.State != CellState.Unknown)) { GameSolved.Raise(this, EventArgs.Empty); return(true); } return(false); }
private void ExplodeNextBomb() { cellsWithBombs.Remove(nextCellToExplode); var explosion = Instantiate(explosionPrefab); Destroy(explosion.gameObject, explosionPrefab.main.duration); explosion.transform.position = nextCellToExplode.transform.position - new Vector3(0, 0, 0.1f); if (cellsWithBombs.Count > 0) { nextCellToExplode = cellsWithBombs[RandomGen.Next(cellsWithBombs.Count)]; Invoke("ExplodeNextBomb", delayBetweenExplosions); } else { GameLost.Invoke(); } }
void OnCollisionEnter(Collision collision) { if ((collision.collider.tag == "Food") && !Movement.TailUnits.Contains(collision.gameObject)) { points++; collision.gameObject.tag = "Obstacle"; collision.gameObject.transform.position = new Vector3(0, 0, -21); Movement.TailUnits.Add(collision.gameObject); Instantiate(TailObject, new Vector3(Random.Range(-16, 17), Random.Range(-9, 10)), new Quaternion()); } else if (collision.collider.tag == "Obstacle" || Movement.TailUnits.Contains(collision.gameObject)) { GameLost.Lost(); return; } }
private void Update() { playerDead = player.isDead; if (quota <= 0 && !playerDead) { QuotaMet?.Invoke(); if (!hasQuotaCollectionSoundPlayed) { quotaCollectionSound.Play(); hasQuotaCollectionSoundPlayed = true; } quotaText.color = green; } if (playerDead) { GameLost?.Invoke(); quotaText.text = "You Lose! Pause (ESC/P) to restart!"; button.enabled = true; quotaImage.enabled = true; quotaText.color = red; } }
private void OnPirateReachedGold(PirateBehaviour pirate) { if (m_remainingLives < 0) { return; } m_remainingLives--; if (m_remainingLives == 0) { // Game is lost! All ye abandon all hope. Debug.Log("The game is over."); GameLost?.Invoke(); m_chestExplosion.Play(); StartCoroutine(DoGameOverSequence()); } // Pivot the chest open, change the bar sprite float life_t = 1.0f - ((float)m_remainingLives / (float)NumLives); m_chestPivot.localRotation = Quaternion.Euler(Vector3.Lerp(Vector3.zero, m_openChestRotation, life_t)); m_barImg.sprite = m_stateSprites[m_remainingLives]; }
public static void LoseGame() => GameLost?.Invoke();
protected virtual void OnGameLost() { GameLost?.Invoke(this, EventArgs.Empty); }
private void OnGameLost(EventData eventData) { GameLost?.Invoke(eventData); }