void RpcImpact(Color Color_, Vector3 Position_, Vector3 Normal_) { _PaintManager.NewParticle(Color_, Position_, Normal_); // Green splash dmg if (Color_ == Color.green) { Collider[] Coll_ = Physics.OverlapSphere(Position_, 1); foreach (Collider hit in Coll_) { PlayerNetworking PN_ = hit.transform.gameObject.GetComponent <PlayerNetworking>(); if (PN_ != null && gameObject.name != "Local player") { PN_.RpcResolveHit(FireDamage * 0.5f); } } } }
void CmdPlayerShot(float FireRate_, float FireDamage_) { // Fire rate if (Time.time > FireRateCD && WeaponManager_.GetCurAmmo() > 0) { // Set time when the gun can fire again FireRateCD = Time.time + FireRate_; // Remove a bullet from the ammo system WeaponManager_.ShotCurAmmo(); // Show muzzle smoke out of the gun RpcMuzzle(); // Play audio RpcPlayAudio(); RaycastHit hit; Vector3 rayPos = CameraPos.transform.position + CameraPos.transform.forward; Debug.DrawRay(rayPos, CameraPos.transform.forward, Color.green, 0.1f, true); if (Physics.Raycast(rayPos, CameraPos.transform.forward, out hit, 10)) { Debug.Log("Hit: " + hit.transform.gameObject.name); Debug.DrawRay(hit.point, hit.normal, Color.red, 2.0f); // Color switch (FireColor) { case FireColors.blue: RpcImpact(Color.blue, hit.point, hit.normal); break; case FireColors.red: RpcImpact(Color.red, hit.point, hit.normal); break; case FireColors.yellow: RpcImpact(Color.yellow, hit.point, hit.normal); break; case FireColors.green: RpcImpact(Color.green, hit.point, hit.normal); break; case FireColors.white: RpcImpact(Color.white, hit.point, hit.normal); break; } // Get Other playerNetworking PlayerNetworking PN_ = hit.transform.gameObject.GetComponent <PlayerNetworking>(); // Check if there is a PlayerNetworking script on the object if (PN_ != null) { PN_.RpcResolveHit(FireDamage_); } } Debug.Log(WeaponManager_.GetCurAmmo()); } else if (WeaponManager_.GetCurAmmo() < 1) { // No ammo left Debug.Log("No ammo left"); } }