コード例 #1
0
    protected void Update()
    {
        if (EntityView != null)
        {
            if (attackText != null)
            {
                if (EntityView.GetAttack() > 0)
                {
                    attackText.text = EntityView.GetAttack().ToString();
                    attackIcon.gameObject.SetActive(true);
                }
                else
                {
                    attackIcon.gameObject.SetActive(false);
                }
            }
            if (healthText != null)
            {
                healthText.text = EntityView.GetHealth().ToString();
            }

            if (shieldIcon != null)
            {
                if (EntityView.GetMaxShields() > 0)
                {
                    shieldIcon.gameObject.SetActive(true);
                }
                else
                {
                    shieldIcon.gameObject.SetActive(false);
                }
            }
            if (ownerTint != null)
            {
                if (IsFriendly)
                {
                    ownerTint.SetColor(friendlyColor, 0.5f);
                }
                else
                {
                    ownerTint.SetColor(enemyColor, 0.5f);
                }
            }

            if (shieldText != null)
            {
                shieldText.text = EntityView.GetShields().ToString();
            }
            if (shields != null)
            {
                shields.Strength = EntityView.GetShields();
            }
        }
    }
コード例 #2
0
 public void dealDamage(DamageEffect damage, GameObject cause = null)
 {
     EntityView.SetHealth(EntityView.GetHealth() - damage.damageTaken);
     EntityView.SetShields(EntityView.GetShields() - damage.shieldBlocked);
     if (damage.damageTaken > 0)
     {
         GameObject go = Instantiate(damageCounterPrefab);
         go.transform.position = new Vector3(transform.position.x, transform.position.y + 15, transform.position.z);
         DamageCounter counter = go.GetComponent <DamageCounter>();
         counter.Damage = damage.damageTaken;
     }
     if (shields != null && damage.shieldBlocked > 0)
     {
         shields.ShieldHit(damage);
     }
 }