예제 #1
0
 public void SkipTutorial()
 {
     Inventory.TutorialSkip();
     dc = Resources.FindObjectsOfTypeAll <DialogueCanvas>()[0];
     if (dc.gameObject.activeSelf)
     {
         dc.GetComponentsInChildren <CanvasGroup>()[0].interactable   = true;
         dc.GetComponentsInChildren <CanvasGroup>()[0].blocksRaycasts = true;
         dc.GetComponentsInChildren <CanvasGroup>()[0].alpha          = 1.0f;
         dc.GetComponent <DialogueCanvas>().active = false;
         dc.gameObject.SetActive(false);
         dc.GetComponentsInChildren <Button>()[0].onClick.RemoveAllListeners();
         exitButton.SetActive(true);
     }
     Time.timeScale = 1;
     if (cat != null)
     {
         GameObject.FindObjectOfType <Pathfinding>().InitializePath(cat.transform.position, new Vector3(0.5f, -4.5f, 0), 0, path);
     }
     skipButton.SetActive(false);
     doorway.SetActive(true);
     GameObject.FindObjectOfType <Player>().allowedToMove = true;
     finishedTutorial = true;
     doingTutorial    = false;
     dc.GetComponentsInChildren <Text>()[4].text = "";
 }
예제 #2
0
    void OnSceneLoaded(int index)
    {
        Scene  loadingScene = SceneManager.GetSceneByBuildIndex(index);
        Player player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();

        if (loadingScene.IsValid())
        {
            Cursor.SetCursor(Resources.Load <Texture2D>("Cursors/Default Mouse"), Vector2.zero, CursorMode.Auto);
            GameObject spawnPoint = GameObject.Find("SpawnPoint");

            player.transform.position = spawnPoint.transform.position;
            GameObject.Find("GarbageCollector").GetComponent <GarbageCollecter>().SpawnDropped();
            if (index == 0)
            {
                GameObject.FindObjectOfType <NPCController>().CurrentMap = 0;
            }
            else if (index == 1)
            {
                GameObject.FindObjectOfType <NPCController>().CurrentMap = 1;
            }
            GameObject.FindObjectOfType <NPCController>().sceneSwapped = true;
            SceneManager.SetActiveScene(loadingScene);
            GameObject.FindObjectOfType <DoorDontDestroy>().gameObject.GetComponent <AudioSource>().Play();
            DialogueCanvas dc = Resources.FindObjectsOfTypeAll <DialogueCanvas>()[0];
            if (dc.active)
            {
                dc.active = false;
                dc.gameObject.SetActive(false);
            }
        }

        player.GetComponent <Player>().swappingScenes = false;
        player.Speed = player.previousSpeed;
    }
예제 #3
0
    void Start()
    {
        dialogueCanvas    = this;
        speakerText.text  = "";
        dialogueText.text = "";

        SpeakerPanel.GetComponent <RectTransform>().LeanScale(new Vector3(0, 0, 0), 0f);
        DialoguePanel.GetComponent <RectTransform>().LeanScale(new Vector3(0, 0, 0), 0f);

        actions = GameManager.Instance.playerController.playerActions;
    }
 public static void PlayDialogue(Dialogue dialogue, DialogueCanvas dialogueCanvas, MonoBehaviour runOnInstance)
 {
     if (!inDialog)
     {
         currentlyRunningOnInstance = runOnInstance;
         runOnInstance.StartCoroutine(PlayDialogueCor(dialogue, dialogueCanvas, runOnInstance));
     }
     else
     {
         Debug.LogError("PlayConversation() called by " + runOnInstance + " but is already running dialogue on " + currentlyRunningOnInstance + ".");
     }
 }
예제 #5
0
        public void DisplayDialogue(string dialogue)
        {
            Canvas newCanvas = new DialogueCanvas(dialogue);

            if (currentCanvas != null)
            {
                currentCanvas.UnloadContent();
            }

            Paused = true;

            newCanvas.LoadContent();
            currentCanvas = newCanvas;
        }
