예제 #1
0
    private void Start()
    {
        myMaster = GetComponent <Character>();

        idle       = new CharacterIdle(myMaster, this);
        locomotion = new CharacterLocomotion(myMaster, this);
        jump       = new CharacterJump(myMaster, this);
        fall       = new CharacterFall(myMaster, this);
        climb      = new CharacterClimb(myMaster, this);
        crouch     = new CharacterCrouch(myMaster, this);
        zapped     = new CharacterZapped(myMaster, this);
        turn       = new CharacterTurn(myMaster, this);
        interact   = new CharacterInteract(myMaster, this);
        death      = new CharacterDeath(myMaster, this);
        dialogue   = new CharacterDialogue(myMaster, this);
        disabled   = new CharacterDisabled(myMaster, this);
        train      = new CharacterEventTrain(myMaster, this);

        currentState = idle;

        //Special event niveau 1
        if (!GameManager.instance.spcLvlMan.hasHead)
        {
            ChangeState(train);
        }
    }
예제 #2
0
    private static void LoadDialogue()
    {
        TextAsset jsonFile;
        int       r = Random.Range(0, 3);

        scenario = r;
        Debug.Log(r);
        switch (r)
        {
        case 0:
            jsonFile = Resources.Load("CharacterDialogue") as TextAsset;
            break;

        case 1:
            jsonFile = Resources.Load("CharacterDialogue 1") as TextAsset;
            break;

        case 2:
            jsonFile = Resources.Load("CharacterDialogue 2") as TextAsset;
            break;

        default:
            jsonFile = Resources.Load("CharacterDialogue") as TextAsset;
            break;
        }

        dialogue = JsonUtility.FromJson <CharacterDialogue>(jsonFile.text);

        Debug.Log("****Retrieved character dialogue.");
    }
예제 #3
0
파일: Virgil.cs 프로젝트: toki1/Helltrail
    //triggers next dialogue
    void nextDialogue()
    {
        if (dialogueStage >= dialogues.Length)
        {
            inDialogue = false;

            return;
        }
        CharacterDialogue d = dialogues[dialogueStage];

        if (d.speaker == 0)
        {
            VirildialogueUI.SetActive(false);
            AidendialogueUI.SetActive(true);
            textUI.GetComponent <Text>().text = "";
            StopCoroutine(coroutine);
            coroutine = TextAnimation(d.text);
            StartCoroutine(coroutine);
        }
        else
        {
            VirildialogueUI.SetActive(true);
            AidendialogueUI.SetActive(false);
            textUI.GetComponent <Text>().text = "";
            StopCoroutine(coroutine);
            coroutine = TextAnimation(d.text);

            StartCoroutine(coroutine);
        }

        // Play weapon animations when Virgil introduces a weapon
        if (dialogueStage == 7)
        {
            daggerIcon.GetComponent <Animator>().enabled = true;
        }

        else if (dialogueStage == 15)
        {
            daggerIcon.GetComponent <Animator>().enabled = false;
            swordIcon.GetComponent <Animator>().enabled  = false;
            bowIcon.GetComponent <Animator>().enabled    = false;
        }


        dialogueStage++;


        if (dialogueStage == dialogueEndPoint)
        {
            inDialogue = false;
            if (pause)
            {
            }
            else
            {
                next();
            }
        }
    }
예제 #4
0
 public void ShowDialogue(string newDialogueText)
 {
     if (_characterDialogue == null)
     {
         _characterDialogue = gameObject.AddComponent <CharacterDialogue>() as CharacterDialogue;
     }
     _characterDialogue.OpenDialogue(newDialogueText);
 }
예제 #5
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            CharacterDialogue dialogue = (CharacterDialogue)target;

            if (GUILayout.Button("Say Something!"))
            {
                dialogue.LoadRandomDialogue();
            }
        }
예제 #6
0
    public void StartDialogueEnd(CharacterDialogue dialogue)
    {
        dialogueWindow.SetActive(true);
        MoveDialogueWindow(true);

        if (dialogue)
        {
            StartCoroutine(VisualizeDialogue(dialogue));
        }
    }
