private static void AttachRequiredReferences(ObjectiveGameLogic objectiveGameLogic, string contractObjectiveGuid)
        {
            if (contractObjectiveGuid != null)
            {
                ContractObjectiveGameLogic contractObjectiveGameLogic = MissionControl.Instance.EncounterLayerData.GetContractObjectiveGameLogicByGUID(contractObjectiveGuid);
                ObjectiveRef objectiveRef = new ObjectiveRef(objectiveGameLogic);
                contractObjectiveGameLogic.objectiveRefList.Add(objectiveRef);
            }

            objectiveGameLogic.onSuccessDialogue = new DialogueRef();
            objectiveGameLogic.onFailureDialogue = new DialogueRef();
        }
Esempio n. 2
0
        private void BuildObjectiveStatusConditional(JObject conditionalObject)
        {
            Main.LogDebug("[BuildObjectiveStatusConditional] Building 'ObjectiveStatusConditional' conditional");
            string guid   = conditionalObject["Guid"].ToString();
            string status = conditionalObject["Status"].ToString();
            ObjectiveStatusEvaluationType statusType  = (ObjectiveStatusEvaluationType)Enum.Parse(typeof(ObjectiveStatusEvaluationType), status);
            ObjectiveStatusConditional    conditional = ScriptableObject.CreateInstance <ObjectiveStatusConditional>();

            ObjectiveRef objectiveRef = new ObjectiveRef();

            objectiveRef.EncounterObjectGuid = guid;

            conditional.objective       = objectiveRef;
            conditional.objectiveStatus = statusType;

            conditionalList.Add(new EncounterConditionalBox(conditional));
        }
Esempio n. 3
0
        public override void Run(RunPayload payload)
        {
            Main.Logger.Log($"[AddObjectiveToAutocompleteTrigger] Adding objective '{objectiveId}' to AutocompleteGameLogic");
            EncounterLayerData    encounterLayerData    = MissionControl.Instance.EncounterLayerData;
            AutoCompleteGameLogic autoCompleteGameLogic = encounterLayerData.GetComponent <AutoCompleteGameLogic>();

            if (autoCompleteGameLogic != null)
            {
                TriggeringObjectiveStatus triggeringObjectiveStatus = new TriggeringObjectiveStatus();
                ObjectiveRef objectiveRef = new ObjectiveRef();
                objectiveRef.EncounterObjectGuid          = objectiveId;
                triggeringObjectiveStatus.objective       = objectiveRef;
                triggeringObjectiveStatus.objectiveStatus = ObjectiveStatusEvaluationType.Complete;

                autoCompleteGameLogic.triggeringObjectiveList.Add(triggeringObjectiveStatus);
            }
            else
            {
                Main.LogDebugWarning($"[AddObjectiveToAutocompleteTrigger] Contract type '{MissionControl.Instance.CurrentContractType}' has no Autocomplete logic. Unable to add objective '{objectiveId}' to triggers");
            }
        }
