Ejemplo n.º 1
0
    public void OnInteractionComplete(IInteractableObject interaction, bool state)
    {
        bool allComplete = true;

        for (int i = 0; i < m_interactions.Count; ++i)
        {
            if (m_interactions[i] == interaction)
            {
                if (!hasInteracted(i) && state)
                {
                    interactionsComplete[i] = true;
                }
                else if (hasInteracted(i) && !state)
                {
                    interactionsComplete[i] = false;
                }
            }
            else if (m_type == Objective.ObjectiveType.Sequentive && state)
            {
                return;
            }

            allComplete = allComplete && hasInteracted(i);
        }

        if (allComplete)
        {
            m_state = ObjectiveState.Completed;
            m_onObjectiveComplete.Invoke();

            Debug.Log("Objective completed");

            ObjectivesManager.Instance.InitializeNextObjective();
        }
    }
Ejemplo n.º 2
0
    private void ManagersOffice()
    {
        // if the managers door has been found
        if (managersDoor.GetFoundDoor())
        {
            // disable the players controls
            fpsController.enabled = false;

            // activate the objective dialogue
            objectiveDialogue.SetActive(true);

            // update the objective UI
            if (objectiveDialogue.activeInHierarchy == true)
            {
                handlerUI.UpdateObjectiveDialogue("OBJECTIVE UPDATED", objectives[1]);
            }

            // once the objective UI has finished, disable it, change objective state and re-enable player controls
            if (Timer(ref timer, 4f, true))
            {
                objectiveDialogue.SetActive(false);
                currentObjectiveState = ObjectiveState.FindKey;
                fpsController.enabled = true;
            }
        }

        // update objective UI
        handlerUI.UpdateObjective(objectives[0]);

        // ensure screen fade is set to false
        screenFader.gameObject.SetActive(false);
    }
Ejemplo n.º 3
0
 void Start()
 {
     objectiveTimer   = 30f;
     playerCollisions = FindObjectOfType <PlayerCollisions>();
     tutorialQuit     = FindObjectOfType <TutorialQuit>();
     currentState     = ObjectiveState.Tutorial;
 }
Ejemplo n.º 4
0
    private void SwitchStates()
    {
        if (tutorialQuit.tutorialOff)
        {
            currentState = ObjectiveState.FirstObjective;
        }
        if (FirstObjectiveIsEnabled == true)
        {
            currentState = ObjectiveState.SecondObjective;
        }
        if (SecondObjectiveIsEnabled == true)
        {
            currentState = ObjectiveState.ThirdObjective;
        }
        if (ThirdObjectiveIsEnabled == true)
        {
            currentState = ObjectiveState.EndGame;

            ThirdObjective.SetActive(false);
        }
        if (playerCollisions.buildingIsHit == true)
        {
            currentState = ObjectiveState.EndGame;
        }
        if (playerCollisions.carIsHit == true)
        {
            currentState = ObjectiveState.EndGame;
        }
        if (objectiveTimer < 0)
        {
            currentState = ObjectiveState.TimesUpEnding;
        }
    }
Ejemplo n.º 5
0
        public ISerializable FromObject(object obj)
        {
            Dictionary <string, object> dictionary = obj as Dictionary <string, object>;

            if (dictionary.ContainsKey("uid"))
            {
                this.ObjectiveUid = (dictionary["uid"] as string);
            }
            if (dictionary.ContainsKey("hq"))
            {
                this.HQ = Convert.ToInt32(dictionary["hq"], CultureInfo.InvariantCulture);
            }
            if (dictionary.ContainsKey("count"))
            {
                this.Count = Convert.ToInt32(dictionary["count"], CultureInfo.InvariantCulture);
            }
            if (dictionary.ContainsKey("target"))
            {
                this.Target = Convert.ToInt32(dictionary["target"], CultureInfo.InvariantCulture);
            }
            if (dictionary.ContainsKey("state"))
            {
                this.State = StringUtils.ParseEnum <ObjectiveState>(dictionary["state"] as string);
            }
            return(this);
        }
