예제 #1
0
    /**
     * Updates the visual information on the page pairing
     * to the information in the given quest
     */
    private void UpdateQuestInfo(PagePairing pair, Quest quest)
    {
        /* Get the left page */
        QuestsLeftPage leftPage = (QuestsLeftPage)pair.pageLeft;

        /* Update the quest name and quest description */
        leftPage.SetQuestInformation(quest.name, quest.description, quest.complete);

        /* Load the right page */
        QuestsRightPage rightPage = (QuestsRightPage)pair.pageRight;

        rightPage.ClearObjectives();

        /* Add completed objectives, and active objectives */
        foreach (Objective o in quest.GetCompletedObjectives())
        {
            rightPage.AddCompletedObjective(o.GetDescription());
        }

        /* Add the current objectives */
        foreach (Objective o in quest.GetObjectivesInProgress())
        {
            rightPage.AddObjective(o.GetDescription());
        }
    }
예제 #2
0
    private void CurrentFlipRight(List <PagePairing> nextList, int nextIndex)
    {
        /* Get the old pair */
        PagePairing oldPair = GetCurrentPair();

        /* Update the current stats */
        currentList  = nextList;
        currentIndex = nextIndex;

        /* Get this page pairing */
        PagePairing newPair = GetCurrentPair();

        /* Set the states of the pages */
        newPair.pageLeft.SetState(JournalPage.JournalPageState.CreatedFlippingToResting);
        newPair.pageRight.SetState(JournalPage.JournalPageState.CreatedResting);

        /* Flip the old right page */
        oldPair.pageRight.SetState(JournalPage.JournalPageState.RestToFlipped);

        /* Make the flipping sound */
        journal.PageSwipingSound();

        if (debug)
        {
            Debug.Log("PageManager: We are flipping right.");
        }
    }
예제 #3
0
    /**
     * Update the target that the book is flipping to.
     */
    private bool UpdateTarget(PagePairing pair)
    {
        foreach (List <PagePairing> list in masterList)
        {
            /* Does this list contain this page pair? */
            if (list.Contains(pair))
            {
                /* Set the target */
                targetList  = list;
                targetIndex = list.IndexOf(pair);

                if (debug)
                {
                    Debug.Log("PageManager: We found the target page pairing L" + masterList.IndexOf(targetList) + ":I" + targetIndex);
                }

                /* We found the page pairing */
                return(true);
            }
        }

        if (debug)
        {
            Debug.LogWarning("PageManager: We couldn't find the given page pairing!");
        }

        /* We didn't find this page pair */
        return(false);
    }
예제 #4
0
    /**
     * Open up to a specific page pair in the journal.
     */
    public bool OpenTo(PagePairing pair)
    {
        if (debug)
        {
            Debug.Log("PageManager: We are attempting to open this journal to: " + pair.id);
        }

        /* Update the target */
        return(UpdateTarget(pair));
    }
예제 #5
0
    private PagePairing CreateQuestPair(Quest quest)
    {
        /* Create the page pair */
        PagePairing pair = LoadPair("QuestLeftPage", "QuestRightPage", quest.quest_id);

        /* Update the information for this quest */
        UpdateQuestInfo(pair, quest);

        /* Return the pair */
        return(pair);
    }
예제 #6
0
    /**
     * Called when the journal starts opening.
     */
    public void JournalOpening(float journalLerp)
    {
        /* We always start at our target */
        currentList  = targetList;
        currentIndex = targetIndex;

        /* Get our current pair */
        PagePairing pair = GetCurrentPair();

        /* Uncull and set the state of the pair */
        pair.SetState(JournalPage.JournalPageState.OpeningWithJournal, journalLerp);
    }
예제 #7
0
    private PagePairing LoadPair(string leftPage, string rightPage, string id)
    {
        /* Create the page pairing */
        PagePairing pair = new PagePairing(LoadPage(leftPage), LoadPage(rightPage), id);

        /* Cull the pair */
        pair.CullPages();

        /* Update the pairing for the pages */
        pair.pageLeft.SetPagePairing(pair);
        pair.pageRight.SetPagePairing(pair);

        /* Return the new pair */
        return(pair);
    }
