Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Spawner, Start " + "active");
        gameState = GameState.GetInstance();

        //get LevelBubbles and form an array of ints to choose from

        int currentLvl = gameState.getCurrentLevel();

        Debug.Log("Spawner, Start " + "CurrentLevel: " + currentLvl);
        Level currentLevel = LevelsDescription.getLevelDescription(currentLvl);

        LevelBubble[] levelBubbles = currentLevel.getLevelBubbles();

        int arrayOfBubbleNumbersLength = 0;

        for (int i = 0; i < levelBubbles.Length; i++)
        {
            arrayOfBubbleNumbersLength = arrayOfBubbleNumbersLength + levelBubbles[i].getBubbleProbability();
        }

        bubbleNumbers = new int[arrayOfBubbleNumbersLength];

        int counter = 0;

        Debug.Log("Spawnr: counter 0");

        for (int z = 0; z < levelBubbles.Length; z++)
        {
            for (int k = 0; k < levelBubbles[z].getBubbleProbability(); k++)
            {
                Debug.Log("Spawnr: add " + k + " bubbles with number " + levelBubbles[z].getBubbleNumber() + "to array");
                bubbleNumbers[counter] = levelBubbles[z].getBubbleNumber();
                counter++;
            }
        }


        for (int t = 0; t < bubbleNumbers.Length; t++)
        {
            int tmp = bubbleNumbers[t];
            int r   = Random.Range(t, bubbleNumbers.Length);
            bubbleNumbers[t] = bubbleNumbers[r];
            bubbleNumbers[r] = tmp;
        }

        string bubbleNumbersString = "";

        for (int k = 0; k < bubbleNumbers.Length; k++)
        {
            bubbleNumbersString = bubbleNumbersString + bubbleNumbers[k];
        }

        Debug.Log("Spawner: randomizedBubbleNombres: " + bubbleNumbersString);
    }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        gameState  = GameState.GetInstance();
        speed      = Random.Range(minSpeed, maxSpeed);
        fishScript = GameObject.FindGameObjectWithTag("fish").GetComponent <fish>();
        //string a = GameObject.FindGameObjectWithTag("fishNumberText").GetComponentInChildren<TMP_Text>().text.ToString();
        //fishNum = int.Parse(a);

        Level currentLevel = LevelsDescription.getLevelDescription(gameState.getCurrentLevel());

        fishNum = currentLevel.getFishTargetNumber();
    }
Пример #3
0
    private void setLevel(int levelNumber)
    {
        Level currentLevel = LevelsDescription.getLevelDescription(levelNumber);

        Debug.Log("LevelManager: " + "setLevel,  levelNumber = " + levelNumber);

        //apply level values to scene
        //fish number
        int  fishNum    = currentLevel.getFishTargetNumber();
        fish fishScript = GameObject.FindGameObjectWithTag("fish").GetComponent <fish>();

        fishScript.setFishNumber(fishNum);

        Debug.Log("LevelManager: " + "setLevel,  fishNum = " + fishNum);

        //level name
        string levelName = "" + currentLevel.getLevelName();

        GameObject.FindGameObjectWithTag("LevelName").GetComponentInChildren <TMP_Text>().SetText(levelName);


        Debug.Log("LevelManager: " + "levelName: " + levelName);
    }