예제 #7
0
    void ChangeCharacter(Character character)
    {
        firstCharacterSelection = true;
        cluesPanelAnim.Play("Idle");

        ResetDialogue();

        characters.ForEach(item =>
        {
            if (item.character == character)
            {
                item.UI.Grey(true);
            }
            else
            {
                item.UI.Grey(false);
            }
        });

        if (actualCharacterDialogue != null)
        {
            actualCharacterDialogue.ResetDialoguePath();
        }

        actualCharacter = character;

        // select shogun return when needed
        if (actualState != GameData.GameState.NORMAL && character == Character.SHOGUN)
        {
            actualCharacterDialogue = actualDialogue.shogunReturnDialogues;
        }
        else         // select normal in other cases
        {
            actualCharacterDialogue = actualDialogue.GetCharacterDialogue(actualCharacter);
        }

        characterPortrait.SetCharacterPortrait(GetCharacter(actualCharacter));
        characterPortrait.detail.color = GameData.GetColorFromCharacter(actualCharacter);

        characterName.text  = GetCharacter(actualCharacter).name;
        characterName.color = GameData.GetColorFromCharacter(actualCharacter);

        dialogueScrollDetail.color = GameData.GetColorFromCharacter(actualCharacter);

        ColorBlock colors = dialogueScroll.colors;

        colors.pressedColor   = GameData.GetColorFromCharacter(actualCharacter);
        dialogueScroll.colors = colors;

        waitForPlayerChoice = false;
        characterTextColor  = GameData.GetColorFromCharacter(character);

        SpawnCharacterLine(actualCharacterDialogue.firstLine, characterTextColor);
    }
예제 #8
0
 void Start()
 {
     // Add components to character
     _characterMovement    = gameObject.AddComponent <CharacterMovement>() as CharacterMovement;
     _characterTimer       = gameObject.AddComponent <CharacterTimer>() as CharacterTimer;
     _characterInteraction = gameObject.AddComponent <CharacterInteraction>() as CharacterInteraction;
     _characterInventory   = gameObject.AddComponent <CharacterInventory>() as CharacterInventory;
     _characterDialogue    = gameObject.AddComponent <CharacterDialogue>() as CharacterDialogue;
     // Assign default values
     _characterMovement.CharacterPhysicalObject = _characterPhysicalObject;
     _characterTimer.StartTime = _startTime;
 }
예제 #9
0
    // gets CharacterDialogue from Character variable
    public CharacterDialogue GetCharacterDialogue(Character character)
    {
        CharacterDialogue selected = charactersDialogues.Find(item => { return(item.character == character); });

        if (selected == null)
        {
            Debug.LogError(debugableInterface.debugLabel + "Couldn't find CharacterDialogue with character " + character.ToString());
            return(null);
        }

        return(selected);
    }
예제 #10
0
 public void StartDialogue(CharacterDialogue dialogue)
 {
     dialogueWindow.SetActive(true);
     MoveDialogueWindow(true);
     if (OnOpenWindow != null)
     {
         OnOpenWindow();
     }
     if (dialogue)
     {
         StartCoroutine(VisualizeDialogue(dialogue));
     }
 }
예제 #11
0
 private void OnEnable()
 {
     if (_characterTimer == null)
     {
         _characterTimer = _character.GetComponent <CharacterTimer>();
     }
     if (_characterDialogue == null)
     {
         _characterDialogue = _character.GetComponent <CharacterDialogue>();
     }
     CharacterTimer.OnMileStoneReached        += ChangeMusic;
     CharacterDialogue.OnDialogueStateChanged += PlayInteractionSound;
 }
예제 #12
0
 void Update()
 {
     if (runTutorialHubText == true && dialogueIndex < introductionDialogue.Length)
     {
         CharacterDialogue tabithaDialogue = openingTabithaCharacter.GetComponent <CharacterDialogue>();
         progressDialogue(introductionDialogue, introductionNames);
         if (dialogueIndex == introductionDialogue.Length)
         {
             tabithaDialogue.toggleRight = true;
             tabithaDialogue.toggleLeft  = false;
         }
     }
 }
