Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        float currentHP     = unit.GetCurrentHP();
        float maxHP         = unit.GetMaxHP();
        float HPPercentage  = currentHP / maxHP;
        int   TextureNumber = LayerHealthBarGUIDataArray.Length;
        float divisor       = 1f / (float)TextureNumber;
        int   currentForegroundTextureIndex = HPPercentage == 1 ? TextureNumber - 1 : (int)(HPPercentage * 100) / (int)(divisor * 100);

        topLayeredHealthbar = LayerHealthBarGUIDataArray[currentForegroundTextureIndex];
        if (currentForegroundTextureIndex != 0)
        {
            bottomLayedHealthbar = LayerHealthBarGUIDataArray[currentForegroundTextureIndex - 1];
        }
        else
        {
            bottomLayedHealthbar = null;
        }
        float divisorHP = divisor * maxHP;

        topLayeredHealthbar.realtimeHealthPercentage = (currentHP % divisorHP == 0) ? 1 : (currentHP % divisorHP) / divisorHP;

        topLayeredHealthbar.realtimeColor = Color.Lerp(LayerHealthBarGUIDataArray[currentForegroundTextureIndex].ZeroHealthColor,
                                                       LayerHealthBarGUIDataArray[currentForegroundTextureIndex].FullHealthColor,
                                                       topLayeredHealthbar.realtimeHealthPercentage);

        LocationRect                = HealthBarLocation.GetBound();
        RectOfHealthRealtime        = new Rect(LocationRect);
        RectOfHealthRealtime.width *= topLayeredHealthbar.realtimeHealthPercentage;
        foreach (AdaptiveIcon adaptiveIcon in adaptiveIcons)
        {
            adaptiveIcon.realtimeRect = adaptiveIcon.adaptiveRect.GetBound();
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        float currentHP = unit.GetCurrentHP();
        float maxHP = unit.GetMaxHP();
        float HPPercentage = currentHP / maxHP;
        int TextureNumber = LayerHealthBarGUIDataArray.Length;
        float divisor = 1f / (float)TextureNumber;
        int currentForegroundTextureIndex = HPPercentage == 1 ? TextureNumber - 1 : (int)(HPPercentage * 100) / (int)(divisor * 100);

        topLayeredHealthbar = LayerHealthBarGUIDataArray[currentForegroundTextureIndex];
        if(currentForegroundTextureIndex != 0)
        {
            bottomLayedHealthbar = LayerHealthBarGUIDataArray[currentForegroundTextureIndex-1];
        }
        else
        {
            bottomLayedHealthbar = null;
        }
        float divisorHP = divisor * maxHP;

        topLayeredHealthbar.realtimeHealthPercentage = (currentHP % divisorHP == 0) ? 1 : (currentHP % divisorHP) / divisorHP;

        topLayeredHealthbar.realtimeColor = Color.Lerp(LayerHealthBarGUIDataArray[currentForegroundTextureIndex].ZeroHealthColor,
                                                            LayerHealthBarGUIDataArray[currentForegroundTextureIndex].FullHealthColor,
                                                            topLayeredHealthbar.realtimeHealthPercentage);

        LocationRect = HealthBarLocation.GetBound();
        RectOfHealthRealtime = new Rect(LocationRect);
        RectOfHealthRealtime.width *= topLayeredHealthbar.realtimeHealthPercentage;
        foreach(AdaptiveIcon adaptiveIcon in adaptiveIcons)
        {
            adaptiveIcon.realtimeRect = adaptiveIcon.adaptiveRect.GetBound();
        }
    }
Beispiel #3
0
//	public AdaptiveIcon

    void Awake()
    {
        topLayeredHealthbar  = LayerHealthBarGUIDataArray[LayerHealthBarGUIDataArray.Length - 1];
        bottomLayedHealthbar = LayerHealthBarGUIDataArray.Length == 1 ? topLayeredHealthbar : LayerHealthBarGUIDataArray[LayerHealthBarGUIDataArray.Length - 2];
    }
Beispiel #4
0
 //    public AdaptiveIcon
 void Awake()
 {
     topLayeredHealthbar = LayerHealthBarGUIDataArray[LayerHealthBarGUIDataArray.Length - 1];
     bottomLayedHealthbar = LayerHealthBarGUIDataArray.Length == 1 ? topLayeredHealthbar : LayerHealthBarGUIDataArray[LayerHealthBarGUIDataArray.Length - 2];
 }