private void InitializeViewModel(QuestStage stage)
        {
            WeaponRewards = new List <WeaponStatsViewModel>();
            ArmorRewards  = new List <ArmorStatsViewModel>();
            QuestRewards  = new List <QuestRewardViewModel>();
            NextStages    = new List <QuestStageDetailsViewModel>();
            QuestID       = stage.QuestID;
            Stage         = stage.Stage;
            Description   = stage.Description;

            WeaponRewards.AddRange(stage.Weapons.Select(x => new WeaponStatsViewModel(x)));
            ArmorRewards.AddRange(stage.Armor.Select(x => new ArmorStatsViewModel(x)));
            QuestRewards.AddRange(stage.Companions.Select(x => new QuestRewardViewModel(x)));
            QuestRewards.AddRange(stage.Settlements.Select(x => new QuestRewardViewModel(x)));
            QuestRewards.AddRange(stage.OtherRewards.Select(x => new QuestRewardViewModel(x)));

            var nextStages = stage.GetNextStages();

            foreach (var item in nextStages)
            {
                NextStages.Add(new QuestStageDetailsViewModel(item));
            }

            HasOtherRewards = QuestRewards.Count > 0;
        }
예제 #2
0
    public void ProceedQuest(int questId, int nextStageId)
    {
        Quest  quest      = questlog.GiveQuest(questId);
        string formerTask = quest.activeStage.task;
        //QuestStage nextStage = questRepository.GiveStage(nextStageId);
        QuestStage nextStage = questRepository.readQuestStageFromDB(nextStageId);

        markerManager.RemoveMarker(quest);
        string nextTask = nextStage.task;

        quest.passedStages.Add(quest.activeStage);
        quest.activeStage = nextStage;
        Logger.log(quest.activeStage.task);
        if (nextStage.nextQuestStagesID[0, 0] == -1)
        {
            StartCoroutine(ShowQuest(formerTask, null));
            FinishQuest(questId);
            return;
        }

        StartCoroutine(ShowQuest(formerTask, nextTask));
        questlog.MoveToFirst(quest);
        journalDisplay.ManageMarker(quest);
        //markerManager.AddMarker(quest);
    }
예제 #3
0
    protected override QuestStage[] GenerateQuestStages()
    {
        if (base.reporter == null)
        {
            return(null);
        }
        QuestStage[] stages = new QuestStage[NUM_STAGES];

        List <string> exclude = new List <string>()
        {
            base.reporter.GetName()
        };

        exclude.AddRange(takenNpcNames);

        NPC[] targetNpcs1 = NPCSpawner.instance.GetRandomNpcs(1, exclude);
        stages[0] = new BeatdownQuestStage(targetNpcs1, 15);
        exclude.AddRange(targetNpcs1.Select(npc => npc.GetName()));

        NPC[] targetNpcs2 = NPCSpawner.instance.GetRandomNpcs(3, exclude);
        stages[1] = new BeatdownQuestStage(targetNpcs2, 25);

        takenNpcNames.AddRange(targetNpcs1.Select(npc => npc.GetName()));
        takenNpcNames.AddRange(targetNpcs2.Select(npc => npc.GetName()));

        targetNpcs1 = null;
        targetNpcs2 = null;

        return(stages);
    }
예제 #4
0
 public Quest(int questId, string questName, string status, QuestStage firstStage, QuestStage activeStage, bool isTargetted)
 {
     this.questId     = questId;
     this.questName   = questName;
     this.status      = status;
     this.firstStage  = firstStage;
     this.activeStage = activeStage;
     this.isTargetted = isTargetted;
 }
예제 #5
0
    /// <summary>
    /// Execute an event by name.
    /// </summary>
    /// <param name="eventName">Name of the event to trigger.</param>
    /// <param name="eventObject">QuestStage to be passed to listeners' handler function (must not be null).</param>
    public static void TriggerEvent(string eventName, QuestStage eventObject)
    {
        UnityEvent <QuestStage> thisEvent = null;

        if (instance.questStageEventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(eventObject);
        }
    }
