예제 #1
0
파일: Building.cs 프로젝트: kkaren/ES2016B
    /*
     * Applies texture to ub depending on its Health and Level
     *
     */

    public void ApplyMainTexture()
    {
        var hp   = health.GetCurrentHealthPercentage();
        var text = skin.material.mainTexture; // to avoid null values

        if (hp > (float)HPThreshold.Medium)
        {
            text = textures[3 * (currentLevel - 1) + (int)UBTextureHPIndex.Full];
        }
        else if ((hp > (float)HPThreshold.Low) && (hp < (float)HPThreshold.Medium))
        {
            text = textures[3 * (currentLevel - 1) + (int)UBTextureHPIndex.Medium];
        }
        else
        {
            text = textures[3 * (currentLevel - 1) + (int)UBTextureHPIndex.Low];
        }

        skin.material.mainTexture = text;
    }
예제 #2
0
파일: Unit.cs 프로젝트: kkaren/ES2016B
 // Receive damage by weapon
 public void ReceiveDamage(float damage)
 {
     try
     {
         health.LoseHealth(damage);
         NotifyHUD();
         //change texture if hp is bellow 50%
         if (health.GetCurrentHealthPercentage() < damageThreshold)
         {
             skin.material.mainTexture = damagedTexture;
         }
     }
     catch (Exception)
     {
         NotifyHUD();
         Die();
     }
 }