示例#1
0
 private void Update()
 {
     if (initialized)                                   // check if it is safe to update
     {
         float[] currentHealth = player.GetHealth();    // grab the health values
         float[] maxHealth     = player.GetMaxHealth();
         for (int i = 0; i < currentHealth.Length; i++) // iterate through bar arrays
         {
             if (barsArray[i].fillAmount != 1)          // check if the bar can gleam again to indicate full health
             {
                 gleamed[i] = false;                    // ready bool value for another gleam
             }
             if (gleaming[i])                           // check if gleaming
             {
                 Gleam(i);                              // continue gleaming if so
             }
             // check if the bar is ready to gleam
             if (barsArray[i].fillAmount == 1 && !gleamed[i])
             {
                 gleamArray[i].color = Color.white; // reset gleam bar
                 gleamed[i]          = true;        // update bool values if so
                 gleaming[i]         = true;
             }
             barsArray[i].fillAmount = UpdateBar(barsArray[i].fillAmount, currentHealth[i], maxHealth[i]);
             if (barsArray[i].GetComponentInChildren <Text>())
             {
                 var x = barsArray[i].GetComponentsInChildren <Text>();
                 x[0].text = (int)currentHealth[i] + "/" + maxHealth[i];
                 x[1].text = names[i];
             }
         }
     }
 }