예제 #13
0
파일: Virgil.cs 프로젝트: toki1/Helltrail
    // Start is called before the first frame update
    void Start()
    {
        weaponWheel = GameObject.Find("Weapon Wheel");
        daggerIcon  = weaponWheel.transform.GetChild(0).GetChild(0).gameObject;
        swordIcon   = weaponWheel.transform.GetChild(1).GetChild(0).gameObject;
        bowIcon     = weaponWheel.transform.GetChild(2).GetChild(0).gameObject;

        // Dagger icon initial position and scale
        daggerIcon.transform.position   = new Vector3(-250.0f, 400.0f, 1);
        daggerIcon.transform.localScale = new Vector3(14.0f, 14.0f, 0);
        daggerIcon.GetComponent <Animator>().enabled = false;

        // Sword icon initial position and scale
        swordIcon.transform.position   = new Vector3(-357.0f, 470.0f, 1);
        swordIcon.transform.localScale = new Vector3(8.0f, 8.0f, 0);
        swordIcon.GetComponent <Animator>().enabled = false;

        // Bow icon initial position and scale
        bowIcon.transform.position   = new Vector3(-460.0f, 450.0f, 1);
        bowIcon.transform.localScale = new Vector3(8.0f, 8.0f, 0);
        bowIcon.GetComponent <Animator>().enabled = false;


        transform.position = new Vector3(17.5f, 11.5f, -2);
        target             = transform.position;
        dialogueUI.SetActive(false);
        dialogues     = new CharacterDialogue[17];
        dialogues[0]  = new CharacterDialogue("Huh? Where am I?", 0);
        dialogues[1]  = new CharacterDialogue("You’re in Limbo. You’ve been sent to help us.", 1);
        dialogues[2]  = new CharacterDialogue("Help you? How?", 0);
        dialogues[3]  = new CharacterDialogue("Satan has illegally taken pure souls from the mortal realm. Recently the border between the afterlife and the mortal realm has begun to weaken. So, we must take this opportunity to rescue them. ", 1);
        dialogues[4]  = new CharacterDialogue("But why me?", 0);
        dialogues[5]  = new CharacterDialogue("Satan has captured and corrupted many of the world’s most powerful warriors and saints. However, only a mortal can traverse both Heaven and Hell. That’s why you were chosen, a pure soul with a strong resistance to the corruption and temptation of Hell, to reclaim the lost souls.", 1);
        dialogues[6]  = new CharacterDialogue("If we hurry, we'll be able to get you to Gluttony, the third circle of Hell.", 1);
        dialogues[7]  = new CharacterDialogue("First, you’ll need some weapons. Here’s a small dagger. Use it by pressing the arrows keys in the direction of your attack. This will deal a small amount of damage, but you can use it quickly. When you’re ready, let’s head to the next room, I heard something coming from there. Use the WASD keys to move around.", 1);
        dialogues[8]  = new CharacterDialogue("Press E to prepare your special attack for your next strike", 1);
        dialogues[9]  = new CharacterDialogue("A wretch! These enemies are common in all circles of Hell. They are quick but pretty easy to kill! Use your dagger to attack.", 1);
        dialogues[10] = new CharacterDialogue("It looks like that enemy had a sword from a fallen soldier. You can use that on your journey, it will be stronger but slower than your dagger.", 1);
        dialogues[11] = new CharacterDialogue("To rotate between your weapons use the key ‘Q’. There are a lot of enemies in here, if you see your health bar dropping, look for a health potion for strength. ", 1);
        dialogues[12] = new CharacterDialogue("That was close. If you find yourself needing help, always keep your eyes open for potions, they can help you in lots of ways. Also, it looks like you now have a bow and arrow! That will be useful for ranged attacks. ", 1);
        dialogues[13] = new CharacterDialogue("It looks like one of the Gluttony monsters has wandered into Limbo!", 1);
        dialogues[14] = new CharacterDialogue("A soul! One of the monsters must’ve trapped it inside them! You can use these freed souls to help fuel your journey.", 1);
        dialogues[15] = new CharacterDialogue("It looks like we’ve made it to the entry of the Gluttony circle of Hell. I think you’re ready to head on your journey. Remember, every circle of Hell will contain the sin it embodies. Giving in to these sins, will only make these enemies stronger.", 1);
        dialogues[16] = new CharacterDialogue("We wish you luck on your journey. You are our only hope in returning these pure souls to the world.", 1);
        coroutine     = TextAnimation("");

        next();
    }
