Exemplo n.º 1
0
    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();
    }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// The Finish
 /// </summary>
 public void Lose()
 {
     OnRefresh?.Invoke();
     Stats.Finish();
     State = new FinishedState();
     //OnFinish?.Invoke();
     OnLose?.Invoke();
 }
Exemplo n.º 4
0
 public void MarkPlayerDeath()
 {
     if (!m_HasLost)
     {
         m_HasLost = true;
         OnLose?.Invoke();
     }
 }
Exemplo n.º 5
0
 void PlayerDeath(Bot _bot)
 {
     if (!roundIsDecided)
     {
         roundIsDecided = true;
         OnLose.Invoke();
     }
 }
Exemplo n.º 6
0
        private void Player_OnDie(IDamageable instance)
        {
            m_EnemyContainer.gameObject.SetActive(false);

            instance.OnDie -= Player_OnDie;

            OnLose?.Invoke();
        }
Exemplo n.º 7
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            GameObject other = collision.gameObject;

            if (other.CompareTag("Player"))
            {
                OnLose?.Invoke();
            }
        }
Exemplo n.º 8
0
 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;
     }
 }
Exemplo n.º 10
0
 private void EndGame(bool win)
 {
     gameUIController.TurnOfRocketButton();
     PlayerPrefs.SetString(GlobalModule.GameData.PPKEY_HAS_SAVE, "false");
     if (win)
     {
         OnWin?.Invoke();
     }
     else
     {
         OnLose?.Invoke();
     }
 }
Exemplo n.º 11
0
    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();
    }
Exemplo n.º 13
0
    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);
    }
Exemplo n.º 14
0
 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();
         }
     }
 }
Exemplo n.º 15
0
        /// <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();
        }
Exemplo n.º 16
0
 /// <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;
            }
        }
Exemplo n.º 18
0
 public void Lose()
 {
     OnLose.Invoke();
 }
Exemplo n.º 19
0
 /// <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();
 }
Exemplo n.º 20
0
 /// <summary>
 /// Метод, оторый вызывает ивент проигрыша
 /// </summary>
 public void Lose()
 {
     OnUpdateSimulator?.Invoke();
     Stop();
     OnLose?.Invoke();
 }