예제 #1
0
    private void Update()
    {
        int   layer = _hitLayer;
        float dist  = _speed * _timer.Delta;

        if (Physics.Linecast(_prevPosition, transform.position, out _hitInfo, layer))
        {
            var sceneObj = _hitInfo.transform.GetComponent <SceneObject>() ?? _hitInfo.transform.GetComponent <BodyPart>().Root;
            if (sceneObj != null && _shooter.layer != sceneObj.gameObject.layer)
            {
                var damageable = sceneObj as IDamageable;
                damageable?.TakeDamage(_shooter, _damage);

                if (_hitEffectMap != null)
                {
                    TextureEffectEmitter.Emit(_hitEffectMap, sceneObj.TextureType, _hitInfo.point, Quaternion.LookRotation(_hitInfo.normal));
                }
            }

            PoolManager.Instance.Despawn(gameObject);
            return;
        }

        _prevPosition       = transform.position;
        transform.position += transform.forward * dist;
    }
예제 #2
0
    private void InvokeHit(GameObject gameObject, Vector3 point, Vector3 normal)
    {
        var sceneObj = gameObject.GetComponent <SceneObject>() ?? gameObject.GetComponent <BodyPart>().Root;

        if (sceneObj != null && _processorInfo.Attacker.layer != sceneObj.gameObject.layer && !_hitExcluders.Contains(sceneObj.gameObject))
        {
            var damageable = sceneObj as IDamageable;
            damageable?.TakeDamage(_processorInfo.Attacker, _processorInfo.Damage, _processorInfo.ReactionId);

            if (_hitEffectMap != null)
            {
                TextureEffectEmitter.Emit(_hitEffectMap, sceneObj.TextureType, point, Quaternion.LookRotation(normal));
            }

            _onHit?.Invoke(sceneObj.gameObject);
            _hitExcluders.Add(sceneObj.gameObject);
        }
    }
예제 #3
0
    private void OnFootPlant(int hash, Vector3 origin, ref float value)
    {
        float current = _animator.GetFloat(hash);

        if (value < 0f && current > 0f)
        {
            RaycastHit hitInfo;
            if (Physics.Raycast(origin + new Vector3(0F, 0.1F, 0F), Vector3.down, out hitInfo, 0.5F + 0.1F, _groundLayer))
            {
                var sceneObj = hitInfo.transform.GetComponent <SceneObject>();
                if (sceneObj != null)
                {
                    TextureEffectEmitter.Emit(_footstepEffectMap, sceneObj.TextureType, hitInfo.point, Quaternion.LookRotation(hitInfo.normal));
                }
            }
        }

        value = current;
    }