예제 #14
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        CharacterDialogue cd = (CharacterDialogue)target;

        if (GUILayout.Button("Next Dialogue Line"))
        {
            cd.SetDialogue(cd.currentDialogueIndex + 1);
        }

        if (GUILayout.Button("Reset Dialogue"))
        {
            cd.SetDialogue(cd.startingLine);
        }
    }
예제 #15
0
    public void SaveCharacterDataToXML(CharacterDialogue dialogue, string fileLocation)
    {
        StreamWriter writer;
        FileInfo     t = new FileInfo(fileLocation + "\\" + dialogue.Name + FileExtension);

        if (!t.Exists)
        {
            writer = t.CreateText();
        }
        else
        {
            t.Delete();
            writer = t.CreateText();
        }
        writer.Write(ObjectToXml(dialogue));
        writer.Close();
        Debug.Log("File written.");
    }
예제 #16
0
 void Start()
 {
     playerShip   = GameObject.Find("PlayerShip");
     playerScript = playerShip.GetComponent <PlayerScript>();
     if (MiscData.finishedTutorial == false)
     {
         MiscData.finishedTutorial     = true;
         runTutorialHubText            = true;
         playerShip.transform.position = new Vector3(20, -22, 0);
         playerScript.playerDead       = true;
         dialogueText.transform.parent.gameObject.SetActive(true);
         dialogueText.text           = introductionDialogue[dialogueIndex];
         nameText.text               = introductionNames[dialogueIndex];
         tabithaDialogue             = openingTabithaCharacter.GetComponent <CharacterDialogue>();
         tabithaDialogue.toggleLeft  = true;
         tabithaDialogue.toggleRight = false;
     }
 }
예제 #17
0
    private IEnumerator VisualizeDialogue(CharacterDialogue dialogue)
    {
        int pieceIndex = 0;

        while (pieceIndex < dialogue.pieces.Count)
        {
            nextPiece = false;
            SetName(dialogue.pieces[pieceIndex].speaker.chName);
            SetImage(dialogue.pieces[pieceIndex].speaker.img, dialogue.pieces[pieceIndex].speaker.useAnimator);
            SetDialogueText(dialogue.pieces[pieceIndex].message);
            yield return(new WaitUntil(() => nextPiece));

            pieceIndex++;
        }
        yield return(new WaitUntil(() => nextPiece));

        MoveDialogueWindow(false);
        //dialogueWindow.SetActive(false);
    }
예제 #18
0
    public CharacterDialogue LoadCharacterData(string path)
    {
        CharacterDialogue character = null;

        TextAsset xml = Resources.Load(path) as TextAsset;

        if (xml != null)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(CharacterDialogue));
            StringReader  reader     = new StringReader(xml.text);
            character = serializer.Deserialize(reader) as CharacterDialogue;
            reader.Close();
        }
        else
        {
            Debug.LogError("XML File Was Null At Path: " + path);
        }

        return(character);
    }
예제 #19
0
    public void OpenPanel(string id)
    {
        currentCharacter = FindDialogue(id);

        if (currentCharacter != null)
        {
            Debug.Log("char found");
            characterSprite.sprite = currentCharacter.image;
            characterName.text     = currentCharacter.name;
            message.text           = currentCharacter.dialogues[currentLine];

            if (currentCharacter.dialogues.Length > 1)
            {
                buttonText.text = "Continue";
            }
            else
            {
                buttonText.text = "Close";
            }
        }
    }
