public ContractContent() { Tier = 1; Title = ""; Description = ""; Objectives = new Objective[2]; //Default objectives to kill target Objectives[0] = new ObjectiveKillTarget(); Objectives[1] = new ObjectiveTurnInContract(); }
//GUI layout for a specific objective private void ObjectiveArea(ref Objective objective, Type derivedType) { EditorGUILayout.BeginVertical(); //If the objective has no given sector, we default to 0, otherwise get the proper index int sectorNameIndex = 0; if (objective.sector) { sectorNameIndex = Array.IndexOf(sectorNames, objective.sector.name); } else { objective.sector = sectors[sectorNames[0]]; //Set default sector } //if a new sector is selected, find it by name in the dictionary and set the proper sector int newSectorNameIndex = EditorGUILayout.Popup("Sector", sectorNameIndex, sectorNames); if (sectorNameIndex != newSectorNameIndex) { string sectorName = sectorNames[newSectorNameIndex]; objective.sector = sectors[sectorName]; } if (derivedType == typeof(ObjectiveKillTarget)) { ObjectiveKillTarget obj = (ObjectiveKillTarget)objective; obj.GuardCount = EditorGUILayout.IntField("Guards", obj.GuardCount); objective = obj; } else if (derivedType == typeof(ObjectiveEscortCargo)) { ObjectiveEscortCargo obj = (ObjectiveEscortCargo)objective; obj.CargoShipCount = EditorGUILayout.IntField("Cargo Ships", obj.CargoShipCount); objective = obj; } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }
public void SetObjectives(List <Objective> p_Objectives) { objectives.text = ""; for (int i = 0; i < p_Objectives.Count; i++) { Objective objective = p_Objectives[i]; switch (objective.GetType().ToString()) { case "ObjectiveKillTarget": ObjectiveKillTarget kill = (ObjectiveKillTarget)objective; objectives.text += "Kill Target - " + kill.GuardCount + " Guards"; break; case "ObjectiveEscortCargo": ObjectiveEscortCargo escort = (ObjectiveEscortCargo)objective; objectives.text += "Escort " + escort.CargoShipCount + " Cargo Ships"; break; } objectives.text += '\n'; } }