Esempio n. 1
0
    private void OnHit(PlayerHitVolume hitVolume, GameObject hittingGameObject)
    {
        currentShots = -maxCharge;

        if (dischargePrefab != null)
        {
            GameObject dischargeEffect = Instantiate(dischargePrefab, transform.position, transform.rotation);
            dischargeEffect.transform.localScale *= 0.33f;
        }
    }
Esempio n. 2
0
    void Start()
    {
        currentShots = maxCharge;

        PlayerHitVolume playerHitVolume = GetComponent <PlayerHitVolume>();

        if (playerHitVolume != null)
        {
            playerHitVolume.OnHit += OnHit;
        }
    }
Esempio n. 3
0
    private void OnHit(PlayerHitVolume hitVolume, GameObject hittingGameObject)
    {
        if (hitVolume.GetComponent <PistolControl>() != null)
        {
            currentHits += damagePointsPerHitOnPistol;
        }

        if (hitVolume.GetComponent <Camera>() != null)
        {
            currentHits += damagePointsPerHitOnHead;
        }
    }
Esempio n. 4
0
    private void OnTriggerEnter(Collider other)
    {
        if (IsValidCollisionTarget(other))
        {
            PlayerHitVolume playerHitVolume = other.GetComponent <PlayerHitVolume>();
            if (playerHitVolume != null)
            {
                playerHitVolume.Hit(gameObject);
            }

            if (other.GetComponent <PistolControl>() != null)
            {
                Vector3 direction    = transform.TransformDirection(Vector3.forward);
                Vector3 impactPoint  = other.ClosestPoint(transform.position);
                Vector3 normal       = (transform.position - impactPoint).normalized;
                Vector3 newDirection = Vector3.Reflect(direction, normal);
                transform.rotation *= Quaternion.FromToRotation(direction, newDirection);
            }
            else
            {
                Disappear();
            }
        }
    }