예제 #1
0
    // Use this for initialization
    void Start()
    {
        audio_manager = GameObject.FindGameObjectWithTag("Audio_Manager").GetComponent <AudioManager>();
        turret_marker = GameObject.FindGameObjectWithTag("Pos_Turret");
        cannon        = GameObject.FindGameObjectWithTag("Cannon");
        ground_marker = GameObject.FindGameObjectWithTag("Terrain");

        game_phase = GAME_PHASES.MENU;

        timer = 0.0f;
        time_between_items  = Random.Range(min_time_items, max_time_items);
        time_between_spawns = Random.Range(min_time_spawns, max_time_spawns);

        score = 0;

        list_of_enemies           = new List <GameObject>();
        list_of_enemies_to_remove = new List <GameObject>();

        list_of_items           = new List <GameObject>();
        list_of_items_to_remove = new List <GameObject>();

        ui_manager = GameObject.Find("UIManager").GetComponent <InGameUI>();

        //Set ui score
        ui_manager.SetCurrentScore(score);
    }
예제 #2
0
    void ResetLevel()
    {
        // Deleting all enemies
        foreach (GameObject e in list_of_enemies)
        {
            Destroy(e);
        }
        list_of_enemies.Clear();
        list_of_enemies_to_remove.Clear();

        // Deleting all items
        foreach (GameObject i in list_of_items)
        {
            Destroy(i);
        }
        list_of_items.Clear();
        list_of_items_to_remove.Clear();

        // Deleting all balls
        GameObject[] balls = GameObject.FindGameObjectsWithTag("Ball");
        foreach (GameObject b in balls)
        {
            Destroy(b);
        }

        //Reset cannon bullets
        cannon.GetComponent <TurretController>().num_balls = cannon.GetComponent <TurretController>().game_defined_balls;
        ui_manager.SetCurrentBalls(cannon.GetComponent <TurretController>().game_defined_balls);

        // Resetting timers
        last_time_spawn = 0.0f;
        last_time_items = 0.0f;
        timer           = 0.0f;

        // Reset Score value and UI
        score = 0;
        ui_manager.SetCurrentScore(score);

        // Stop music
        audio_manager.StopMusic();
    }