Exemple #1
0
    // Use this for initialization
    void Start()
    {
        //activated = true;
        //cachedY = timeTransform.position.y;

        minXValue = 0;
        maxXValue = timeTransform.rect.width;

        //currentTime = maxTime;
        g = new Gradient();

        // Populate the color keys at the relative time 0 and 1 (0 and 100%)
        gck = new GradientColorKey[3];
        gck[0].color = new Color32(9,183,62,1);
        gck[0].time = 0.0f;
        gck[1].color = new Color32(255,228,0,1);
        gck[1].time = 0.5f;
        gck[2].color = new Color32(219,101,63,1);
        gck[2].time = 1.0f;

        // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
        gak = new GradientAlphaKey[2];
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 1.0f;
        gak[1].time = 1.0f;
        g.SetKeys(gck, gak);

        CurrentTime = maxTime;
    }
    // Use this for initialization
    void Start()
    {
        ren = GetComponent<MeshRenderer>();
        mat = ren.material;
        initialPos = transform.position;

        pillarGradient = new Gradient();

        gck = pillarGradient.colorKeys;
        gck[0].color = mat.color;
        gck[0].time = 0.0f;
        gck[1].color = hotColor;
        gck[1].time = 1.0f;

        gak = pillarGradient.alphaKeys;
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 1.0f;
        gak[1].time = 1.0f;

        pillarGradient.SetKeys(gck, gak);
    }
    //this method will update the gradient
    private void UpdateGradient()
    {
        //error handling
        if (g == null)
        {
            return;
        }

        //set the new value
        CurrentValue = Value;

        //the FadeFactor is used to set the FadeValue, see ReadMe document for more Info
        FadeValue = ((Mathf.Sin ((Value) * 3.14f))/FadeFactor) ;

        if (FadeFactor == 0)
        {
            print ("FadeFactor = 0 does not produce a good gradient all the way through the bar");
        }

        //clamping values of variables
        FadeFactor = Mathf.Clamp(FadeFactor,-1f,20f);
        CurrentValue = Mathf.Clamp(CurrentValue,0f,1f);
        Value = Mathf.Clamp(Value,0f,1f);
        FadeValue = Mathf.Clamp(FadeValue,0.0001f,1f);

        //create variable to store the colors for the gradient
        gck = new GradientColorKey[GradientColors.Count];

        //add colors to gradient
        int i = 0;
        float f = 0f;
        while (i < GradientColors.Count)
        {
            gck[i].color = GradientColors[i];
            gck[i].time =  f/(GradientColors.Count - 1);
            i++;
            f++;
        }

        //if you do not want to use these colors you can hardcode them like so
        /*
         * gck[0].color = [any color];
         * gck[0].time =  [float number between 0, and 1];
         *
         * gck[1].color = [any color];
         * gck[1].time =  [float number between 0, and 1];
         *
         * ...etc etc etc
         *
         */

        //set the alpha keys for the gradient
        gak = new GradientAlphaKey[3];
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;

        gak[1].alpha = 1.0f;
        gak[1].time = CurrentValue - (FadeValue/2);

        gak[2].alpha = 0.00f;
        gak[2].time = CurrentValue + (FadeValue/2);

        //add keys to gradient
        g.SetKeys(gck,gak);
    }
Exemple #4
0
    void setGradient()
    {
        gradientKeys = new GradientColorKey[4];
        gradientKeys [0].color = headColor_hsv;
        gradientKeys [0].time = 0.0f;
        gradientKeys [1].color = headASColor_hsv;
        gradientKeys [1].time = 0.2f;
        gradientKeys [2].color = bottomAScolor_hsv;
        gradientKeys [2].time = 0.7f;
        gradientKeys [3].color = bottomColor_hsv;
        gradientKeys [3].time = 1.0f;

        gradientAlpha = new GradientAlphaKey[4];
        gradientAlpha [0].alpha = 1.0f;
        gradientAlpha [1].alpha = 1.0f;
        gradientAlpha [2].alpha = 1.0f;
        gradientAlpha [3].alpha = 1.0f;
        gradientAlpha[0].time = 0.0f;
        gradientAlpha[1].time = 0.2f;
        gradientAlpha[2].time = 0.7f;
        gradientAlpha[3].time = 1.0f;

        randomGradient = new Gradient();
        randomGradient.SetKeys(gradientKeys,gradientAlpha);

        gradientKeys = new GradientColorKey[4];
        gradientKeys [0].color = bottomColor_hsv;
        gradientKeys [0].time = 0.0f;
        gradientKeys [1].color = bottomAScolor_hsv;
        gradientKeys [1].time = 0.2f;
        gradientKeys [2].color = headASColor_hsv;
        gradientKeys [2].time = 0.7f;
        gradientKeys [3].color = headColor_hsv;
        gradientKeys [3].time = 1.0f;

        randomGradient2 = new Gradient();
        randomGradient2.SetKeys(gradientKeys,gradientAlpha);
    }
    // Use this for initialization
    void Start()
    {
        // On zoom
        myCamera.to = 3.22f;

        inTuto = PlayerPrefs.GetInt(Constants.PROPULSION_GAME_MAX_PLAYED, 0) < 1;
        //inTuto = PropulsionLevelConfiguration.showTutorial;

        // TODO will not be needed to check max level later...
        int maxDifficulty = PlayerPrefs.GetInt(Constants.PROPULSION_GAME_MAX_DIFFICULTY, 1);
        currentDifficulty = PropulsionLevelConfiguration.currentLevel;
        currentDifficulty = currentDifficulty < 1 ? 1 :
                (currentDifficulty > maxDifficulty ? maxDifficulty : currentDifficulty);

        parentArea = GameObject.Find("/Container").transform;
        // load Tutorial level if needed
        if(inTuto) {
            grid = instanciateLevelFromXml(levelTuto);
        }
        else {
            grid = instanciateLevelFromXml (getRandomLevel(currentDifficulty));
        }
        instanciatePipeGrid (grid);

        // pipe gradient, very ugly
        gradient = new Gradient();
        // Populate the color keys at the relative time 0 and 1 (0 and 100%)
        gck = new GradientColorKey[3];
        gck[0].color = new Color32(0,228,255,1);
        gck[0].time = 0.0f;
        gck[1].color = new Color32(228,198,109,1);
        gck[1].time = 0.5f;
        gck[2].color = new Color32(219,101,63,1);
        gck[2].time = 1.0f;

        // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
        gak = new GradientAlphaKey[2];
        gak[0].alpha = 1.0f;
        gak[0].time = 0.0f;
        gak[1].alpha = 1.0f;
        gak[1].time = 1.0f;
        gradient.SetKeys(gck, gak);

        // manage timer
        timebar.endCallback = onTimerEnd;

        // start camera zoom (the game is virtually paused before zoom is done)
        isPause = true;
        Time.timeScale = 1;
        myCamera.zoomFinishedCallback = delegate() {
            emilieSpeakTime();
        };
    }