void OnSetViewNodeChildContent(int index, GameObject child) { UIMissionGoalNode node = child.GetComponent <UIMissionGoalNode>(); MissionGoal mg = _goals[index]; string txt = ""; if (mg is MissionGoal_Bool) { MissionGoal_Bool mb = mg as MissionGoal_Bool; txt = mb.text; node.value2 = mg.id; } else if (mg is MissionGoal_Item) { MissionGoal_Item mi = mg as MissionGoal_Item; txt = mi.text + " " + mi.current.ToString() + "/" + mi.target.ToString(); node.value0 = mi.current; node.value1 = mi.target; node.value2 = mg.id; } else if (mg is MissionGoal_Kill) { MissionGoal_Kill mi = mg as MissionGoal_Kill; txt = mi.text + " " + mi.current.ToString() + "/" + mi.target.ToString(); node.value0 = mi.current; node.value1 = mi.target; node.value2 = mg.id; } node.SetContent(txt, false, false); }
public static void ShowGoalPopup(MissionGoal goal, int amount) { LevelGoalPopup newP = new LevelGoalPopup(graphics, font, GOAL_WIDTH, GOAL_HEIGHT); newP.Show(windowWidth, windowHeight, goal, amount); goalPopups.Add(newP); }
public void AddGoals(MissionGoal[] goals) { foreach (var g in goals) { g.mission = this; } goalList.AddRange(goals); }
private void Start() { AktRating = (Ratings)PlayerPrefs.GetInt("Mission_" + MissionGroupID + "_" + MissionVariantID, (int)Ratings.NOT_COMPLETED); missionAvailabilityManager.Refresh(); foreach (var createAndOrderUnit in EnemyUnitsArr) { EnemyUnits.Add(createAndOrderUnit.AttachedUnit); } switch (goalThreeCondition) { case MissionGoal.GoalTypes.ONLY_USE_TYPE: missionGoal = new MissionGoal(goalThreeCondition, TypeRestriction); break; case MissionGoal.GoalTypes.MAX_AMOUNT: case MissionGoal.GoalTypes.MIN_TYPE_AMOUNT: case MissionGoal.GoalTypes.MAX_TYPE_AMOUNT: missionGoal = new MissionGoal(goalThreeCondition, AmountRestriction); break; default: throw new ArgumentOutOfRangeException(); } MissionTime = MissionTimeMinutes * 60; }
public static GameEvent Build(MissionGoal goal) { GameEvent gameEvent = Build( missionGoalEvent, goal.goalName, goal.isSuccess() ? "SUCCESS" : "FAILURE"); return gameEvent; }
void Update() { if (!_initialized) { return; } if (missionWnd.isShow) { if (_currentGoals != null) { for (int i = 0; i < _goals.Count; i++) { MissionGoal mg = _goals[i]; if (mg as MissionGoal_Item != null) { MissionGoal_Item mgi = mg as MissionGoal_Item; UIMissionGoalItem item = missionWnd.GetGoalItem(i); int current = mgi.current; int target = mgi.target; if (item != null && (current != item.value0 || target != item.value1)) { string text = mgi.text + " " + mgi.current.ToString() + "/" + mgi.target.ToString(); item.itemText = text; item.value0 = current; item.value1 = target; } } else if (mg as MissionGoal_Kill != null) { MissionGoal_Kill mgi = mg as MissionGoal_Kill; UIMissionGoalItem item = missionWnd.GetGoalItem(i); int current = mgi.current; int target = mgi.target; if (item != null && (current != item.value0 || target != item.value1)) { string text = mgi.text + " " + mgi.current.ToString() + "/" + mgi.target.ToString(); item.itemText = text; item.value0 = current; item.value1 = target; } } } } } }
public void Show(int windowWidth, int windowHeight, MissionGoal goal, int amount) { this.windowWidth = windowWidth; this.windowHeight = windowHeight; this.goal = goal; slidingIn = true; bgRect.X = windowWidth / 2 - (bgRect.Width / 2); bgRect.Y = bgRect.Height * -1; thumbRect.X = bgRect.X + (bgRect.Width / 2 - (thumbRect.Width / 2)); thumbRect.Y = bgRect.Y + SPACING; goalText = TextFor(goal, amount); goalPos.X = bgRect.X + (bgRect.Width / 2 - (font.MeasureString(goalText).X / 2)); goalPos.Y = thumbRect.Bottom + SPACING; currentThumbImg = Utilities.GetImgOfGoal(goal); Active = true; }
protected void RenderLocalResources() { localresources = MainClient.GetLocalResources(); repLocalResources.DataSource = localresources; repLocalResources.DataBind(); missionGoals = MainClient.GetMissionGoals(); if (missionGoals.Count == 0) { MissionGoal mg = new MissionGoal(Construction.Farm); mg.ImageSrc = "Images/winscreen.jpg"; missionGoals.Add(mg); } repMission.DataSource = missionGoals; repMission.DataBind(); }
void OnMissionGoalAchieved(int goal_id, int mission_id) { int index = _currentGoals.IndexOfKey(goal_id); UIMissionGoalItem item = missionWnd.GetGoalItem(index); if (item != null) { MissionGoal mg = _currentGoals[goal_id]; if (!mg.achieved) { item.textColor = Color.white; } else { item.textColor = Color.green; } } }
private void notifyGoalFailure(MissionGoal goal) { if (goal.isSuccess()) { GameLogger.printRed("notifyGoalFailure called on successful goal!"); return; } completedGoals.Add(currentGoal); failedGoals.Add(currentGoal); agent.health.ApplyDamage(MissionConstants.DAMAGE_PER_GOAL); if (!agent.health.isAlive()) { agent.OnAgentKilled(); } print(string.Format("{0} received {1} points of damage!", agent.descriptor.name, MissionConstants.DAMAGE_PER_GOAL)); MissionManager.Instance.OnGoalComplete(currentGoal); }
public static string TextFor(MissionGoal goal, int amount) { switch (goal) { case MissionGoal.KillAll: return(Language.Translate(KILL_ALL_TEXT)); case MissionGoal.DestroyMechanics: return(string.Format(Language.Translate(MECH_TEXT), amount)); case MissionGoal.SavePeople: return(string.Format(Language.Translate(amount > 1 ? SAVE_TEXT1 : SAVE_TEXT2), amount)); case MissionGoal.DestroyLaser: return(Language.Translate(LASER_TEXT)); case MissionGoal.KillMalos: return(Language.Translate(BOSS_TEXT)); default: return(""); } }
void Update() { if (!_initialized) { return; } if (missionTrackWnd.isShow) { for (int i = 0; i < missionTrackWnd.viewNodes.Count; i++) { UIMissionGoalNode vNode = missionTrackWnd.viewNodes[i]; int mission_id = m_TrackedIds[i]; for (int j = 0; j < vNode.childNode.Count; j++) { UIMissionGoalNode child_node = vNode.childNode[j].GetComponent <UIMissionGoalNode>(); MissionGoal mg = PeCustomScene.Self.scenario.missionMgr.GetGoal(child_node.value2, mission_id); if (mg != null) { if (mg is MissionGoal_Item) { MissionGoal_Item mgi = mg as MissionGoal_Item; int current = mgi.current; int target = mgi.target; if (current != child_node.value0 || target != child_node.value1) { if (mgi.achieved) { child_node.titleColor = new Color(0.65f, 0.65f, 0.65f); } else { child_node.titleColor = Color.white; } string text = mgi.text + " " + mgi.current.ToString() + "/" + mgi.target.ToString(); child_node.SetContent(text, false, false); child_node.value0 = current; child_node.value1 = target; } } else if (mg is MissionGoal_Kill) { MissionGoal_Kill mgi = mg as MissionGoal_Kill; int current = mgi.current; int target = mgi.target; if (current != child_node.value0 || target != child_node.value1) { if (mgi.achieved) { child_node.titleColor = new Color(0.75f, 0.75f, 0.75f); } else { child_node.titleColor = Color.white; } string text = mgi.text + " " + mgi.current.ToString() + "/" + mgi.target.ToString(); child_node.SetContent(text, false, false); child_node.value0 = current; child_node.value1 = target; } } } } } } }
public void AddGoal(MissionGoal g) { g.mission = this; goalList.Add(g); }
private void notifyGoalSuccess(MissionGoal goal) { if (!goal.isSuccess()) { GameLogger.printRed("notifyGoalSuccess called on unsuccesful goal!"); return; } completedGoals.Add(currentGoal); successfulGoals.Add(currentGoal); agent.xp.AddXP(MissionConstants.XP_PER_GOAL); print(string.Format("{0} earned {1} XP points!", agent.descriptor.name, MissionConstants.XP_PER_GOAL)); float intelEarned = mission.descriptor.targetStructure.intel.GetAndDecrement(MissionConstants.INTEL_PER_GOAL); print(string.Format("{0} earned {1} points of intel!", agent.descriptor.name, intelEarned)); MissionManager.Instance.OnGoalComplete(currentGoal); }
void Update() { if (isProgressCompleted) {//progres completed with some result return; } if (currentGoal == null && goalsToComplete.Count == 0) { print("FINAL MISSION RESULT BY COMPARING failed vs. completed count!"); if (successfulGoals.Count >= failedGoals.Count) { notifyMissionSuccess(); }//TODO better resolution else { notifyMissionFailure(); } return; } if (currentGoal == null) { currentGoal = getNextGoal(); } if (currentGoal != null && currentGoal.isCompleted()) { if (currentGoal.isSuccess()) { print("SUCCESS FOR " + currentGoal.goalName); notifyGoalSuccess(currentGoal); currentGoal = null; return; } //failure if (currentGoal.isMissionCritical()) { print("mission critical failure " + currentGoal.goalName); notifyGoalFailure(currentGoal); notifyMissionFailure(); return; } if (currentGoal.isRetriable()) { print("Retrying " + currentGoal.goalName); currentGoal.retry(); return; } print("FAILURE FOR " + currentGoal.goalName); notifyGoalFailure(currentGoal);//all retries exhausted, was not mission critical currentGoal = null; } }
void OnSetGoalItemContent(UIMissionGoalItem item) { MissionGoal mg = _goals[item.index]; if (!mg.achieved) { item.textColor = Color.white; } else { item.textColor = Color.green; } if (mg as MissionGoal_Bool != null) { MissionGoal_Bool mgb = mg as MissionGoal_Bool; item.SetBoolContent(mgb.text, mgb.achieved); } else if (mg as MissionGoal_Item != null) { MissionGoal_Item mgi = mg as MissionGoal_Item; string text = mgi.text + " " + mgi.current.ToString() + "/" + mgi.target.ToString(); item.value0 = mgi.current; item.value1 = mgi.target; if (mgi.item.isSpecificPrototype) { string[] sprites = ItemAsset.ItemProto.GetIconName(mgi.item.Id); if (sprites != null) { item.SetItemContent(text, sprites[0]); } else { item.SetItemContent(text); } } else { item.SetItemContent(text); } } else if (mg as MissionGoal_Kill != null) { MissionGoal_Kill mgk = mg as MissionGoal_Kill; string text = mgk.text + " " + mgk.current.ToString() + "/" + mgk.target.ToString(); MissionGoal_Kill mgi = mg as MissionGoal_Kill; item.value0 = mgi.current; item.value1 = mgi.target; if (item != null) { if (mgi.monster.isSpecificEntity) { SpawnPoint sp = PeCustomScene.Self.spawnData.GetSpawnPoint(mgi.id); if (sp as MonsterSpawnPoint != null) { MonsterProtoDb.Item proto = MonsterProtoDb.Get(sp.ID); item.SetItemContent(text, proto.icon); } else if (sp as NPCSpawnPoint != null) { NpcProtoDb.Item proto = NpcProtoDb.Get(sp.ID); item.SetItemContent(text, proto.icon); } else { item.SetItemContent(text); } } else if (mgi.monster.isSpecificPrototype) { MonsterProtoDb.Item proto = MonsterProtoDb.Get(mgi.monster.Id); if (proto != null) { item.SetItemContent(text, proto.icon); } else { item.SetItemContent(text); } } else { item.SetItemContent(text); } } else { item.SetItemContent(text); } } }