public void ProgressQuest() { if (curQuestA.isCompleted && curQuestA.GetNextNode()) { questUI.UpdateQuest(curQuestA); curQuestA = curQuestA.GetNextNode(); questUI.UpdateQuest(curQuestA); } if (sameQuest) { curQuestB = curQuestA; return; } if (curQuestB.isCompleted && curQuestB.GetNextNode()) { questUI.UpdateQuest(curQuestB); curQuestB = curQuestB.GetNextNode(); questUI.UpdateQuest(curQuestB); } }
// Use this for initialization void Start() { test = this.transform.GetChild(1); availableButtonList = new Dictionary <string, GameObject>(); progressButtonList = new Dictionary <string, GameObject>(); completedButtonList = new Dictionary <string, GameObject>(); questList = new Dictionary <string, int>(); QuestNode questA = QuestSystem.instance.GetQuestA().GetComponent <QuestNode>(); QuestNode questB = QuestSystem.instance.GetQuestA().GetComponent <QuestNode>(); do { if (questA != null) { if (questA.isCompleted) { Vector3 pos = new Vector3(xPos, topPos - completedButtonList.Count * 30.0f, 0); GameObject obj = Instantiate(Resources.Load("QuestButton"), completedContent.transform, false) as GameObject; obj.GetComponent <RectTransform>().sizeDelta = buttonSize; obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(pos.x, pos.y); completedButtonList.Add(questA.GetQuestName(), obj); questList.Add(questA.GetQuestName(), 1); obj.GetComponent <QuestButton>().SetQuestNode(questA); SetQuestButton(obj); } else if (questA.isInProgress) { Vector3 pos = new Vector3(xPos, topPos - progressButtonList.Count * 30.0f, 0); GameObject obj = Instantiate(Resources.Load("QuestButton"), progressContent.transform, false) as GameObject; obj.GetComponent <RectTransform>().sizeDelta = buttonSize; obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(pos.x, pos.y); progressButtonList.Add(questA.GetQuestName(), obj); questList.Add(questA.GetQuestName(), 2); obj.GetComponent <QuestButton>().SetQuestNode(questA); SetQuestButton(obj); } else if (questA.GetParentNode() == null || questA.GetParentNode().isCompleted) { Vector3 pos = new Vector3(xPos, topPos - availableButtonList.Count * 30.0f, 0); GameObject obj = Instantiate(Resources.Load("QuestButton"), availableContent.transform, false) as GameObject; obj.GetComponent <QuestButton>().SetQuestNode(questA); obj.GetComponent <RectTransform>().sizeDelta = buttonSize; obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(pos.x, pos.y); availableButtonList.Add(questA.GetQuestName(), obj); questList.Add(questA.GetQuestName(), 3); SetQuestButton(obj); } questA = questA.GetNextNode(); } if (QuestSystem.instance.GetSameQuest()) { questB = questB.GetNextNode(); } if (questB != null && !QuestSystem.instance.GetSameQuest()) { if (questB.isCompleted) { Vector3 pos = new Vector3(xPos, topPos - completedButtonList.Count * 30.0f, 0); GameObject obj = Instantiate(Resources.Load("QuestButton"), completedContent.transform, false) as GameObject; obj.GetComponent <RectTransform>().sizeDelta = buttonSize; obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(pos.x, pos.y); completedButtonList.Add(questB.GetQuestName(), obj); questList.Add(questB.GetQuestName(), 1); obj.GetComponent <QuestButton>().SetQuestNode(questB); SetQuestButton(obj); } else if (questB.isInProgress) { Vector3 pos = new Vector3(xPos, topPos - progressButtonList.Count * 30.0f, 0); GameObject obj = Instantiate(Resources.Load("QuestButton"), progressContent.transform, false) as GameObject; obj.GetComponent <RectTransform>().sizeDelta = buttonSize; obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(pos.x, pos.y); progressButtonList.Add(questB.GetQuestName(), obj); questList.Add(questB.GetQuestName(), 2); obj.GetComponent <QuestButton>().SetQuestNode(questB); SetQuestButton(obj); } else if (questB.GetParentNode() == null || questB.GetParentNode().isCompleted) { Vector3 pos = new Vector3(xPos, topPos - availableButtonList.Count * 30.0f, 0); GameObject obj = Instantiate(Resources.Load("QuestButton"), availableContent.transform, false) as GameObject; obj.GetComponent <RectTransform>().sizeDelta = buttonSize; obj.GetComponent <RectTransform>().anchoredPosition = new Vector2(pos.x, pos.y); availableButtonList.Add(questB.GetQuestName(), obj); questList.Add(questB.GetQuestName(), 3); obj.GetComponent <QuestButton>().SetQuestNode(questB); SetQuestButton(obj); } questB = questB.GetNextNode(); } } while (questA != null || questB != null); }