EndTutorial() public method

public EndTutorial ( ) : void
return void
    void OnTriggerEnter2D(Collider2D coll)
    {
        // if(SceneManager.GetActiveScene().name == "play"){
        if (coll.gameObject.tag == "Obstacle")
        {
            ObstacleChildBehaviour obs = coll.gameObject.GetComponent <ObstacleChildBehaviour>() as ObstacleChildBehaviour;
            if (!obs.GetPassable())//obstacle is not passable
            {
                if (SceneManager.GetActiveScene().name == "tutorial")
                {// if tutorial is ongoing
                    GameObject p = Instantiate(playerExplosionParticles, this.transform.position, this.transform.rotation);
                    Destroy(p, 3);

                    TutorialManager tm = GameObject.Find("TutorialManager").GetComponent <TutorialManager>();
                    smashCount = 0;
                    tm.RestartObstaclesTutorial();
                    return;
                }
                if (PowerUpManager.powerUpActive == false)
                { //kill the player
                    GameObject p = Instantiate(playerExplosionParticles, this.transform.position, this.transform.rotation);
                    Destroy(p, 3);
                    GameManager g = GameObject.Find("GameManager").GetComponent <GameManager>();
                    g.EndGame();
                }
                else
                { //player still has life, because power up is active thus disable the powerup
                    Destroy(Instantiate(obstacleBurst, obs.transform.position, obs.transform.rotation), 1.5f);
                    obs.gameObject.SetActive(false);
                    powerUpManager.DisableAdvantages();
                    GameManager.IncreaseScore(1);
                }
            }
            else
            {     //obstacle is passable
                if (SceneManager.GetActiveScene().name == "tutorial")
                { //if tutorial is ongoing
                    smashCount++;
                    if (smashCount >= 5)
                    {
                        TutorialManager tm = GameObject.Find("TutorialManager").GetComponent <TutorialManager>();
                        tm.EndTutorial();
                    }
                }
                Destroy(Instantiate(obstacleBurst, obs.transform.position, obs.transform.rotation), 1.5f);
                obs.gameObject.SetActive(false);
                GameManager.IncreaseScore(1);
            }
        }
        else if (coll.gameObject.tag == "PowerUp")
        { //player has collided with a power up
            GetComponent <AudioSource>().PlayOneShot(powerUpAudioClip);
            coll.gameObject.SetActive(false);
            powerUpManager.ActivatePowerUp();
            Destroy(coll.gameObject);
        }
    }
    private void Update()
    {
        // natural disasters
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            // cheat for cyclone
            Debug.Log("cyclone cheat");
            disasters.DoCyclone();
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            // cheat for drought
            Debug.Log("drought cheat");
            disasters.DoDrought();
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            // cheat for sea level rise
            Debug.Log("sea level rise cheat");
            disasters.DoSeaLevelRise();
        }

        // resources
        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            // cheat for more money
            Debug.Log("money cheat");
            resources.Money += 1_000_000;
        }

        // game state
        if (Input.GetKeyDown(KeyCode.O))
        {
            // cheat for win
            Debug.Log("win cheat");
            endScreen.EnableWinScreen();
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            // cheat for lose
            Debug.Log("lose cheat");
            endScreen.EnableLoseScreen();
        }

        // tutorial
        if (Input.GetKeyDown(KeyCode.Alpha9))
        {
            // cheat to skip the tutorial
            tutorialManager.EndTutorial();
        }
    }
Beispiel #3
0
    public IEnumerator Repair()
    {
        isRepairing = true;
        StartCoroutine(characterSound.BarricadeSound(3));
        yield return(new WaitForSeconds(repairTime));

        if (isRepairing)
        {
            health = _MaxHealth;
            if (_MaxHealth != 0.0f)
            {
                healthBar.fillAmount = health / _MaxHealth;
            }
        }
        isRepairing = false;
        isAlive     = true;

        if (ServiceLocator.Get <LevelManager>().isTutorial == true)
        {
            TutorialManager tutorialManager = GameObject.FindGameObjectWithTag("TutorialManager").GetComponent <TutorialManager>();
            tutorialManager.EndTutorial();
        }
    }