Esempio n. 1
0
        /// <summary>
        /// Hide a hint on the right or left hand.
        /// </summary>
        /// <param name="button">The ButtonID of the hint to be disabled.</param>
        public void HideHint(ButtonID button)
        {
            if (activeHints == null)
            {
                return;
            }

            List <HintRankPair> hintsActive = activeHints.FindAll(h => h.hint.HintButton.Equals(button));

            if (hintsActive.Count == 0)
            {
                return;
            }
            else
            {
                // Removes highest rank hint from active list
                HintRankPair hintHighestRank = hintsActive.Find(h => h.rank == hintsActive.Count);
                activeHints.Remove(hintHighestRank);
                GameObject.Destroy(hintHighestRank.hint.gameObject);

                // Displays highest rank hint
                hintsActive.Remove(hintHighestRank);
                hintHighestRank = hintsActive.Find(h => h.rank == hintsActive.Count);
                if (hintHighestRank == null)
                {
                    // No second highest rank, return
                    return;
                }
                else
                {
                    // Sets second highest hint to display
                    hintHighestRank.hint.gameObject.SetActive(true);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Display a hint.
        /// </summary>
        /// <param name="text">Text to be displayed/</param>
        /// <param name="button">A ButtonID to display the hint.</param>
        public void DisplayHint(string text, ButtonID button)
        {
            if (activeHints == null)
            {
                activeHints = new List <HintRankPair>();
            }

            GameObject newHint = GameObject.Instantiate(HintPrefab);

            newHint.name = button.ToString() + " Hint";

            Hint hint = newHint.GetComponent <Hint>();

            hint.SetText(text);
            hint.HintButton = button;
            /* Check if the hint hooks was loaded before. If not load it now. */
            if (hintHooks == null)
            {
                hint.LoadHintHooks();
            }

            /* This hint should be on the right hand. */
            if (button.ToString().Contains("Right"))
            {
                newHint.transform.SetParent(ControllerManager.Instance.GetControllerAttachPosition(true).transform);
            }
            else if (button.ToString().Contains("Left"))
            {
                newHint.transform.SetParent(ControllerManager.Instance.GetControllerAttachPosition(false).transform);
            }
            else
            {
                Debug.LogError("HintManager: Something is wrong, can't figure out which hand to place hint.");
            }

            /* Position the hint */
            hint.SetPosition(hintHooks.Find(h => h.Button.Equals(button)).HintPosition);

            /* Draw the line linking hint and controller */
            hint.DrawLine(hintHooks.Find(h => h.Button.Equals(button)).LinePosition);

            List <HintRankPair> hintsOnTheSameButton = activeHints.FindAll(h => h.hint.HintButton.Equals(button));
            HintRankPair        rankPair             = new HintRankPair(hint);

            rankPair.rank = hintsOnTheSameButton.Count + 1;

            if (hintsOnTheSameButton.Count == 0)
            {
                /* Add hint to actives*/
                activeHints.Add(rankPair);
            }
            else
            {
                /* Protect the activeHints from spamming. (If a rogue programmer misuse this method). */
                if (hintsOnTheSameButton.Find(h => h.hint.GetText().Equals(text)) != null)
                {
                    Destroy(newHint);
                    return;
                }

                /* Disable the active hint with rank below and add new hint. */
                HintRankPair hintToDisable;
                hintToDisable = hintsOnTheSameButton.Find(h => h.rank == hintsOnTheSameButton.Count);
                hintToDisable.hint.gameObject.SetActive(false);
                activeHints.Add(rankPair);
            }
        }