Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "Barrel")
     {
         game_phase = GAME_PHASES.LOSE;
     }
 }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        switch (game_phase)
        {
        case (GAME_PHASES.MENU):
        {
            if (AreTargetsReady() && ui_manager.game_start || debug_mode)
            {
                audio_manager.PlayMusic();
                game_phase = GAME_PHASES.GAME;
            }

            break;
        }

        case (GAME_PHASES.GAME):
        {
            if (score >= score_to_reach)
            {
                game_phase = GAME_PHASES.WIN;
            }

            //          ---- ENEMIES ----
            // Each "time_between_spawns", a new enemy appears"
            if (timer - last_time_spawn > time_between_spawns)
            {
                GenerateEnemy();
                last_time_spawn     = timer;
                time_between_spawns = Random.Range(min_time_spawns, max_time_spawns);
            }

            // Update movement and states of enemies
            UpdateEnemies();

            //           ---- ITEMS ----
            if (timer - last_time_items > time_between_items)
            {
                GenerateItem();
                last_time_items    = timer;
                time_between_items = Random.Range(min_time_items, max_time_items);
            }

            // Update items
            UpdateItems();

            timer += Time.deltaTime;          // Incrementing timer
        }
        break;

        case (GAME_PHASES.WIN):
        {
            if (ui_manager.main_menu)
            {
                ResetLevel();
                game_phase = GAME_PHASES.MENU;
            }
            break;
        }

        case (GAME_PHASES.LOSE):
        {
            if (ui_manager.main_menu)
            {
                ResetLevel();
                game_phase = GAME_PHASES.MENU;
            }
            break;
        }
        }
    }
Ejemplo n.º 4
0
 public void ChangeGameState(GAME_PHASES phase)
 {
     game_phase = phase;
 }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        game_phase = level_manager.GetComponent <LevelManager>().GetCurrentPhase();

        switch (game_phase)
        {
        case (GAME_PHASES.MENU):
        {
            if (game_on == true)
            {
                game_start = false;
                main_menu  = false;

                you_win_go.SetActive(false);
                you_lose_go.SetActive(false);
                main_menu_go.SetActive(false);

                game_on = false;
            }

            charging_bar_value = 0;

            start_go.SetActive(true);

            break;
        }

        case (GAME_PHASES.GAME):
        {
            if (game_on == false)
            {
                start_go.SetActive(false);

                game_on = true;
            }

            actual_time_value  = player_cannon.GetComponent <TurretController>().final_time;
            charging_bar_value = (int)(actual_time_value / charging_units);

            if (current_balls >= 0)
            {
                balls_marker_go.GetComponent <Text>().text = "Balls: " + current_balls.ToString();
            }
            score_go.GetComponent <Text>().text = "Score: " + current_score.ToString();
        }
        break;

        case (GAME_PHASES.WIN):
        {
            you_win_go.SetActive(true);
            main_menu_go.SetActive(true);

            break;
        }

        case (GAME_PHASES.LOSE):
        {
            you_lose_go.SetActive(true);
            main_menu_go.SetActive(true);

            break;
        }
        }
    }