/// <summary>
 /// Stop skip
 /// </summary>
 /// <remarks>
 /// This method should be called when the state is Skip
 /// </remarks>
 private void StopSkip()
 {
     Assert.AreEqual(State, DialogueBoxState.Skip, "DialogueBoxState State != DialogueBoxState.Skip");
     needAnimation = shouldNeedAnimation;
     _state        = DialogueBoxState.Normal;
     TryRemoveSchedule();
 }
    private void HideDialogueBox()
    {
        dialogueTextBox.gameObject.SetActive(false);
        dialogueBoxShadow.gameObject.SetActive(false);
        characterController.enabled = true;

        dialogueBoxState = DialogueBoxState.Hidden;
    }
Exemple #3
0
 public static bool IsDialogueBoxState(Interactor intr, DialogueBoxState desiredState)
 {
     switch (desiredState)
     {
     case DialogueBoxState.InvocationSuccess:
         return(Screen.ImageSearch(intr, "InvocationSuccessWindowTitle").Found);
     }
     return(false);
 }
 /// <summary>
 /// Begin skip
 /// </summary>
 /// <remarks>
 /// This method should be called when the state is normal
 /// </remarks>
 private void BeginSkip()
 {
     Assert.AreEqual(State, DialogueBoxState.Normal, "DialogueBoxState State != DialogueBoxState.Normal");
     // Stop character animation
     StopCharacterAnimation();
     shouldNeedAnimation = needAnimation;
     needAnimation       = false;
     _state = DialogueBoxState.Skip;
     TrySchedule(SkipDelay);
 }
    public void ShowDialogueBox(int dialogueIdentifier)
    {
        currentDialogue = dialogues[dialogueIdentifier];

        UpdateDialogueBox();

        dialogueTextBox.gameObject.SetActive(true);
        dialogueBoxShadow.gameObject.SetActive(true);
        characterController.enabled = false;

        dialogueBoxState = DialogueBoxState.Shown;
    }
 /// <summary>
 /// Start auto
 /// </summary>
 /// <remarks>
 /// This method should be called when the state is normal
 /// </remarks>
 private void BeginAuto()
 {
     Assert.AreEqual(State, DialogueBoxState.Normal, "DialogueBoxState State != DialogueBoxState.Normal");
     _state = DialogueBoxState.Auto;
     AutoModeStarts.Invoke();
     // Make sure no one stop auto mode after immediately recieves an AutoModeStarts event
     // There is no need to worry about BeginAuto method called again when this event happens, since
     // This is a private method called by the setter of State
     if (_state == DialogueBoxState.Auto)
     {
         autoCoroutine = StartCoroutine(Auto());
     }
 }
        public void Update(GameTime gameTime)
        {
            switch (_currentState)
            {
            case DialogueBoxState.Closed:
                if (_dialogueQueue.Count > 0)
                {
                    _currentDialogue = _dialogueQueue.Dequeue();
                    _currentState    = DialogueBoxState.Opening;
                }
                break;

            case DialogueBoxState.Opening:
                // todo animation stuff, just jump right to open for now
                _currentState         = DialogueBoxState.Open;
                _currentDialogueIndex = 0;
                break;

            case DialogueBoxState.Open:
                if (_currentDialogueIndex != _dialogIndexPreviousFrame &&
                    _currentDialogue.DialogueEntries.Count > _currentDialogueIndex)
                {
                    _currentTextInBox = WordWrapper.WrapWord(
                        new StringBuilder(_currentDialogue.DialogueEntries[_currentDialogueIndex]),
                        _defaultFont,
                        new Rectangle(0, 450, 800, 150),
                        1f);

                    _dialogIndexPreviousFrame = _currentDialogueIndex;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.Z))
                {
                    if (_currentDialogueIndex + 1 < _currentDialogue.DialogueEntries.Count)
                    {
                        _currentDialogueIndex++;
                    }
                    else
                    {
                        _currentState = DialogueBoxState.Closing;
                    }
                }

                break;

            case DialogueBoxState.Closing:
                //todo animation stuff, just jump right to closed for now
                _currentState = DialogueBoxState.Closed;
                break;
            }
        }
        /// <summary>
        /// Stop Auto
        /// </summary>
        /// <remarks>
        /// This method should be called when the state is auto
        /// </remarks>
        private void StopAuto()
        {
            Assert.AreEqual(State, DialogueBoxState.Auto, "DialogueBoxState State != DialogueBoxState.Auto");
            _state = DialogueBoxState.Normal;
            // The if condition here is to make sure no error will be raised if someone switch the State immediately
            // after receives AutoModeStarts event
            if (autoCoroutine != null)
            {
                StopCoroutine(autoCoroutine);
                autoCoroutine = null;
            }

            AutoModeStops.Invoke();
        }
        public void OnPointerClick(PointerEventData eventData)
        {
            if (State == DialogueBoxState.Normal && !isAnimating)
            {
                gameState.Step();
                return;
            }

            if (isAnimating)
            {
                StopCharacterAnimation();
            }

            State = DialogueBoxState.Normal;
        }
        /// <summary>
        /// Stop skip
        /// </summary>
        /// <remarks>
        /// This method should be called when the state is Skip
        /// </remarks>
        private void StopSkip()
        {
            Assert.AreEqual(State, DialogueBoxState.Skip, "DialogueBoxState State != DialogueBoxState.Skip");
            needAniamtion = shouldNeedAnimation;
            _state        = DialogueBoxState.Normal;
            // The if condition here is to make sure no error will be raised if someone switch the State immediately
            // after receives SkipModeStarts event
            if (skipCoroutine != null)
            {
                StopCoroutine(skipCoroutine);
                skipCoroutine = null;
            }

            SkipModeStops.Invoke();
        }
        private IEnumerator Skip()
        {
            while (true)
            {
                if (currentDialogue == null)
                {
                    Debug.LogError("current dialogue not set, Skip mode stop");
                    _state        = DialogueBoxState.Normal;
                    needAniamtion = shouldNeedAnimation;
                    SkipModeStops.Invoke();
                    yield break;
                }

                gameState.Step();
                yield return(new WaitForSeconds(SkipDuration));
            }
        }
 /// <summary>
 /// Begin skip
 /// </summary>
 /// <remarks>
 /// This method should be called when the state is normal
 /// </remarks>
 private void BeginSkip()
 {
     Assert.AreEqual(State, DialogueBoxState.Normal, "DialogueBoxState State != DialogueBoxState.Normal");
     // Stop character animation
     StopCharacterAnimation();
     shouldNeedAnimation = needAniamtion;
     needAniamtion       = false;
     _state = DialogueBoxState.Skip;
     SkipModeStarts.Invoke();
     // Make sure no one stop skip mode after immediately recieves an SkipModeStarts event
     // There is no need to worry about BeginSkip method called again when this event happens, since
     // This is a private method called by the setter of State
     if (_state == DialogueBoxState.Skip)
     {
         skipCoroutine = StartCoroutine(Skip());
     }
 }
        private IEnumerator Auto()
        {
            while (true)
            {
                if (currentDialogue == null)
                {
                    Debug.LogError("current dialogue not set, Auto mode stop");
                    _state = DialogueBoxState.Normal;
                    AutoModeStops.Invoke();
                    yield break;
                }

                yield return(new WaitForSeconds(currentDialogue.Length * AutoWaitTimePerCharacter));

                gameState.Step();
            }
        }
        /// <summary>
        /// Check if should restore the previous state before the branch happens
        /// </summary>
        /// <param name="branchSelectedEventData"></param>
        private void OnBranchSelected(BranchSelectedEventData branchSelectedEventData)
        {
            Assert.AreEqual(State, DialogueBoxState.Normal, "DialogueBoxState.Normal != DialogueBox.State");
            switch (stateBeforeBranch)
            {
            case DialogueBoxState.Normal:
                break;

            case DialogueBoxState.Auto:
                State = continueAutoAfterBranch ? DialogueBoxState.Auto : DialogueBoxState.Normal;
                break;

            case DialogueBoxState.Skip:
                State = continueSkipAfterBranch ? DialogueBoxState.Skip : DialogueBoxState.Normal;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private IEnumerator ScheduledStep(float scheduledDelay)
        {
            Assert.IsTrue(dialogueAvaliable, "Dialogue should available when a step scheduled for it");
            while (scheduledDelay > timeAfterDialogueChange)
            {
                yield return(new WaitForSeconds(scheduledDelay - timeAfterDialogueChange));
            }

            // Pause one frame before step
            // Give time for rendering and can stop schedule step in time before any unwanted effects occurs
            yield return(null);

            if (gameState.canStepForward)
            {
                gameState.Step();
            }
            else
            {
                State = DialogueBoxState.Normal;
            }
        }
Exemple #16
0
 public static bool IsDialogueBoxState(Interactor intr, DialogueBoxState desiredState)
 {
     switch (desiredState) {
         case DialogueBoxState.InvocationSuccess:
             return Screen.ImageSearch(intr, "InvocationSuccessWindowTitle").Found;
     }
     return false;
 }
 /// <summary>
 /// Stop Auto
 /// </summary>
 /// <remarks>
 /// This method should be called when the state is auto
 /// </remarks>
 private void StopAuto()
 {
     Assert.AreEqual(State, DialogueBoxState.Auto, "DialogueBoxState State != DialogueBoxState.Auto");
     _state = DialogueBoxState.Normal;
     TryRemoveSchedule();
 }
 void Start()
 {
     HideDialogueBox();
     endgameBoxShadow.gameObject.SetActive(false);
     endgameBoxShadow.gameObject.SetActive(false);
     currentDialogue  = null;
     dialogueBoxState = DialogueBoxState.Hidden;
     dialogues        = new Dictionary <int, Dialogue>
     {
         [1] = new Dialogue("Rimald", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("Zostaw mnie w spokoju! Nie mam ci nic do powiedzenia!", new List <Response>()
             {
                 new Response("Szukam zabójcy Twojej żony. Czy mółgbyś mi powiedzieć coś więcej na ten temat.", 1),
             }),
             [1] = new DialoguePart("Nawet nie wiesz, co musiałem przejść tamtej nocy! Moja żona leżała cała we krwi, z zakrwawionym sztyletem w ręce. Jak byś ty się czuł w moim położeniu!? Niech ja tylko dorwę tego drania, który to zrobił!", new List <Response>())
         }),
         [2] = new Dialogue("Duchowny Olivier", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("Witaj, jestem duchownym i przewodzę tej gromadce dusz. Ostatnio, jak pewnie wiesz, zamordowano tu Romuellę. Czy dowiedziałeś się kto stoi za tą zbrodnią?", new List <Response>()
             {
                 new Response("Powiedz mi coś więcej o tej zbrodni.", 1),
                 new Response("Co robiłeś tej nocy, kiedy Romuella umarła?", 2),
                 new Response("Wiem, kto zabił Romuellę.", 3)
             }),
             [1] = new DialoguePart("Dowiedziałem się o śmierci Romuelli od jej męża, Rimalda. Przybiegł do mnie przedwczoraj w nocy i opowiedział o tym, jak znalazł ją martwą w chatce leśnej, gdzie przygotowywała medykamenty dla potrzebujących.", new List <Response>()
             {
                 new Response("A więc była zielarką?", 4),
                 new Response("Co robiłeś tej nocy, kiedy Romuella umarła?", 2)
             }),
             [2] = new DialoguePart("Spałem, aż do trzeciej warty, gdy przybiegł do mnie Rimald i opowiedział o wszystkim.", new List <Response>()),
             [3] = new DialoguePart("Któż dokonał tej jakże straszliwej zbrodni?", new List <Response>()
             {
                 new Response("Był to Gregor.", -1),
                 new Response("Rimald zabił swoją żonę.", -1),
                 new Response("Jarom doprowadził do śmierci własną matkę.", -1),
                 new Response("Cathie ją zabiła.", 0),
                 new Response("Ty ją zabiłeś!", -1),
                 new Response("Popełniła samobójstwo.", -1)
             }),
             [4] = new DialoguePart("Dokładnie tak, przejęła tę rolę po poprzedniej zielarce, która okazała się być czarownicą, a, jak wiadomo, w naszym królestwie uprawianie wszelkiej formy magii jest surowo wzbronione. Należy walczyć z objawami wszelkiej herezji.", new List <Response>())
         }),
         [3] = new Dialogue("Gregor", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("Szukasz mordercy Romuelli, prawda? To niewyobrażalne, żeby ktoś mógł dokonać czegoś tak strasznego!", new List <Response>()
             {
                 new Response("Co robiłeś tamtej nocy?", 1),
             }),
             [1] = new DialoguePart("Od czego zacząć? Romuella poprosiła mnie, abym narąbał Jej trochę drewna na opał. Wziąłem więc siekierę i poszedłem ściąć drzewo w pobliżu Jej chaty. Ścinałem właśnie stary dąb, gdy usłyszałem krzyk. Pobiegłem niezwłocznie i zobaczyłem krwawiącą Romuellę. Położyłem Ją na brzuchu i próbowałem zatamować krwawienie, ale rana była zbyt głęboka. Na zawsze będę miał ten widok przed oczami.", new List <Response>()
             {
                 new Response("Możesz mi powiedzieć coś więcej o tej sprawie?", 2),
                 new Response("Gdzie zostawiłeś tę siekierę?", 3)
             }),
             [2] = new DialoguePart("Kiedy tylko wbiegłem do chaty, zobaczyłem stojącego nad Nią męża. Stał jak słup soli i patrzył na Nią. Myślę, że miał Jej za złe, że spędza za dużo czasu na szukaniu ziół i że zaniedbuje rodzinę.", new List <Response>()
             {
                 new Response("Gdzie zostawiłeś tę siekierę?", 3)
             }),
             [3] = new DialoguePart("Siekierę? Zostawiłem ją przy kominku. Zawsze tam ją odkładam, koło drewna na opał.", new List <Response>())
         }),
         [4] = new Dialogue("Jarom", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("Jesteś tym Panem, który ma znaleźć osobę, która zrobiła coś złego mamie?", new List <Response>()
             {
                 new Response("Tak, jestem. Jak ostatnio zachowywała się Twoja mama?", 1)
             }),
             [1] = new DialoguePart("Ostatnio była jakaś taka smutna. Mówiła mi, że świat jest niesprawiedliwy. Tata był jakiś zły, kiedy późno wracała do domu. Mówił, że Go oszukuje, ale ja nie wiem, co to znaczy.", new List <Response>()
             {
                 new Response("Zaczęła później wracać?", 2)
             }),
             [2] = new DialoguePart("Tak. Kilka razy wracała późno do domu. Mówiła mi, że musiała pomagać innym. Kiedyś, gdy wróciła, powiedziała, że musiała zrobić jakiś balsmam, czy jakoś tak, dla Pana Gregora, bo się zranił siekierą podczas pracy.", new List <Response>()
             {
                 new Response("Co ostatnio robiłeś?", 3)
             }),
             [3] = new DialoguePart("Wczoraj z tatą przenosiliśmy rzeczy z jej chatki. Ja... wziąłem sobie jedną książkę z Jej kufra. Miała takie duże obrazki...", new List <Response>()
             {
                 new Response("Przepraszam, czy mógłbyś mi powiedzieć, gdzie zostawiłeś tę książkę?", 4)
             }),
             [4] = new DialoguePart("Tak, proszę Pana. Zostawiłem ją na górze, tam jest więcej takich książek, ale tylko ta miała obrazki. Trochę straszne były. Ale nie mów tego tacie. Boję się, że znowu złoi mi skórę, a Pani Cathie znowu będzie mówić, że źle się zachowuję.", new List <Response>()
             {
                 new Response("Dlaczego Pani Cathie tak mówi?", 5)
             }),
             [5] = new DialoguePart("Ostatnio, gdy przyszła do mamy, stałem pod drzwiami i... podsłuchiwałem. Nie rozumiałem zbytnio, co mówią, ale mama była zła, gdy Pani Cathie poprosiła ją o zrobienie eliskiru, jakoś tak mówiła. Potem mnie nakryły, a Pani Cathie mówiła, że jestem bardzo niegrzeczny.", new List <Response>())
         }),
         [5] = new Dialogue("Cathie", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("To bardzo smutne, że Romuella umarła. Była dobrą znajomą i zawsze była chętna pomóc.", new List <Response>()
             {
                 new Response("Co robiłaś przedwczoraj?", 1),
                 new Response("Wygląda na to, że Ją dobrze znałaś. Możesz mi powiedzieć o Niej coś więcej?", 2)
             }),
             [1] = new DialoguePart("Najpierw zrobiłam obiad dla Gregora, mojego męża. Mówił mi, że musi iść narąbać drewna i wspomniał, żebym wybrała się do miasta po nową ostrzałkę. Wzięłam trochę pieniędzy i poszłam do miasta. Kiedy wróciłam, dowiedziałam się o wszystkim. To musiało być straszne!", new List <Response>()
             {
                 new Response("Dlaczego Gregor poprosił Cię o nową ostrzałkę?", 3)
             }),
             [2] = new DialoguePart("Tak, znałam ją bardzo dobrze. Czasami nawet pomagałam jej w obowiązkach domowych. Mają bardzo niewychowanego syna, który ciągle gdzieś znika. Myślę, że przebywa w złym towarzystwie.", new List <Response>()),
             [3] = new DialoguePart("Poprzednia ostrzałka już jest zniszczona, a Gregor jest drwalem i musi dbać o swoją siekierę. Mój mąż jest często zajęty, więc ja udaję się do miasta po różne rzeczy - czy to jedzenie czy ubrania. Trzeba dbać o swój dom.", new List <Response>())
         }),
         [6] = new Dialogue("Sztylet", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("*Na podłodze zobaczyłeś leżący sztylet. Podniosłeś go, by lepiej się przyjrzeć znalezisku.*", new List <Response>()
             {
                 new Response("*Obejrzyj sztylet.*", 1)
             }),
             [1] = new DialoguePart("*Obejrzałeś dokładnie sztylet - jego powierzchnia jest dość mocno zarysowana. Przy jelcu znalazłeś czerwony-brązowy obiekt, który wygląda na skrzep krwi. To może być narzędzie zbrodni.*", new List <Response>())
         }),
         [7] = new Dialogue("Książka", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("*Na ziemi leży jakaś zakurzona książka.*", new List <Response>()
             {
                 new Response("*Obejrzyj książkę.*", 1)
             }),
             [1] = new DialoguePart("*Książka wygląda na starą. Okładka jest już dość zniszczona, a strony pożółkły. Tekst jednak zachował się dość dobrze. Wertując kolejne kartki znajdujesz dużo tajemniczych przepisów oraz inkantacji. W pewnym momencie zauważasz, że ktoś wyrwał kilka kartek. Jedyne, co po nich pozostało, to fragment tytułu - \"Eliksir pra\".*", new List <Response>())
         }),
         [8] = new Dialogue("Siekiera", new Dictionary <int, DialoguePart>
         {
             [0] = new DialoguePart("*Obok kominka leży siekiera. Wygląda na wysłużoną.*", new List <Response>()
             {
                 new Response("*Uważnie obejrzyj siekierę.*", 1)
             }),
             [1] = new DialoguePart("*Siekiera wygląda na nieco zużytą, jednak jej ostrze jest bardzo ostre, jakby nie było używane od jakiegoś czasu.*", new List <Response>())
         })
     };
 }
 /// <summary>
 /// Make the state normal when branch occurs
 /// </summary>
 /// <param name="branchOccursEventData"></param>
 private void OnBranchOcurrs(BranchOccursEventData branchOccursEventData)
 {
     stateBeforeBranch = State;
     State             = DialogueBoxState.Normal;
 }
 /// <summary>
 /// Start auto
 /// </summary>
 /// <remarks>
 /// This method should be called when the state is normal
 /// </remarks>
 private void BeginAuto()
 {
     Assert.AreEqual(State, DialogueBoxState.Normal, "DialogueBoxState State != DialogueBoxState.Normal");
     _state = DialogueBoxState.Auto;
     TrySchedule(GetAutoScheduledTime());
 }
 /// <summary>
 /// Stop all posible coroutine when game ends
 /// </summary>
 /// <param name="currentRouteEndedEventData"></param>
 private void OnCurrentRounteEnded(CurrentRouteEndedEventData currentRouteEndedEventData)
 {
     State = DialogueBoxState.Normal;
 }