示例#1
0
    private void Update()
    {
        if (_hasWon)
        {
            return;
        }

        bool isThereAnAliveEnemy = false;

        for (int i = 0; i < _enemyControllers.Length; i++)
        {
            if (_enemyControllers[i] != null && !_enemyControllers[i].isDead)
            {
                isThereAnAliveEnemy = true;
                break;
            }
        }
        if (!isThereAnAliveEnemy)
        {
            _hasWon = true;
            DataManager.AddPlayerMaxHealth(DataManager.GetMaxHPRewardForScene(GameManager.gameData.LoadedJamScene));
            JamSceneManager.LoadSceneWithDelay(JamScene.MainMenu, 2.0F);

            if (onPlayerWon != null)
            {
                onPlayerWon.Invoke();
            }
        }
    }
示例#2
0
    public void TakeDamage(int damage)
    {
        if (_isDead)
        {
            return;
        }

        if (DataManager.TakeDamage(damage))
        {
            _isDead = true;

            _rb2d.velocity = Vector2.zero;
            _upperBodyController.Died();
            _lowerBodyController.Died();
            _lowerBodyController.SetMoving(false);
            JamSceneManager.LoadSceneWithDelay(JamScene.MainMenu, 1.0F);
        }

        DamageManager.DisplayDamageAt(damage, transform.position + _damageOffset);
    }