void RPCExplode() { explosionParticle.transform.SetParent(null, true); explosionParticle.transform.localScale = Vector3.one; explosionParticle.Emit(explosionParticle.maxParticles); Destroy(explosionParticle.gameObject, Mathf.Max(explosionParticle.startLifetime * 1.1f, source.clip.length * 1.1f)); source.Play(); if (Physics.CheckSphere(transform.position, maxRadius, GameController.Instance.explosionLayers)) { Collider[] colliders = Physics.OverlapSphere(transform.position, maxRadius, GameController.Instance.explosionLayers); for (int i = 0; i < colliders.Length; i++) { Collider coll = colliders[i]; Player player = coll.transform.root.GetComponent <Player>(); if (player == null || coll.tag != "Player") { continue; } if (!player.photonView.isMine) { continue; } RaycastHit hit; if (Physics.Linecast(transform.position, player.mouseLook.mouseLookRoot.position, out hit, GameController.Instance.explosionLayers)) { if (hit.collider == coll && !ServerController.AreFriends(photonView.owner, player.photonView.owner, true)) { float ratio = Mathf.InverseLerp(maxRadius, radius, Mathf.Clamp( Vector3.Distance(player.transform.position, transform.position), radius, maxRadius )); int finalDamage = Mathf.RoundToInt(damage * ratio); if (player.health - finalDamage > 0) { player.photonView.RPC("RPCDamageCustomReason", player.photonView.owner, finalDamage, grenade.KillfeedName); } else { if (player.photonView.owner != photonView.owner) { player.photonView.RPC("RPCDamage", player.photonView.owner, finalDamage, Vector3.zero, Vector3.forward, 0f, photonView.ownerId, grenade.ID ); } else { player.photonView.RPC("RPCDamageCustomReason", player.photonView.owner, finalDamage, grenade.KillfeedName); } } } } } } }
void OnValidate() { rend.material = ServerController.GetObjectFromTeam <Material>(team, redTeam, blueTeam, noneTeam); gameObject.name = string.Format("Spawnpoint ({0})", ServerController.GetObjectFromTeam <string>(team, "Red", "Blue", "None")); }
public void RPCSendChatMessage(string message) { ServerController.OnChatMessage(photonView.owner, message); }
void Start() { PunTeams.Team team = PhotonView.Get(transform.root.gameObject).owner.GetTeam(); renderer.material = ServerController.GetObjectFromTeam <Material>(team, redTeamMaterial, blueTeamMaterial, noneTeamMaterial); }
void Attack() { if (!canAttack) { return; } CrosshairRecoill(); t = Time.time + fireRate; AudioClip soundToPlay = missSound; player.raycaster.localEulerAngles = Vector3.zero; Ray ray = new Ray(player.raycaster.position, player.raycaster.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, hitDistance, GameController.Instance.fireLayers)) { if (hit.transform.gameObject.layer == 31 && hit.transform.root != transform.root) { Player target = hit.transform.root.GetComponent <Player>(); if (target != null && !ServerController.AreFriends(target.photonView.owner, PhotonNetwork.player)) { soundToPlay = fleshSound; int finalDamage = ServerController.gamemode != ServerController.Gamemode.OITC ? damage : 100; target.photonView.RPC("RPCDamage", target.photonView.owner, finalDamage, ray.origin, ray.direction, hitForce, player.photonView.ownerId, info.ID); player.photonView.RPC("RPCBlood", PhotonTargets.All, hit.point, hit.normal); MapController.hud.ShowHitmarker(); } } else { if (hit.transform.gameObject.layer == 30) { soundToPlay = fleshSound; } else { soundToPlay = wallSound; player.photonView.RPC("RPCBulletHole", PhotonTargets.All, hit.point, hit.normal); } } } anim.Stop(); anim.PlayQueued(attackAnimation.name, QueueMode.PlayNow); anim.PlayQueued(drawAnimation.name, QueueMode.CompleteOthers); RandomizeSize(); main.source.PlayOneShot(soundToPlay); if (soundToPlay == wallSound) { player.photonView.RPC("RPCPlayCustomSound", PhotonTargets.Others, 1); } else if (soundToPlay == fleshSound) { player.photonView.RPC("RPCPlayCustomSound", PhotonTargets.Others, 2); } else { player.photonView.RPC("RPCPlayCustomSound", PhotonTargets.Others, 0); } }