public void ReplaceClue(string currentClueInScene, string newClue) { Debug.Log("replce enter"); //get both placeholders CluePlaceholder currentPlaceholder = GetPlaceholderFromSpecName(currentClueInScene); CluePlaceholder newPlaceholder = GetPlaceholderFromSpecName(newClue); //remove old model RemoveClueModel(currentClueInScene); //place different clue if (newPlaceholder == null) { Debug.Log("Very bad"); } if (currentPlaceholder == null) { Debug.Log("Very bad"); } GameObject clue = Instantiate( newPlaceholder.Clue.ModelPrefab, currentPlaceholder.transform.position, currentPlaceholder.transform.rotation, activeClueContainter.transform ); //set placeholder reference to new position newPlaceholder.transform.position = currentPlaceholder.transform.position; newPlaceholder.transform.rotation = currentPlaceholder.transform.rotation; clueReference[newPlaceholder] = clue; //assign general text clue.GetComponent <TextOnHover>().ChangeText(newPlaceholder.Clue.GeneralDisplayText.ToString()); Debug.Log("Clue replaced"); }
//replace placeholder with real clue private void SpawnClueInScene(CluePlaceholder placeholder) { if (placeholder != null && placeholder.Clue && placeholder.Clue.ModelPrefab != null) { if (!placeholder.gameObject.activeInHierarchy) { return; } try { //instantiate a replacement object for the placehodler, place in active clue container placeholder.gameObject.SetActive(false); GameObject clue = Instantiate( placeholder.Clue.ModelPrefab, placeholder.transform.position, placeholder.transform.rotation, activeClueContainter.transform ); //assign the hoverable text to what is said in the clue general text clue.GetComponent <TextOnHover>().ChangeText(placeholder.Clue.GeneralDisplayText.ToString()); clueReference.Add(placeholder, clue); } catch (Exception e) { Debug.LogWarning(e.Message); Debug.Log("We got an exception bois"); } } }
/// <summary> /// Method that handles player interaction with an interactable gameobject /// </summary> /// <param name="obj">The game object the player is trying to interact with</param> public void HandleOnClickAction(GameObject obj, ref RaycastResult result) { if (Input.anyKeyDown && !Input.GetButton("Horizontal") && !Input.GetButton("Vertical")) //LMB release { CluePickupController controller = obj.GetComponent <CluePickupController>() ?? obj.GetComponentInParent <CluePickupController>(); Debug.Log(obj.name); Debug.Log(result); Debug.Log(controller.ToString()); if (controller != null) { Debug.Log("pos1"); Debug.Log(controller.ToString()); CluePlaceholder spec = controller.spec; Debug.Log(spec.ToString() + "-------------------------"); CmdPlayerLeftClickClue(spec.Clue.Name.ToString(), thisGameObject); Debug.Log("Left clicked Clue \n"); } else { CmdPlayerLeftClick(obj); Debug.Log("Left clicked Object! \n"); } } //Extend this as necessary }
public void RemoveClueModel(string spec) { CluePlaceholder p = GetPlaceholderFromSpecName(spec); //reverseClueReference.Remove(clue); GameObject clue; clueReference.TryGetValue(p, out clue); //clueReference.Remove(p); Destroy(clue); Debug.Log("Successful destroy"); }
public void CmdPlayerLeftClickClue(string specName, GameObject thisPlayer) { //check for if murderer if (thisPlayer.GetComponent <Player>().IsMurderer()) { Debug.Log("------Player is murderer"); GameObject clueSpawner = GameObject.Find("ClueController"); CluePlaceholder spec = clueSpawner.GetComponent <ClueSpawner>().GetPlaceholderFromSpecName(specName); //check if player holds clue string currentClue = thisPlayer.GetComponent <Player>().GetHeldClue(); //rpc remove model or swap if (currentClue != null) { //current held clue = currentClue //got specname //clue to hold = spec name thisPlayer.GetComponent <Player>().SetHeldClue(specName); thisPlayer.GetComponent <Player>().RpcSetClue(specName); //remove clue model //place new clue model with text clueSpawner.GetComponent <ClueSpawner>().ReplaceClue(specName, currentClue); RpcReplaceClue(specName, currentClue); RpcReplaceText(); } else { //rpc set player holding clue Debug.Log("Adding new clue to murderer"); thisPlayer.GetComponent <Player>().SetHeldClue(specName); thisPlayer.GetComponent <Player>().RpcSetClue(specName); //remove models on server and clients clueSpawner.GetComponent <ClueSpawner>().RemoveClueModel(specName); RpcRemoveClue(specName); } } }
//assign spec associated with this clue void GetSpec() { CluePlaceholder p = clueSpawner.GetComponent <ClueSpawner>().GetPlaceholderFromClue(this.gameObject); this.spec = p; }