コード例 #1
0
 //Hides black image used between levels
 public void HideLevelImage()
 {
     //Disable the levelImage gameObject.
     levelImage.SetActive(false);
     VDIMG.SetActive(false);
     //Set doingSetup to false allowing player to move again.
     doingSetup = false;
 }
コード例 #2
0
    //Initializes the game for each level.
    void InitGame()
    {
        //While doingSetup is true the player can't move, prevent player from moving while title card is up.
        doingSetup = true;
        VDIMG      = GameObject.Find("VDIMG");
        //Get a reference to our image LevelImage by finding it by name.
        levelImage = GameObject.Find("LevelImage");

        //Get a reference to our text LevelText's text component by finding it by name and calling GetComponent.
        levelText = GameObject.Find("LevelText").GetComponent <Text>();

        //Set the text of levelText to the string "Day" and append the current level number.
        VDIMG.SetActive(false); // This hides the Valhalla Denied logo after first level.
        bool isBoss = level % 5 == 0 || level == 3;

        if (isBoss)
        {
            levelText.text = "What is that menacing noise?";
        }
        else if (level == 1 || level == 0)
        {
            VDIMG.SetActive(true);
            levelText.text = " ";
        }
        else if (level >= 0 && level <= 10 && level != 1)
        {
            levelText.text = beginningThoughts[Random.Range(0, beginningThoughts.Length)];
        }
        else if (level > 10 && level < 20)
        {
            levelText.text = middleThoughts[Random.Range(0, middleThoughts.Length)];
        }
        else
        {
            levelText.text = endThoughts[Random.Range(0, endThoughts.Length)];
        }


        //Set levelImage to active blocking player's view of the game board during setup.
        levelImage.SetActive(true);

        //Call the HideLevelImage function with a delay in seconds of levelStartDelay.
        Invoke("HideLevelImage", levelStartDelay);

        //Clear any Enemy objects in our List to prepare for next level.
        enemies.Clear();

        //Call the SetupScene function of the BoardManager script, pass it current level number.
        boardScript.SetupScene(level, isBoss);
    }