Exemple #1
0
    /// <summary>
    /// Reset level to initial settings
    /// </summary>
    private void ResetLevel()
    {
        _score = 0f;

        StopEnemyFishSpawning();
        StopPowerupsSpawning();

        // reset player position
        _player.transform.position   = new Vector3(0, 0, GameConstants.FISH_Z_VALUE);
        _player.transform.localScale = GameConstants.PLAYER_STARTING_SCALE;
        _player.GetComponent <Rigidbody2D>().velocity = Vector2.zero;

        // find all enemy fish game objects and destroy them
        var enemyFish = GameObject.FindGameObjectsWithTag("EnemyFish").ToList();

        DestroyAll(enemyFish);

        // find all obstacle objects and destroy them
        var obstacles = GameObject.FindGameObjectsWithTag("Obstacle").ToList();

        DestroyAll(obstacles);

        // find all active powerups and destroy them
        var powerUps = GameObjectExtensions.FindAllIngameObjectsWithTagPrefix("PowerUp").ToList();

        DestroyAll(powerUps);

        // rest fish speed modifier
        FishEnemySpeedModifier = 1.0f;
    }