Exemplo n.º 1
0
 public void PrepareForQuestion(IOptionsListener newQuestionDelegate, int newOptionsToAllocate)
 {
     if ((newQuestionDelegate != null) && (newOptionsToAllocate > 0))
     {
         questionDelegate  = newQuestionDelegate;
         optionsToAllocate = newOptionsToAllocate;
     }
 }
Exemplo n.º 2
0
 public void PrepareForQuestion(IOptionsListener newQuestionDelegate)
 {
     if (newQuestionDelegate != null)
     {
         questionDelegate   = newQuestionDelegate;
         optionAwaitedIndex = 0;
     }
 }
Exemplo n.º 3
0
 private void RemoveQuestionPreparation()
 {
     questionDelegate       = null;
     enunciateBoxComponent  = null;
     optionAwaitedIndex     = -1;
     optionChosenIndex      = -1;
     optionIndexConfirm     = -1;
     optionIndexCancel      = -1;
     optionComponentConfirm = null;
     optionComponentCancel  = null;
 }
Exemplo n.º 4
0
    private TextBoxManager()
    {
        textBoxParent      = null;
        boxObjects         = null;
        boxComponents      = null;
        boxMasterEvents    = null;
        boxQuestionRoles   = null;
        boxOptionIndexes   = null;
        boxSpeakerIDs      = null;
        boxTryAboves       = null;
        boxTailObjects     = null;
        boxTailRenderers   = null;
        symbolDatabase     = null;
        boxDatabase        = null;
        boxAppearanceIndex = -1;
        bodySpriteSystem   = null;
        bodySpriteDialogue = null;
        tailSpriteDialogue = null;
        tailWidth          = 0f;
        tailHeight         = 0f;
        tailHalfWidth      = 0f;
        tailHalfHeight     = 0f;
        stage                  = null;
        cameraObject           = null;
        cameraController       = null;
        cameraWidth            = 0f;
        cameraHeight           = 0f;
        cameraHalfWidth        = 0f;
        cameraHalfHeight       = 0f;
        cameraPixelWidth       = 0;
        cameraPixelHeight      = 0;
        boxDepth               = DisplayDepthManager.GetElementDepth(DisplayDepthManager.ELEMENT_CODE_TEXT);
        systemBoxLimits        = new Vector2(TextBox.DEFAULT_MAX_BOX_WIDTH, TextBox.DEFAULT_MAX_BOX_HEIGHT);
        systemBoxTopOffset     = 0f;
        dialogueBoxLimits      = new Vector2(DialogueBox.DEFAULT_MAX_D_BOX_WIDTH, DialogueBox.DEFAULT_MAX_D_BOX_HEIGHT);
        questionDelegate       = null;
        enunciateBoxTopOffset  = 0f;
        enunciateBoxComponent  = null;
        optionsToAllocate      = 0;
        optionAreaHeight       = 0f;
        optionHalfAreaHeight   = 0f;
        optionBoxTopOffset     = 0f;
        optionAwaitedIndex     = -1;
        optionChosenIndex      = -1;
        optionIndexConfirm     = -1;
        optionIndexCancel      = -1;
        optionComponentConfirm = null;
        optionComponentCancel  = null;
        paused                 = false;

        textBoxParent = new GameObject("TextBoxParent");
        textBoxParent.transform.position = new Vector3(0f, 0f, boxDepth);
    }
Exemplo n.º 5
0
 private TextBoxUIManager()
 {
     boxObjects             = null;
     boxComponents          = null;
     boxMasterEvents        = null;
     boxMasterItems         = null;
     boxQuestionRoles       = null;
     boxOptionIndexes       = null;
     symbolDatabase         = null;
     boxDatabase            = null;
     boxAppearanceIndex     = -1;
     bodySprite             = null;
     uiCanvasTrans          = null;
     questionDelegate       = null;
     enunciateBoxComponent  = null;
     optionAwaitedIndex     = -1;
     optionChosenIndex      = -1;
     optionIndexConfirm     = -1;
     optionIndexCancel      = -1;
     optionComponentConfirm = null;
     optionComponentCancel  = null;
     itemOnDisplay          = false;
 }
