Exemple #1
0
    void Start()
    {
        mc = GameObject.Find("MasterController").GetComponent <MasterControllerScript> ();
        ds = mc.getStorage();

        levelName = ds.retrieveStringValue("CurrentLevel");

        setLevel(0, -1);

        deployedScale = this.transform.localScale.x;
        this.transform.localPosition = new Vector3(0, 0, 0);
        radius  = minRadius;
        status  = warriorIconState.unfolding;
        angle   = Index * 2.0f * 3.1416f / ((float)numberOfElements);
        opacity = targetOpacity = 1.0f;
        this.gameObject.GetComponent <Image>().color = new Vector4(1, 1, 1, opacity * globalOpacity);
    }
Exemple #2
0
    void Update()
    {
        if (opacity < targetOpacity)
        {
            opacity += Time.deltaTime;
            if (opacity > targetOpacity)
            {
                opacity = targetOpacity;
            }
            this.gameObject.GetComponent <Image>().color = new Vector4(1, 1, 1, opacity * globalOpacity);
        }

        if (opacity > targetOpacity)
        {
            opacity -= Time.deltaTime;
            if (opacity < targetOpacity)
            {
                opacity = targetOpacity;
            }
            this.gameObject.GetComponent <Image>().color = new Vector4(1, 1, 1, opacity * globalOpacity);
        }

        float scale = (radius - minRadius) / (maxRadius - minRadius);

        this.transform.localScale = new Vector3(deployedScale * scale, deployedScale * scale, deployedScale * scale);


        if (status == warriorIconState.unfolding)
        {
            radius += radiusSpeed * Time.deltaTime;
            angle  += angleSpeed * Time.deltaTime;
            if (radius > maxRadius)
            {
                radius = maxRadius;
                status = warriorIconState.unfolded;
            }

            float x, y;
            x = radius * Mathf.Cos(angle);
            y = radius * Mathf.Sin(angle);
            Vector3 newPos = new Vector3(x, y, 0);
            this.transform.localPosition = newPos;
        }

        else if (status == warriorIconState.folding)
        {
            radius -= radiusSpeed * Time.deltaTime;
            angle  += angleSpeed * Time.deltaTime;
            if (radius < minRadius)
            {
                radius = minRadius;
                status = warriorIconState.folded;
            }

            float x, y;
            x = radius * Mathf.Cos(angle);
            y = radius * Mathf.Sin(angle);
            Vector3 newPos = new Vector3(x, y, 0);
            this.transform.localPosition = newPos;
        }

        else
        {
            angle += slowAngleSpeed * Time.deltaTime;
            float x, y;
            x = radius * Mathf.Cos(angle);
            y = radius * Mathf.Sin(angle);
            Vector3 newPos = new Vector3(x, y, 0);
            this.transform.localPosition = newPos;
        }
    }