void Awake() { //Create scrripts playerFunctions = new PlayerFunctionsScript(this); markerDistribution = new MarkerDistributionScript(); playerTool = new PlayerToolScript(Tool.NONE); //set TrackedTarget and Tracked Tool to unknown and -1 trackedTarget = Player_ID.UNKNOWN; trackedToolMarker = -1; }
//this method is called, whenever the interaction button is pressed public void interact() { //only do something, if the player is not arrested if (!playerScript.playerArrested) { int cast_trackedTarget = (int)playerScript.trackedTarget; //If tracked target is a valid player marker, which also belongs to a active player AND the current user has a tool equipped if (cast_trackedTarget != playerScript.getMarkerID() && (cast_trackedTarget != (int)Player_ID.UNKNOWN) && (playerScript.playerTool.getToolType() != Tool.NONE)) { int photonID = playerScript.markerDistribution.getMarkerToPhotonID(cast_trackedTarget); //Send an rpc call to that player, that he is about to get arrested playerScript.player.GetComponent <PhotonView>().RPC("rpc_continueArresting", PhotonPlayer.Find(photonID), (int)playerScript.playerID, playerScript.playerTool.getToolEffectiveness()); } //otherwise check if the current tracked marker is a tool marker and also check if it contains a tool and is not already empty else if (playerScript.trackedToolMarker != -1 && playerScript.markerDistribution.getMarkerToTool(playerScript.trackedToolMarker) != Tool.NONE) { //send rpc call to all other players, that the tool on that marker was taken, and that the marker is now empty or contains the players previous tool playerScript.player.GetComponent <PhotonView>().RPC("rpc_changeToolMarker", PhotonTargets.Others, (int)playerScript.playerTool.getToolType(), playerScript.trackedToolMarker); //exchange the tool on the marker with the players current tool PlayerToolScript tmp = new PlayerToolScript(playerScript.markerDistribution.getMarkerToTool(playerScript.trackedToolMarker)); changeToolMarker((int)playerScript.playerTool.getToolType(), playerScript.trackedToolMarker); playerScript.playerTool = tmp; playerScript.toolImage.setImage((int)playerScript.playerTool.getToolType()); } else if (playerScript.playerTool.getToolType() == Tool.NONE) { //Create info text at the top of the screen playerScript.infoTextHUD.text = "You have no tool equipped!"; playerScript.infoTextColor.a = 1.0f; playerScript.infoTextHUD.color = playerScript.infoTextColor; } } }