示例#1
0
    private void MakeChoiceWithEffect(ChoiceEffect choiceEffect)
    {
        playerInventory.AddChoiceEffect(choiceEffect);
        UpdateInventoryDisplay();

        if (playerInventory.Love <= 0)
        {
            GameOverWithEnding("Love");
        }
        else if (playerInventory.Hope <= 0)
        {
            GameOverWithEnding("Hope");
        }
        else if (playerInventory.Joy <= 0)
        {
            GameOverWithEnding("Joy");
        }
        else if (playerInventory.Parts <= 0)
        {
            GameOverWithEnding("Parts");
        }
        else if (playerInventory.Appearances <= 0)
        {
            GameOverWithEnding("Appearances");
        }
        else
        {
            ShowNextQuandary();
        }
    }
示例#2
0
    protected virtual bool CheckOptionsHit(Vector2 canvasPoint)
    {
        RectTransform  optionTransform = null;
        ButtonAnimator optionComponent = null;
        float          realWidth       = 0f;
        float          realHeight      = 0f;
        float          xMin            = 0f;
        float          yMax            = 0f;

        if (optionTransforms != null)
        {
            for (int i = 0; i < optionTransforms.Length; i++)
            {
                optionTransform = optionTransforms[i];
                realWidth       = optionTransform.rect.width * optionTransform.localScale.x;
                realHeight      = optionTransform.rect.height * optionTransform.localScale.y;
                xMin            = optionTransform.anchoredPosition.x - realWidth / 2f;
                yMax            = optionTransform.anchoredPosition.y + realHeight / 2f;
                if (optionsParentTransform != null)
                {
                    xMin += optionsParentTransform.anchoredPosition.x;
                    yMax += optionsParentTransform.anchoredPosition.y;
                }
                if (UsefulFunctions.AreaContainsPoint(xMin, yMax, realWidth, realHeight, canvasPoint.x, canvasPoint.y))
                {
                    selectedOptionComponent = null;
                    if (optionComponents != null)
                    {
                        if (optionComponents.Length > i)
                        {
                            optionComponent = optionComponents[i];
                            if (optionComponent != null)
                            {
                                selectedOptionComponent = optionComponent;
                                selectedOptionComponent.SetPressed(true);
                            }
                        }
                    }
                    selectedChoiceEffect = ChoiceEffect.None;
                    if (optionEffects != null)
                    {
                        if (optionEffects.Length > i)
                        {
                            selectedChoiceEffect = optionEffects[i];
                        }
                    }
                    return(true);
                }
            }
        }
        return(false);
    }
示例#3
0
 public virtual bool ReactToQuitRequest(bool ignoreQuitAvailability)
 {
     if (!ignoreQuitAvailability)
     {
         if (quitComponent != null)
         {
             selectedQuitComponent = quitComponent;
             selectedQuitComponent.SetPressed(true);
         }
         else
         {
             return(false);
         }
     }
     selectedChoiceEffect = ChoiceEffect.CloseMenu;
     return(true);
 }