Ejemplo n.º 6
0
 public MissionObjective(string description, string type, bool required = true)
 {
     Description = description;
     Type        = type;
     Required    = required;
     State       = ObjectiveState.Incomplete;
 }
Ejemplo n.º 7
0
 protected void InitializeObjective(bool bonus = false, ObjectiveState state = ObjectiveState.InProgress)// Initializes objectives that inherit variables, this code is never run in the objective controller
 {
     mapConfig          = GameObject.FindGameObjectWithTag("Map").GetComponent <MapConfig>();
     objectiveAnimatior = GetComponentInChildren <Animator>();
     descriptionText    = GetComponentInChildren <Text>();
     isBonus            = bonus;
     SetState(state);
 }
Ejemplo n.º 8
0
 // Use this for initialization
 protected virtual void Start()
 {
     State = PreReqs.Count > 0 ? ObjectiveState.Locked : ObjectiveState.Enabled;
     for (int i = 0; i < PreReqs.Count; i++)
     {
         PreReqs[i].dependants.Add(this);
     }
     OnStateChange();
 }
Ejemplo n.º 9
0
 public ObjectiveProgress(ObjectiveProgress cloneFrom)
 {
     this.ObjectiveUid = cloneFrom.ObjectiveUid;
     this.PlanetId     = cloneFrom.PlanetId;
     this.HQ           = cloneFrom.HQ;
     this.Count        = cloneFrom.Count;
     this.Target       = cloneFrom.Target;
     this.State        = cloneFrom.State;
 }
Ejemplo n.º 10
0
    public void SetState(ObjectiveState state)
    {
        currentState = state;

        if (currentState == ObjectiveState.Finished)
        {
            LevelLoader.Instance.GetObjective(levelNumber + 1)?.SetState(ObjectiveState.Opened);
        }

        Save();
    }
Ejemplo n.º 11
0
 // Check if prereqs are met
 private void CheckPreReqs()
 {
     State = ObjectiveState.Enabled;
     for (int i = 0; i < PreReqs.Count; i++)
     {
         if (PreReqs[i].State != ObjectiveState.Finished)
         {
             State = ObjectiveState.Locked;
         }
     }
     OnStateChange();
 }
Ejemplo n.º 12
0
    protected void DrawScript(ObjectiveScript script, ObjectiveState objective, int scriptIndex)
    {
        miniButtonStyle.stretchWidth = true;

        switch (script.GetType().Name)
        {
        //should be done with reflection
        case "ObjectiveGetQuestItem":
            ObjectiveGetQuestItem ogqe = (ObjectiveGetQuestItem)script;
            GUILayout.Label("Item Name:", MiniLabelStyle);
            ogqe.ItemName = GUILayout.TextField(ogqe.ItemName);
            break;

        case "ObjectiveConversationExchange":
            ObjectiveConversationExchange oce = (ObjectiveConversationExchange)script;
            GUILayout.Label("Conversation Name:", MiniLabelStyle);
            oce.ConversationName = GUILayout.TextField(oce.ConversationName);
            GUILayout.Label("Exchange Name:", MiniLabelStyle);
            oce.ExchangeName = GUILayout.TextField(oce.ExchangeName);
            break;

        case "ObjectiveCharacterReachQuestNode":
            ObjectiveCharacterReachQuestNode ocrqn = (ObjectiveCharacterReachQuestNode)script;
            GUILayout.Label("Character Name:", MiniLabelStyle);
            ocrqn.CharacterName = GUILayout.TextField(ocrqn.CharacterName);
            GUILayout.Label("Quest Node Name:", MiniLabelStyle);
            ocrqn.QuestNodeName = GUILayout.TextField(ocrqn.QuestNodeName);
            break;

        case "ObjectiveVisitLocation":
            ObjectiveVisitLocation ovl = (ObjectiveVisitLocation)script;
            DrawMobileReference(ovl.LocationReference);
            break;

        case "ObjectivePreventCharacterDeath":
            ObjectivePreventCharacterDeath opcd = (ObjectivePreventCharacterDeath)script;
            GUILayout.Label("Character Name:", MiniLabelStyle);
            opcd.CharacterName = GUILayout.TextField(opcd.CharacterName);
            break;

        default:
            GUILayout.Label("(Unknown script type)", MiniLabelStyle);
            break;
        }

        miniButtonStyle.stretchWidth = false;
        GUI.color = Color.red;
        if (GUILayout.Button("X"))
        {
            deleteScriptObjective        = objective;
            objectiveScriptIndexToDelete = scriptIndex;
        }
    }
