public void SelectVehicle(short vehicleId, VehicleGuiData guiData) { // update the selected team vehicle in the gamestate tracker currentVehicleId = vehicleId; lockButton.interactable = true; textGui vehicleData = new textGui(guiData.displayName, guiData.speed, guiData.strength, guiData.weapon, guiData.ultimate); GetComponent <PhotonView>().RPC(nameof(DisplaySelectedVehicle_RPC), RpcTarget.All, vehicleId, otherId, (short)PhotonNetwork.LocalPlayer.ActorNumber, JsonUtility.ToJson(vehicleData)); }
void DisplaySelectedVehicle_RPC(short vehicleId, short otherPlayerId, short myId, string guiDataJSON) { if (otherPlayerId == PhotonNetwork.LocalPlayer.ActorNumber || myId == PhotonNetwork.LocalPlayer.ActorNumber) { currentVehicle = gamestateVehicleLookup.sortedVehicleNames[vehicleId]; // destroy last vehicle textGui guiData = JsonUtility.FromJson <textGui>(guiDataJSON); Debug.Log("Display Selected"); if (currentVehicleInstance != null) { Destroy(currentVehicleInstance); } // spawn new vehicle statsPanel.SetActive(true); currentVehicleInstance = Instantiate(Resources.Load(prefix + currentVehicle) as GameObject, spawnPoint.position, spawnPoint.rotation); displayName.text = guiData.displayName; speed.text = $"Speed: {guiData.speed}"; strength.text = $"Strength: {guiData.strength}"; weapon.text = $"Weapon: {guiData.weapon}"; ultimate.text = $"Ultimate: {guiData.ultimate}"; } }