예제 #20
0
    private void DisplayText()
    {
        if (_characterDialogue == null)
        {
            _characterDialogue = _character.gameObject.GetComponent <CharacterDialogue>();
        }

        _textToDisplay = _characterDialogue.DialogueText;
        this.gameObject.SetActive(true);

        char[] charArr  = _textToDisplay.ToCharArray();
        string charText = "";

        foreach (char ch in charArr)
        {
            charText        = charText + ch;
            dialogText.text = _textToDisplay;
        }
        _characterDialogue.DoneTyping();
        _textToDisplay = "";
    }
예제 #21
0
    public void Interact()
    {
        if (_characterDialogue == null)
        {
            _characterDialogue = gameObject.AddComponent <CharacterDialogue>() as CharacterDialogue;
        }

        if (_characterDialogue.GetDialogueState() != DialogueState.Disabled)
        {
            _characterDialogue.NextState();
        }
        else
        {
            RaycastHit objectInRange;
            if (Physics.Raycast(transform.position, _characterPhysicalObject.transform.forward, out objectInRange, _interactionRange))
            {
                if (objectInRange.collider.gameObject.GetComponent <InteractableObject>())
                {
                    _characterInteraction.InteractWithObject(objectInRange.collider.gameObject.GetComponent <InteractableObject>());
                }
            }
        }
    }
예제 #22
0
    // Reads the dialogue from the path
    void readDialogue(string dialoguePath)
    {
        TextAsset jsonTextFile = Resources.Load <TextAsset>(dialoguePath);

        this.dialogue = JsonUtility.FromJson <CharacterDialogue>(jsonTextFile.ToString());
    }
예제 #23
0
 void Awake()
 {
     singleton = this;
 }
예제 #24
0
 void Awake()
 {
     path         = path + characterNameToLoad + "_" + DialogueManagement.Language;
     dialogueData = XMLFileHandler.Instance.LoadCharacterData(path);
 }