Ejemplo n.º 13
0
    public void OnClick(InteractionData data)
    {
        // Find the agent who clicked our button
        AgentPrivate agent = ScenePrivate.FindAgent(data.AgentId);

        // Get the Objective data for that agent
        Objective PlayerObjective = (WaitFor(PlayerObjectiveDefinition.GetObjective, agent) as ObjectiveDefinition.GetObjectiveData).Objective;

        ObjectiveState DesiredState = LockObjective ? ObjectiveState.Locked : ObjectiveState.Active;

        WaitFor(PlayerObjective.SetState, DesiredState);
    }
Ejemplo n.º 14
0
 public void SetState(ObjectiveState objectiveState)
 {
     if (objectiveState.currentObjective != Guid.Empty)
     {
         currentObjective   = objectiveList.Where(x => x.GUID == objectiveState.currentObjective).First();
         objectiveText.text = currentObjective.objectiveReminder;
     }
     else
     {
         currentObjective   = null;
         objectiveText.text = "No Objective";
     }
 }
Ejemplo n.º 15
0
    public ObjectiveState GetState()
    {
        ObjectiveState os = new ObjectiveState();

        if (currentObjective != null)
        {
            os.currentObjective = currentObjective.GUID;
        }
        else
        {
            os.currentObjective = Guid.Empty;
        }
        return(os);
    }
