Ejemplo n.º 1
0
    private void ProcessHits(int hitCount, RaycastHit[] hits)
    {
        _hitsByDistance.Clear();

        for (int i = 0; i < hitCount && hitCount < hits.Length; ++i)
        {
            try
            {
                _hitsByDistance.Add(hits[i].distance, hits[i]);
            }
            catch (ArgumentException)
            {
                // Technically it's possible that two hits occur at the same exact
                // distance, which yields an ArgumentException. I don't try to
                // resolve this, just ignore the second hit.
            }
        }

        var damage = _activeConfig.damagePerProjectile;

        for (int i = 0; i < _hitsByDistance.Count && damage > 0.1f; ++i)
        {
            var hit = _hitsByDistance.Values[i];
            _hitManager.ReportHit(hit.collider.gameObject, hit.point, damage);
            damage = (int)(damage * (1f - _activeConfig.dmgReductionRate));
        }
    }