コード例 #1
0
ファイル: Unit.cs プロジェクト: KianBennett/Etherium
    private void updateHealthbar()
    {
        bool show = healthbar.isOnScreen() && (IsHovered() || IsSelected()) && isVisible;

        healthbar.gameObject.SetActive(show);
        healthbar.SetWorldPos(transform.position + Vector3.up * 1.0f);
        healthbar.SetPercentage((float)healthCurrent / healthMax);
    }
コード例 #2
0
    private void updateResourceBar()
    {
        bool show = resourceBar.isOnScreen() && (IsHovered() || lastHarvestTime < 1.0f) && isVisible;

        resourceBar.gameObject.SetActive(show);
        resourceBar.SetWorldPos(transform.position + Vector3.up * 1.5f);
        resourceBar.SetPercentage(resourceAmount);
        resourceBar.offset = shakeOffset;
    }
コード例 #3
0
ファイル: StructureBase.cs プロジェクト: KianBennett/Etherium
    private void updateProgressBar()
    {
        bool show = progressBar.isOnScreen() && unitBuildQueue.Count > 0;

        progressBar.gameObject.SetActive(show);
        progressBar.SetWorldPos(transform.position + Vector3.up * 1.5f);
        if (show)
        {
            progressBar.SetPercentage(buildTick / unitBuildQueue[0].buildTime);
        }
    }
コード例 #4
0
ファイル: Boss.cs プロジェクト: TimWatsonNZ/SpaceShooter
 public override void TakeHit(float damage, string tag)
 {
     base.TakeHit(damage, tag);
     if (!alive)
     {
         Destroy(healthbar);
     }
     else
     {
         healthbar.SetPercentage(currentHealth / startingHealth);
     }
 }
コード例 #5
0
 void Update()
 {
     if (unit != null)
     {
         healthbar.SetPercentage(unit.healthCurrent / unit.healthMax);
         bool borderActive = unit.IsSelected() || isHovered;
         border.gameObject.SetActive(borderActive);
         if (borderActive)
         {
             border.color = unit.IsSelected() ? unit.outlineColourSelected : unit.outlineColourHovered;
         }
     }
 }
コード例 #6
0
ファイル: UnitBuilder.cs プロジェクト: KianBennett/Etherium
    private void updateProgressBar()
    {
        bool show = progressBar.isOnScreen() && isBuilding;

        progressBar.gameObject.SetActive(show);
        if (targetTile != null)
        {
            progressBar.SetWorldPos(targetTile.worldPos + Vector3.up * 1.5f);
        }
        if (show)
        {
            progressBar.SetPercentage(buildAmount / structureToBuild.buildTime);
        }
    }