예제 #8
0
    /**
     * Open the player journal open to the given quest.
     */
    public bool OpenQuest(Quest quest)
    {
        if (debug)
        {
            Debug.Log("PageManager: We are opening the journal to a quest: " + quest.quest_id);
        }

        /* The page pairing we are hoping to find */
        PagePairing pair = null;

        /* Is this a quest in progress? */
        if ((pair = GetQuestPagePair(ipQuests, quest.quest_id)) != null)
        {
            /* Set our target */
            if (!UpdateTarget(pair, ipQuests, false))
            {
                Debug.LogError("PageManager: Failed to find target!");
                return(false);
            }

            /* We updated the target */
            return(true);
        }
        else if ((pair = GetQuestPagePair(cQuests, quest.quest_id)) != null)
        {
            /* Set our target */
            if (!UpdateTarget(pair, cQuests, false))
            {
                Debug.LogError("PageManager: Failed to find target!");
                return(false);
            }

            /* We updated the target */
            return(true);
        }

        if (debug)
        {
            Debug.LogWarning("PageManager: We failed to find the page pairing that is responsible for this quest.");
        }

        /* We didn't find this quest */
        return(false);
    }
예제 #9
0
    public PageManager(JournalManager journal, List <Quest> currentQuests, List <Quest> completedQuests)
    {
        /* Save the journal */
        this.journal = journal;

        /* Setup required lists */
        metaList = new List <PagePairing>();
        ipQuests = new List <PagePairing>();
        cQuests  = new List <PagePairing>();

        /* Setup the master list */
        masterList = new List <List <PagePairing> >();
        masterList.Add(metaList);
        masterList.Add(ipQuests);
        masterList.Add(cQuests);

        /* Setup the item inspector */
        itemInspector = LoadPair("ItemInspectorLeftPage", "ItemInspectorRightPage");
        /* Setup the players stats */
        playerStats = LoadPair("PlayerStatsLeftPage", "PlayerStatsRightPage");

        /* Add these pairings to the meta list */
        metaList.Add(itemInspector);
        metaList.Add(playerStats);

        /* Add all of the in progress quests */
        foreach (Quest q in currentQuests)
        {
            ipQuests.Add(CreateQuestPair(q));
        }

        /* Add all of the completed quests */
        foreach (Quest q in completedQuests)
        {
            cQuests.Add(CreateQuestPair(q));
        }

        /* We start out just looking at the player stats */
        currentList  = targetList = metaList;
        currentIndex = targetIndex = metaList.IndexOf(playerStats);
        /* We're ready to flip whenever */
        flipTimer = 0.0f;
    }
예제 #10
0
    /**
     * Update the target that the book should flip to. This is an optimization method
     * where you can supply a list in which to search for the page pairing. You can also
     * restrict the search to only this list. If restrict is set to false, if the search
     * fails then all lists will be searched.
     */
    private bool UpdateTarget(PagePairing pair, List <PagePairing> list, bool restrict)
    {
        /* Does this list contain the pair? */
        if (list.Contains(pair))
        {
            /* Set the target */
            targetList  = list;
            targetIndex = list.IndexOf(pair);

            if (debug)
            {
                Debug.Log("PageManager: We found the target page pairing L" + masterList.IndexOf(targetList) + ":I" + targetIndex);
            }

            /* Target has been set */
            return(true);
        }

        if (debug)
        {
            Debug.LogWarning("PageManager: Failed to find page pairing in list!");
        }

        /* We failed to find the page pairing in the given list */
        if (restrict)
        {
            return(false);
        }

        if (debug)
        {
            Debug.Log("PageManager: We are doing a master search.");
        }

        /* Try searching through all of the lists */
        return(UpdateTarget(pair));
    }