예제 #6
0
        public void Start()
        {
            _questStage = QuestStage.Started;

            foreach (var script in IntroScripts)
            {
                ScriptHelpers.Execute(script);
            }

            _questStage = QuestStage.Doing;
        }
        public static List <QuestStage> GetNextStages(this QuestStage stage)
        {
            var stages = new List <QuestStage>();

            foreach (var chain in stage.NextQuestStages)
            {
                stages.Add(chain.NextQuestStage);
            }

            return(stages);
        }
    public Quest readQuestFromDB(int questID)
    {
        QuestObjectDB questDB = new QuestObjectDB();

        System.Data.IDataReader reader = questDB.getDataById(questID);
        QuestStage firstStage          = readQuestStageFromDB(int.Parse(reader[2].ToString()));
        bool       isTargetted         = true;
        Quest      quest = new Quest(int.Parse(string.Format("{0}", reader[0])), string.Format("{0}", reader[1]), "In Progress", firstStage, firstStage, isTargetted);

        questDB.close();
        return(quest);
    }
예제 #9
0
 public void AddQuestStage(QuestStage stage)
 {
     // Checks to see if the quest already has a QuestStage assigned to the stage number.
     if (StageNumbers.Contains(stage.StageNumber))
     {
         Debug.LogError(string.Format("Quest '{0}' already contains a stage at number {1}", QuestName, stage.StageNumber));
         return;
     }
     else
     {
         QuestStages.Add(stage);
     }
 }
