Quest GenerateQuest(GraphVertex[] path, int index) { if (path == null) { GD.Print("Path is null, returning."); return(null); } Properties properties; Quest.Objective[] objectives = new Quest.Objective[path.Length]; Quest.Option[] options = new Quest.Option[path.Length]; for (int i = 0; i < path.Length; i++) { properties = path[i].Region.P0; objectives[i] = GenerateObjective(properties); options[i] = GenerateOption(properties); } Quest quest = new Quest(path, objectives, options, index); quests.Add(quest); return(quest); }
Quest.Objective GenerateObjective(Properties properties) { List <Quest.Objective> availableObjectives = new List <Quest.Objective>(); Quest.Objective obj = Quest.Objective.None; if (properties == null) { return(obj); } if (properties.DefendableArea) { availableObjectives.Add(Quest.Objective.DefendArea); } if (properties.Enemies > 0) { availableObjectives.Add(Quest.Objective.Kill); } if (properties.DeliverableNPC) { availableObjectives.Add(Quest.Objective.Deliver); } if (properties.Resources > 3) { availableObjectives.Add(Quest.Objective.Gather); } if (properties.EscortableNPC) { availableObjectives.Add(Quest.Objective.Escort); } if (properties.InteractableOBJ) { availableObjectives.Add(Quest.Objective.Interact); } if (availableObjectives.Count == 0) { return(obj); } int selection = Maths.random.Next(availableObjectives.Count); obj = availableObjectives[selection]; return(obj); }