/// <summary> /// Draws the specified tool tip. If null is passed for closest puzzle /// no tooltip will be drawn. /// </summary> /// <param name="closestPuzzle">Data to help draw the tool tip or null to disable the tip</param> void SetToolTip(IAmAPuzzle closestPuzzle) { if (closestPuzzle != null) { if (toolTipControl.isActiveAndEnabled == false) { toolTipControl.gameObject.SetActive(true); toolTipControl.enabled = true; } toolTipControl.SetTipText(closestPuzzle.ToolTipText); } else { toolTipControl.gameObject.SetActive(false); toolTipControl.enabled = false; } }
/// <summary> /// finds the tooltip for the closest unsolved puzzle while immersed /// Only users not immersed should see the tooltip /// </summary> void DrawToolTip() { IAmAPuzzle puzzleNearPlayer = null; foreach (KeyValuePair <string, LevelPlayerStateData> players in systemIdToPlayerState) { if (players.Value.Immersed == true) { GameObject puzzle = AvatarStuff[players.Value.PathIndex].Puzzle; IAmAPuzzle puzzleInterface = puzzle.GetComponent <IAmAPuzzle>(); if (puzzleInterface.Solved == false && (players.Value.ImmersedAvatar.transform.position - puzzle.transform.position).magnitude < 0.1f) { puzzleNearPlayer = puzzleInterface; toolTipControl.transform.localPosition = AvatarStuff[players.Value.PathIndex].PuzzleTipPos.transform.localPosition; } } } SetToolTip(puzzleNearPlayer); }
/// <summary> /// Checks to see if the current puzzle is solved. /// </summary> void CheckPuzzle() { // only do this once, we don't want to spam success if (sentPuzzleComplete == false) { // Get the puzzle object GameObject puzzle = AvatarStuff[onPathIndex].Puzzle; // And the puzzle interface (we could cache this...) IAmAPuzzle puzzleInterface = puzzle.GetComponent <IAmAPuzzle>(); // If we have solved the puzzle if (puzzleInterface.Solved) { // Let everyone know playerController.SendPuzzleSolved(onPathIndex); // And don't send the completion again. sentPuzzleComplete = true; } } }