예제 #1
0
    private void OnQuestRewardClaimed(Quest quest)
    {
        RemoveQuest(quest);

        //TEMP, START A NEW QUEST
        QuestDefinition firstQuestDefinition = m_QuestListDefinition.GetQuestDefinition(1);

        quest = new Quest(m_QuestListDefinition, firstQuestDefinition, GameClock.Instance.GetDateTime(), firstQuestDefinition.CalculateDeadline(), m_Inventory);
        quest.QuestCompleteEvent += OnQuestCompleted;
        quest.QuestRemovedEvent  += OnQuestRewardClaimed;

        AddQuest(quest);
    }
예제 #2
0
    public void Deserialize(JSONClass questNode)
    {
        //Quest ID
        int id = (questNode["quest_id"].AsInt);

        m_QuestDefinition = m_QuestListDefinition.GetQuestDefinition(id);

        //Start Time
        JSONNode startTimeNode = questNode["start_time"];

        if (startTimeNode != null)
        {
            try
            {
                m_StartTime = DateTime.ParseExact(startTimeNode.Value, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            }
            catch (Exception e)
            {
                throw new System.Exception("The quest save file has an invalid \"start_time\" node! Expected DateTime. Source: " + startTimeNode.ToString() + " Exception: " + e.Message);
            }
        }

        //Deadline
        JSONNode endTimeNode = questNode["end_time"];

        if (endTimeNode != null)
        {
            try
            {
                m_EndTime = DateTime.ParseExact(endTimeNode.Value, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            }
            catch (Exception e)
            {
                throw new System.Exception("The quest save file has an invalid \"end_time\" node! Expected DateTime. Source: " + endTimeNode.ToString() + " Exception: " + e.Message);
            }
        }

        //Selected picture
        JSONClass pictureNode = questNode["selected_picture"].AsObject;

        if (pictureNode != null)
        {
            Picture picture = new Picture();
            bool    success = picture.Deserialize(pictureNode);

            if (success)
            {
                m_SelectedPicture = picture;
            }
        }
    }