예제 #25
0
    void Update()
    {
        // sets character grey state
        if (actualDialogue != null && actualDialogue.GetCharacterDialogue(Character.SHOGUN).IsDone())
        {
            if (!firstCharacterSelection && !cluesPanelAnim.GetCurrentAnimatorStateInfo(0).IsName("Tutorial"))
            {
                cluesPanelAnim.Play("ShowTutorial");
            }

            List <UICharacter> notGreyed = new List <UICharacter>();

            characters.ForEach(item =>
            {
                if (item.character != actualCharacter)
                {
                    item.selectionButton.interactable = true;
                    item.UI.Grey(false);
                }

                if (!item.UI.IsGreyed())
                {
                    notGreyed.Add(item.UI);
                }
            });

            // if shogun dialogue is already done
            if (notGreyed.Count > 1)
            {
                characterMoveTimer += Time.deltaTime;
            }

            // animates characters
            if (characterMoveTimer >= characterMoveDelay)
            {
                characterMoveTimer = 0;

                // select random character except shogun
                List <ShogunCharacter> allButShogunAndSelected = new List <ShogunCharacter>();

                foreach (ShogunCharacter shogunCharacter in characters)
                {
                    if (shogunCharacter.character != Character.SHOGUN && shogunCharacter.character != actualCharacter && shogunCharacter.character != lastAnimated)
                    {
                        allButShogunAndSelected.Add(shogunCharacter);
                    }
                }

                int index = UnityEngine.Random.Range(0, allButShogunAndSelected.Count);

                // select random animation
                int animationIndex = UnityEngine.Random.Range(0, characterAnimationTag.Length);

                // give random animation to random character
                allButShogunAndSelected[index].UI.movementAnimator.Play(characterAnimationTag[animationIndex]);

                // stores last animated
                lastAnimated = allButShogunAndSelected[index].character;
            }
        }

        scrollDown.SetActive(cluesScrollList.anchoredPosition.y < cluesScrollList.rect.height / 2);
        scrollUp.SetActive(cluesScrollList.anchoredPosition.y > cluesScrollList.parent.GetComponent <RectTransform>().rect.height - (cluesScrollList.rect.height / 2));

        // unlock all cheat
        if (Input.GetKeyDown(unlockAllClues) && !didCheat && useCheats)
        {
            foreach (Clue clue in actualDialogue.GetAllClues())
            {
                if (findClueEvent.Invoke(clue))
                {
                    AddClueToList(clue);
                }
            }

            Debug.Log(debugableInterface.debugLabel + "Unlocked all clues");

            didCheat = true;
        }

        // timer for clues panel
        if (cluesAddTimer > 0)
        {
            cluesAddTimer -= Time.deltaTime;

            if (cluesAddTimer <= 0)
            {
                cluesAddTimer = 0;
                cluesOpen     = false;

                cluesPanelAnim.Play("Close");
                AudioManager.PlaySound("CluesPanel");
            }
        }

        // when character writer is done
        if (lastWriter != null && lastWriter.isDone)
        {
            // prevents update from spawning lines if we are waiting for the player to choose a dialogue line
            if (waitForPlayerChoice)
            {
                return;
            }

            characterDone = true;

            // previous line was a character line
            if (needsPlayerSpawn)
            {
                {
                    // sets shogun dialogue done if return dialogue done
                    CharacterDialogue selected = actualDialogue.charactersDialogues.Find(item => { return(item.character == Character.SHOGUN); });

                    if (actualDialogue.shogunReturnDialogues.IsDone() && !selected.IsDone())
                    {
                        actualDialogue.charactersDialogues.Find(item => { return(item.character == Character.SHOGUN); }).ForceSetAsDone();
                    }
                }

                // spawns next dialogues choices
                if (Input.GetMouseButtonDown(0) || forceClick)
                {
                    forceClick = false;

                    Dialogue[] availableDialogues;

                    // if we are not at beginning of dialogue
                    if (actualCharacterDialogue.indexesPath.Count > 0)
                    {
                        // adds clue to player clue list if there was one
                        if (actualCharacterDialogue.indexesPath.Count > 1 && actualCharacterDialogue.GetActualDialogue().hasClue)
                        {
                            if (findClueEvent.Invoke(actualCharacterDialogue.GetActualDialogue().clue))
                            {
                                AddClueToList(actualCharacterDialogue.GetActualDialogue().clue);
                            }
                        }

                        availableDialogues = actualCharacterDialogue.GetActualDialogue().nextDialogues;

                        // resets indexes path if branch can't go any further
                        if (availableDialogues == null || availableDialogues.Length == 0)
                        {
                            actualCharacterDialogue.ResetDialoguePath();
                            return;
                        }
                    }
                    else
                    {
                        availableDialogues = actualCharacterDialogue.initialDialogues.ToArray();
                    }

                    for (int i = 0; i < availableDialogues.Length; i++)
                    {
                        int    j      = i;
                        Color  actual = Skinning.GetSkin(availableDialogues[i].IsDone() ? playerChoiceDone : playerChoiceUndone);
                        string line   = availableDialogues[i].playerQuestion;

                        if (availableDialogues[i].IsDone())
                        {
                            line = "<s>" + line + "</s>";
                        }

                        SpawnPlayerChoice(line, availableDialogues[i].playerQuestion, actual, j);
                    }
                }
            }
            else             // previous line was player line
            {
                SpawnCharacterLine(actualCharacterDialogue.GetActualDialogue().characterAnswer, characterTextColor);
            }
        }
        else if (Input.GetMouseButtonDown(0) || forceClick)
        {
            forceClick = false;

            if (lastWriter != null)
            {
                lastWriter.Finish();
            }
        }
    }
예제 #26
0
 public void setDialogue(CharacterDialogue dialogue)
 {
     this.dialogue = dialogue;
 }