예제 #6
0
    IEnumerator RunTutorial()
    {
        yield return(new WaitForSecondsRealtime(1.5f));

        if (!finishedTutorial)
        {
            Time.timeScale = 0;
            doorway.SetActive(false);
            player.allowedToMove = false;
            speed = 4;
            cat   = Instantiate(Resources.Load <GameObject>("Characters/TutorialCat"));
            cat.transform.position = new Vector3(0.5f, -4.5f, 0);
            cat.name = "Princess";
            GameObject.FindObjectOfType <Pathfinding>().InitializePath(cat.transform.position, new Vector3(2.5f, 1.5f, 0), 0, path);
            anim        = cat.GetComponent <Animator>();
            currentAnim = "Forward";

            dc         = Resources.FindObjectsOfTypeAll <DialogueCanvas>()[0];
            exitButton = dc.GetComponentsInChildren <Button>()[1].gameObject;
            dialogue   = new string[] { "Hail, young witch.", "Oh, don’t look so surprised!", "How do you expect to become a witch if you can’t handle a talking cat?", "I’m Princess, I’ve lived in these parts for a while, I even knew your Great Aunt back in the day", "She would be proud to know you’ve decided to take over the family business.", "I’m glad to see you’ve already started dressing the part, too.", "So... you don’t really know where to start, do you?", "Well, luckily for you your Great Aunt left her old spellbook. I think you can open it up with M.",
                                        "Great, I’m glad that old pile of papers still works, although it looks like some pages have gone missing over the years.", "You’re new to brewing potions, right? Well, it’s not too hard to get started.", "Here, take these ingredients, plop ‘em in the cauldron over there, and see what you can make.",
                                        "Nice, that looks like a great potion of speed. You can drink it now if you want, or you can save it for later.", "You can get more ingredients by finding them in the wild surrounding your house", "Or you can grow them yourself! Here are some seeds you can plant in the old garden plots outside.",
                                        "There, now you have some to get you started.", "Don’t worry about saying thanks, I’m a cat, I don’t have thumbs so I can’t use them anyways.", "You can put them in that storage chest for now, if you’d like.", "Why don’t you go ahead and make sure the darn thing isn’t rusted shut?",
                                        "One last thing -- your Aunt passed her spellcraft knowledge along, didn’t she?", "You can equip spells by pressing and holding Left Ctrl.", "Spells aren’t my area of expertise though, so you’ll have to figure out how to use them yourself.",
                                        "I think you’re ready to get started, I better get back home before my roommates get worried.", "Oh, one last thing...", "There’s been talk of strange entities in these woods...", "You best watch yourself around anyone who looks... suspicious.", "That aside though, I expect the locals will be coming by and asking you for help once word gets out that there’s a new witch in town.", "They may not all like magic, but they do like shoving their problems on others.", "Good luck, little witch." };



            while (!startText)
            {
                yield return(null);
            }

            dc.gameObject.SetActive(true);
            dc.active = true;

            dc.GetComponentsInChildren <Button>()[0].onClick.RemoveAllListeners();

            dc.GetComponentsInChildren <Button>()[0].onClick.AddListener(NextButton);
            exitButton.SetActive(false);
            dc.GetComponentInChildren <Text>().text     = dialogue[index];
            dc.GetComponentsInChildren <Text>()[4].text = "Princess";
        }
    }
예제 #7
0
    void Start()
    {
        manager        = GameObject.FindObjectOfType <ShrineManager>();
        on             = false;
        finishedRiddle = false;
        dc             = Resources.FindObjectsOfTypeAll <DialogueCanvas>()[0];
        if (gameObject.name.Contains("Order"))
        {
            dialogue = manager.dialogue["order"];
        }
        else if (gameObject.name.Contains("Social"))
        {
            dialogue = manager.dialogue["social"];
        }
        else if (gameObject.name.Contains("Nature"))
        {
            dialogue = manager.dialogue["nature"];
        }

        StartCoroutine(Check());
    }
예제 #8
0
 public DialogueTraverser(DialogueCanvas canvas) : base(canvas)
 {
     nodeCanvas    = canvas;
     startNodeName = "StartDialogueNode";
 }
 private void Awake()
 {
     dialogueCanvas = FindObjectOfType <DialogueCanvas>();
     animator       = GetComponent <Animator>();
 }
