Exemple #1
0
    private int numOfTimesScoreTimesTwoLaunched;                                // the number of times that the Freeze Banana has been launched

    // Use this for pre-initialization
    void Awake()
    {
        //make sure our static LaunchController Instance is set to THIS gameObject
        LaunchControllerInstance = this;

        //our timer reference by calling GetComponent on THIS gameObject
        timer = GetComponent <CountdownTimer>();

        //Use GameObjects FindObjectWithTag method to setup our references to the freeze,frenzy, and 2xScore objects/classes.  Using our Const Strings in "Tags"
        freezeEffectReference        = GameObject.FindGameObjectWithTag(Tags.freezeEffectGameObjectTag).GetComponent <FreezeEffect>();
        frenzyEffectReference        = GameObject.FindGameObjectWithTag(Tags.frenzyEffectGameObjectTag).GetComponent <FrenzyEffect>();
        twoTimesScoreEffectReference = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>();

        //Use GameObjects FindObjectWithTag method to setup our references to the bottom and side fruitLaunchers.
        bottomFruitLaunchers = GameObject.FindGameObjectsWithTag(Tags.bottomFruitLaunchers);
        sideFruitLaunchers   = GameObject.FindGameObjectsWithTag(Tags.sideFruitLaunchers);

        //Initialize the lists  "bottomLaunchersScriptReference" && "sideLaunchersScriptReference"
        bottomLaunchersScriptReference = new List <FruitLauncher>();
        sideLaunchersScriptReference   = new List <FruitLauncher>();

        //loop through all of the bottom fruit launchers
        for (int i = 0; i < bottomFruitLaunchers.Length; i++)
        {
            //now add each bottom fruit launcher to our List ("bottomLaunchersScriptReference")
            bottomLaunchersScriptReference.Add(bottomFruitLaunchers[i].GetComponent <FruitLauncher>());
        }
        //loop through all of the side fruit launchers
        for (int j = 0; j < sideFruitLaunchers.Length; j++)
        {
            //now add each side fruit launcher to our List ("sideLaunchersScriptReference")
            sideLaunchersScriptReference.Add(sideFruitLaunchers[j].GetComponent <FruitLauncher>());
        }
    }
    void Awake()
    {
        //I usually use awake for setting up references, so we will do that first.
        //the next three lines will get a reference to the 3 gameObjects in the game scenes that control the powerUp
        //effects.  These gameObjects each have a spriteRenderer that is used to display the powerUp labels and some have
        //borders (like Freeze Effect).

        //all of the tags in the game are stored in [const readonly strings], in our Tags Class.  There was quite a few
        //different tags, and since I would prefer the scripts to autoComplete, I created read only strings for them.
        freezeEffectGameObject        = GameObject.FindGameObjectWithTag(Tags.freezeEffectGameObjectTag).GetComponent <FreezeEffect>();
        frenzyEffectGameObject        = GameObject.FindGameObjectWithTag(Tags.frenzyEffectGameObjectTag).GetComponent <FrenzyEffect>();
        twoTimesScoreEffectGameObject = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>();

        //cache a reference to this gameObject.
        thisGameObject = this.gameObject;

        //Setup Shake and Chroma Script References... both scripts are on the main camera
        shake  = Camera.main.GetComponent <SimpleCameraShake>();
        chroma = Camera.main.GetComponent <ChromaticAberration>();
    }