Ejemplo n.º 1
0
    //Player is about to finish this "level", and the game will generate another one.
    private void OnTriggerEnter(Collider other)
    {
        if (other.name == "Player" && open && !entered)
        {
            if (transform.parent.name != "StartingLevel")
            {
                //Add score depending on what the theme difficulty is
                if (Skins.levelTheme == Skins.Themes.RUINS)
                {
                    GlobalStats.AddScore(150, other.transform.position);
                }
                else if (Skins.levelTheme == Skins.Themes.FACTORY)
                {
                    GlobalStats.AddScore(250, other.transform.position);
                }
                else if (Skins.levelTheme == Skins.Themes.DUNGEON)
                {
                    GlobalStats.AddScore(150, other.transform.position);
                }
                else
                {
                    GlobalStats.AddScore(100, other.transform.position);
                }

                CoinObjective.CheckForObjective((int)CoinObjective.Objective.BEAT_THEMED_LEVELS, (int)Skins.levelTheme);
            }

            //Remove the arrow cube reference if it exists
            GameObject arrowObject = GameObject.Find("CubeArrow");
            if (arrowObject)
            {
                arrowObject.GetComponent <LookAtCube>().RemoveRefernce();
            }

            SoundManager.PlaySound(SoundManager.Sounds.ENTER_GATE);


            //Remove any obstacles so they stop with the damn spike trap sounds :P
            GameObject[] hazardsToKill = GameObject.FindGameObjectsWithTag("BurnableNotSolid");
            for (int i = hazardsToKill.Length - 1; i >= 0; i--)
            {
                Destroy(hazardsToKill[i]);
            }

            //Ranzomide level theme if that is set
            Skins.CheckForRandomization(true);

            Snake snake = other.GetComponent <Snake>();
            snake.IncreaseSpeed();
            snake.lastSpawnPosition = transform.position;

            //Spawn in more level here. Despawn the oldest level, but not the one being exited.
            entered = true;
            LevelSpawner spawner = GameObject.Find("LevelSpawner").GetComponent <LevelSpawner>();
            spawner.EndLevel(transform.position);
        }
        else if (other.tag == "Wall") //Alternatively if a level is spawned in, despawn any walls that would  be in the way of the door.
        {
            Destroy(other.gameObject);
        }

        Debug.Log(other.tag);
    }