예제 #10
0
 private void Awake()
 {
     dialogueCanvas = FindObjectOfType <DialogueCanvas>();
 }
    private static IEnumerator PlayDialogueCor(Dialogue dialogue, DialogueCanvas dialogueCanvasPrefab, MonoBehaviour runOnInstance)
    {
        inDialog = true;

        DialogueCanvas dialogueCanvas = Instantiate(dialogueCanvasPrefab);

        //Object pool
        DialogueBox pooledBox_BL = null, pooledBox_BR = null, pooledBox_TL = null, pooledBox_TR = null;

        //If speakers persist, keep track of where the last speaker was and their portrait
        Image previousSpeakerPortrait_BL = null, previousSpeakerPortrait_BR = null, previousSpeakerPortrait_TL = null, previousSpeakerPortrait_TR = null;

        //Iterate over number of dialogue boxes needed
        int i = 0, iMax = dialogue.dialogueTexts.Count;

        //Scroll text for i'th dialogue box
        while (i < iMax)
        {
            DialogueBox curDialogueBox = null;

            switch (dialogue.boxPositions[i])
            {
            //Create new box or use pooled one
            case Dialogue.BoxPositions.bottomLeft:
                if (pooledBox_BL == null)
                {
                    pooledBox_BL = Instantiate(dialogueCanvas.DialogueBoxPrefab_BL, dialogueCanvas.ShakePivot);
                    pooledBox_BL.GetComponent <RectTransform>().position = dialogueCanvas.DialogueBoxPosistion_BL.position;
                }
                pooledBox_BL.gameObject.SetActive(true);
                curDialogueBox = pooledBox_BL;
                if (dialogue.previousSpeakerPortraitPersists)
                {
                    curDialogueBox.Portrait.transform.SetParent(dialogueCanvas.ShakePivot);
                    curDialogueBox.Portrait.transform.SetAsFirstSibling();
                }
                break;

            case Dialogue.BoxPositions.bottomRight:
                if (pooledBox_BR == null)
                {
                    pooledBox_BR = Instantiate(dialogueCanvas.DialogueBoxPrefab_BR, dialogueCanvas.ShakePivot);
                    pooledBox_BR.GetComponent <RectTransform>().position = dialogueCanvas.DialogueBoxPosistion_BR.position;
                }
                pooledBox_BR.gameObject.SetActive(true);
                curDialogueBox = pooledBox_BR;
                if (dialogue.previousSpeakerPortraitPersists)
                {
                    curDialogueBox.Portrait.transform.SetParent(dialogueCanvas.ShakePivot);
                    curDialogueBox.Portrait.transform.SetAsFirstSibling();
                }
                break;

            case Dialogue.BoxPositions.topLeft:
                if (pooledBox_TL == null)
                {
                    pooledBox_TL = Instantiate(dialogueCanvas.DialogueBoxPrefab_TL, dialogueCanvas.ShakePivot);
                    pooledBox_TL.GetComponent <RectTransform>().position = dialogueCanvas.DialogueBoxPosistion_TL.position;
                }
                pooledBox_TL.gameObject.SetActive(true);
                curDialogueBox = pooledBox_TL;
                if (dialogue.previousSpeakerPortraitPersists)
                {
                    curDialogueBox.Portrait.transform.SetParent(dialogueCanvas.ShakePivot);
                    curDialogueBox.Portrait.transform.SetAsFirstSibling();
                }
                break;

            case Dialogue.BoxPositions.topRight:
                if (pooledBox_TR == null)
                {
                    pooledBox_TR = Instantiate(dialogueCanvas.DialogueBoxPrefab_TR, dialogueCanvas.ShakePivot);
                    pooledBox_TR.GetComponent <RectTransform>().position = dialogueCanvas.DialogueBoxPosistion_TR.position;
                }
                pooledBox_TR.gameObject.SetActive(true);
                curDialogueBox = pooledBox_TR;
                if (dialogue.previousSpeakerPortraitPersists)
                {
                    curDialogueBox.Portrait.transform.SetParent(dialogueCanvas.ShakePivot);
                    curDialogueBox.Portrait.transform.SetAsFirstSibling();
                }
                break;
            }

            //Update current box's information
            curDialogueBox.Portrait.sprite = (dialogue.portraitSprites[i] != null) ? dialogue.portraitSprites[i] : null;
            curDialogueBox.Portrait.color  = new Color(255f, 255f, 255f, (dialogue.portraitSprites[i] != null) ? 255f : 0f);
            float xScaleAbs = Mathf.Abs(curDialogueBox.Portrait.rectTransform.localScale.x);
            curDialogueBox.Portrait.rectTransform.localScale = new Vector3(dialogue.flipPortraits[i] ? -xScaleAbs : xScaleAbs, curDialogueBox.Portrait.rectTransform.localScale.y, curDialogueBox.Portrait.rectTransform.localScale.z);
            curDialogueBox.SpeakerName.text = dialogue.speakerNames[i];
            curDialogueBox.Dialogue.text    = dialogue.dialogueTexts[i];
            curDialogueBox.Dialogue.maxVisibleCharacters = 0;
            curDialogueBox.AdvanceDialogueButton.color   = new Color(255f, 255f, 255f, 0f);

            yield return(new WaitForSeconds(dialogue.textStartDelay));

            //Shake camera
            if (dialogue.shakeAtStarts[i])
            {
                Shake(dialogueCanvas.ShakePivot, dialogue.shakeStrengths[i], runOnInstance);
            }

            //Shake camera
            if (dialogue.initialDelays[i] > 0)
            {
                yield return(new WaitForSeconds(dialogue.initialDelays[i]));
            }

            //Iterate over number of characters
            int   totalCharacters = dialogue.dialogueTexts[i].Length;
            float elapsedTime     = 0f;
            while (!ListenForKeyDown(dialogue.advanceDialogueKey) && curDialogueBox.Dialogue.maxVisibleCharacters != totalCharacters)
            {
                //If character interval has elapsed
                if (elapsedTime > dialogue.characterInterval)
                {
                    elapsedTime = 0f;

                    //Add character
                    curDialogueBox.Dialogue.maxVisibleCharacters += 1;
                    if (dialogue.textScrollSound != null && dialogueCanvas.AudioSource != null)
                    {
                        if (!(curDialogueBox.Dialogue.text[curDialogueBox.Dialogue.maxVisibleCharacters - 1].ToString() == " "))
                        {
                            dialogueCanvas.AudioSource.PlayOneShot(dialogue.textScrollSound);
                        }
                    }
                }

                elapsedTime += Time.deltaTime;
                yield return(null);
            }
            //If skipped dialogue, play sound
            if (ListenForKeyDown(dialogue.advanceDialogueKey) && dialogue.textSkipSound != null && dialogueCanvas.AudioSource != null)
            {
                dialogueCanvas.AudioSource.PlayOneShot(dialogue.textSkipSound);
            }

            //Scroll ended, set all character visisble
            curDialogueBox.Dialogue.maxVisibleCharacters = totalCharacters;

            //Wait to prevent immediately advancing to next box
            yield return(new WaitForEndOfFrame());

            //Show advance icon
            if (dialogue.advanceDialoguePromptSprite != null)
            {
                curDialogueBox.AdvanceDialogueButton.color  = new Color(255f, 255f, 255f, 255f);
                curDialogueBox.AdvanceDialogueButton.sprite = dialogue.advanceDialoguePromptSprite;
            }

            //Wait for advance press
            while (!ListenForKeyDown(dialogue.advanceDialogueKey))
            {
                yield return(null);
            }

            //Play sound once pressed
            if (dialogue.textSkipSound != null)
            {
                dialogueCanvas.AudioSource.PlayOneShot(dialogue.textSkipSound);
            }

            //Hide window for between speaker delay
            curDialogueBox.Window.gameObject.SetActive(false);
            if (i != iMax - 1)
            {
                if (dialogue.speakerNames[i] != dialogue.speakerNames[i + 1] && dialogue.betweenSpeakerDelay > 0)
                {
                    yield return(new WaitForSeconds(dialogue.betweenSpeakerDelay));
                }
            }
            curDialogueBox.Window.gameObject.SetActive(true);

            //Pool box
            curDialogueBox.gameObject.SetActive(false);

            //Step forward to next box
            i++;
        }

        //Dialogue has ended

        //Hide leftover portraits
        if (previousSpeakerPortrait_BL != null)
        {
            previousSpeakerPortrait_BL.gameObject.SetActive(false);
            previousSpeakerPortrait_BR.gameObject.SetActive(false);
            previousSpeakerPortrait_TL.gameObject.SetActive(false);
            previousSpeakerPortrait_TR.gameObject.SetActive(false);
        }

        Destroy(dialogueCanvas.gameObject, .4f);

        currentlyRunningOnInstance = null;
        inDialog = false;
    }
        protected override void Conversation()
        {
            if (index < 2)
            {
                background.SetActive(false);
            }
            else if (index == 2)
            {
                background.SetActive(true);
                StartCoroutine("FadeIn");
                return;
            }
            else if (index == 4)
            {
                StopCoroutine("FadeIn");
                StartCoroutine("FadeOut");
            }
            else if (index == 5)
            {
                StopCoroutine("FadeOut");
                abaddon.SetActive(true);
                sprite = abaddon.GetComponent <SpriteRenderer>();
                StartCoroutine("FadeIn");
            }
            else if (index == 6)
            {
                StopCoroutine("FadeIn");
                StartCoroutine("FadeOut");
            }
            else if (index == 7)
            {
                StopCoroutine("FadeOut");
                SceneManager.LoadScene("InsideHeadquarters");
            }

            DialogueCanvas.SetActive(true);
            dialogueText.SetActive(true);

            if (index < currNode.dialogue.Count) //still has something to write
            {
                //_dlg.text = currNode.dialogue[index];
                if (!isTyping && !finishedTyping)
                {
                    StartCoroutine(TypeText(currNode.dialogue[index], _dlg));
                }
            }
            else
            {
                // SceneManager.LoadScene("Map");
            }

            if (index + 1 == currNode.dialogue.Count && currNode.optionList.Count > 0) //got to the end of the node
            {
                isOption = true;
            }

            if (isOption) //writes the options found on node
            {
                _timer.StartTimer();

                if (currNode.optionList.Count > 0)
                {
                    opt1Text.SetActive(true);
                    opt2Text.SetActive(true);
                    opt3Text.SetActive(true);

                    _opt1.text = currNode.optionList[0].text;
                    _opt2.text = currNode.optionList[1].text;
                    _opt3.text = currNode.optionList[2].text;
                }
            }
            else
            {
                opt1Text.SetActive(false);
                opt2Text.SetActive(false);
                opt3Text.SetActive(false);
            }
        }