Inheritance: MonoBehaviour
Example #1
0
    protected void Add(SaveQuest quest)
    {
        var index = items.FindIndex(i => i.squest.questid == quest.questid);

        if (index >= 0)
        {
            items[index].squest = quest;
        }
        else
        {
            items.Add(new QuestTrace()
            {
                squest = quest, desc = string.Empty
            });
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        isNear = IsCharacterClose();
        if (isNear && Input.GetKeyDown(KeyCode.Z) && isAccepted && questText.activeInHierarchy == false)
        {
            isDisplayed = true;
            questText.SetActive(true);
            questText.GetComponentInChildren <Text>().text = "Hows that quest going?";
        }
        if (isDisplayed && Input.GetKeyDown(KeyCode.Z) && !isAccepted)
        {
            // Change the name to Enemy Information name <- found the looppole do in the morning
            FetchQuest quest = new FetchQuest();

            string temp = quest.GetObjective(questId);           // I need a system to after certian levels the quest iD for the npc changes, or after certain prerequistes are meet.
            if (!quest.isQuestComplete && temp.Contains("Kill")) // Maybe if i make an array of quest iDs then make as system to where the quest id changes
            {                                                    // After the player completes a prerequistes, also make NPC information that stores all of
                                                                 // There quest...
                                                                 // Also i have to add all the quest to a active quest list for the player.
                EnemyInformation[] temporary   = GameObject.FindObjectsOfType(typeof(EnemyInformation)) as EnemyInformation[];
                List <GameObject>  enemysFound = new List <GameObject>();
                for (int i = 0; i < temporary.Length; i++)
                {
                    if (temporary[i].name == quest.GetObjectiveName(questId))
                    {
                        enemysFound.Add(temporary[i].gameObject);
                    }
                }
                GameObject[] temp2 = enemysFound.ToArray();
                KillQuest    kill  = gameObject.GetComponent <KillQuest>();
                // Learn Regex-> this is how you convert find numbers in a string and add it to the string then parse
                string result    = Regex.Match(quest.GetObjective(questId), @"\d+").Value;
                int    resultNum = int.Parse(result);
                kill.InitializeKillQuest(temp2, resultNum);
                GameObject tempQuestText = GameObject.FindGameObjectWithTag("QuestNotif");
                tempQuestText.GetComponent <Text>().text = "Quest Started!!";
                StartCoroutine(GetRidOfCompleteText());
            }
            else if (temp.Contains("Save"))
            {
                GameObject tempQuestText = GameObject.FindGameObjectWithTag("QuestNotif");
                tempQuestText.GetComponent <Text>().text = "Quest Started!!";
                StartCoroutine(GetRidOfCompleteText());
                SaveQuest saveQuest = gameObject.GetComponent <SaveQuest>();
                saveQuest.StartSaveQuest(quest.GetObjectiveName(questId), this.gameObject);
            }
            else if (temp.Contains("Find"))
            {
                GameObject tempQuestText = GameObject.FindGameObjectWithTag("QuestNotif");
                tempQuestText.GetComponent <Text>().text = "Quest Started!!";
                DropQuests drop = gameObject.GetComponent <DropQuests>();
                drop.ItemToFind(2, this.gameObject, 5);
            }
            FetchQuest tempQuest = new FetchQuest();
            tempQuest = (FetchQuest)Quest.quest[questId - 1];
            GameInformation.activeQuest.Add(tempQuest);
            questList.AddToQuestLog();
            isAccepted = true;
        }
        if (isNear && Input.GetKeyDown(KeyCode.Z) && !isAccepted)
        {
            isDisplayed = true;
            questText.SetActive(true);
            FetchQuest quest = new FetchQuest();
            if (quest.GetRequriedLevel(questId) < GameInformation.PlayerLevel && quest.IsPlayerReady(questId))
            {
                questText.GetComponentInChildren <Text>().text = quest.GetDescription(questId) + "\n Press Z to accept quest";
                text.text = "";
            }
        }
    }