示例#4
0
    private void Awake()
    {
        gsm = GetComponent(typeof(GameStateManager)) as GameStateManager;

        prompts      = textFilePrompts.text.Split('\n');
        effectsArray = new ChoiceEffect[prompts.Length * 3];

        choices = new string[prompts.Length][];
        string[] choiceLines = textFileChoices.text.Split('\n');
        for (int i = 0; i < choiceLines.Length; i++)
        {
            choices[i] = choiceLines[i].Split('|');
        }

        string[] effectSplit = textFileEffects.text.Split(';');

        for (int i = 0; i < prompts.Length * 3; i++)
        {
            string[]     pairSplit = effectSplit[i].Split(',');
            ChoiceEffect newEffect = new ChoiceEffect(int.Parse(pairSplit[0]), int.Parse(pairSplit[1]));
            effectsArray[i] = newEffect;
        }
    }
    void initializeTestingEnvironment()
    {
        Character testCharacter = new Character();

        testCharacter.setName(this.testCharacterName);

        Character narratorCharacter = new Character();

        narratorCharacter.setName(string.Empty);

        Day testDay = new Day();

        testDay.setStartingNode(10);

        DialogueDictionary testDialogue = new DialogueDictionary();
        ChoiceDictionary   testChoice   = new ChoiceDictionary();
        BranchDictionary   testBranch   = new BranchDictionary();

        //// list of dialogues nodes////
        DialoguePreAction preAction0 = new DialoguePreAction();

        preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int> (DialoguePreAction.ACTION.FADE_IN, -1));
        preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int> (DialoguePreAction.ACTION.SHOW_DIALOGUE_BAR, 0));
        preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int> (DialoguePreAction.ACTION.PLAY_SFX, (int)SoundManagerScript.SFX_TYPE.PLANE_SFX));
        preAction0.addNewPreAction(new KeyValuePair <DialoguePreAction.ACTION, int>(DialoguePreAction.ACTION.PLAY_BGM, (int)SoundManagerScript.BGM_TYPE.BGM_WHATEVER));

        List <string> dialogue0List = new List <string> {
            "> Airport, Food Court.",
            "> You've finished checking in and have your boarding pass with you.",
            "> You are now waiting for Graham to come."
        };

        Dialogue dialogue0 = new Dialogue();

        dialogue0.setListOfDialogues(dialogue0List);
        dialogue0.setPreAction(preAction0);
        dialogue0.setCharacter(narratorCharacter);

        dialogue0.setNextNodeID(0);

        List <string> dialogue1List = new List <string> {
            "Hmm... I still can't believe that he is really going to come see me off...",
            "I mean, it's not a bad thing.",
        };

        Dialogue dialogue1 = new Dialogue();

        dialogue1.setListOfDialogues(dialogue1List);

        ConditionalNextNode nextNode1 = new ConditionalNextNode();

        nextNode1.setConditional(false);
        nextNode1.setDefaultNextNode(1);

        dialogue1.setCharacter(testCharacter);

        dialogue1.setNextNodeID(1);

        List <string> dialogue2List = new List <string> {
            "uuu... I am nervous...",
            "I hope this time around it will be better than our last date...",
            "Does he even actually consider it a date? Or is he just being friendly and offer to help me find the figurine that I want..",
            "Am I getting ahead of myself? is it just me that think he is interested in me?"
        };

        Dialogue dialogue2 = new Dialogue();

        dialogue2.setListOfDialogues(dialogue2List);

        dialogue2.setCharacter(testCharacter);
        dialogue2.setNextNodeID(2);

        List <string> dialogue3List = new List <string> {
            "What if he think I am weird after that outing.",
            "He did say he enjoy our time together though...",
            "But, what if he was just being kind... What if he actually think otherwise!?",
            "Shio... Why did you even decide to get a kid's seat for lunch!",
            "Stupid! STUPID!",
            "...",
            "Huh?",
            "Oh no! He's already here!?",
            "What should I tell him..."
        };

        Dialogue dialogue3 = new Dialogue();

        dialogue3.setListOfDialogues(dialogue3List);

        ConditionalNextNode nextNode3 = new ConditionalNextNode();

        nextNode3.setConditional(false);

        dialogue3.setCharacter(testCharacter);
        dialogue3.setNextNodeID(5);

        Choice choice1 = new Choice();

        ChoiceEffect c10 = new ChoiceEffect(3, 0);
        ChoiceEffect c20 = new ChoiceEffect(4, 0);
        KeyValuePair <string, ChoiceEffect> c1 = new KeyValuePair <string, ChoiceEffect> ("Don't answer immediately", c10);
        KeyValuePair <string, ChoiceEffect> c2 = new KeyValuePair <string, ChoiceEffect> ("Tell him where you currently are", c20);

        List <KeyValuePair <string, ChoiceEffect> > listOfChoices1 = new List <KeyValuePair <string, ChoiceEffect> > {
            c1, c2
        };

        choice1.populateChoices(listOfChoices1);


        List <string> dialogue4List = new List <string> {
            "Calm down... Calm Down...",
            "Now, where were we?"
        };

        Dialogue dialogue4 = new Dialogue();

        dialogue4.setListOfDialogues(dialogue4List);

        ConditionalNextNode nextNode4 = new ConditionalNextNode();


        dialogue4.setCharacter(testCharacter);
        dialogue4.setNextNodeID(5);

        List <string> dialogue5List = new List <string> {
            "Hummm... I hope I look okay...",
            "But... He does like to wear fancy stuff.",
            "No matter what I do, I'll probably look like a plebian next to him."
        };

        Dialogue dialogue5 = new Dialogue();

        dialogue5.setListOfDialogues(dialogue5List);


        dialogue5.setCharacter(testCharacter);
        dialogue5.setNextNodeID(-1);

        testDialogue.Add(10, dialogue0);
        testDialogue.Add(0, dialogue1);
        testDialogue.Add(1, dialogue2);
        testDialogue.Add(2, dialogue3);
        testDialogue.Add(3, dialogue4);
        testDialogue.Add(4, dialogue5);

        testChoice.Add(5, choice1);
        testDay.populateConversationnodes(testDialogue);
        testDay.populateBranchNodes(testBranch);
        testDay.populateChoiceNodes(testChoice);

        this.currentDay   = testDay;
        this.currentDayID = 0;

        this.player.yourProgression.setCurrentDay(this.currentDayID);
    }
 void resolveChoiceEffect(ChoiceEffect selectedChoiceEffect)
 {
     this.player.yourProgression.addAffectionLevel(selectedChoiceEffect.getAffectionPointEarned());
     currentNode = (Node)currentDay.getNextNode(selectedChoiceEffect.getDestinationNodeID());
     displayNode();
 }
