예제 #1
0
    void Shoot()
    {
        currentBullets--;
        hudController.SetCurrentAmmo(currentBullets);
        EffectManager.Instance.SyncGunshotEffect(pointOfGunLocation.position, pointOfGunLocation.rotation, Vector3.zero, "foo");;
        gunAnimator.SetTrigger("ShotFired");
        lastShotTime = Time.time;
        RaycastHit _hit;

        if (
            Physics.Raycast(
                fpsCam.transform.position,
                fpsCam.transform.forward,
                out _hit,
                Mathf.Infinity,
                shootableMask
                )
            )
        {
            Shootable.ShootableType shootableType = _hit.transform.gameObject.GetComponent <Shootable>().shootableType;
            EffectManager.Instance.SyncGunHitEffect(_hit.point, shootableType);

            string hitTag    = _hit.collider.tag;
            bool   hitPlayer = hitTag == "PlayerHead" || hitTag == "PlayerBody" || hitTag == "PlayerLegs";
            if (hitPlayer)
            {
                PhotonView photonView = PhotonView.Get(_hit.transform.parent.parent.gameObject);
                Debug.Log("DEBUG :: Hit player with viewID " + photonView.ViewID);
                photonView.RPC("RpcGetHit", RpcTarget.All, equippedWeapon.name, hitTag);
            }
        }
    }
예제 #2
0
        void DoGunHitEffect(Vector3 position, Shootable.ShootableType shootableType)
        {
            AudioClip hitClip = null;

            switch (shootableType)
            {
            case Shootable.ShootableType.Terrain:
                AudioClip ricochetClip = ricochetClips[Random.Range(0, ricochetClips.Length)];
                hitClip = ricochetClip;
                break;

            case Shootable.ShootableType.Player:
                hitClip = playerHitClip;
                VisualEffect tmpBloodspray = Instantiate(bloodSprayEffect, position, Quaternion.identity);
                Destroy(tmpBloodspray.gameObject, 4.0f);
                break;
            }
            PlaySoundFromLocation(position, hitClip);
        }
예제 #3
0
 public void SyncGunHitEffect(Vector3 position, Shootable.ShootableType shootableType)
 {
     DoGunHitEffect(position, shootableType);
     photonView.RPC("RpcDoGunHitEffect", RpcTarget.Others, position, shootableType);
 }
예제 #4
0
 void RpcDoGunHitEffect(Vector3 position, Shootable.ShootableType shootableType)
 {
     DoGunHitEffect(position, shootableType);
 }