예제 #10
0
    void DisplayQuestStages()
    {
        EditorGUILayout.LabelField("Current Stages", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical();

        // Display the currently-added quest stages
        addStagesScrollPos = EditorGUILayout.BeginScrollView(addStagesScrollPos, false, false, GUILayout.Width(400), GUILayout.Height(150), GUILayout.ExpandHeight(true));
        for (int i = 0; i < questStages.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("X", GUILayout.Width(50)))
            {
                questStages.RemoveAt(i);
                break;
            }
            if (GUILayout.Button("E", GUILayout.Width(50)))
            {
                showEditQuestStage = true;
                showAddQuestStage  = false;
                ResetQuestStageFields();
                selectedQuestStage = questStages[i];
                GetQuestStageData();
                break;
            }
            EditorGUILayout.LabelField(string.Format("#{0}: {1} \n{2}", questStages[i].StageNumber.ToString(), questStages[i].StageName, questStages[i].ShortDescription), GUILayout.ExpandHeight(true));
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();

        // Button for adding a new stage:
        if (!showAddQuestStage)
        {
            if (GUILayout.Button("New Quest Stage", GUILayout.Width(300)))
            {
                ResetQuestStageFields();
                showAddQuestStage  = true;
                showEditQuestStage = false;
            }
        }
        else
        {
            ShowAddQuestStage();
        }

        if (showEditQuestStage)
        {
            ShowEditQuestStage();
        }

        EditorGUILayout.EndVertical();
    }
예제 #11
0
    // This extracts information from the JSON database (through conditionData)
    void CreateQuestDatabase()
    {
        for (int i = 0; i < questData["Quests"].Count; i++)
        {
            if (!Contains((int)questData["Quests"][i]["QuestID"]))
            {
                Quest newQuest = new Quest();

                // Map each line in the ith JSON entry to a variable:
                newQuest.QuestName           = (string)questData["Quests"][i]["QuestName"];
                newQuest.QuestID             = (int)questData["Quests"][i]["QuestID"];
                newQuest.QuestShortDesc      = (string)questData["Quests"][i]["QuestShortDesc"];
                newQuest.QuestCurrencyReward = (int)questData["Quests"][i]["QuestCurrencyReward"];

                // Get associated quest stages
                for (int j = 0; j < questData["Quests"][i]["QuestStages"].Count; j++)
                {
                    QuestStage newQuestStage = new QuestStage();

                    newQuestStage.StageName           = (string)questData["Quest"][i]["QuestStage"][j]["StageName"];
                    newQuestStage.ProgressDescription = (string)questData["Quest"][i]["QuestStage"][j]["ProgressDescription"];
                    newQuestStage.FinishedDescription = (string)questData["Quest"][i]["QuestStage"][j]["FinishedDescription"];
                    newQuestStage.StageNumber         = (int)questData["Quest"][i]["QuestStage"][j]["StageNumber"];
                    newQuestStage.StageType           = (QuestStageType)((int)questData["Quest"][i]["QuestStage"][j]["StageType"]);

                    newQuest.QuestStages.Add(newQuestStage);
                }

                // Get associated requirements
                for (int m = 0; m < questData["Quests"][i]["QuestStages"].Count; m++)
                {
                    newQuest.QuestRequirements.Add((int)questData["Quests"][i]["QuestRequirements"][m]);
                }

                // Get associated item rewards
                for (int n = 0; n < questData["Quests"][i]["QuestStages"].Count; n++)
                {
                    newQuest.QuestItemRewards.Add((int)questData["Quests"][i]["QuestItemRewards"][n]);
                }

                // Add this quest to the database.
                AddQuest(newQuest);
                Debug.Log("(QuestDB) " + newQuest.QuestName + " loaded.");
            }
        }
    }
예제 #12
0
        public void Update()
        {
            if (_questStage != QuestStage.Doing)
            {
                return;
            }

            if (Tasks.Count <= 0)
            {
                _questStage = QuestStage.Completed;
            }

            for (int i = Tasks.Count - 1; i >= 0; i--)
            {
                if (Tasks[i].Evaluate())
                {
                    Tasks.RemoveAt(i);
                }
                else
                {
                    _questStage = QuestStage.Failed;
                }
            }

            if (_questStage == QuestStage.Failed)
            {
                foreach (var script in FailedScripts)
                {
                    ScriptHelpers.Execute(script);
                }
            }

            if (_questStage == QuestStage.Completed)
            {
                foreach (var script in SuccessScripts)
                {
                    ScriptHelpers.Execute(script);
                }
            }
        }
예제 #13
0
    public void AddData(QuestStage questStage)
    {
        string nextIds = "";

        for (int i = 0; i < questStage.nextQuestStagesID.GetLength(0); i++)
        {
            nextIds = nextIds + questStage.nextQuestStagesID[i, 0] + ";" + questStage.nextQuestStagesID[i, 1] + "%";
        }

        IDbCommand dbcmd = getDbCommand();

        dbcmd.CommandText = "REPLACE INTO " + TABLE_NAME + " ( "
                            + KEY_ID + ", "
                            + KEY_TASK + ", "
                            + KEY_NEXTSTAGEIDS + " ) "

                            + "VALUES ( '"
                            + questStage.stageId + "', '"
                            + questStage.task + "', '"
                            + nextIds + "' )";
        dbcmd.ExecuteNonQuery();
    }
예제 #14
0
    protected override QuestStage[] GenerateQuestStages()
    {
        if (base.reporter == null)
        {
            return(null);
        }
        QuestStage[] stages = new QuestStage[NUM_STAGES];

        Item common = ItemManager.instance.GetRandomCommonItem(base.reporter.GetInventory().items);

        stages[0] = new SellingQuestStage(common, 15);

        Item uncommon = ItemManager.instance.GetRandomUncommonItem(base.reporter.GetInventory().items);

        stages[1] = new SellingQuestStage(uncommon, 20);

        Item rare = ItemManager.instance.GetRandomRareItem(base.reporter.GetInventory().items);

        stages[2] = new SellingQuestStage(rare, 25);

        return(stages);
    }
    public QuestStage readQuestStageFromDB(int stageID)
    {
        QuestStageDB stageDB = new QuestStageDB();

        System.Data.IDataReader reader = stageDB.getDataById(stageID);
        string nextIDs = string.Format("{0}", reader[2]);

        string[] idList = nextIDs.Split('%');
        int[,] list = new int[idList.Length - 1, 2];
        for (int i = 0; i < idList.Length - 1; i++)
        {
            string[] row = idList[i].Split(';');
            for (int j = 0; j < row.Length; j++)
            {
                int.TryParse(row[j], out list[i, j]);
                Logger.log(list[i, j] + "|" + i + "|" + j);
            }
        }
        QuestStage stage = new QuestStage(int.Parse(string.Format("{0}", reader[0])), list, string.Format("{0}", reader[1]));

        return(stage);
    }
예제 #16
0
    //QuestRepository questRepository = new QuestRepository();
    void Start()
    {
        QuestStageDB  stageDB = new QuestStageDB();
        QuestObjectDB questDB = new QuestObjectDB();


        int[,] nextStages = new int[2, 2] {
            { 12, 2 }, { 13, 3 }
        };
        QuestStage stage = new QuestStage(1, nextStages, "Stufe 1");

        stageDB.AddData(stage);

        questDB.AddData(new Quest(21, "TestQuest1", "In Progress", stage, stage, false));


        nextStages = new int[1, 2] {
            { 16, 8 }
        };
        stage = new QuestStage(6, nextStages, "Quest 2 Stage 1");
        stageDB.AddData(stage);

        questDB.AddData(new Quest(22, "TestQuest2", "In Progress", stage, stage, false));


        nextStages = new int[1, 2] {
            { 17, 9 }
        };
        stage = new QuestStage(7, nextStages, "Quest 3 Stage 1");
        stageDB.AddData(stage);

        questDB.AddData(new Quest(23, "TestQuest3", "In Progress", stage, stage, false));


        nextStages = new int[1, 2] {
            { 14, 4 }
        };
        stage = new QuestStage(2, nextStages, "Stufe 2 Decision 1");
        stageDB.AddData(stage);

        nextStages = new int[1, 2] {
            { 15, 5 }
        };
        stage = new QuestStage(3, nextStages, "Stufe 2 Decision 2");
        stageDB.AddData(stage);

        nextStages = new int[1, 2] {
            { -1, -1 }
        };
        stage = new QuestStage(4, nextStages, "Finished Quest with Decision 1");
        stageDB.AddData(stage);

        nextStages = new int[1, 2] {
            { -1, -1 }
        };
        stage = new QuestStage(5, nextStages, "Finished Quest with Decision 2");
        stageDB.AddData(stage);

        nextStages = new int[1, 2] {
            { -1, -1 }
        };
        stage = new QuestStage(8, nextStages, "Quest 2 Stage 2");
        stageDB.AddData(stage);

        nextStages = new int[1, 2] {
            { -1, -1 }
        };
        stage = new QuestStage(9, nextStages, "Quest 3 Stage 2");
        stageDB.AddData(stage);

        stageDB.close();
        questDB.close();

        DialogueLineDB dialogueLineDB1 = new DialogueLineDB();

        dialogueLineDB1.AddData(new DialogueLine(1, "Hallo!", 2));
        dialogueLineDB1.AddData(new DialogueLine(2, "Ich bin ein Stein!", 3));
        dialogueLineDB1.AddData(new DialogueLine(3, "Schnauze, Stein!", 4));
        dialogueLineDB1.AddData(new DialogueLine(4, "Hallo Roboter!", 5));
        dialogueLineDB1.AddData(new DialogueLine(5, "Erzähl mir was!", 10));
        dialogueLineDB1.AddData(new DialogueLine(6, "Ich bin kein Roboter, ich bin ein Stein!", 6));
        dialogueLineDB1.AddData(new DialogueLine(7, "Sorry!", 8));
        dialogueLineDB1.AddData(new DialogueLine(8, "Ich bestehe auf Roboter.", 7));
        dialogueLineDB1.AddData(new DialogueLine(9, "Dann unterhalt dich halt mit dir selbst!", 4));
        dialogueLineDB1.AddData(new DialogueLine(10, "Ist ok...", 9));
        dialogueLineDB1.AddData(new DialogueLine(11, "Möchtest du was interessantes wissen?", 15));
        dialogueLineDB1.AddData(new DialogueLine(12, "Nein", 4));
        dialogueLineDB1.AddData(new DialogueLine(13, "Ja", 10));
        dialogueLineDB1.AddData(new DialogueLine(14, "Was willst du hören?", 11));
        dialogueLineDB1.AddData(new DialogueLine(15, "Einen Witz bitte.", 12));
        dialogueLineDB1.AddData(new DialogueLine(16, "Was cooles!", 13));
        dialogueLineDB1.AddData(new DialogueLine(17, "Etwas, das ich wieder vergessen will.", 14));
        dialogueLineDB1.AddData(new DialogueLine(18, "Deine Mutter!", 4));
        dialogueLineDB1.AddData(new DialogueLine(19, "Wer eine nukleare Explosion verursacht, wird in Deutschland mit einer Freiheitsstrafe bis zu fünf Jahren oder mit einer Geldstrafe bestraft.", 4));
        dialogueLineDB1.AddData(new DialogueLine(20, "Bei Giraffen uriniert das Weibchen vor der Paarung in den Mund des Männchens.", 4));

        dialogueLineDB1.close();


        DialogueObjectDB dialogueObjectDB1 = new DialogueObjectDB();

        int[] array1 = { 1 };
        dialogueObjectDB1.AddData(new DialogueObject(1, "Line", array1));
        int[] array2 = { 2 };
        dialogueObjectDB1.AddData(new DialogueObject(2, "Line", array2));
        int[] array3 = { 3, 4, 5 };
        dialogueObjectDB1.AddData(new DialogueObject(3, "Decision", array3));
        int[] array4 = { 0 };
        dialogueObjectDB1.AddData(new DialogueObject(4, "End", array4));
        int[] array5 = { 6 };
        dialogueObjectDB1.AddData(new DialogueObject(5, "Line", array5));
        int[] array6 = { 7, 8 };
        dialogueObjectDB1.AddData(new DialogueObject(6, "Decision", array6));
        int[] array7 = { 9 };
        dialogueObjectDB1.AddData(new DialogueObject(7, "Line", array7));
        int[] array8 = { 10 };
        dialogueObjectDB1.AddData(new DialogueObject(8, "Line", array8));
        int[] array9 = { 11 };
        dialogueObjectDB1.AddData(new DialogueObject(9, "Line", array9));
        int[] array10 = { 14 };
        dialogueObjectDB1.AddData(new DialogueObject(10, "Line", array10));
        int[] array11 = { 15, 16, 17 };
        dialogueObjectDB1.AddData(new DialogueObject(11, "Decision", array11));
        int[] array12 = { 18 };
        dialogueObjectDB1.AddData(new DialogueObject(12, "Line", array12));
        int[] array13 = { 19 };
        dialogueObjectDB1.AddData(new DialogueObject(13, "Line", array13));
        int[] array14 = { 20 };
        dialogueObjectDB1.AddData(new DialogueObject(14, "Line", array14));
        int[] array15 = { 12, 13 };
        dialogueObjectDB1.AddData(new DialogueObject(15, "Decision", array15));

        dialogueObjectDB1.close();

        DialogueClipDb dialogueClipDb = new DialogueClipDb();

        const string dialogueSteinPath = "Dialogue/Stein/";

        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-hallo", 1, 1));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-ich-bin", 2, 2));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-roboter", 6, 6));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-unterhalte", 9, 9));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-okay", 10, 10));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-interessant", 11, 11));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-hören", 14, 14));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-mutter", 18, 18));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-nuklear", 19, 19));
        dialogueClipDb.AddData(new DialogClip($"{dialogueSteinPath}stein-giraffe", 20, 20));

        const string dialoguePlayerPath = "Dialogue/Player/";

        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-schnauze", 3, 3));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-hallo-roboter", 4, 4));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-erzähl", 5, 5));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-sorry", 7, 7));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-roboter", 8, 8));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-nein", 12, 12));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-ja", 13, 13));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-witz", 15, 15));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-cool", 16, 16));
        dialogueClipDb.AddData(new DialogClip($"{dialoguePlayerPath}player-vergessen", 17, 17));


        dialogueClipDb.close();
    }
 public QuestStageDetailsViewModel(QuestStage stage)
 {
     InitializeViewModel(stage);
 }
