private void Start() { if (onStartActions != null) { onStartActions.Execute(gameObject, null); } }
public void PunPickup(PhotonMessageInfo msgInfo) { // when this client's RPC gets executed, this client no longer waits for a sent pickup and can try again if (msgInfo.Sender.IsLocal) { this.SentPickup = false; } // In this solution, picked up items are disabled. They can't be picked up again this way, etc. // You could check "active" first, if you're not interested in failed pickup-attempts. if (!this.gameObject.activeInHierarchy) { // optional logging: //Debug.Log("Ignored PUN RPC, cause item is inactive. " + this.gameObject + " SecondsBeforeRespawn: " + secondsBeforeRespawn + " TimeOfRespawn: " + this.timeOfRespawn + " respawn in future: " + (timeOfRespawn > PhotonNetwork.time)); return; // makes this RPC being ignored } // if the RPC isn't ignored by now, this is a successful pickup. this might be "my" pickup and we should do a callback this.PickupIsMine = msgInfo.Sender.IsLocal; //Debug.Log("Invoker " + gameObject + " / " + msgInfo.photonView.gameObject + " / " + msgInfo.sender.TagObject); if (onPickUpEveryone != null) { onPickUpEveryone.Execute((msgInfo.Sender.TagObject as GameObject) ?? msgInfo.photonView.gameObject, null); } if (msgInfo.Sender.IsLocal) { if (onPickUpMine != null) { onPickUpMine.Execute((msgInfo.Sender.TagObject as GameObject) ?? msgInfo.photonView.gameObject, null); } } else { if (onPickUpOthers != null) { onPickUpOthers.Execute((msgInfo.Sender.TagObject as GameObject) ?? msgInfo.photonView.gameObject, null); } } // setup a respawn (or none, if the item has to be dropped) if (secondsBeforeRespawn <= 0) { this.PickedUp(); // item doesn't auto-respawn. must be dropped } else { // how long it is until this item respanws, depends on the pickup time and the respawn time double timeSinceRpcCall = (PhotonNetwork.Time - msgInfo.SentServerTime); timeUntilRespawn = secondsBeforeRespawn - timeSinceRpcCall; //Debug.Log("msg timestamp: " + msgInfo.timestamp + " time until respawn: " + timeUntilRespawn); if (timeUntilRespawn > 0) { this.PickedUp(); } } }