예제 #1
0
    // Use this for initialization
    void Start()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius);

        foreach (Collider otherCollider in colliders)
        {
            ExplodingElement explodingElement = otherCollider.gameObject.GetComponent <ExplodingElement>();

            if (explodingElement != null)
            {
                explodingElement.Explode(transform.position, m_ExplosionRadius, m_ExplosionForce);
            }

            BaseHealth <int> health = otherCollider.gameObject.GetComponent <BaseHealth <int> >();
            if (health != null)
            {
                health.Damage(m_Damage);
            }
        }

        m_Camera = Camera.main.GetComponent <CameraController>();
        if (m_Camera != null)
        {
            m_Camera.Shake(m_CameraShake);
        }
    }
예제 #2
0
    protected void Update()
    {
        isActive = self.GetCurrentHealth() > self.GetMaxHealth() * healthMinRatio;

        foreach (BaseHealth i in inside)
        {
            if (!isActive)
            {
                return;
            }
            if (timers.ContainsKey(i))
            {
                timers[i] -= Time.deltaTime;
                if (timers[i] <= 0)
                {
                    timers[i] = tickTime;

                    float amountToHeal = (i.GetCurrentHealth() + healRate >= i.GetMaxHealth()) ? i.GetMaxHealth() - i.GetCurrentHealth() : healRate;

                    i.Heal(healRate, gameObject, self.gameObject);

                    self.Damage(amountToHeal * selfDamageRatio, gameObject, i.gameObject);
                }
            }
            else
            {
                timers.Add(i, tickTime);
            }
        }
    }
예제 #3
0
    protected virtual void OnTick(BaseHealth target)
    {
        if (Lib.HasTagInHierarchy(target.gameObject, "Player"))
        {
            return;
        }

        target.Damage(1, creator, target.gameObject);
    }
예제 #4
0
    void OnCollisionEnter(Collision collisionInfo)
    {
        if (collisionInfo.gameObject.tag != tag)
        {
            BaseHealth <int> health = collisionInfo.gameObject.GetComponent <BaseHealth <int> >();
            if (health != null)
            {
                health.Damage(1);
            }

            if (m_HitParticles != null)
            {
                Instantiate(m_HitParticles, transform.position, Quaternion.identity);
            }

            Destroy(gameObject);
        }
    }
예제 #5
0
 public override void OnInspectorGUI()
 {
     if (EditorApplication.isPlaying || EditorApplication.isPaused)
     {
         EditorGUILayout.LabelField(string.Format("{0}/{1}", baseHealth.GetCurrentHealth(), baseHealth.GetMaxHealth()));
         if (GUILayout.Button("Take 1 Damage"))
         {
             baseHealth.Damage(1, null, null);
         }
         return;
     }
     if (statBlock == null || !statBlock.HasStat(StatName.Toughness))
     {
         base.OnInspectorGUI();
     }
     else
     {
         EditorGUILayout.LabelField("Max Health is being set by the StatBlock");
         EditorGUILayout.LabelField("Value: " + statBlock.GetValue(StatName.Toughness));
     }
 }
예제 #6
0
 public bool ReceiveDamage(float damage)
 {
     Health.Damage(damage);
     return(true);
 }