public override void Enter() { base.Enter(); OnControlState?.Invoke(); scoreMultiplier.SetValue(multipliers.baseMultipier); currentScore.SetValue(0); if (IsGameOver() == true) { OnLose?.Invoke(); } else { //Set controller to spawner location control.transform.localPosition = spawner.transform.localPosition; //Spawn blocks SpawnBlocks(); control.StopMovement(); //Give control to player control.StartMovement(); } }
private void ProcessHit(DamageDealer damageDealer) { CameraShake.Instance.ShakeCamera(3f, 0.2f); if (hasShield) { shieldHitCount -= 1; if (shieldHitCount <= 0) { RemoveShield(); } AudioManager.Instance.PlaySound(SoundType.HurtShield); } else { AudioManager.Instance.PlaySound(SoundType.Hurt); health -= damageDealer.GetDamage(); if (health <= 0) { OnHealthUpdate?.Invoke(0); OnLose?.Invoke(0); Destroy(this.gameObject); return; } } OnHealthUpdate?.Invoke(health); damageDealer.Hit(); }
private void Player_OnDie(IDamageable instance) { m_EnemyContainer.gameObject.SetActive(false); instance.OnDie -= Player_OnDie; OnLose?.Invoke(); }
public void MarkPlayerDeath() { if (!m_HasLost) { m_HasLost = true; OnLose?.Invoke(); } }
void PlayerDeath(Bot _bot) { if (!roundIsDecided) { roundIsDecided = true; OnLose.Invoke(); } }
/// <summary> /// The Finish /// </summary> public void Lose() { OnRefresh?.Invoke(); Stats.Finish(); State = new FinishedState(); //OnFinish?.Invoke(); OnLose?.Invoke(); }
private void OnTriggerEnter2D(Collider2D collision) { GameObject other = collision.gameObject; if (other.CompareTag("Player")) { OnLose?.Invoke(); } }
public override void Update() { if (Condition.CheckList(winConditions) && OnWin != null) { OnWin.Invoke(); } if (Condition.CheckList(loseConditions) && OnLose != null) { OnLose.Invoke(); } }
private void CheckForFoodOnScene() { if (foodOnScene.Count == 0) { OnLose?.Invoke(false); FindObjectOfType <PauseController>().enabled = false; } else { _isFoodOnSceneEnd = true; } }
private void EndGame(bool win) { gameUIController.TurnOfRocketButton(); PlayerPrefs.SetString(GlobalModule.GameData.PPKEY_HAS_SAVE, "false"); if (win) { OnWin?.Invoke(); } else { OnLose?.Invoke(); } }
private void CheckGameState() { if (_charactersState[EnemyTag] == 0 && _charactersState[AllyTag] == _alliesToSave) { OnWin?.Invoke(this, EventArgs.Empty); LevelLoader.Instance.LoadNextLevel(); } if (_charactersState[AllyTag] != _alliesToSave) { OnLose?.Invoke(this, EventArgs.Empty); LevelLoader.Instance.ReloadLevel(); } }
private void CheckForLoseCondition() { var sceneSatiety = foodOnScene.Where(food => food != null).Sum(food => food.GetComponent <Collectible>().mealStats.satiety); if (_currentCatSatiety + _currentFoodMachineSatiety + sceneSatiety < maxCatSatiety) { ClearFoodTable(); StopSpawnFood(); OnLose?.Invoke(true); FindObjectOfType <PauseController>().enabled = false; } if (_currentFoodMachineSatiety > 0) { return; } StopSpawnFood(); CheckForFoodOnScene(); }
public void GameOver() { isGameOver = true; bool won = score.CurrentStars >= 1; //TODO: If we see that saving and oading slows the device, //we can import the loaded data that was loaded previously and thus avoid loading inside TrySaveLevelData SaveAndLoadManager.TrySaveLevelData(LevelsManager.CurrentLevelNumber, (UInt32)Score.score, won); //currentLevel.PlayingCount++; if (won /*currentLevel.MinStarsToWin*/) //TODO: hardcoded winning condition(Can be moved to Level) { // currentLevel.LevelSucceeded(); //SaveAndLoadManager.TrySaveLevelData(LevelsManager.CurrentLevelNumber, (UInt32)Score.score); OnWin?.Invoke(score.CurrentStars);//TODO: Record the number of stars or/and score if it's larger than it was previously } else { OnLose.Invoke(); } OnGameOver?.Invoke(Score.score); }
private void Update() { if (!hasFinished && Time.frameCount > 4) // Magic number whatever it works { var location = new Vector2 { x = homeLocation.position.x, y = homeLocation.position.z, }; var distance = Vector2.Distance(location, HerdMember.Target); if (distance < homeRadius) { hasFinished = true; Debug.Log("Won the game."); OnWin?.Invoke(); } else if (herd.JoinedCount() == 0) { hasFinished = true; Debug.Log("Lost the game."); OnLose?.Invoke(); } } }
/// <summary> /// Prevents a default instance of the <see cref="GameController"/> class from being created. /// </summary> /// <param name="width">The width<see cref="int"/></param> /// <param name="height">The height<see cref="int"/></param> private GameController(int width, int height) { if (width < 10) { throw new ArgumentException(nameof(width)); } if (height < 10) { throw new ArgumentException(nameof(height)); } _board = new Board(new StatsRepository(), width, height); _board.OnRefresh += () => OnRefresh?.Invoke(); _board.OnFinish += () => OnFinish?.Invoke(); _board.OnLose += () => OnLose?.Invoke(); _board.OnClear += () => OnClear?.Invoke(); _board.OnMove += () => OnMove?.Invoke(); _board.OnSlide += () => OnSlide?.Invoke(); _board.OnPause += () => OnPause?.Invoke(); _board.OnContinue += () => OnContinue?.Invoke(); _board.OnDrop += () => OnDrop?.Invoke(); }
/// <summary> /// Поставить фигуру /// </summary> /// <returns>Удалось ли поставить фигуру</returns> public bool PutTheFigure() { if (CanWePlaceFigure(PointerCoordinates.X, PointerCoordinates.Y)) { for (int i = 0; i < Figure.FIGURE_SIZE; i++) { for (int j = 0; j < Figure.FIGURE_SIZE; j++) { if (FiguresShapes.Figures[ActiveFigureNumber].FigureShape[i][j].IsFull) { GameField.PlayingField[i + PointerCoordinates.Y][j + PointerCoordinates.X].IsFull = true; } } } DeleteFilledRowsAndColumns(); Score += FiguresShapes.Figures[ActiveFigureNumber].PointsForFigure; ActiveFigureNumber = _pseudoRandomNumberGenerator.Next(0, FiguresShapes.Figures.Length); PointerCoordinates.X = 3; PointerCoordinates.Y = 3; SpawnNewFigure(); if (!IsTherePlaceForFigure()) { _lastGameResults.Score = Score; if ((SortedScores.Capacity == 0) || (SortedScores.Capacity < 10) || (SortedScores[Math.Min(9, SortedScores.Count - 1)].Value < Score)) { OnLose?.Invoke(); } else { OnLoseToMenu?.Invoke(); } return(true); } } return(false); }
private void OnUpdateGameResult(object sender, ClientListener <PlayGameMessage> .TArg e) { //Проверка статуса игры: string status = e.Arg.GameStatus; switch (status) { case PlayGameMessage.PlayingGameStatus: OnUpdate?.Invoke(e.Arg); break; case PlayGameMessage.WinGameStatus: tcpClient.Dispose(); playGameListener.Stop(); OnWin?.Invoke(); break; case PlayGameMessage.LoseGameStatus: tcpClient.Dispose(); playGameListener.Stop(); OnLose?.Invoke(); break; } }
public void Lose() { OnLose.Invoke(); }
/// <summary> /// Método creado para iniciar el broadcast del evento de perdida /// para los componentes del juego que se encuentran suscritos. /// </summary> public void TriggerLose() { OnLose?.Invoke(); }
/// <summary> /// Метод, оторый вызывает ивент проигрыша /// </summary> public void Lose() { OnUpdateSimulator?.Invoke(); Stop(); OnLose?.Invoke(); }
// Metodo que se encarga para los rebotes de la pelota private void ReboundBall() { if (ball.Bottom > Height) { Timer.Stop(); GameData.GameLives(); MessageBox.Show("Ha perdido..." + "\nCuenta con " + GameData.lives + " vidas restantes"); if (GameData.lives == 0) { MessageBox.Show("Ha perdido...\nFin de la partida"); //Agregar puntaje a la Base de Datos var dt = Connection_DataBase.ExecuteQuery($"SELECT player_id FROM players WHERE nickname = '{GameData.Nickname}'"); if (!dt.ExtendedProperties.Values.Count.Equals(0) && !dt.Rows.Count.Equals(0)) { var dr = dt.Rows[0]; var player_id = Convert.ToInt32(dr[0].ToString()); Connection_DataBase.ExecuteNonQuery($"INSERT INTO scores(player_id, score)" + $" VALUES({player_id}, {GameData.Score})"); } GameData.GameRestart(); onLose?.Invoke(); } LiveCount.Text = "Vidas: " + GameData.lives.ToString(); GameData.GameStarted = false; RepositionElements(); Timer.Start(); } if (ball.Left < 0 || ball.Right > Width) { GameData.dirX = -GameData.dirX; return; } if (ball.Bounds.IntersectsWith(PictureBox.Bounds)) { GameData.dirY = -GameData.dirY; } for (int i = 4; i >= 0; i--) { for (int j = 0; j < 10; j++) { if (ball.Bounds.IntersectsWith(CustomPictureBox[i, j].Bounds) && Controls.Contains(CustomPictureBox[i, j])) { CustomPictureBox[i, j].Hits--; if (CustomPictureBox[i, j].Hits == 0) { Controls.Remove(CustomPictureBox[i, j]); GameData.BrokenBricks++; GameData.Score += (GameData.BrokenBricks * 10) + 100; Score.Text = GameData.Score.ToString(); } GameData.dirY = -GameData.dirY; return; } } } }