Esempio n. 4
0
        private void BuildCompleteObjectiveResult(JObject resultObject)
        {
            Main.LogDebug("[BuildCompleteObjectiveResult] Building 'CompleteObjectiveResult' result");
            string objectiveGuid                 = resultObject["ObjectiveGuid"].ToString();
            string completionTypeStr             = (resultObject.ContainsKey("CompletionType")) ? resultObject["CompletionType"].ToString() : "Succeed";
            CompleteObjectiveType completionType = (CompleteObjectiveType)Enum.Parse(typeof(CompleteObjectiveType), completionTypeStr);

            if (objectiveGuid != null)
            {
                CompleteObjectiveResult result       = ScriptableObject.CreateInstance <CompleteObjectiveResult>();
                ObjectiveRef            objectiveRef = new ObjectiveRef();
                objectiveRef.EncounterObjectGuid = objectiveGuid;
                result.objectiveRef          = objectiveRef;
                result.completeObjectiveType = completionType;

                results.Add(result);
            }
            else
            {
                Main.Logger.LogError("[BuildCompleteObjectiveResult] You have not provided an 'ObjectiveGuid' to CompleteObjectiveResult on");
            }
        }
        public static DestroyLanceObjective CreateDestroyLanceObjective(string objectiveGuid, GameObject parent, LanceSpawnerRef lanceToDestroy, string lanceGuid, string title, bool showProgress,
                                                                        string progressFormat, string description, int priority, bool displayToUser, ObjectiveMark markUnitsWith, string contractObjectiveGameLogicGuid, bool createObjectiveOverride = true)
        {
            // TODO: Probably want to split out these two main chunks into their own methods
            // OBJECTIVE OBJECTIVE GAME LOGIC
            GameObject destroyWholeLanceObjectiveGo = CreateGameObject(parent, $"Objective_DestroyLance_{lanceGuid}");

            DestroyLanceObjective destroyLanceObjective = destroyWholeLanceObjectiveGo.AddComponent <DestroyLanceObjective>();

            destroyLanceObjective.encounterObjectGuid = objectiveGuid;
            destroyLanceObjective.title          = title;
            destroyLanceObjective.showProgress   = showProgress;
            destroyLanceObjective.progressFormat = progressFormat;
            destroyLanceObjective.description    = description;
            destroyLanceObjective.priority       = priority;
            destroyLanceObjective.displayToUser  = displayToUser;
            destroyLanceObjective.markUnitsWith  = markUnitsWith;
            destroyLanceObjective.lanceToDestroy = lanceToDestroy;

            // Rewards
            List <SimGameEventResult>           onSuccessResults = new List <SimGameEventResult>();
            List <Dictionary <string, string> > rewards          = Main.Settings.ActiveAdditionalLances.RewardsPerLance;

            foreach (Dictionary <string, string> reward in rewards)
            {
                string type  = Main.Settings.ActiveAdditionalLances.GetRewardType(reward);
                float  value = Main.Settings.ActiveAdditionalLances.GetRewardValue(reward);
                onSuccessResults.Add(CreateRewardResult(type, value));
            }

            destroyLanceObjective.OnSuccessResults  = onSuccessResults;
            destroyLanceObjective.onSuccessDialogue = new DialogueRef();
            destroyLanceObjective.onFailureDialogue = new DialogueRef();

            ContractObjectiveGameLogic contractObjectiveGameLogic = null;

            if (contractObjectiveGameLogicGuid == null)
            {
                // For ease of user we track objectives, by default, against the first contract objective
                contractObjectiveGameLogic = MissionControl.Instance.EncounterLayerData.GetComponent <ContractObjectiveGameLogic>();
            }
            else
            {
                contractObjectiveGameLogic = MissionControl.Instance.EncounterLayerData.GetContractObjectiveGameLogicByGUID(contractObjectiveGameLogicGuid);
            }

            if (contractObjectiveGameLogic == null)
            {
                Main.Logger.LogError($"[CreateDestroyLanceObjective] Contract Objective is null!");
            }

            ObjectiveRef objectiveRef = new ObjectiveRef(destroyLanceObjective);

            contractObjectiveGameLogic.objectiveRefList.Add(objectiveRef);

            // OBJECTIVE OVERRIDE - This is needed otherwise the results don't apply in the 'End Contract' screen
            // IF - the objective override is not specified in the contract override .json
            if (createObjectiveOverride)
            {
                ObjectiveOverride objectiveOverride = new ObjectiveOverride(destroyLanceObjective);
                objectiveOverride.title                 = destroyLanceObjective.title;
                objectiveOverride.description           = destroyLanceObjective.description;
                objectiveOverride.OnSuccessResults      = destroyLanceObjective.OnSuccessResults;
                objectiveOverride.OnFailureResults      = destroyLanceObjective.OnFailureResults;
                objectiveOverride.OnSuccessDialogueGUID = destroyLanceObjective.onSuccessDialogue.EncounterObjectGuid;
                objectiveOverride.OnFailureDialogueGUID = destroyLanceObjective.onFailureDialogue.EncounterObjectGuid;
                MissionControl.Instance.CurrentContract.Override.objectiveList.Add(objectiveOverride);
            }

            return(destroyLanceObjective);
        }