Exemplo n.º 6
0
    private void RemoveDialogue(int dialogueIndex, bool affectOptions)
    {
        GameObject       boxTailObject         = null;
        TextBox          boxComponent          = null;
        GameObject       boxObject             = null;
        EventDialogue    boxMasterEvent        = null;
        QuestionRole     boxQuestionRole       = QuestionRole.None;
        IOptionsListener savedQuestionDelegate = null;
        int savedOptionIndex = -1;

        if (boxObjects != null)
        {
            if ((dialogueIndex > -1) && (dialogueIndex < boxObjects.Length))
            {
                /*halmeida - relying on the coherence of all box related arrays.*/
                boxTailObject = boxTailObjects[dialogueIndex];
                if (boxTailObject != null)
                {
                    GameObject.Destroy(boxTailObject);
                    boxTailObjects[dialogueIndex] = null;
                }
                boxComponent = boxComponents[dialogueIndex];
                if (boxComponent != null)
                {
                    boxComponent.Clear();
                    boxComponents[dialogueIndex] = null;
                }
                boxObject = boxObjects[dialogueIndex];
                if (boxObject != null)
                {
                    GameObject.Destroy(boxObject);
                    boxObjects[dialogueIndex] = null;
                }
                boxMasterEvent = boxMasterEvents[dialogueIndex];
                if (boxMasterEvent != null)
                {
                    boxMasterEvent.ReactToDialogueEnd();
                    boxMasterEvents[dialogueIndex] = null;
                }
                boxQuestionRole = boxQuestionRoles[dialogueIndex];
                UsefulFunctions.DecreaseArray <SpriteRenderer>(ref boxTailRenderers, dialogueIndex);
                UsefulFunctions.DecreaseArray <GameObject>(ref boxTailObjects, dialogueIndex);
                UsefulFunctions.DecreaseArray <bool>(ref boxTryAboves, dialogueIndex);
                UsefulFunctions.DecreaseArray <int>(ref boxSpeakerIDs, dialogueIndex);
                UsefulFunctions.DecreaseArray <int>(ref boxOptionIndexes, dialogueIndex);
                UsefulFunctions.DecreaseArray <QuestionRole>(ref boxQuestionRoles, dialogueIndex);
                UsefulFunctions.DecreaseArray <EventDialogue>(ref boxMasterEvents, dialogueIndex);
                UsefulFunctions.DecreaseArray <TextBox>(ref boxComponents, dialogueIndex);
                UsefulFunctions.DecreaseArray <GameObject>(ref boxObjects, dialogueIndex);
                if ((boxQuestionRole == QuestionRole.Option) && (questionDelegate != null) && affectOptions)
                {
                    CloseQuestion();
                }
                else if (boxQuestionRole == QuestionRole.Enunciate)
                {
                    /*halmeida - send choice to questionDelegate, reset variables to allow preparation for other questions.*/

                    /*halmeida - we need to immediately remove the remaining options, because if a new question is loaded
                     * now, as we send the chosen index, and any remaining options of this closed question happen to be removed after
                     * that, the closure of the old option will trigger the closure of the new question entirely, before the player is
                     * given the chance of choosing anything or even the chance of seeing the new question.*/
                    RemoveRemainingOptions();

                    /*halmeida - when we send the choice, the questionDelegate may immediately start a new question, assigning
                     * itself or another questionDelegate to this TextBoxManager in the process. If we remove the question prep
                     * after sending the choice, we may be losing this new question's preparation. That's why we need to send
                     * the chosen choice only after the removal of the preparation of the current question, not before. To do
                     * that we need to save the values first.*/
                    savedQuestionDelegate = questionDelegate;
                    savedOptionIndex      = optionChosenIndex;
                    RemoveQuestionPreparation();
                    if (savedQuestionDelegate != null)
                    {
                        savedQuestionDelegate.ChooseOption(savedOptionIndex);
                    }
                }
            }
        }
    }
