예제 #1
0
    public void HideBubble()
    {
        if (InstructionBubbleObj != null)
        {
            InstructionBubbleObj.SetActive(false);
        }

        if (ExpositionBubbleObj != null)
        {
            ExpositionBubbleObj.SetActive(false);
        }

        Instruction = false;
    }
예제 #2
0
    public void Init(GameObject itemToTarget, bool CanvasElement, Canvas canvasToApply)
    {
        HideBubble();
        activePage          = 0;
        canvasElement       = CanvasElement;
        targetObj           = itemToTarget;
        canvasRectTransform = canvasToApply.GetComponent <RectTransform>();

        //Debug.Log("Setting exposition to active");

        /*
         * Link all variables. Really dirty right now
         */
        ExpositionBubbleObj    = Instantiate(expositionBubblePrefab, canvasToApply.transform);
        InstructionBubbleObj   = Instantiate(instructionBubblePrefab, canvasToApply.transform);
        tutorialRuneObj        = Instantiate(TutorialRunePrefab, canvasToApply.transform);
        nextButton             = ExpositionBubbleObj.transform.GetChild(1).GetComponent <Button>();
        exitButton             = ExpositionBubbleObj.transform.GetChild(2).GetComponent <Button>();
        expositionTextBox      = ExpositionBubbleObj.transform.GetChild(0).GetComponent <TextMeshProUGUI>();
        instructionTextBox     = InstructionBubbleObj.transform.GetChild(0).GetComponent <TextMeshProUGUI>();
        expositionTextBox.text = informationTextToDisplay[activePage];
        ExpositionBubbleObj.SetActive(true);
        InstructionBubbleObj.SetActive(false);
        tutorialRuneObj.SetActive(false);
        Instruction = false;
        nextButton.onClick.AddListener(NextText);

        //Modify size of exposition bubble
        ExpositionBubbleObj.GetComponent <ExpositionBubbleSizing>().UpdateSize();

        //clear old events
        if (onInstruction != null)
        {
            Delegate[] clientList = onInstruction.GetInvocationList();
            foreach (var d in onInstruction.GetInvocationList())
            {
                onInstruction -= (d as Instruct);
            }
        }

        //Add listener
        exitButton.onClick.AddListener(delegate { ShowInstructionBubbleNextTo(instructionText); });

        //Set position to middle of screen
        Vector2 defaultPos = new Vector2(0.5f, 0.5f);

        ExpositionBubbleObj.transform.position = Camera.main.ViewportToScreenPoint(defaultPos);
        UpdateCloser();
    }
예제 #3
0
    public void ShowInstructionBubbleNextTo(List <string> instructions)
    {
        //Debug.Log("Showing instruction bubble and canvasElement is " + canvasElement);
        if (instructions == null)
        {
            HideBubble();
            return;
        }

        activePage  = 0;
        Instruction = true;
        //Debug.Log(instructions.Count + " is instruction length");
        instructionTextBox.text = instructions[activePage];
        Vector2       pos           = new Vector2(0f, 0f);
        RectTransform rectTransform = InstructionBubbleObj.GetComponent <RectTransform>();

        //Need to manage canvas vs normal gameObjects
        if (targetObj != null)
        {
            if (canvasElement)
            {
                pos = Camera.main.ScreenToViewportPoint(targetObj.transform.position);
                //Debug.Log("pos = " + pos);
                pos = ModifyPosition(pos);
                pos = Camera.main.ViewportToScreenPoint(pos);
                InstructionBubbleObj.transform.position = pos;
            }
            else
            {
                pos = Camera.main.WorldToViewportPoint(targetObj.transform.position);
                //Debug.Log("pos = " + pos);
                pos = ModifyPosition(pos);
                //Debug.Log("Modified pos = " + pos);
                pos = Camera.main.ViewportToScreenPoint(pos);
                //Debug.Log("Final pos = " + pos);
                InstructionBubbleObj.transform.position = pos;
                //InstructionBubbleObj.GetComponent<RectTransform>().anchoredPosition = pos;
            }
        }
        InstructionBubbleObj.SetActive(true);
        ExpositionBubbleObj.SetActive(false);

        //Put tutorial indicator over item
        tutorialRuneObj.GetComponent <TutorialRuneIndicator>().SetPosition(targetObj, canvasElement);
        tutorialRuneObj.SetActive(true);

        OnInstruct();
    }