Beispiel #1
0
    private void UpdateTargetStateUI(Sprite icon, float hp, float maxHp, float mp, float maxMp, int level)
    {
        targetIcon.sprite      = icon;
        targetHpBar.fillAmount = hp / maxHp;
        targetHpText.text      = Mathf.Clamp(hp, 0, maxHp) + " / " + maxHp;
        targetMpBar.fillAmount = mp / maxMp;
        targetMpText.text      = Mathf.Clamp(mp, 0, maxMp) + " / " + maxMp;

        if (target.Level >= Player.Instance.Level + 5)              // >5
        {
            targetLevelText.color = Color.red;
        }
        else if (target.Level >= Player.Instance.Level + 3)         //3~4
        {
            targetLevelText.color = new Color32(255, 124, 0, 255);
        }
        else if (target.Level >= Player.Instance.Level - 2)         //-2~2
        {
            targetLevelText.color = Color.yellow;
        }
        else if (target.Level <= Player.Instance.Level - 3 && target.Level > EXPManager.CalculateGrayLevel())
        {
            targetLevelText.color = Color.green;
        }
        else
        {
            targetLevelText.color = Color.grey;
        }

        targetLevelText.text = level + "";
    }
Beispiel #2
0
    public void ShowTargetFrame(Enemy target)
    {
        targetFrame.SetActive(true);
        enemyHealthStat.Initialize(target.MyHealth.MyCurrentValue, target.MyHealth.MyMaxValue);

        enemyLevelText.text = target.MyLevel.ToString();
        enemyNameText.text  = target.MyName;

        // I have an event on target called healthchanged,
        // updatetargetframe listens for a change in HealthChanged
        // if event is triggered, it executes function UpdateTargetFrame
        target.healthChanged += new HealthChanged(UpdateTargetFrame);

        target.characterRemoved += new CharacterRemoved(HideTargetFrame);

        // change level text colour of enemy relative to player's level
        if (target.MyLevel >= Player.MyInstance.MyLevel + 5)
        {
            enemyLevelText.color = Color.red;
        }
        else if (target.MyLevel == Player.MyInstance.MyLevel + 3 || target.MyLevel == Player.MyInstance.MyLevel + 4)
        {
            enemyLevelText.color = new Color32(255, 124, 0, 255);
        }
        else if (target.MyLevel >= Player.MyInstance.MyLevel - 2 && target.MyLevel <= Player.MyInstance.MyLevel + 2)
        {
            enemyLevelText.color = Color.yellow;
        }
        else if (target.MyLevel <= Player.MyInstance.MyLevel - 3 && target.MyLevel > EXPManager.CalculateGrayLevel())
        {
            enemyLevelText.color = Color.green;
        }
        else
        {
            enemyLevelText.color = Color.gray;
        }
    }