Exemplo n.º 7
0
    private void RemoveDialogue(int dialogueIndex, bool affectOptions)
    {
        TextBoxUI        boxComponent          = null;
        GameObject       boxObject             = null;
        EventDialogue    boxMasterEvent        = null;
        QuestionRole     boxQuestionRole       = QuestionRole.None;
        IOptionsListener savedQuestionDelegate = null;
        int  savedOptionIndex  = -1;
        bool lastOptionToClose = false;

        if (boxObjects != null)
        {
            if ((dialogueIndex > -1) && (dialogueIndex < boxObjects.Length))
            {
                /*halmeida - relying on the coherence of all box related arrays.*/
                boxComponent = boxComponents[dialogueIndex];
                if (boxComponent != null)
                {
                    boxComponent.Clear();
                    boxComponents[dialogueIndex] = null;
                }
                boxObject = boxObjects[dialogueIndex];
                if (boxObject != null)
                {
                    GameObject.Destroy(boxObject);
                    boxObjects[dialogueIndex] = null;
                }
                boxMasterEvent = boxMasterEvents[dialogueIndex];
                if (boxMasterEvent != null)
                {
                    boxMasterEvent.ReactToDialogueEnd();
                    boxMasterEvents[dialogueIndex] = null;
                }
                boxMasterItems[dialogueIndex] = null;
                boxQuestionRole = boxQuestionRoles[dialogueIndex];
                UsefulFunctions.DecreaseArray <int>(ref boxOptionIndexes, dialogueIndex);
                UsefulFunctions.DecreaseArray <QuestionRole>(ref boxQuestionRoles, dialogueIndex);
                UsefulFunctions.DecreaseArray <EventDialogue>(ref boxMasterEvents, dialogueIndex);
                UsefulFunctions.DecreaseArray <ItemData>(ref boxMasterItems, dialogueIndex);
                UsefulFunctions.DecreaseArray <TextBoxUI>(ref boxComponents, dialogueIndex);
                UsefulFunctions.DecreaseArray <GameObject>(ref boxObjects, dialogueIndex);
                /*halmeida - if there are no more items associated with dialogues, we update the related variable.*/
                itemOnDisplay = (boxMasterItems == null) ? false : itemOnDisplay;
                if (itemOnDisplay)
                {
                    itemOnDisplay = false;
                    for (int i = 0; i < boxMasterItems.Length; i++)
                    {
                        if (boxMasterItems[i] != null)
                        {
                            itemOnDisplay = true;
                            break;
                        }
                    }
                }

                /*halmeida - the chosen option closes before the others, as a visual feedback to the player as to
                 * which option did he choose. If there was more than one available choice, we start closing them when
                 * the closure of the chosen one ends. We only send the chosen index to the delegate by the time all
                 * options have finished closing.*/
                if ((boxQuestionRole == QuestionRole.Option) && (questionDelegate != null))
                {
                    /*halmeida - since we don't really require an enunciate, I can't use the end of the closure of the
                     * enunciate as the trigger to send the chosen option and prepare for another question. I will use the
                     * end of the closure of the last option as this trigger.*/
                    lastOptionToClose = (boxQuestionRoles == null);
                    if (!lastOptionToClose)
                    {
                        lastOptionToClose = true;
                        for (int i = 0; i < boxQuestionRoles.Length; i++)
                        {
                            if (boxQuestionRoles[i] == QuestionRole.Option)
                            {
                                lastOptionToClose = false;
                            }
                        }
                    }
                    if (lastOptionToClose)
                    {
                        /*halmeida - send choice to questionDelegate, reset variables to allow preparation for other questions.*/

                        /*halmeida - when we send the choice, the questionDelegate may immediately start a new question, assigning
                         * itself or another questionDelegate to this TextBoxManager in the process. If we remove the question prep
                         * after sending the choice, we may be losing this new question's preparation. That's why we need to send
                         * the chosen choice only after the removal of the preparation of the current question, not before. To do
                         * that we need to save the values first.*/
                        savedQuestionDelegate = questionDelegate;
                        savedOptionIndex      = optionChosenIndex;
                        RemoveQuestionPreparation();
                        if (savedQuestionDelegate != null)
                        {
                            savedQuestionDelegate.ChooseOption(savedOptionIndex);
                        }
                    }
                    else
                    {
                        if (affectOptions)
                        {
                            CloseQuestion();
                        }
                    }
                }
            }
        }
    }