Exemplo n.º 1
0
    // Attempts to damage the passed GameObject whilst managing the piercing state of the bullet
    void DamageMob(GameObject mob, int damage, bool incrementPierceCounter = false)
    {
        if (Network.isServer && mob)
        {
            if (!m_isPiercing || !m_pastHits.Contains(mob))
            {
                //Debug.Log("Attempting to damage mob: " + mob.name);
                HealthScript health = mob.GetComponent <HealthScript>();

                if (health)
                {
                    health.DamageMob(damage, firer, gameObject);

                    m_isPiercing = m_isPiercing && health.GetCurrShield() == 0 ? true : false;

                    if (incrementPierceCounter)
                    {
                        m_pastHits.Add(mob);
                        networkView.RPC("ApplyPierceModifiers", RPCMode.All);
                    }
                }

                else
                {
                    Debug.LogError("Unable to find HealthScript on: " + mob.name);
                }
            }
        }
    }