示例#7
0
 public void setNewChoiceEffect(ChoiceEffect newEffect)
 {
     this.cEffect = newEffect;
 }
示例#8
0
    private IEnumerator Wait(float time, ChoiceEffect effect)
    {
        yield return(new WaitForSeconds(time));

        MakeChoiceWithEffect(CurrentCharacterModel.GiveEffect);
    }
示例#9
0
    protected virtual void Awake()
    {
        GameObject     optionModel          = null;
        RectTransform  optionTrans          = null;
        ButtonAnimator optionComponent      = null;
        ChoiceEffect   optionChoiceEffect   = ChoiceEffect.None;
        GameObject     optionEventObject    = null;
        EventBase      optionEventComponent = null;
        int            optionEventID        = EventBase.INVALID_EVENT_ID;
        Vector2        optionScale          = Vector2.one;

        gameController                  = null;
        font                            = null;
        interfaceCanvasObject           = null;
        interfaceCanvasTrans            = null;
        interfaceCanvasComponent        = null;
        interfaceCanvasRect             = new Rect(0f, 0f, 0f, 0f);
        interfaceCanvasScreenRect       = new Rect(0f, 0f, 0f, 0f);
        imageOverlayModel               = null;
        imageOverlayObject              = null;
        imageOverlayComponent           = null;
        titleObject                     = null;
        titleTransform                  = null;
        titleComponent                  = null;
        titleTextObject                 = null;
        titleText                       = null;
        quitObject                      = null;
        quitTransform                   = null;
        quitComponent                   = null;
        quitTextObject                  = null;
        quitText                        = null;
        allowQuitOption                 = true;
        optionsParent                   = null;
        optionsParentTransform          = null;
        totalValidModels                = 0;
        totalValidOptionModels          = null;
        totalValidOptionScales          = null;
        totalValidOptionChoiceEffects   = null;
        totalValidOptionEventIDs        = null;
        currentValidModels              = 0;
        currentValidOptionModels        = null;
        currentValidOptionScales        = null;
        currentValidOptionChoiceEffects = null;
        currentValidOptionEventIDs      = null;
        optionObjects                   = null;
        optionTransforms                = null;
        optionComponents                = null;
        optionEffects                   = null;
        optionTextObjects               = null;
        optionTexts                     = null;
        selectedChoiceEffect            = ChoiceEffect.None;
        selectedQuitComponent           = null;
        selectedOptionComponent         = null;
        overlayFadeSpeed                = 0f;
        overlayFadeSpeedRef             = (backgroundAlphaSpeed > 0f) ? backgroundAlphaSpeed : 1f;
        overlayMaxAlpha                 = backgroundMaxAlpha;
        overlayDark                     = false;
        overlayClear                    = false;
        graphicsReady                   = false;
        graphicsCleared                 = false;
        touchingOverlay                 = false;
        draggingMenu                    = false;
        lastDragCanvasX                 = 0f;
        lastDragCanvasY                 = 0f;
        highestOptionTopY               = 0f;
        hiddenOptionHeight              = 0f;
        maxScreenOffsetLeft             = 0f;
        maxScreenOffsetRight            = 0f;
        maxScreenOffsetUp               = 0f;
        maxScreenOffsetDown             = 0f;
        requiringProgress               = false;
        clearBeforeEffect               = true;
        eventManager                    = null;
        previousMenu                    = null;
        if (optionModels != null)
        {
            for (int i = 0; i < optionModels.Length; i++)
            {
                optionModel = optionModels[i];
                if (optionModel != null)
                {
                    optionTrans     = optionModel.GetComponent <RectTransform>();
                    optionComponent = optionModel.GetComponent <ButtonAnimator>();
                    if ((optionTrans != null) && (optionComponent != null))
                    {
                        optionScale        = Vector2.one;
                        optionChoiceEffect = ChoiceEffect.None;
                        optionEventID      = EventBase.INVALID_EVENT_ID;
                        if (optionButtonScales != null)
                        {
                            if (optionButtonScales.Length > i)
                            {
                                optionScale = optionButtonScales[i];
                            }
                        }
                        if (optionChoiceEffects != null)
                        {
                            if (optionChoiceEffects.Length > i)
                            {
                                optionChoiceEffect = optionChoiceEffects[i];
                            }
                        }
                        if (optionEventRequirements != null)
                        {
                            if (optionEventRequirements.Length > i)
                            {
                                optionEventObject = optionEventRequirements[i];
                                if (optionEventObject != null)
                                {
                                    optionEventComponent = optionEventObject.GetComponent <EventBase>();
                                    if (optionEventComponent != null)
                                    {
                                        optionEventID = optionEventComponent.eventID;
                                    }
                                }
                            }
                        }
                        totalValidModels++;
                        UsefulFunctions.IncreaseArray <GameObject>(ref totalValidOptionModels, optionModel);
                        UsefulFunctions.IncreaseArray <Vector2>(ref totalValidOptionScales, optionScale);
                        UsefulFunctions.IncreaseArray <ChoiceEffect>(ref totalValidOptionChoiceEffects, optionChoiceEffect);
                        UsefulFunctions.IncreaseArray <int>(ref totalValidOptionEventIDs, optionEventID);
                    }
                }
            }
        }
    }
