Added NPCs to game, fixed explore and collect quest, added quest remove, fixed quest update, v1.4.0
This commit is contained in:
@@ -19,16 +19,12 @@ namespace Assets.Scripts
|
||||
void Start()
|
||||
{
|
||||
quests = new Dictionary<string, List<Quest>>();
|
||||
quests.Add("main", new List<Quest>());
|
||||
quests.Add("find", new List<Quest>());
|
||||
GameObject newQuest = Instantiate(quest);
|
||||
newQuest.transform.SetParent(content.transform, false);
|
||||
FindQuest main = new FindQuest(newQuest);
|
||||
main.generateCityQuest();
|
||||
quests["main"].Add(main);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
addQuest();
|
||||
}
|
||||
quests["find"].Add(main);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -39,9 +35,12 @@ namespace Assets.Scripts
|
||||
|
||||
public void updateQuests(string key, object obj, int amount)
|
||||
{
|
||||
foreach (Quest quest in quests[key])
|
||||
if (quests.ContainsKey(key))
|
||||
{
|
||||
quest.update(obj, amount);
|
||||
foreach (Quest quest in quests[key])
|
||||
{
|
||||
quest.update(obj, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +99,42 @@ namespace Assets.Scripts
|
||||
scrollBar.value = 0;
|
||||
content.transform.localPosition = new Vector3(0,0,0);
|
||||
}
|
||||
|
||||
public void removeQuests()
|
||||
{
|
||||
Inventory inventory = GameObject.Find("Inventory").GetComponent<Inventory>();
|
||||
int luck = GameObject.Find("Player").GetComponent<Player>().getLuck();
|
||||
luck = luck + inventory.getEquipmentBonus()["LCK"];
|
||||
Dictionary<string, List<Quest>> toDelete = new Dictionary<string, List<Quest>>();
|
||||
foreach (string key in quests.Keys)
|
||||
{
|
||||
foreach (Quest quest in quests[key])
|
||||
{
|
||||
if (quest.isFinishedQuest())
|
||||
{
|
||||
if (!toDelete.ContainsKey(key))
|
||||
{
|
||||
toDelete.Add(key, new List<Quest>());
|
||||
}
|
||||
toDelete[key].Add(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string key in toDelete.Keys)
|
||||
{
|
||||
foreach (Quest quest in toDelete[key])
|
||||
{
|
||||
if (quest is CollectQuest)
|
||||
{
|
||||
((CollectQuest)quest).removeItems(inventory);
|
||||
}
|
||||
quest.delete();
|
||||
quests[key].Remove(quest);
|
||||
inventory.addItem(new Item(luck));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user