using Photon.Pun; using UnityEngine; public class SpawnedAttack : MonoBehaviour { public Player spawner; public int attackLevel; public int attackID; public PhotonView view; private void Awake() { view = GetComponent(); } [PunRPC] public void RPCA_SetSpawner(int spawnerID) { spawner = PhotonNetwork.GetPhotonView(spawnerID).GetComponent(); } public void CopySpawnedAttackTo(GameObject to) { SpawnedAttack spawnedAttack = to.GetComponent(); if (!spawnedAttack) { spawnedAttack = to.AddComponent(); } spawnedAttack.spawner = spawner; spawnedAttack.attackLevel = attackLevel; } public void SetColor(Color color) { TrailRenderer[] componentsInChildren = GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].startColor = color; componentsInChildren[i].endColor = color; } ProjectileHit component = GetComponent(); if ((bool)component) { component.projectileColor = color; } } public bool IsMine() { if ((bool)view) { return view.IsMine; } if ((bool)spawner) { return spawner.data.view.IsMine; } return false; } }