private void BuildOccupyRegionObjective(GameObject parent, JObject objective, string name, string title, string guid, bool isPrimaryObjectve, int priority, bool displayToUser, string contractObjectiveGuid) { string lanceToUseRegionGuid = objective["LanceToUseRegionGuid"].ToString(); string regionGuid = objective["RegionGuid"].ToString(); string progressFormat = (objective.ContainsKey("ProgressFormat")) ? objective["ProgressFormat"].ToString() : ""; string description = objective["Description"].ToString(); int numberOfUnitsToOccupy = (objective.ContainsKey("NumberOfUnitsToOccupy")) ? (int)objective["NumberOfUnitsToOccupy"] : 0; int durationToOccupy = (objective.ContainsKey("DurationToOccupy")) ? (int)objective["DurationToOccupy"] : 0; bool useDropship = (objective.ContainsKey("UseDropship")) ? (bool)objective["UseDropship"] : false; string[] requiredTagsOnUnit = (objective.ContainsKey("RequiredTagsOnUnit")) ? ((JArray)objective["RequiredTagsOnUnit"]).ToObject <string[]>() : null; string[] requiredTagsOnOpposingUnits = (objective.ContainsKey("RequiredTagsOpposingUnits")) ? ((JArray)objective["RequiredTagsOpposingUnits"]).ToObject <string[]>() : null; OccupyRegionObjective occupyRegionObjective = ObjectiveFactory.CreateOccupyRegionObjective( guid, parent, contractObjectiveGuid, lanceToUseRegionGuid, regionGuid, this.name, title, progressFormat, description, numberOfUnitsToOccupy, durationToOccupy, useDropship, requiredTagsOnUnit, requiredTagsOnOpposingUnits ); }
private void BuildGenericObjective(GameObject parent, JObject objective, string name, string title, string guid, bool isPrimaryObjectve, int priority, bool displayToUser, string contractObjectiveGuid) { string description = (objective.ContainsKey("Description") ? objective["Description"].ToString() : title); EmptyObjectiveObjective objectiveLogic = ObjectiveFactory.CreateEmptyObjective(guid, parent, contractObjectiveGuid, name, title, description, isPrimaryObjectve, priority, displayToUser); }
void Start() { List <Objective> goals = new List <Objective>(5); for (int i = 0; i < 5; i++) { goals.Add(ObjectiveFactory.CreateGoal(i + 1)); Debug.Log($"Goal {i + 1} - {goals[i].Description}"); } }
public override void Run(RunPayload payload) { Main.Logger.Log($"[AddDestroyWholeUnitChunk] Adding encounter structure"); EncounterLayerData encounterLayerData = MissionControl.Instance.EncounterLayerData; DestroyWholeLanceChunk destroyWholeChunk = ChunkFactory.CreateDestroyWholeLanceChunk(); destroyWholeChunk.encounterObjectGuid = System.Guid.NewGuid().ToString(); this.objectiveLabel = MissionControl.Instance.CurrentContract.Interpolate(this.objectiveLabel).ToString(); bool spawnOnActivation = true; LanceSpawnerGameLogic lanceSpawner = LanceSpawnerFactory.CreateLanceSpawner( destroyWholeChunk.gameObject, spawnerName, lanceGuid, teamGuid, spawnOnActivation, SpawnUnitMethodType.InstantlyAtSpawnPoint, unitGuids ); LanceSpawnerRef lanceSpawnerRef = new LanceSpawnerRef(lanceSpawner); bool showProgress = true; DestroyLanceObjective objective = ObjectiveFactory.CreateDestroyLanceObjective( objectiveGuid, destroyWholeChunk.gameObject, lanceSpawnerRef, lanceGuid, objectiveLabel, showProgress, ProgressFormat.PERCENTAGE_COMPLETE, "The primary objective to destroy the enemy lance", priority, displayToUser, ObjectiveMark.AttackTarget, contractObjectiveGameLogicGuid, Main.Settings.ActiveAdditionalLances.GetRewards() ); if (isPrimary) { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objective, true); } else { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objective, false); } DestroyLanceObjectiveRef destroyLanceObjectiveRef = new DestroyLanceObjectiveRef(); destroyLanceObjectiveRef.encounterObject = objective; destroyWholeChunk.lanceSpawner = lanceSpawnerRef; destroyWholeChunk.destroyObjective = destroyLanceObjectiveRef; }
public Quest fromJson(JSONNode data) { JSONNode questData = data["Quest"].AsObject; questName = questData["QuestName"]; foreach (JSONNode objectiveType in questData["Objectives"]) { Objective obj = ObjectiveFactory.create(objectiveType["Type"]); obj.fromJson(objectiveType); objectives.Add(obj); } return(this); }
public IObjectiveFactory CreateObjectiveFactory() { IObjectiveFactory factory = null; try { factory = new ObjectiveFactory(); } catch (Exception exception) { this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace); } return(factory); }
private void BuildDestroyWholeLanceObjective(GameObject parent, JObject objective, string name, string title, string guid, bool isPrimaryObjectve, int priority, bool displayToUser, string contractObjectiveGuid) { DestroyWholeLanceChunk destroyWholeLanceChunk = parent.GetComponent <DestroyWholeLanceChunk>(); string lanceToDestroyGuid = objective["LanceToDestroyGuid"].ToString(); Dictionary <string, float> rewards = (objective.ContainsKey("Rewards")) ? objective["Rewards"].ToObject <Dictionary <string, float> >() : new Dictionary <string, float>(); bool showProgress = true; LanceSpawnerRef lanceSpawnerRef = new LanceSpawnerRef(); lanceSpawnerRef.EncounterObjectGuid = lanceToDestroyGuid; DestroyLanceObjective objectiveLogic = ObjectiveFactory.CreateDestroyLanceObjective( guid, parent, lanceSpawnerRef, lanceToDestroyGuid, title, showProgress, ChunkLogic.ProgressFormat.PERCENTAGE_COMPLETE, "The primary objective to destroy the enemy lance", priority, displayToUser, ObjectiveMark.AttackTarget, contractObjectiveGuid, rewards, rewards.Count > 0 ); if (isPrimaryObjectve) { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objectiveLogic, true); } else { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objectiveLogic, false); } DestroyLanceObjectiveRef destroyLanceObjectiveRef = new DestroyLanceObjectiveRef(); destroyLanceObjectiveRef.encounterObject = objectiveLogic; if (destroyWholeLanceChunk != null) { destroyWholeLanceChunk.lanceSpawner = lanceSpawnerRef; destroyWholeLanceChunk.destroyObjective = destroyLanceObjectiveRef; } }
public IObjectiveFactory CreateObjectiveFactory() { IObjectiveFactory factory = null; try { factory = new ObjectiveFactory(); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(factory); }
private void BuildDestroyWholeLanceObjective(GameObject parent, JObject objective, string name, string title, string guid, bool isPrimaryObjectve, int priority, string contractObjectiveGuid) { DestroyWholeLanceChunk destroyWholeLanceChunk = parent.GetComponent <DestroyWholeLanceChunk>(); string lanceToDestroyGuid = objective["LanceToDestroyGuid"].ToString(); bool showProgress = true; bool displayToUser = true; LanceSpawnerRef lanceSpawnerRef = new LanceSpawnerRef(); lanceSpawnerRef.EncounterObjectGuid = lanceToDestroyGuid; DestroyLanceObjective objectiveLogic = ObjectiveFactory.CreateDestroyLanceObjective( guid, parent, lanceSpawnerRef, lanceToDestroyGuid, title, showProgress, ChunkLogic.ProgressFormat.PERCENTAGE_COMPLETE, "The primary objective to destroy the enemy lance", priority, displayToUser, ObjectiveMark.AttackTarget, contractObjectiveGuid, false // Don't create the objective override as it's provided by the contract json ); if (isPrimaryObjectve) { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objectiveLogic, true); } else { AccessTools.Field(typeof(ObjectiveGameLogic), "primary").SetValue(objectiveLogic, false); } DestroyLanceObjectiveRef destroyLanceObjectiveRef = new DestroyLanceObjectiveRef(); destroyLanceObjectiveRef.encounterObject = objectiveLogic; destroyWholeLanceChunk.lanceSpawner = lanceSpawnerRef; destroyWholeLanceChunk.destroyObjective = destroyLanceObjectiveRef; }
private void BuildDefendXUnitsObjective(GameObject parent, JObject objective, string name, string title, string guid, bool isPrimaryObjectve, int priority, bool displayToUser, string contractObjectiveGuid) { string[] requiredTagsOnUnit = (objective.ContainsKey("RequiredTagsOnUnit")) ? ((JArray)objective["RequiredTagsOnUnit"]).ToObject <string[]>() : null; int numberOfUnitsToDefend = (objective.ContainsKey("NumberOfUnitsToDefend")) ? ((int)objective["NumberOfUnitsToDefend"]) : 1; int durationToDefend = (objective.ContainsKey("DurationToDefend")) ? (int)objective["DurationToDefend"] : 0; string durationTypeStr = (objective.ContainsKey("DurationType")) ? objective["DurationType"].ToString() : "Rounds"; string progressFormat = (objective.ContainsKey("ProgressFormat")) ? objective["ProgressFormat"].ToString() : ""; string description = objective["Description"].ToString(); if (durationToDefend <= 0) { ObjectiveFactory.CreateDefendXUnitsForeverObjective(guid, parent, contractObjectiveGuid, name, title, priority, progressFormat, description, requiredTagsOnUnit, numberOfUnitsToDefend); } else { DurationType durationType = (DurationType)Enum.Parse(typeof(DurationType), durationTypeStr); ObjectiveFactory.CreateDefendXUnitsObjective(guid, parent, contractObjectiveGuid, name, title, priority, progressFormat, description, requiredTagsOnUnit, numberOfUnitsToDefend, durationToDefend, durationType); } }
public override void Run(RunPayload payload) { if (!state.GetBool("Chunk_Withdraw_Exists")) { Main.Logger.Log($"[AddWithdrawChunk] Adding encounter structure"); string playerSpawnerGuid = GetPlayerSpawnGuid(); EmptyCustomChunkGameLogic emptyCustomChunk = ChunkFactory.CreateEmptyCustomChunk("Chunk_Withdraw"); GameObject escapeChunkGo = emptyCustomChunk.gameObject; emptyCustomChunk.encounterObjectGuid = chunkGuid; emptyCustomChunk.startingStatus = EncounterObjectStatus.Inactive; emptyCustomChunk.notes = debugDescription; RegionFactory.CreateRegion(escapeChunkGo, regionGameLogicGuid, objectiveGuid, "Region_Withdraw", "regionDef_EvacZone"); bool useDropship = true; OccupyRegionObjective occupyRegionObjective = ObjectiveFactory.CreateOccupyRegionObjective( objectiveGuid, escapeChunkGo, null, playerSpawnerGuid, regionGameLogicGuid, "Withdraw", "Get to the Evac Zone", $"with {ProgressFormat.UNITS_OCCUPYING_SO_FAR}/{ProgressFormat.NUMBER_OF_UNITS_TO_OCCUPY} unit(s)", "The objective for the player to withdraw and complete, or withdraw, the mission", 0, 0, useDropship, new string[] { MissionControl.Instance.IsCustomContractType ? "Player 1" : "player_unit" }, new string[] { "opposing_unit" } ); ObjectiveFactory.CreateContractObjective(occupyRegionObjective); } else { Main.Logger.Log($"[AddWithdrawChunk] 'Chunk_Withdraw' already exists in map. No need to recreate."); } }