示例#10
0
 public void ClearVisualRepresentation(bool immediately)
 {
     if (!graphicsCleared)
     {
         if (overlayDark || immediately)
         {
             if (titleText != null)
             {
                 titleText.Clear();
                 titleText = null;
             }
             if (titleTextObject != null)
             {
                 Destroy(titleTextObject);
                 titleTextObject = null;
             }
             if (titleComponent != null)
             {
                 titleComponent.Clear();
                 titleComponent = null;
             }
             titleTransform = null;
             if (titleObject != null)
             {
                 Destroy(titleObject);
                 titleObject = null;
             }
             selectedQuitComponent = null;
             if (quitText != null)
             {
                 quitText.Clear();
                 quitText = null;
             }
             if (quitTextObject != null)
             {
                 Destroy(quitTextObject);
                 quitTextObject = null;
             }
             if (quitComponent != null)
             {
                 quitComponent.Clear();
                 quitComponent = null;
             }
             quitTransform = null;
             if (quitObject != null)
             {
                 Destroy(quitObject);
                 quitObject = null;
             }
             ClearOptions();
             if (optionsParent != null)
             {
                 optionsParentTransform = null;
                 Destroy(optionsParent);
                 optionsParent = null;
             }
             if (!immediately && (imageOverlayComponent != null))
             {
                 overlayFadeSpeed = -overlayFadeSpeedRef;
             }
             else
             {
                 overlayDark  = false;
                 overlayClear = true;
             }
         }
         if (overlayClear)
         {
             if (imageOverlayObject != null)
             {
                 imageOverlayComponent = null;
                 Destroy(imageOverlayObject);
                 imageOverlayObject = null;
             }
             graphicsCleared = true;
             if (immediately)
             {
                 requiringProgress    = false;
                 selectedChoiceEffect = ChoiceEffect.None;
             }
         }
     }
 }
示例#11
0
    public virtual void Progress(float timeStep)
    {
        bool clearMenu = false;

        ProgressOverlay(timeStep);
        if (titleComponent != null)
        {
            titleComponent.Progress(timeStep);
        }
        if (quitComponent != null)
        {
            quitComponent.Progress(timeStep);
        }
        if (!graphicsReady)
        {
            if (overlayDark)
            {
                BuildVisualRepresentation();
            }
        }
        else
        {
            if (!graphicsCleared)
            {
                ProgressOptionComponents(timeStep);
                if (selectedChoiceEffect != ChoiceEffect.None)
                {
                    clearMenu = true;
                    if (selectedQuitComponent != null)
                    {
                        if (selectedQuitComponent.GetCurrentStatus() != ButtonAnimator.STATUS_ACTIVATED)
                        {
                            clearMenu = false;
                        }
                    }
                    if (selectedOptionComponent != null)
                    {
                        if (selectedOptionComponent.GetCurrentStatus() != ButtonAnimator.STATUS_ACTIVATED)
                        {
                            clearMenu = false;
                        }
                    }
                    if (clearMenu)
                    {
                        if (!clearBeforeEffect)
                        {
                            PerformChoiceEffect();
                            selectedChoiceEffect = ChoiceEffect.None;

                            /*halmeida - in this case the menu will not clear its visual representation by itself.
                             * It will be waiting for a call to ClearVisualRepresentation to start the process. We can
                             * call this a manual closure.*/
                        }
                        else
                        {
                            ClearVisualRepresentation(false);

                            /*halmeida - in this case the menu will clear its visual representation before passing
                             * on the choice that was made. Since the selection effect value is not yet lost, this
                             * instruction will be called again at every Process() call, until the graphics are actually
                             * cleared and the choice effect is performed.*/
                        }
                    }
                }
                else if (overlayClear)
                {
                    /*halmeida - this is needed for the manual closure process. The outside call to clear the visual
                     * representation removes the options and starts the overlay fading into clear. To trully complete
                     * the closure we gotta remove the overlay, and this is done by calling the clearing function with
                     * the overlay already at a clear color.*/
                    ClearVisualRepresentation(false);
                }
            }
            else
            {
                requiringProgress = false;
                if ((selectedChoiceEffect != ChoiceEffect.None) && clearBeforeEffect)
                {
                    PerformChoiceEffect();
                    selectedChoiceEffect = ChoiceEffect.None;
                }
            }
        }
    }
