Exemple #1
0
    void Awake()
    {
        Debug.Log("Awake called");
        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);

        player          = GameObject.Find("Player");
        mcHammer        = GameObject.Find("MC Hammer");
        levelImage      = GameObject.Find("LevelImage");
        levelText       = GameObject.Find("LevelText").GetComponent <Text>();
        playAgainButton = GameObject.Find("PlayAgainButton");
        giveUpButton    = GameObject.Find("GiveUpButton");

        DancerSpawner = GameObject.Find("BG Spawner").GetComponent <CreateDancer>();
        HammerSpawner = GameObject.Find("HammerSpawner").GetComponent <HammerSpawn>();
        PopperSpawner = GameObject.Find("Popper Spawner").GetComponent <PopperSpawner>();
        RocketSpawner = GameObject.Find("RocketSpawner").GetComponent <RocketSpawner>();
        MCMove        = GameObject.Find("MC Hammer").GetComponent <MCMove>();

        //SCORE - get the score text UI
        scoreUITextGO  = GameObject.FindGameObjectWithTag("ScoreTextTag");
        scoreUITextGO2 = GameObject.FindGameObjectWithTag("ScoreText2Tag");
        scoreUITextGO3 = GameObject.FindGameObjectWithTag("ScoreHiTextTag");
        imgNewGO       = GameObject.Find("NEW");

        //SCORE - initialize
        scoreUITextGO.GetComponent <GameScore>().Score = 0;
        //SCORE - hide hiscore features
        imgNewGO.SetActive(false);


        levelImage.SetActive(false);
        playAgainButton.SetActive(false);
        giveUpButton.SetActive(false);

        level = 1;
        InitGame();
    }
Exemple #2
0
    private void Awake()
    {
        rb                           = GetComponent <Rigidbody>();
        rocketTrail                  = GetComponent <RocketTrail>();
        slowMotionController         = GetComponent <SlowMotionController>();
        progressManager              = FindObjectOfType <ProgressManager>();
        GameManager.ChangeModeEvent += ChangeMode;

        rocketT = GetComponent <Transform>();
        playerT = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();

        //Выстраивание рокеты в мировом пространстве
        rocketSpawner = RocketSpawner.Instatnce;
    }
Exemple #3
0
 private void Awake()
 {
     Instatnce = this;
     Random.InitState(System.DateTime.Now.Millisecond);
     GameManager.ChangeModeEvent += ChangeMode;
 }