/// <summary> /// 更新某个收集类任务目标,用于在其他前置目标完成时,更新其后置收集类目标 /// </summary> private void UpdateNextCollectObjectives(ObjectiveData objective) { if (!objective || !objective.nextObjective) { return; } ObjectiveData nextObjective = objective.nextObjective; while (nextObjective != null) { if (nextObjective is not CollectObjectiveData && nextObjective.Model.InOrder && nextObjective.nextObjective != null && nextObjective.nextObjective.Model.InOrder && nextObjective.Model.Priority < nextObjective.nextObjective.Model.Priority) { //若相邻后置目标不是收集类目标,该后置目标按顺序执行,其相邻后置也按顺序执行,且两者不可同时执行,则说明无法继续更新后置的收集类目标 return; } if (nextObjective is CollectObjectiveData co) { if (co.Model.CheckBagAtStart && !SaveManager.Instance.IsLoading) { co.CurrentAmount = BackpackManager.Instance.GetAmount(co.Model.ItemToCollect); } else if (!co.Model.CheckBagAtStart && !SaveManager.Instance.IsLoading) { co.amountWhenStart = BackpackManager.Instance.GetAmount(co.Model.ItemToCollect); } } nextObjective = nextObjective.nextObjective; } }
public void ObjDataToPanel(ObjectiveData data) { GameObject ret = Instantiate(objPrefab); ret.transform.parent = container.transform; ret.GetComponent <ObjectiveLogic>().Set(data); }
void Update() { // Checks if vegetable exists // If not - generates a new one if (_currentObject == null) { // Generate vegetable _currentObject = GameObject.Instantiate(prefab); BoxCollider2D collider = _currentObject.AddComponent <BoxCollider2D>(); Rigidbody2D rb = _currentObject.AddComponent <Rigidbody2D>(); Animator anim = _currentObject.GetComponent <Animator>(); float x = Random.Range(-5, 6); _currentObject.transform.position = new Vector2(x, 3.5f); bool isParsley = Random.Range(0, 11) > 5 ? true : false; anim.SetBool("Parsley", isParsley); rb.gravityScale = 0; collider.size = _currentObject.GetComponent <SpriteRenderer>().size; collider.isTrigger = true; ObjectiveData objectiveData = _currentObject.AddComponent <ObjectiveData>(); rb.AddForce(new Vector2(0, fallSpeed * -1)); objectiveData.isParsley = isParsley; } }
private void ForwardCallback(ObjectiveData d, Action <AgentInfo, Objective, bool> call) { try { var objective = activeSessionIds[d.AgentId]; if (objective == null) { QLog(LogLevel.Info, "Stale agent.", d.AgentId); return; } var info = AgentFromObjective(objective); if (info != null && objective.IsValid) { call(info, objective, false); } else { QLog(LogLevel.Warning, "Invalid agent or objective.", d.AgentId); } } catch (NullReferenceException nre) when(nre.Message == "Null internal reference.") { QLog(LogLevel.Warning, "Null internal reference.", d.AgentId); } catch (Exception e) { QLog(LogLevel.Error, "Exception " + e.GetType().ToString() + " forwarding " + call.Target.ToString()); } }
private void CreateObjectiveMapIcon(ObjectiveData objective) { if (!objective || !objective.Model.ShowMapIcon) { return; } //Debug.Log("Create icon for " + objective.DisplayName); if (objective is TalkObjectiveData to) { if (DialogueManager.Instance.Talkers.TryGetValue(to.Model.NPCToTalk.ID, out TalkerData talkerFound)) { if (talkerFound.currentScene == ZetanUtility.ActiveScene.name) { CreateIcon(talkerFound.currentPosition); } } } else if (objective is SubmitObjectiveData so) { if (DialogueManager.Instance.Talkers.TryGetValue(so.Model.NPCToSubmit.ID, out TalkerData talkerFound)) { if (talkerFound.currentScene == ZetanUtility.ActiveScene.name) { CreateIcon(talkerFound.currentPosition); } } } else if (objective.Model.AuxiliaryPos && objective.Model.AuxiliaryPos.Scene == ZetanUtility.ActiveScene.name) { foreach (var position in objective.Model.AuxiliaryPos.Positions) { CreateIcon(position); } } void CreateIcon(Vector3 destination) { var icon = MiscSettings.Instance.QuestIcon ? (objective is KillObjectiveData ? MapManager.Instance.CreateMapIcon(MiscSettings.Instance.QuestIcon, new Vector2(48, 48), destination, true, 144f, MapIconType.Objective, false, objective.Model.DisplayName) : MapManager.Instance.CreateMapIcon(MiscSettings.Instance.QuestIcon, new Vector2(48, 48), destination, true, MapIconType.Objective, false, objective.Model.DisplayName)) : MapManager.Instance.CreateDefaultMark(destination, true, false, objective.Model.DisplayName); if (icon) { if (questIcons.TryGetValue(objective, out var iconsExist)) { iconsExist.Add(icon); } else { questIcons.Add(objective, new List <MapIcon>() { icon }); } } } }
public bool CanParallelWith(ObjectiveData other) { if (!other || !other.Model.InOrder || !Model.InOrder) { return(true); } else if (other.Model.Priority == Model.Priority) { return(true); } return(false); }
void MakeHydraList(out List <ObjectiveData> ob_list) { ob_list = new List <ObjectiveData> (); //Head objective ObjectiveData headObjective = new ObjectiveData(); headObjective.name = "Head 1"; // Use this name to find this later headObjective.description = "Defeat head 1 "; headObjective.total = 0; //Assign headObjective.currentCount = 0; //Start at 0 headObjective.bIsCompleted = false; //Head2 objective ObjectiveData head2Objective = new ObjectiveData(); head2Objective.name = "Head 2"; // Use this name to find this later head2Objective.description = "Defeat head 2 "; head2Objective.total = 0; //Assign head2Objective.currentCount = 0; //Start at 0 head2Objective.bIsCompleted = false; //Head 3 objective ObjectiveData headThreebjective = new ObjectiveData(); headThreebjective.name = "Head 3"; // Use this name to find this later headThreebjective.description = "Defeat head 3 "; headThreebjective.total = 0; //Assign headThreebjective.currentCount = 0; //Start at zero headThreebjective.bIsCompleted = false; //Add our abjectives to the list ob_list.Add(headObjective); ob_list.Add(head2Objective); ob_list.Add(headThreebjective); print("hydra listed"); }
private void RemoveObjectiveMapIcon(ObjectiveData objective) { if (!objective) { return; } if (questIcons.TryGetValue(objective, out var icons)) { foreach (var icon in icons) { MapManager.Instance.RemoveMapIcon(icon, true); } questIcons.Remove(objective); } }
public ObjectiveData SaveObjectives() { string[] keysToSave = new string[activeObjectives.Count]; int[] stepsToSave = new int[activeObjectives.Count]; int[] progressValues = new int[activeObjectives.Count]; for (int i = 0; i < activeObjectives.Count; i++) { keysToSave[i] = activeObjectives[i].nameOfObjective; stepsToSave[i] = activeObjectives[i].currentSubObjective; progressValues[i] = activeObjectives[i].progress; } ObjectiveData dataToSave = new ObjectiveData(keysToSave, stepsToSave, progressValues); return(dataToSave); }
public void TryRemoveObjective(ObjectiveData objective, bool befCmplt) { if (!befCmplt && objective.IsComplete) { if (objective is TalkObjectiveData || objective is SubmitObjectiveData) { if (objectivesTalkToThis.Contains(objective as TalkObjectiveData)) { objectivesTalkToThis.RemoveAll(x => x == objective as TalkObjectiveData); } else if (objectivesSubmitToThis.Contains(objective as SubmitObjectiveData)) { objectivesSubmitToThis.RemoveAll(x => x == objective as SubmitObjectiveData); } } } }
public void LoadObjectives(ObjectiveData dataToLoad) { if (activeObjectives.Count > 0) { for (int i = 0; i < activeObjectives.Count; i++) { activeObjectives[i].DestroyGUIPanelInstance(); activeObjectives.Remove(activeObjectives[i]); } } string[] keysToLoad = dataToLoad.activeKeys; int[] stepsToLoad = dataToLoad.subObjectiveSteps; int[] progressToLoad = dataToLoad.progressValues; for (int i = 0; i < keysToLoad.Length; i++) { LoadObjective(keysToLoad[i], stepsToLoad[i], progressToLoad[i]); } }
public static void CreateObjective(string id, int value = 0) { GameObject obj = Instantiate(OPrefab); obj.transform.SetParent(GameObject.Find("ObjectivesPanel").transform); obj.transform.localScale = Vector3.one; Objectiv script = obj.GetComponent <Objectiv>(); script.CreateText(id); obj.GetComponent <Localization>().Id = id; obj.GetComponent <Localization>().CreateText(id); script.CreateCounter(value); ObjectiveData data = new ObjectiveData(id, value, obj, script); ObjectiveDataList.Add(id, data); }
public void AddOrUpdateObjective(int region, bool[] completed) { ObjectiveData objData = null; foreach (ObjectiveData res in this.objectives) { if (res.region == region) { objData = res; } } if (objData == null) { objData = new ObjectiveData(region, completed); this.objectives.Add(objData); } }
public ObjectiveData GetObjective(int region) { ObjectiveData targetObj = null; foreach (ObjectiveData temp in this.objectives) { if (temp.region == region) { targetObj = temp; } } if (targetObj == null) { bool[] complete = { false, false, false }; objectives.Add(new ObjectiveData(region, complete)); } return(targetObj); }
void MakeSnakeList(out List <ObjectiveData> ob_list) { ob_list = new List <ObjectiveData> (); //fight objective ObjectiveData fightObjective = new ObjectiveData(); fightObjective.name = "Defend"; // Use this name to find this later fightObjective.description = "Defeat the machine."; fightObjective.total = 0; //Assign fightObjective.currentCount = 0; //Start at zero fightObjective.bIsCompleted = false; //Add our abjectives to the list ob_list.Add(fightObjective); }
public void Set(ObjectiveData data) { reward = data.reward; id = data.id; magnitude = data.magnitude; nameText.text = GetName(data.element, data.reference, data.magnitude); actual = GetActual(data.element, data.reference); actualText.text = actual.ToString(); if (DataManager.instance.UserSessionHasAchievement(id)) { acomplished = true; retrieved = true; } else if (data.magnitude <= actual) { acomplished = true; } SetButton(); }
private void EditObjective(ObjectiveData objective) { var formEditObjective = _serviceProvider.GetRequiredService <formEditObjective>(); formEditObjective.objectiveData = objective; var result = formEditObjective.ShowDialog(this); if (result == DialogResult.OK) { if (!selectedScenario.Objectives.Contains(objective)) { selectedScenario.Objectives.Add(objective); } } else if (result == DialogResult.Abort) { var index = selectedScenario.Objectives.IndexOf(objective); selectedScenario.Objectives.Remove(objective); for (int y = 0; y < GRID_SIZE; y++) { for (int x = 0; x < GRID_SIZE; x++) { var cell = selectedScenario.ObjectiveMap[y][x]; if (cell.HasValue) { if (cell.Value == index) { selectedScenario.ObjectiveMap[y][x] = null; } else if (cell.Value > index) { selectedScenario.ObjectiveMap[y][x]--; } } } } } RefreshKeyItems(); }
private IEnumerable <QuestData> FindQuestsRequiredItem(ItemBase item, int leftAmount) { return(questsInProgress.FindAll(quest => { if (quest.Model.CmpltObjctvInOrder) { foreach (ObjectiveData o in quest.Objectives) { //当目标是收集类目标且在提交任务同时会失去相应道具时,才进行判断 if (o is CollectObjectiveData co && item == co.Model.ItemToCollect && co.Model.LoseItemAtSbmt) { if (o.IsComplete && o.Model.InOrder) { //如果剩余的道具数量不足以维持该目标完成状态 if (o.Model.Amount > leftAmount) { ObjectiveData tempObj = o.nextObjective; while (tempObj != null) { //则判断是否有后置目标在进行,以保证在打破该目标的完成状态时,后置目标不受影响 if (tempObj.CurrentAmount > 0 && tempObj.Model.Priority > o.Model.Priority) { //Debug.Log("Required"); return true; } tempObj = tempObj.nextObjective; } } //Debug.Log("NotRequired3"); return false; } //Debug.Log("NotRequired2"); return false; } } } //Debug.Log("NotRequired1"); return false; }).AsEnumerable()); }
void MakeAngelList(out List <ObjectiveData> ob_list) { ob_list = new List <ObjectiveData> (); //get Angel's AI // _aBoss = GameObject.FindObjectOfType<Genbu_AI>(); //Regen objective ObjectiveData regenObjective = new ObjectiveData(); regenObjective.name = "Regen"; // Use this name to find this later regenObjective.description = "Stop Disir from Regenerating."; regenObjective.total = 0; //Assign regenObjective.currentCount = 0; //Start at zero regenObjective.bIsCompleted = false; //Fight objective ObjectiveData fightObjective = new ObjectiveData(); fightObjective.name = "Fight"; // Use this name to find this later fightObjective.description = "Defeat Disir."; fightObjective.total = 0; //Assign fightObjective.currentCount = 0; //Start at 0 fightObjective.bIsCompleted = false; //Add our abjectives to the list ob_list.Add(regenObjective); ob_list.Add(fightObjective); }
void MakeGenbuList(out List <ObjectiveData> ob_list) { ob_list = new List <ObjectiveData> (); //get genbu's AI Genbu_AI _gBoss = GameObject.FindObjectOfType <Genbu_AI>(); //List<ObjectiveData> objectives = new List<ObjectiveData>(); //Bolts objective ObjectiveData boltObjective = new ObjectiveData(); boltObjective.name = "Shield bolts"; // Use this name to find this later boltObjective.description = "Shoot off the bolts holding the armoured plates."; int numofBolts = 0; //to stor the sum of the bolts in the scene //run through the array and give us the sum of the number of bolts on each plate foreach (int bolt in _gBoss.shieldsBlah) { numofBolts += bolt; } boltObjective.total = numofBolts; //Assign boltObjective.currentCount = 0; //Start at zero boltObjective.bIsCompleted = false; //plate objective ObjectiveData plateObjective = new ObjectiveData(); plateObjective.name = "armoured plating"; // Use this name to find this later plateObjective.description = "Armoured plates Destroyed: "; int numofPlates = 0; //to stor the sum of the bolts in the scene //run through the array and give us the sum of the number of plate prent in the scen foreach (GameObject _plate in _gBoss.shields) { numofPlates++; } plateObjective.total = numofPlates; //Assign plateObjective.currentCount = 0; //Start at Zero plateObjective.bIsCompleted = false; //puncture objective ObjectiveData punctureObjective = new ObjectiveData(); punctureObjective.name = "Puncture legs"; // Use this name to find this later punctureObjective.description = "legs damaged: "; punctureObjective.total = 4; //Assign punctureObjective.currentCount = 0; //Start at zero punctureObjective.bIsCompleted = false; // break Legs objective ObjectiveData legObjective = new ObjectiveData(); legObjective.name = "broken legs"; // Use this name to find this later legObjective.description = "Number of legs destroyed: "; legObjective.total = 4; //Assign legObjective.currentCount = 0; //Start at zero legObjective.bIsCompleted = false; //Add our abjectives to the list ob_list.Add(boltObjective); ob_list.Add(plateObjective); ob_list.Add(punctureObjective); ob_list.Add(legObjective); //return ob_list; //Send out the list }
void Awake() { instance = this; m_objectiveManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ObjectiveManager>(); }
public void AddObjective(ObjectiveData oD) { Objectives.Add(oD); UpdateObjectivesVisual(); }
public ObjectiveSaveData(ObjectiveData objective) { objectiveID = objective.ID; currentAmount = objective.CurrentAmount; }
void ObjectiveStateChange(ObjectiveData data, int index) { ObjectiveStateChange(data.State, data.AgentId, index, false); }
private void AddObjectiveButton(object sender, EventArgs e) { var newObjective = new ObjectiveData(); EditObjective(newObjective); }
private void LoadScenarioData() { foreach (var scenario in map.Scenarios) { var scenarioData = new ScenarioData() { Id = scenario.Id, Name = scenario.Name, Description = scenario.Description, IsDefault = scenario.IsDefault, EnemyDeckId = scenario.EnemyDeckId, }; if (scenario.EnemyDeckId.HasValue) { scenarioData.EnemyDeckName = scenario.EnemyDeck.Name; } foreach (var objective in scenario.ObjectiveMap.Where(x => x.ObjectiveId.HasValue).Select(x => x.Objective).Distinct()) { var objectiveData = new ObjectiveData() { Id = objective.Id, Name = objective.Name, Color = Color.FromArgb(objective.Red, objective.Green, objective.Blue), }; scenarioData.Objectives.Add(objectiveData); } foreach (var scenarioRule in scenario.ScenarioRuleSet) { var scenarioRuleData = new ScenarioRuleData() { Id = scenarioRule.RuleId, Name = scenarioRule.Rule.Name, Description = scenarioRule.Rule.Description, }; scenarioData.ScenarioRules.Add(scenarioRuleData); } scenarioData.DeploymentMap = new List <List <int?> >(); scenarioData.ObjectiveMap = new List <List <int?> >(); for (int y = 0; y < GRID_SIZE; y++) { var deploymentRow = new List <int?>(); var objectiveRow = new List <int?>(); scenarioData.DeploymentMap.Add(deploymentRow); scenarioData.ObjectiveMap.Add(objectiveRow); for (int x = 0; x < GRID_SIZE; x++) { var deploymentCell = scenario.DeploymentMap.Single(cell => cell.RowId == y && cell.ColumnId == x); var objectiveCell = scenario.ObjectiveMap.Single(cell => cell.RowId == y && cell.ColumnId == x); deploymentRow.Add(deploymentCell.PlayerId); int?objectiveIndex = scenarioData.Objectives.FindIndex(x => x.Id == objectiveCell.ObjectiveId); if (objectiveIndex == -1) { objectiveIndex = null; } objectiveRow.Add(objectiveIndex); } } scenarioList.Add(scenarioData); } scenarioList = scenarioList.OrderByDescending(x => x.IsDefault).ThenBy(x => x.Name).ToList(); }
public void region1() { //Main data for region 1 ObjectiveData obj = DataBaseManager.instance.GetObjective(1); string title = "Start a Fire"; string[] sub1 = { "Gather 10 wood", "Chop 3 trees", "build a campfire" }; bool[] c1 = DataBaseManager.instance.GetObjective(1).completed; int[] exp1 = { 4, 3, 4 }; string[] rewards1 = { "gold", "food", "gold" }; int[] amount1 = { 2, 3, 4 }; //Putting data into UI for sub 0 objText.text = title; ExpObjText.text = title + " (1/3)"; ExpSubText.text = sub1[0]; ExpXp.text = "Exp Earned: " + exp1[0].ToString(); string r = ""; //Rewards for region 1 for (int i = 0; i < rewards1.Length; i++) { r = r + " " + rewards1[i] + " " + amount1[i] + "\n"; } Rewards.text = r; //////////////////////////////////////////////////////////////////////////////////////////////SUBOBJECTIVE 1 if (c1[0] == false) { // dataholder: takes initial amount that the player had as soon as the region unlocked. Used to compare between future amount of resource if (dataHolder == -1) { dataHolder = DataBaseManager.instance.GetResourceData(DataBaseManager.WOOD_RESOURCE_NAME); } int n = 10; //Represents the amount of wood needed to get (goal) //check if player reached the goal int diff = (DataBaseManager.instance.GetResourceData(DataBaseManager.WOOD_RESOURCE_NAME) - dataHolder); if (diff < n) { subText.text = sub1[0] + ": " + diff + "/" + n; } else if (diff >= n) { c1[0] = true; subText.text = sub1[0] + ": \n Complete"; DataBaseManager.instance.UpdateObjectiveData(1, c1); dataHolder = -1; //changes c1[0] to true } } ///////////////////////////////////////////////////////////////////////////////////////////////SUBOBJECTIVE2 else if (c1[1] == false && c1[0] == true) //c1[0] must be true in order to unlock the next objective { // Sub2 Data subText.text = sub1[1]; ExpObjText.text = title + " (2/3)"; ExpSubText.text = sub1[1]; ExpXp.text = "Exp Earned: " + exp1[1].ToString(); if (dataHolder == -1) { dataHolder = ItemOptionsWindowScript.chopCount; } int n = 3; int diff = ItemOptionsWindowScript.chopCount - dataHolder; if (diff < 3) { subText.text = sub1[1] + ": " + diff + "/" + n; } else if (diff >= n) { c1[1] = true; subText.text = sub1[1] + ": \n Complete"; DataBaseManager.instance.UpdateObjectiveData(1, c1); dataHolder = -1; //changes c1[1] to true } } }
public string CreateJSON(ObjectiveData objectiveData) { return(JsonUtility.ToJson(objectiveData)); }
private readonly List <QuestData> questsFinished = new List <QuestData>();//分开存储完成任务可减少不必要的检索开销 #region 任务处理相关 /// <summary> /// 接取任务 /// </summary> /// <param name="quest">要接取的任务</param> public bool AcceptQuest(QuestData quest) { if (!quest || !IsQuestValid(quest.Model)) { MessageManager.Instance.New("无效任务"); return(false); } if (!MiscFuntion.CheckCondition(quest.Model.AcceptCondition) && !SaveManager.Instance.IsLoading) { MessageManager.Instance.New("未满足任务接取条件"); return(false); } if (HasOngoingQuest(quest)) { MessageManager.Instance.New("已经在执行"); return(false); } ObjectiveData currentObjective = quest.Objectives[0]; for (int i = 0; i < quest.Objectives.Count; i++) { var o = quest.Objectives[i]; o.OnStateChangeEvent += OnObjectiveStateChange; if (o is CollectObjectiveData co) { BackpackManager.Instance.Inventory.OnItemAmountChanged += co.UpdateCollectAmount; if (o.AllPrevComplete) { if (co.Model.CheckBagAtStart && !SaveManager.Instance.IsLoading) { co.CurrentAmount = BackpackManager.Instance.GetAmount(co.Model.ItemToCollect); } else if (!co.Model.CheckBagAtStart && !SaveManager.Instance.IsLoading) { co.amountWhenStart = BackpackManager.Instance.GetAmount(co.Model.ItemToCollect); } } } if (o is KillObjectiveData ko) { switch (ko.Model.KillType) { case KillObjectiveType.Specific: GameManager.Enemies[ko.Model.Enemy.ID].ForEach(e => e.OnDeathEvent += ko.UpdateKillAmount); break; case KillObjectiveType.Race: foreach (List <Enemy> enemies in GameManager.Enemies.Values.Where(x => x.Count > 0 && x[0].Info.Race && x[0].Info.Race == ko.Model.Race)) { enemies.ForEach(e => e.OnDeathEvent += ko.UpdateKillAmount); } break; case KillObjectiveType.Group: foreach (List <Enemy> enemies in GameManager.Enemies.Values.Where(x => x.Count > 0 && ko.Model.Group.Contains(x[0].Info.ID))) { enemies.ForEach(e => e.OnDeathEvent += ko.UpdateKillAmount); } break; case KillObjectiveType.Any: foreach (List <Enemy> enemies in GameManager.Enemies.Select(x => x.Value)) { enemies.ForEach(e => e.OnDeathEvent += ko.UpdateKillAmount); } break; } } if (o is TalkObjectiveData to) { if (!o.IsComplete) { var talker = DialogueManager.Instance.Talkers[to.Model.NPCToTalk.ID]; talker.objectivesTalkToThis.Add(to); o.OnStateChangeEvent += talker.TryRemoveObjective; } } if (o is MoveObjectiveData mo) { mo.targetPoint = CheckPointManager.Instance.CreateCheckPoint(mo.Model.AuxiliaryPos, mo.UpdateMoveState); } if (o is SubmitObjectiveData so) { if (!o.IsComplete) { var talker = DialogueManager.Instance.Talkers[so.Model.NPCToSubmit.ID]; talker.objectivesSubmitToThis.Add(so); o.OnStateChangeEvent += talker.TryRemoveObjective; } } if (o is TriggerObjectiveData cuo) { TriggerManager.Instance.RegisterTriggerEvent(cuo.UpdateTriggerState); var state = TriggerManager.Instance.GetTriggerState(cuo.Model.TriggerName); if (cuo.Model.CheckStateAtAcpt && state != TriggerState.NotExist) { TriggerManager.Instance.SetTrigger(cuo.Model.TriggerName, state == TriggerState.On); } } } quest.InProgress = true; questsInProgress.Add(quest); if (quest.Model.NPCToSubmit) { DialogueManager.Instance.Talkers[quest.Model.NPCToSubmit.ID].TransferQuestToThis(quest); } if (!SaveManager.Instance.IsLoading) { MessageManager.Instance.New($"接取了任务 [{quest.Model.Title}]"); } quest.latestHandleDays = TimeManager.Instance.Days; CreateObjectiveMapIcon(quest.Objectives[0]); NotifyCenter.PostNotify(QuestStateChanged, quest, false); return(true); }
private void OnObjectiveStateChange(ObjectiveData objective, bool befCmplt) { if (!SaveManager.Instance.IsLoading) { if (objective.CurrentAmount > 0) { string message = objective.Model.DisplayName + (objective.IsComplete ? "(完成)" : $"[{objective.AmountString}]"); MessageManager.Instance.New(message); } if (objective.parent.IsComplete) { MessageManager.Instance.New($"[任务]{objective.parent.Model.Title}(已完成)"); } } if (!befCmplt && objective.IsComplete) { UpdateNextCollectObjectives(objective); //Debug.Log("\"" + objective.DisplayName + "\"" + "从没完成变成完成"); ObjectiveData nextToDo = null; QuestData quest = objective.parent; List <ObjectiveData> parallelObj = new List <ObjectiveData>(); for (int i = 0; i < quest.Objectives.Count - 1; i++) { if (quest.Objectives[i] == objective) { for (int j = i - 1; j > -1; j--)//往前找可以并行的目标 { ObjectiveData prevObj = quest.Objectives[j]; if (!prevObj.Parallel) { break; //只要碰到一个不能并行的,就中断 } else { parallelObj.Add(prevObj); } } for (int j = i + 1; j < quest.Objectives.Count; j++)//往后找可以并行的目标 { ObjectiveData nextObj = quest.Objectives[j]; if (!nextObj.Parallel)//只要碰到一个不能并行的,就中断 { if (nextObj.AllPrevComplete && !nextObj.IsComplete) { nextToDo = nextObj;//同时,若该非并行目标的所有前置目标都完成了,那么它就是下一个要做的目标 } break; } else { parallelObj.Add(nextObj); } } break; } } if (!nextToDo) //当目标不能并行时此变量才不为空,所以此时表示所有后置目标都是可并行的,或者不存在后置目标 { parallelObj.RemoveAll(x => x.IsComplete); //把所有已完成的可并行目标去掉 /*if (parallelObj.Count > 0)//剩下未完成的可并行目标,则随机选一个作为下一个要做的目标 * nextToDo = parallelObj[Random.Range(0, parallelObj.Count)];*/ foreach (var obj in parallelObj) { CreateObjectiveMapIcon(obj); } } else { CreateObjectiveMapIcon(nextToDo); } RemoveObjectiveMapIcon(objective); } //else Debug.Log("无操作"); NotifyCenter.PostNotify(ObjectiveUpdate, objective, befCmplt); }