void PickupPotato_RPC(int driverId, int gunnerId, int teamId) { if (driverId == PhotonNetwork.LocalPlayer.ActorNumber || (driverId < 0 && PhotonNetwork.IsMasterClient)) { PhotonView otherpv = FindObjectOfType <PlayerTransformTracker>().GetVehicleTransformFromTeamId(teamId).GetComponent <PhotonView>(); NetworkPlayerVehicle npv = otherpv.GetComponentInParent <NetworkPlayerVehicle>(); HealthManager hm = otherpv.gameObject.GetComponentInChildren <HealthManager>(); TeamNameSetup tns = otherpv.gameObject.GetComponentInParent <TeamNameSetup>(); HotPotatoManager hpm = otherpv.gameObject.GetComponentInParent <HotPotatoManager>(); this.GetComponent <PhotonView>().RPC(nameof(PunPickup), RpcTarget.AllViaServer, npv.GetDriverID(), npv.GetGunnerID()); hm.HealObject(healthIncrease); tns.ChangeColour(true); hpm.pickupPotato(); GameObject a = Instantiate(nutsNBoltsPrefab, transform.position, transform.rotation); Destroy(a, 4f); if (PhotonNetwork.IsMasterClient) { PhotonNetwork.Destroy(this.gameObject); } if (GetComponent <PhotonView>().IsMine) { PhotonNetwork.Destroy(this.gameObject); } } }
void RemovePotato_RPC() { isPotato = false; PhotonView otherpv = GetComponent <PhotonView>(); NetworkPlayerVehicle npv = otherpv.GetComponentInParent <NetworkPlayerVehicle>(); HealthManager hm = otherpv.gameObject.GetComponentInChildren <HealthManager>(); TeamNameSetup tns = otherpv.gameObject.GetComponentInParent <TeamNameSetup>(); HotPotatoManager hpm = otherpv.gameObject.GetComponentInParent <HotPotatoManager>(); canPickupPotato = false; Invoke(nameof(ReactivatePickupPotato), 5f); myDriverId = npv.GetDriverID(); myGunnerId = npv.GetGunnerID(); tns.ChangeColour(false); potatoEffects = GetComponentInChildren <PotatoEffects>(); potatoEffects.DeactivatePotatoEffects(myDriverId, myGunnerId); }