public void WeaponShoot(WeaponEnum weaponEnum, Vector3 position) { Debug.Log("WeaponShoot"); var pool = ObjectPoolingService.GetWeaponObjectPool(weaponEnum); var bullet = pool.GetObject(); bullet.SetActive(true); bullet.GetComponent <BulletMovementScript>().Initialize(position); var definition = LoadedWeapons.FirstOrDefault(w => w.WeaponEnum == weaponEnum); if (definition != null) { SoundService.PlayClip(definition.ClipOnShot); CameraService.SetCameraFollowTarget(bullet.transform); } CheckIfShouldEndRound(); }
public void Shoot(WeaponEnum weaponEnum, Vector3 position, Vector3 direction, int power) { Vector3 spawnPos = direction + position; var definition = LoadedWeapons.FirstOrDefault(w => w.WeaponEnum == weaponEnum); if (definition != null) { if (definition.Shoots > 0) { var bullet = ObjectPoolingService.GrenadesPool.GetObject(); bullet.SetActive(true); bullet.GetComponent <PhotonView>().TransferOwnership(PhotonNetwork.LocalPlayer); bullet.GetComponent <BulletMovementScript>().OwnerInitialize(spawnPos); SoundService.PlayClip(definition.ClipOnShot); CameraService.SetCameraFollowTarget(bullet.transform); var rb = bullet.GetComponent <Rigidbody2D>(); rb.AddForce(direction * power * 100); if (!PhotonNetwork.OfflineMode) { GameObjectsProviderService.MainPhotonView.RPC("RPC_WeaponShoot", RpcTarget.Others, weaponEnum, spawnPos); } else { SoundService.PlayClip(definition.ClipOnShot); CameraService.SetCameraFollowTarget(bullet.transform); } CheckIfShouldEndRound(); } if (definition.Shoots < 0) { SoundService.PlayClip(definition.ClipOnShot); } } }