示例#12
0
    protected virtual void BuildOptions()
    {
        if ((interfaceCanvasComponent == null) || (optionsParentTransform == null))
        {
            return;
        }
        SeparateCurrentlyValidOptions();
        if ((currentValidOptionModels == null) || (currentValidOptionChoiceEffects == null))
        {
            return;
        }
        optionObjects     = new GameObject[currentValidModels];
        optionTransforms  = new RectTransform[currentValidModels];
        optionComponents  = new ButtonAnimator[currentValidModels];
        optionEffects     = new ChoiceEffect[currentValidModels];
        optionTextObjects = new GameObject[currentValidModels];
        optionTexts       = new SpritedStringUI[currentValidModels];
        GameObject      optionModel         = null;
        GameObject      newOptionObject     = null;
        RectTransform   newOptionTrans      = null;
        ButtonAnimator  newOptionComponent  = null;
        Vector2         newOptionScale      = Vector2.one;
        ChoiceEffect    newOptionEffect     = ChoiceEffect.None;
        GameObject      newOptionTextObject = null;
        RectTransform   toDiscard           = null;
        SpritedStringUI newOptionText       = null;
        /*halmeida - discover the canvas X coordinate where all options should be placed.*/
        float newAnchoredX = (optionCenterXRate - 0.5f) * interfaceCanvasRect.width;

        /*halmeida - discover the canvas Y coordinate where the top of the first option should be placed.*/
        highestOptionTopY = (highestOptionTopRate - 0.5f) * interfaceCanvasRect.height;
        float newAnchoredY = highestOptionTopY;
        /*halmeida - discover the vertical distance from one option to the next.*/
        float            optionDistance   = optionDistanceRate * interfaceCanvasRect.height;
        float            halfOptionHeight = 0f;
        GameTextDatabase gameTextDatabase = GameTextDatabase.Instance;
        string           buttonCaption    = null;

        for (int i = 0; i < currentValidModels; i++)
        {
            optionModel        = currentValidOptionModels[i];
            newOptionObject    = Instantiate(optionModel) as GameObject;
            newOptionTrans     = newOptionObject.GetComponent <RectTransform>();
            newOptionComponent = newOptionObject.GetComponent <ButtonAnimator>();
            newOptionScale     = currentValidOptionScales[i];
            newOptionEffect    = currentValidOptionChoiceEffects[i];
            newOptionTrans.SetParent(optionsParentTransform, false);
            newOptionTrans.localScale = new Vector3(newOptionScale.x, newOptionScale.y, 1f);
            halfOptionHeight          = (newOptionTrans.rect.height / 2f) * newOptionScale.y;
            newAnchoredY -= halfOptionHeight;
            newOptionTrans.anchoredPosition = new Vector2(newAnchoredX, newAnchoredY);
            newAnchoredY       -= halfOptionHeight + optionDistance;
            newOptionTextObject = null;
            newOptionText       = null;
            if (useOptionEffectAsText && (gameTextDatabase != null))
            {
                buttonCaption = gameTextDatabase.GetMenuOptionText(newOptionEffect);
                CreateButtonText(newOptionTrans, buttonCaption, ref newOptionTextObject, ref toDiscard, ref newOptionText, false);
            }
            optionObjects[i]     = newOptionObject;
            optionTransforms[i]  = newOptionTrans;
            optionComponents[i]  = newOptionComponent;
            optionEffects[i]     = newOptionEffect;
            optionTextObjects[i] = newOptionTextObject;
            optionTexts[i]       = newOptionText;
        }
        hiddenOptionHeight = 0f;
        if (newAnchoredY < -interfaceCanvasRect.height / 2f)
        {
            hiddenOptionHeight = -newAnchoredY - interfaceCanvasRect.height / 2f;
        }
    }