Example #1
0
    void Update()
    {
        if (gPI == null)
        {
            gPI = GameObject.FindWithTag("Handler").GetComponent <GamePadInputs> ();
        }
        if (tPC == null)
        {
            tPC = GameObject.FindWithTag("Player").GetComponent <ThirdPersonController> ();
        }

        if (!inCutscene && tPC.inACutscene && this.gameObject.name == tPC.currentNPCName)
        {
            textBoxGUIPos.GetComponentInChildren <Text> ().text = "";
            textBoxGUIPos.gameObject.SetActive(false);
            if (currentPage != 0)
            {
                RemoveReplies();
            }
            canInteract = false;
            StartCoroutine(CloseDelay());
            camF.transitionBackFromCutscene = true;
            camF.prevLookAt   = dialogue[currentPage].cameraFocus.position;
            tPC.inACutscene   = false;
            camF.cutsceneMode = false;
            camF.canFreeMode  = true;
            if (!hideHUDDuringCutscene)
            {
                GameObject.FindWithTag("Handler").GetComponent <HUD>().DrawHUD();
            }
        }

        if (currentPage >= dialogue.Length && inCutscene && this.gameObject.name == tPC.currentNPCName)
        {
            inCutscene = false;
            if (!hideHUDDuringCutscene)
            {
                GameObject.FindWithTag("Handler").GetComponent <HUD> ().DrawHUD();
            }
        }

        if (inCutscene && this.gameObject.name == tPC.currentNPCName)
        {
            if (gPI.pressLeftB() && changedSpeed)
            {
                if (currentString >= dialogue [currentPage].content.Length)
                {
                    if (dialogue[currentPage].replies.Length == 0)
                    {
                        if (dialogue[currentPage].nextPageID <0 || dialogue[currentPage].nextPageID> dialogue.Length)
                        {
                            inCutscene = false;
                        }
                        else
                        {
                            prevPage    = currentPage;
                            currentPage = dialogue[currentPage].nextPageID;
                            RefreshValues();
                        }
                    }
                    else
                    {
                        if (eventSys.currentSelectedGameObject != null)
                        {
                            int s = 0;
                            while (s < dialogue[currentPage].replies.Length)
                            {
                                if (replyButtons[s].gameObject == eventSys.currentSelectedGameObject)
                                {
                                    prevPage    = currentPage;
                                    currentPage = dialogue[currentPage].replies[s].resultingPageID;
                                    RefreshValues();
                                }
                                s++;
                            }
                        }
                    }
                }
                else
                {
                    useSpeed     = 0f;
                    changedSpeed = false;
                }
            }

            if (eventSys.currentSelectedGameObject == null && Vector3.Magnitude(new Vector3(gPI.LH(), 0f, gPI.LV())) > 0.4f &&
                dialogue[currentPage].replies.Length > 0 && currentString == dialogue[currentPage].content.Length)
            {
                replyButtons [0].Select();
            }

            if (currentString != dialogue[currentPage].content.Length && !counting)
            {
                counting = true;
                StartCoroutine(DisplayText());
            }
            if (currentString >= dialogue[currentPage].content.Length && dialogue[currentPage].replies.Length > 0 && !organizedReplies)
            {
                organizedReplies = true;
                int a = 0;
                int x = 0;
                int y = 0;
                replyButtons = new Button[dialogue[currentPage].replies.Length];
                RectTransform rectTransform = replyButtonsPosition.GetComponent <RectTransform>();
                while (a < dialogue[currentPage].replies.Length)
                {
                    if (Mathf.Abs(x) == maxReplyButtonsPerRow)
                    {
                        x = 0;
                        if (drawRepliesUpwards)
                        {
                            y++;
                        }
                        else
                        {
                            y--;
                        }
                    }
                    replyButtons[a] = Instantiate(replyButtonsPosition) as Button;
                    replyButtons[a].transform.SetParent(npcCanvas.transform);
                    replyButtons[a].gameObject.SetActive(true);
                    replyButtons[a].name = "Reply Option " + a;
                    replyButtons[a].GetComponent <RectTransform>().anchoredPosition = rectTransform.anchoredPosition +
                                                                                      new Vector2((rectTransform.rect.width + repliesXSpacing) * x,
                                                                                                  (rectTransform.rect.height + repliesYSpacing) * y);
                    replyButtons[a].GetComponentInChildren <Text>().text = dialogue[currentPage].replies[a].text;
                    a++;
                    if (drawRepliesLeftwards)
                    {
                        x--;
                    }
                    else
                    {
                        x++;
                    }
                }
                eventSys.firstSelectedGameObject = replyButtons[0].gameObject;
                replyButtons[0].Select();
            }
        }
    }
    void Start()
    {
        gPI = this.GetComponent <GamePadInputs>();

        activeLXaxis     = () => { return(gPI.LH()); };
        activeLYaxis     = () => { return(gPI.LV()); };
        activeRXaxis     = () => { return(gPI.RH()); };
        activeRYaxis     = () => { return(gPI.RV()); };
        activeMXaxis     = () => { return(gPI.MX()); };
        activeMYaxis     = () => { return(gPI.MY()); };
        activeInstrument = () => { return(gPI.RT()); };

        activeLXaxis2     = () => { return(gPI.LH2()); };
        activeLYaxis2     = () => { return(gPI.LV2()); };
        activeRXaxis2     = () => { return(gPI.RH2()); };
        activeRYaxis2     = () => { return(gPI.RV2()); };
        activeMYaxis2     = () => { return(gPI.MY2()); };
        activeInstrument2 = () => { return(gPI.RT2()); };

        activeLXaxis3     = () => { return(gPI.LH3()); };
        activeLYaxis3     = () => { return(gPI.LV3()); };
        activeRXaxis3     = () => { return(gPI.RH3()); };
        activeRYaxis3     = () => { return(gPI.RV3()); };
        activeMYaxis3     = () => { return(gPI.MY3()); };
        activeInstrument3 = () => { return(gPI.RT3()); };

        activeLXaxis4     = () => { return(gPI.LH4()); };
        activeLYaxis4     = () => { return(gPI.LV4()); };
        activeRXaxis4     = () => { return(gPI.RH4()); };
        activeRYaxis4     = () => { return(gPI.RV4()); };
        activeMYaxis4     = () => { return(gPI.MY4()); };
        activeInstrument4 = () => { return(gPI.RT4()); };


        activeAttackPress = () => { return(gPI.pressRightB()); };
        activeJumpPress   = () => { return(gPI.pressAction()); };
        activeGlidePress  = () => { return(gPI.pressTopB()); };
        activeLeafPress   = () => { return(gPI.pressTopB()); };
        activeRunPress    = () => { return(gPI.pressLeftB()); };
        activeStartPress  = () => { return(gPI.pressStart()); };
        activeAttackHold  = () => { return(gPI.holdRightB()); };
        activeJumpHold    = () => { return(gPI.holdAction()); };
        activeGlideHold   = () => { return(gPI.holdTopB()); };
        activeLeafHold    = () => { return(gPI.holdTopB()); };
        activeRunHold     = () => { return(gPI.holdLeftB()); };
        activeStartPress  = () => { return(gPI.holdStart()); };

        activeAttackPress2 = () => { return(gPI.pressRightB2()); };
        activeJumpPress2   = () => { return(gPI.pressAction2()); };
        activeGlidePress2  = () => { return(gPI.pressTopB2()); };
        activeLeafPress2   = () => { return(gPI.pressTopB2()); };
        activeRunPress2    = () => { return(gPI.pressLeftB2()); };
        activeStartPress2  = () => { return(gPI.pressStart2()); };
        activeAttackHold2  = () => { return(gPI.holdRightB2()); };
        activeJumpHold2    = () => { return(gPI.holdAction2()); };
        activeGlideHold2   = () => { return(gPI.holdTopB2()); };
        activeLeafHold2    = () => { return(gPI.holdTopB2()); };
        activeRunHold2     = () => { return(gPI.holdLeftB2()); };
        activeStartPress2  = () => { return(gPI.holdStart2()); };

        activeAttackPress3 = () => { return(gPI.pressRightB3()); };
        activeJumpPress3   = () => { return(gPI.pressAction3()); };
        activeGlidePress3  = () => { return(gPI.pressTopB3()); };
        activeLeafPress3   = () => { return(gPI.pressTopB3()); };
        activeRunPress3    = () => { return(gPI.pressLeftB3()); };
        activeStartPress3  = () => { return(gPI.pressStart3()); };
        activeAttackHold3  = () => { return(gPI.holdRightB3()); };
        activeJumpHold3    = () => { return(gPI.holdAction3()); };
        activeGlideHold3   = () => { return(gPI.holdTopB3()); };
        activeLeafHold3    = () => { return(gPI.holdTopB3()); };
        activeRunHold3     = () => { return(gPI.holdLeftB3()); };
        activeStartPress3  = () => { return(gPI.holdStart3()); };

        activeAttackPress4 = () => { return(gPI.pressRightB4()); };
        activeJumpPress4   = () => { return(gPI.pressAction4()); };
        activeGlidePress4  = () => { return(gPI.pressTopB4()); };
        activeLeafPress4   = () => { return(gPI.pressTopB4()); };
        activeRunPress4    = () => { return(gPI.pressLeftB4()); };
        activeStartPress4  = () => { return(gPI.pressStart4()); };
        activeAttackHold4  = () => { return(gPI.holdRightB4()); };
        activeJumpHold4    = () => { return(gPI.holdAction4()); };
        activeGlideHold4   = () => { return(gPI.holdTopB4()); };
        activeLeafHold4    = () => { return(gPI.holdTopB4()); };
        activeRunHold4     = () => { return(gPI.holdLeftB4()); };
        activeStartPress4  = () => { return(gPI.holdStart4()); };
    }