void PickupObject( ActorController actor ) { //As with all RPC methods, we branch between online and offline mode here if( PhotonNetwork.offlineMode == true ) { OnPickup( actor ); } else { //We use PhotonTargets.AllBufferedViaServer here to avoid two actors picking up the //same object before one of the pickup events has reached the server //Check out Part 1 Lesson 4 http://youtu.be/Wn9P4d1KwoQ for more detailed explanations PhotonView.RPC( "OnPickup" , PhotonTargets.AllBufferedViaServer , new object[] { actor.PhotonView.viewID } ); } }
/// Called when a actor successfully picked up the object public abstract void OnPickup( ActorController actor );
/// Determines whether this instance [can be picked up by the specified actor. /// THis will be defined by the specific pickup script public abstract bool CanBePickedUpBy( ActorController actor );
public override void OnPickup( ActorController actor ) { m_CarryingActorController = actor; m_CarryingActorController.isScoring = true; }
public override bool CanBePickedUpBy( ActorController actor ) { //If another player is already carrying the flag, no one else can grab it if( m_CarryingActorController != null ) { return false; } return true; }
void OnCapture() { Debug.Log("Event Received: Capture Flag"); m_CarryingActorController = null; transform.position = m_HomePosition; }
void OnDrop( Vector3 position ) { Debug.Log("Event Received: Drop Flag"); m_CarryingActorController.isScoring = false; m_CarryingActorController = null; transform.position = position; m_ReturnTimer = ReturnTime; }