// Start is called before the first frame update void Start() { questField = gameObject; Quests.pickableQuests = Quests.allQuests; viableQuests = Quests.pickableQuests; for (int i = 0; i < qAmount; i++) { int id = Random.Range(0, viableQuests.Count); quests.Add(viableQuests[id]); viableQuests.RemoveAt(id); } currentIndex = 0; currentQuest = quests[currentIndex]; RenderQuest(currentQuest); Debug.Log(currentQuest.name); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.LeftArrow)) { if (Input.GetKeyDown(KeyCode.RightArrow) && currentIndex + 1 < quests.Count) { currentIndex++; } else if (Input.GetKeyDown(KeyCode.LeftArrow) && currentIndex > 0) { currentIndex--; } currentQuest = quests[currentIndex]; RenderQuest(currentQuest); Debug.Log(currentQuest.name); } }
void LoadQuests() { TextAsset quests = Resources.Load <TextAsset>("Lists/Quests"); string[] data = quests.text.Split(new char[] { '\n' }); for (int i = 1; i < data.Length - 1; i++) { string[] row = data[i].Split(new char[] { ';' }); Quests.Quest quest = new Quests.Quest(); int.TryParse(row[0], out quest.id); quest.name = row[1]; quest.description = row[2]; int.TryParse(row[3], out quest.reward); int goalNum; int.TryParse(row[5], out goalNum); quest.goal = new Quests.Quest.Goal((CustomEnums.GoalTypes)System.Enum.Parse(typeof(CustomEnums.GoalTypes), row[4]), goalNum, row[6]); quest.questState = CustomEnums.QuestStates.ToPick; Quests.allQuests.Add(quest); } }
public void RenderQuest(Quests.Quest quest) { transform.GetChild(0).GetComponent <Text>().text = quest.name; transform.GetChild(1).GetComponent <Text>().text = quest.description; transform.GetChild(3).GetComponent <Text>().text = quest.reward.ToString(); }