예제 #18
0
        public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("EditorID", false, out subEle))
            {
                if (EditorID == null)
                {
                    EditorID = new SimpleSubrecord <String>();
                }

                EditorID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Script", false, out subEle))
            {
                if (Script == null)
                {
                    Script = new RecordReference();
                }

                Script.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Name", false, out subEle))
            {
                if (Name == null)
                {
                    Name = new SimpleSubrecord <String>();
                }

                Name.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Large", false, out subEle))
            {
                if (LargeIcon == null)
                {
                    LargeIcon = new SimpleSubrecord <String>();
                }

                LargeIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Icon/Small", false, out subEle))
            {
                if (SmallIcon == null)
                {
                    SmallIcon = new SimpleSubrecord <String>();
                }

                SmallIcon.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Data", false, out subEle))
            {
                if (Data == null)
                {
                    Data = new QuestData();
                }

                Data.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Conditions", false, out subEle))
            {
                if (Conditions == null)
                {
                    Conditions = new List <Condition>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    Condition tempCTDA = new Condition();
                    tempCTDA.ReadXML(e, master);
                    Conditions.Add(tempCTDA);
                }
            }
            if (ele.TryPathTo("Stages", false, out subEle))
            {
                if (Stages == null)
                {
                    Stages = new List <QuestStage>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    QuestStage tempINDX = new QuestStage();
                    tempINDX.ReadXML(e, master);
                    Stages.Add(tempINDX);
                }
            }
            if (ele.TryPathTo("Objectives", false, out subEle))
            {
                if (Objectives == null)
                {
                    Objectives = new List <QuestObjective>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    QuestObjective tempQOBJ = new QuestObjective();
                    tempQOBJ.ReadXML(e, master);
                    Objectives.Add(tempQOBJ);
                }
            }
        }
예제 #19
0
 public void DeleteStage(Quest quest, QuestStage stage)
 {
     quest.QuestStages.Remove(stage);
 }
예제 #20
0
        public override void ReadData(ESPReader reader, long dataEnd)
        {
            while (reader.BaseStream.Position < dataEnd)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "EDID":
                    if (EditorID == null)
                    {
                        EditorID = new SimpleSubrecord <String>();
                    }

                    EditorID.ReadBinary(reader);
                    break;

                case "SCRI":
                    if (Script == null)
                    {
                        Script = new RecordReference();
                    }

                    Script.ReadBinary(reader);
                    break;

                case "FULL":
                    if (Name == null)
                    {
                        Name = new SimpleSubrecord <String>();
                    }

                    Name.ReadBinary(reader);
                    break;

                case "ICON":
                    if (LargeIcon == null)
                    {
                        LargeIcon = new SimpleSubrecord <String>();
                    }

                    LargeIcon.ReadBinary(reader);
                    break;

                case "MICO":
                    if (SmallIcon == null)
                    {
                        SmallIcon = new SimpleSubrecord <String>();
                    }

                    SmallIcon.ReadBinary(reader);
                    break;

                case "DATA":
                    if (Data == null)
                    {
                        Data = new QuestData();
                    }

                    Data.ReadBinary(reader);
                    break;

                case "CTDA":
                    if (Conditions == null)
                    {
                        Conditions = new List <Condition>();
                    }

                    Condition tempCTDA = new Condition();
                    tempCTDA.ReadBinary(reader);
                    Conditions.Add(tempCTDA);
                    break;

                case "INDX":
                    if (Stages == null)
                    {
                        Stages = new List <QuestStage>();
                    }

                    QuestStage tempINDX = new QuestStage();
                    tempINDX.ReadBinary(reader);
                    Stages.Add(tempINDX);
                    break;

                case "QOBJ":
                    if (Objectives == null)
                    {
                        Objectives = new List <QuestObjective>();
                    }

                    QuestObjective tempQOBJ = new QuestObjective();
                    tempQOBJ.ReadBinary(reader);
                    Objectives.Add(tempQOBJ);
                    break;

                default:
                    throw new Exception();
                }
            }
        }
예제 #21
0
 public QuestStageData(QuestStage stage)
 {
     this.reward = stage.GetReward();
 }
예제 #22
0
    void ShowEditQuestStage()
    {
        stageName      = EditorGUILayout.TextField("Name: ", stageName, GUILayout.Width(295));
        stageNum       = EditorGUILayout.IntField("Number: ", stageNum, GUILayout.Width(295));
        stageShortDesc = EditorGUILayout.TextField("Short Desc: ", stageShortDesc, GUILayout.Width(295));

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Type and Objectives", EditorStyles.boldLabel);
        stageType = (QuestStageType)EditorGUILayout.EnumPopup("Type: ", stageType, GUILayout.Width(480));
        switch (stageType)
        {
        case (QuestStageType.Dialog):
            break;

        case (QuestStageType.CollectItem):
        case (QuestStageType.GiveItem_Single):
        case (QuestStageType.Kill_Single):
            stageTargetID = EditorGUILayout.IntField("Item/NPC: ", stageTargetID, GUILayout.Width(295));
            break;

        case (QuestStageType.GiveItem_Multiple):
        case (QuestStageType.Kill_Multiple):
            for (int i = 0; i < targetIDList.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("X", GUILayout.Width(50)))
                {
                    targetIDList.RemoveAt(i);
                    targetQuantityList.RemoveAt(i);
                    break;
                }

                EditorGUILayout.LabelField(string.Format("Item {0} x{1}", targetIDList[i].ToString(), targetQuantityList[i].ToString()));
                EditorGUILayout.EndHorizontal();
            }

            stageTargetID    = EditorGUILayout.IntField("Item/NPC: ", stageTargetID, GUILayout.Width(295));
            stageTargetQuant = EditorGUILayout.IntField("# req: ", stageTargetQuant, GUILayout.Width(295));

            if (GUILayout.Button("+", GUILayout.Width(50)))
            {
                if (!targetIDList.Contains(stageTargetID))
                {
                    targetIDList.Add(stageTargetID);
                    targetQuantityList.Add(stageTargetQuant);
                }

                else
                {
                    Debug.LogError("Cannot add target item/npc: already exists in quest stage.");
                }

                stageTargetID    = -1;
                stageTargetQuant = 0;
                break;
            }
            break;
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Quest Log Text", EditorStyles.boldLabel);
        EditorGUILayout.LabelField("Progress description:");
        stageProgDesc = EditorGUILayout.TextArea(stageProgDesc, GUILayout.Width(350), GUILayout.MinHeight(90));
        EditorGUILayout.LabelField("Finished description:");
        stageFinDesc = EditorGUILayout.TextArea(stageFinDesc, GUILayout.Width(350), GUILayout.MinHeight(90));

        if (GUILayout.Button("Save Changes", GUILayout.Width(300)))
        {
            for (int i = 0; i < questStages.Count; i++)
            {
                if (questStages[i].StageNumber == stageNum && selectedQuestStage.StageNumber != stageNum)
                {
                    Debug.LogWarning("Quest already contains a stage with number " + stageNum);
                    return;
                }
            }

            selectedQuestStage.StageName           = stageName;
            selectedQuestStage.StageNumber         = stageNum;
            selectedQuestStage.ShortDescription    = stageShortDesc;
            selectedQuestStage.ProgressDescription = stageProgDesc;
            selectedQuestStage.FinishedDescription = stageFinDesc;
            selectedQuestStage.StageType           = stageType;

            if (stageType == QuestStageType.Kill_Multiple || stageType == QuestStageType.GiveItem_Multiple)
            {
                List <int> _id    = new List <int>();
                List <int> _quant = new List <int>();

                for (int j = 0; j < targetIDList.Count; j++)
                {
                    _id.Add(targetIDList[j]);
                    _quant.Add(targetQuantityList[j]);
                }

                selectedQuestStage.AddTargets(_id, _quant);
            }

            else if (stageType == QuestStageType.Kill_Single || stageType == QuestStageType.GiveItem_Single)
            {
                List <int> _id = new List <int>();
                _id.Add(stageTargetID);
                List <int> _quant = new List <int>();
                _quant.Add(1);

                selectedQuestStage.StageTargetID       = _id;
                selectedQuestStage.StageTargetQuantity = _quant;
            }

            // Sorts the list by stage number then resets the fields.
            questStages = questStages.OrderBy(o => o.StageNumber).ToList();
            ResetQuestStageFields();

            selectedQuestStage = null;
            showEditQuestStage = false;
        }

        if (GUILayout.Button("Cancel", GUILayout.Width(300)))
        {
            ResetQuestStageFields();
            selectedQuestStage = null;
            showEditQuestStage = false;
        }
    }
예제 #23
0
 public void Display(QuestStage stage)
 {
     this.stageTask.text = stage.task;
 }