Пример #1
0
    public void MoveInstructionScrollLower()
    {
        //Make it the 'top' element
        InstructionBubbleObj.transform.SetAsLastSibling();

        //Move it
        RectTransform rectTransform = InstructionBubbleObj.GetComponent <RectTransform>();
        Vector2       pos           = new Vector3(0.85f, 0.25f);

        pos = Camera.main.ViewportToScreenPoint(pos);
        InstructionBubbleObj.transform.DOMove(pos, 2f, false);
    }
Пример #2
0
    public void PreviousInstructionText()
    {
        if (activePage - 1 >= 0)
        {
            instructionTextBox.text = instructionText[--activePage];

            //Modify size of instruction bubble
            InstructionBubbleObj.GetComponent <InstructionBubbleSizing>().UpdateSize();

            OnInstruct();
        }
    }
Пример #3
0
    public void HideBubble()
    {
        if (InstructionBubbleObj != null)
        {
            InstructionBubbleObj.SetActive(false);
        }

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

        Instruction = false;
    }
Пример #4
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();
    }
Пример #5
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();
    }
Пример #6
0
    public void NextInstructionText()
    {
        //Need to destroy the indicator as changing the instruction means changing its location. Right now it is easier
        //To instantiate the indicator within the inventory than through the instruction bubble
        if (tutorialRuneObj != null)
        {
            Destroy(tutorialRuneObj);
        }

        if (activePage + 1 < instructionText.Count)
        {
            instructionTextBox.text = instructionText[++activePage];

            //Modify size of instruction bubble
            InstructionBubbleObj.GetComponent <InstructionBubbleSizing>().UpdateSize();

            OnInstruct();
        }
    }