Ejemplo n.º 16
0
        public bool ObjectiveCompletedByName(string missionName, string objectiveName, ref bool completed)
        {
            MissionState missionState = null;

            if (MissionStateByName(missionName, out missionState) && missionState.Status != MissionStatus.Dormant)               //<-May need to change this
            {
                ObjectiveState objectiveState = missionState.GetObjective(objectiveName);
                if (objectiveState != null)
                {
                    completed = objectiveState.Completed;
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 17
0
    void Update()
    {
        // Only allow checking for current objective. If a later objective is completed before it is available to the player,
        // it will be set to complete as soon as it is available since all of its targets are completed
        if (state == ObjectiveState.active)
        {
            if (targets != null && targets.Length > 0)
            {
                switch (kind)
                {
                case ObjectiveType.destroy:
                    progress = 0f;
                    foreach (var target in targets)
                    {
                        if (target == null || target.gameObject == null)
                        {
                            progress += 1f / targets.Length;
                        }
                    }
                    break;

                case ObjectiveType.travel:
                    progress = 0f;

                    foreach (var target in targets)
                    {
                        if (target.state == ObjectiveState.complete)
                        {
                            progress += 1f / targets.Length;
                        }
                    }
                    break;

                case ObjectiveType.talk:
                    break;

                case ObjectiveType.collect:
                    break;
                }
            }

            if (Mathf.Approximately(1f, progress) && state != ObjectiveState.complete)
            {
                state = ObjectiveState.complete;
                OnCompletedObjective();
            }
        }
    }
Ejemplo n.º 18
0
 private AnimState GetAnimStateFromObjectiveState(ObjectiveState state)
 {
     if (state == ObjectiveState.Active)
     {
         return(AnimState.Closed);
     }
     if (state == ObjectiveState.Complete)
     {
         return(AnimState.Unlocked);
     }
     if (state != ObjectiveState.Rewarded)
     {
         return(AnimState.Closed);
     }
     return(AnimState.Idle);
 }
Ejemplo n.º 19
0
        public bool ObjectiveStatusByName(string missionName, string objectiveName, ref MissionStatus status)
        {
            MissionState missionState = null;

            if (MissionStateByName(missionName, out missionState) && missionState.Status != MissionStatus.Dormant)
            {
                MissionStatus  objectiveStatus = MissionStatus.Dormant;
                ObjectiveState objectiveState  = missionState.GetObjective(objectiveName);
                if (objectiveState != null)
                {
                    status = objectiveState.Status;
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 20
0
 // Called by end points to reset the objectives
 private void ResetObjectiveHierarchy()
 {
     if (PreReqs.Count > 0)
     {
         for (int i = 0; i < PreReqs.Count; i++)
         {
             PreReqs[i].ResetObjectiveHierarchy();
         }
         State = ObjectiveState.Locked;
     }
     else
     {
         State = ObjectiveState.Enabled;
     }
     OnStateChange();
     OnReset();
 }
Ejemplo n.º 21
0
        public void EndObjective(bool loading = false)
        {
            state = ObjectiveState.Completed;
            onCompleted?.Invoke();
            onComplete?.Invoke(objectiveChoice);

            // Debug.Log("Finished objective: " + objectiveName);
            if (!loading)
            {
                Feedback.I.SendLineQueue("Finished objective: " + objectiveName,
                                         true);
                progression.FinishObjective(this);
                RemoveObjectiveTracker();
                progression.RegisterCompletedState(objectiveId);
            }
            progression.onRegisterInteractable -= OnInteractableRegistered;
        }
Ejemplo n.º 22
0
        void SetObjectiveState(SessionId sessionId, int objectiveIndex, ObjectiveState state)
        {
            var questData = WaitFor(QuestDefinition.GetQuest, sessionId) as QuestDefinition.GetQuestData;

            if (questData.Success)
            {
                var objectives = questData.Quest.Objectives;
                if (objectives.Count() > objectiveIndex)
                {
                    objectives[objectiveIndex].SetState(state);
                }
            }
            else
            {
                ChatLog(sessionId, $"Failed to get objective data");
            }
        }
Ejemplo n.º 23
0
        public void StartObjective(bool loading = false)
        {
            if (state != ObjectiveState.NotStarted)
            {
                Debug.LogWarning("Started objective in started/completed state");
            }
            state = ObjectiveState.Started;
            // Debug.Log("Started objective: " + objectiveName);
            if (!loading)
            {
                Feedback.I.SendLineQueue("Started objective: " + objectiveName, true);
            }

            progression.StartObjective(this);
            RegisterObjectiveTracker();
            onStart?.Invoke();
        }
Ejemplo n.º 24
0
        private AnimState GetAnimStateFromObjectiveState(ObjectiveState state)
        {
            switch (state)
            {
            case ObjectiveState.Active:
                return(AnimState.Closed);

            case ObjectiveState.Complete:
                return(AnimState.Unlocked);

            case ObjectiveState.Rewarded:
                return(AnimState.Idle);

            default:
                return(AnimState.Closed);
            }
        }
Ejemplo n.º 25
0
    void Update()
    {
        // Only allow checking for current objective. If a later objective is completed before it is available to the player, 
        // it will be set to complete as soon as it is available since all of its targets are completed
        if (state == ObjectiveState.active)
        {
            if (targets != null && targets.Length > 0)
            {
                switch (kind)
                {
                    case ObjectiveType.destroy:
                        progress = 0f;
                        foreach (var target in targets)
                        {
                            if (target == null || target.gameObject == null)
                            {
                                progress += 1f / targets.Length;
                            }
                        }
                        break;
                    case ObjectiveType.travel:
                        progress = 0f;

                        foreach (var target in targets)
                        {
                            if (target.state == ObjectiveState.complete)
                            {
                                progress += 1f / targets.Length;
                            }
                        }
                        break;
                    case ObjectiveType.talk:
                        break;
                    case ObjectiveType.collect:
                        break;
                }
            }

            if (Mathf.Approximately(1f, progress) && state != ObjectiveState.complete)
            {
                state = ObjectiveState.complete;
                OnCompletedObjective();
            }
        }
    }
Ejemplo n.º 26
0
        private string ObjectifStateInFrench(ObjectiveState state)
        {
            switch (state)
            {
            case ObjectiveState.ABANDON:
                return("Abandont");

            case ObjectiveState.FAILLURE:
                return("Échec");

            case ObjectiveState.IN_PURSUIT:
                return("En poursuite");

            case ObjectiveState.SUCCESS:
                return("Succès");
            }
            throw new InvalidOperationException($"Cant translate the ObjectiveState {state}");
        }
Ejemplo n.º 27
0
    private void StartObjective()
    {
        // if not skipping the start
        if (skipStart == false)
        {
            // disable player controls
            fpsController.enabled = false;

            // if intro narrative is done and the screen has faded in
            if (narrativeDialogue.IntroNarrativeDone() && screenFader.FadeDone())
            {
                // if the timer until the start of the first mission is done
                if (Timer(ref timer, startToFirstMissionTime, false))
                {
                    // start the objective dialogue
                    objectiveDialogue.SetActive(true);

                    // if objective dialogue is true, update it's UI
                    if (objectiveDialogue.activeInHierarchy == true)
                    {
                        handlerUI.UpdateObjectiveDialogue("OBJECTIVE UPDATED", objectives[0]);
                    }
                }

                // if the timer has reached 4 seconds
                if (Timer(ref timer, 4f, true))
                {
                    // set objective dialogue to false change objective state and enable player controls
                    objectiveDialogue.SetActive(false);
                    currentObjectiveState = ObjectiveState.ManagerOffice;
                    fpsController.enabled = true;
                }
            }

            // start the intro narrative
            narrativeDialogue.StartIntroNarrative();
        }
        else
        {
            currentObjectiveState = ObjectiveState.ManagerOffice;
            fpsController.enabled = true;
        }
    }
Ejemplo n.º 28
0
    public void OnClick(InteractionData data)
    {
        // Find the agent who clicked our button
        AgentPrivate agent = ScenePrivate.FindAgent(data.AgentId);

        // Get the Quest data for that agent
        Quest PlayerQuest = (WaitFor(PlayerQuestDefinition.GetQuest, agent) as QuestDefinition.GetQuestData).Quest;

        // Reset the state of each objective in the quest
        for (int i = 0; i < PlayerQuest.Objectives.Length; i++)
        {
            Objective      PlayerObjective = PlayerQuest.Objectives[i];
            ObjectiveState DesiredState    = (i == 0 ? ObjectiveState.Active : ObjectiveState.Locked);
            WaitFor(PlayerObjective.SetState, DesiredState);
        }

        // Re-offer the quest
        WaitFor(PlayerQuest.SetState, QuestState.Offered);
    }
Ejemplo n.º 29
0
    public void DrawObjective(ObjectiveState objective, ObjectiveState parentObjective, int currentChildObjective, int depth)
    {
        Color mainColor = Color.white;

        GUI.color = mainColor;
        GUILayout.BeginHorizontal();
        GUILayout.Space(depth * 20);

        mainColor = Color.cyan;
        if (objective.Completed || Flags.Check((uint)objective.Status, (uint)MissionStatus.Active, Flags.CheckType.MatchAll))
        {
            mainColor = Color.Lerp(mainColor, Color.green, 0.5f);
        }
        if (Flags.Check((uint)objective.Status, (uint)MissionStatus.Completed, Flags.CheckType.MatchAll))
        {
            mainColor = Color.Lerp(mainColor, Color.green, 0.5f);
        }
        if (Flags.Check((uint)objective.Status, (uint)MissionStatus.Failed, Flags.CheckType.MatchAll))
        {
            mainColor = Color.Lerp(mainColor, Color.red, 0.5f);
        }

        if (GUILayout.Button(objective.Name + " (" + objective.FileName + ")"))
        {
            if (objective.Status == MissionStatus.Dormant)
            {
                objective.ParentObjective.mission.ActivateObjective(objective.FileName, MissionOriginType.None, string.Empty);
            }
            else
            {
                objective.ParentObjective.ForceComplete();
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Space(depth * 20);
        GUILayout.Label("Completed: " + objective.Completed.ToString());
        GUILayout.Label("Status: " + objective.Status.ToString());
        GUILayout.EndHorizontal();
    }
Ejemplo n.º 30
0
    public void DrawMission(Mission mission)
    {
        //GUILayout.FlexibleSpace ();
        GUILayout.BeginHorizontal();
        GUI.color = Color.cyan;
        if (mission.State.ObjectivesCompleted)
        {
            GUI.color = Color.green;
        }

        if (GUILayout.Button("Title: " + mission.State.Title + " (Click to complete)"))
        {
            mission.ForceComplete();
        }
        GUILayout.Label("Objectives Complted: " + mission.State.ObjectivesCompleted.ToString());
        GUILayout.Label("State: " + mission.State.Status.ToString());
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("MISSION VARIABLES:");
        foreach (KeyValuePair <string, int> mv in mission.State.Variables)
        {
            GUI.color = Colors.ColorFromString(mv.Key, 200);
            GUILayout.Label(mv.Key + ": " + mv.Value.ToString() + " - ");
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginVertical();
        GUILayout.Label("MISSION OBJECTIVES:");

        int           depth          = 1;
        List <string> objectiveNames = mission.State.GetObjectiveNames();

        for (int i = 0; i < objectiveNames.Count; i++)
        {
            ObjectiveState objective = mission.State.GetObjective(objectiveNames[i]);
            DrawObjective(objective, null, 0, depth);
        }
        GUILayout.EndVertical();
    }
Ejemplo n.º 31
0
    public void SetState(ObjectiveState state)
    {
        switch (state)
        {
        case ObjectiveState.Inactive:
            gameObject.SetActive(false);
            break;

        case ObjectiveState.Active:
            gameObject.SetActive(true);
            tick.SetActive(false);
            break;

        case ObjectiveState.Completed:
            gameObject.SetActive(true);
            tick.SetActive(true);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 32
0
 public virtual void OnStart()
 {
     State = ObjectiveState.InProgress;
 }
Ejemplo n.º 33
0
		public MissionObjective(ObjectiveType type, string description)
		{
			Type = type;
			Description = description;
			State = ObjectiveState.Incomplete;
		}
Ejemplo n.º 34
0
        private void SetObjectiveState(Objective objective, ObjectiveState state)
        {
            if (objective == null)
            {
                return;
            }

            objective.State = state;

            // Apply events.
            if (objective.State == ObjectiveState.Active)
            {
                var teleportOnActive = objective.GameObject.GetComponent<TeleportOnActiveComponent>();
                if (teleportOnActive != null)
                {
                    this.Player.transform.position = teleportOnActive.Destination.transform.position;
                    this.LevelSettings.PlayerSpeed = teleportOnActive.NewPlayerSpeed;
                }
            }
            else if (objective.State == ObjectiveState.Complete)
            {
                var teleportOnComplete = objective.GameObject.GetComponent<TeleportOnCompleteComponent>();
                if (teleportOnComplete != null)
                {
                    this.Player.transform.position = teleportOnComplete.Destination.transform.position;
                    this.LevelSettings.PlayerSpeed = teleportOnComplete.NewPlayerSpeed;
                }
            }

            if (objective.State == ObjectiveState.Active)
            {
                this.SetCurrentObjective(objective);
            }

            // Notify listeners.
            this.EventManager.OnObjectiveStateChanged(
                this,
                new ObjectiveStateChangedEventArgs
                {
                    CompletedObjectives = this.objectives.Count(obj => obj.State == ObjectiveState.Complete),
                    Objective = objective.GameObject,
                    State = state,
                    TotalObjectives = this.objectives.Count
                });

            Debug.Log(string.Format("Objective {0} changed to {1}.", objective, state));
        }
	public void OnInteractionComplete(IInteractableObject interaction, bool state )
	{
        bool allComplete = true;
        
        for (int i = 0; i < m_interactions.Count; ++i)
        {
            if (m_interactions[i] == interaction)
            {
                if (!hasInteracted(i) && state)
                    interactionsComplete[i] = true;
                else if (hasInteracted(i) && !state)
                    interactionsComplete[i] = false;
            }
            else if (m_type == Objective.ObjectiveType.Sequentive && state)
            {
                return;
            }

            allComplete = allComplete && hasInteracted(i);
        }
       
		if( allComplete )
		{
			m_state = ObjectiveState.Completed;
			m_onObjectiveComplete.Invoke();

			Debug.Log("Objective completed");

			ObjectivesManager.Instance.InitializeNextObjective();
		}
	}