Esempio n. 1
0
    private void Start()
    {
        // initialising GA sdk
        GameAnalytics.Initialize();

        //Declare all level related parameters - How many rings? Are the rings moving?
        LevelController.SetLevel();

        ringList.Add(Instantiate(rings[0], new Vector3(0, 0, 0), Quaternion.identity));
        // initial spawn of rings at origin
        for (int i = 0; i < (ringNumber - 1); i++)
        {
            ringList.Add(Instantiate(rings[Random.Range(0, rings.Length)], new Vector3(0, 0, 0), Quaternion.identity));
        }
        ringList[ringList.Count - 1].GetComponent <Circles>().Perfect.SetActive(false);
        // arranges rings by x offset depending on ring size
        AddOffset();

        deltaRings = ringList[ringNumber - 1].transform.position.x - ringList[0].transform.position.x;
        //Add finishline after the last circle
        var finishPos = ringList[ringNumber - 1].transform.position + new Vector3(FinishLineOffset, 0, 0);

        //Instantiate a random minigame at the end
        spawnedFinishLine = Instantiate(FinishLine, finishPos, Quaternion.identity);
        var minigame = Minigames[Random.Range(0, Minigames.Length)];

        spawnedDartBoard = Instantiate(minigame, finishPos, Quaternion.identity);
        spawnedFinishLine.SetActive(false);
        spawnedDartBoard.SetActive(false);
        camRef = finishPos.x;


        for (int i = 1; i < ringNumber; i++)
        {
            //Create a counter object for each circle
            float offset = 0;
            if (ringList[i].tag == "ringsmall")
            {
                offset = 0.75f;
            }
            else if (ringList[i].tag == "ringmedium")
            {
                offset = 0.8f;
            }
            else if (ringList[i].tag == "ringlarge")
            {
                offset = 0.9f;
            }
            var counter = Instantiate(Counter, ringList[i].transform.position - new Vector3(offset, 0, 0), Quaternion.identity);
            counter.GetComponent <Counter>().Ring = ringList[i]; //Hold reference to the ring

            //Check if its moving Rings level
            if (movingRingsLevel)
            {
                //Randomly make the circles move
                var ran = Random.Range(0, 1f);
                if (ran <= CircleMoveChance)
                {
                    ringList[i].GetComponent <Circles>().MakeCircleMove();
                }
            }
        }

        textCurrentscore.text = PlayerPrefs.GetInt("score", 0).ToString();
        textLevelCurrent.text = LevelController.GetLevel().ToString();
        textLevelNext.text    = (LevelController.GetLevel() + 1).ToString();
        mainLevel.text        = "level " + LevelController.GetLevel();
        mainScore.text        = PlayerPrefs.GetInt("score", 0).ToString();
        mainHighscore.text    = PlayerPrefs.GetInt("highscore", 0).ToString();
    }