Ejemplo n.º 1
0
 // Use this for initialization
 new void Start()
 {
     scale                     = 0;
     barFraction               = 0.0f;
     targetBarFraction         = 1.0f;
     this.transform.localScale = new Vector3(scale, scale, scale);
     bar.transform.localScale  = new Vector3(barFraction, 1, 1);
     state                     = WFHealthBarState.idle;
     barMat                    = barQuad.GetComponent <Renderer> ().material;
     if (isShadow)
     {
         highColor = Color.black;
         lowColor  = Color.white;
     }
     else
     {
         highColor = Color.white;
         lowColor  = Color.black;
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (state == WFHealthBarState.idle)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > blinkTime)
            {
                blink       = !blink;
                elapsedTime = 0.0f;
            }

            if (barFraction > targetBarFraction)
            {
                barFraction -= barSpeed * Time.deltaTime;

                if (barFraction < targetBarFraction)
                {
                    barFraction    = targetBarFraction;
                    healthBarEvent = true;
                }

                Color newColor = RedGreenLerp(barFraction);
                bar.transform.localScale = new Vector3(barFraction, 1, 1);
                barMat.SetColor("_Tint", newColor);
            }

            if ((barFraction <= 0.25f) && blink)
            {
                bar.transform.localScale = new Vector3(0, 1, 1);
            }
            if ((barFraction <= 0.25f) && !blink)
            {
                bar.transform.localScale = new Vector3(barFraction, 1, 1);
            }
        }



        if (state == WFHealthBarState.growing)
        {
            scale += scaleSpeed * Time.deltaTime;
            if (scale >= 1.0f)
            {
                scale = 1.0f;
                state = WFHealthBarState.growing2;
            }
            this.transform.localScale = new Vector3(scale, scale, scale);
        }

        if (state == WFHealthBarState.growing2)
        {
            barFraction += scaleSpeed * Time.deltaTime;
            if (barFraction > 1.0f)
            {
                scale       = 1.0f;
                elapsedTime = 0.0f;
                state       = WFHealthBarState.idle;
                notifyFinishAction();
            }
            Color newColor = RedGreenLerp(barFraction);
            bar.transform.localScale = new Vector3(barFraction, 1, 1);
            barMat.SetColor("_Tint", newColor);
        }
    }
Ejemplo n.º 3
0
 public void grow()
 {
     state = WFHealthBarState.growing;
 }