Пример #1
0
        public void ShowGUI(string apiPrefix)
        {
            label = CustomGUILayout.TextField("Label:", label, apiPrefix + ".label");
            if (labelLineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", labelLineID.ToString());
            }

            if (ID >= 2)
            {
                stateType = (ObjectiveStateType)CustomGUILayout.EnumPopup("State type:", stateType, apiPrefix + ".stateType");
            }
            else
            {
                EditorGUILayout.LabelField("State type: " + stateType.ToString());
            }

            EditorGUILayout.BeginHorizontal();
            CustomGUILayout.LabelField("Description:", GUILayout.Width(140f), apiPrefix + ".description");
            EditorStyles.textField.wordWrap = true;
            description = CustomGUILayout.TextArea(description, GUILayout.MaxWidth(800f), apiPrefix + ".description");
            EditorGUILayout.EndHorizontal();
            if (descriptionLineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", descriptionLineID.ToString());
            }
        }
Пример #2
0
 public ObjectiveState(int _ID, string _label, ObjectiveStateType _stateType)
 {
     ID                = _ID;
     stateType         = _stateType;
     label             = _label;
     labelLineID       = -1;
     description       = string.Empty;
     descriptionLineID = -1;
 }
Пример #3
0
        public ObjectiveState(int[] idArray)
        {
            stateType         = ObjectiveStateType.Active;
            label             = string.Empty;
            labelLineID       = -1;
            description       = string.Empty;
            descriptionLineID = -1;

            ID = 0;
            // Update id based on array
            foreach (int _id in idArray)
            {
                if (ID == _id)
                {
                    ID++;
                }
            }
        }
Пример #4
0
        /**
         * <summary>Gets all active Objective instances currently set to a particular type of state</summary>
         * <param name = "objectiveStateType">The type of state to search for</param>
         * <returns>All active Objective instances set to the type of state</returns>
         */
        public ObjectiveInstance[] GetObjectives(ObjectiveStateType objectiveStateType)
        {
            List <ObjectiveInstance> completedObjectives = new List <ObjectiveInstance>();

            foreach (ObjectiveInstance objectiveInstance in playerObjectiveInstances)
            {
                if (objectiveInstance.CurrentState.stateType == objectiveStateType)
                {
                    completedObjectives.Add(objectiveInstance);
                }
            }
            foreach (ObjectiveInstance objectiveInstance in globalObjectiveInstances)
            {
                if (objectiveInstance.CurrentState.stateType == objectiveStateType)
                {
                    completedObjectives.Add(objectiveInstance);
                }
            }
            return(completedObjectives.ToArray());
        }
Пример #5
0
        /**
         * <summary>Updates the state of an Objective</summary>
         * <param name = "objectiveID">The ID of the Objective to update</param>
         * <param name = "newStateType">The ObjectiveStateType of the Objective's new state. If not states of this type are found, no change will be made.  If multiple states of this type are found, the first will be set.</param>
         * <param name = "selectAfter">If True, the Objective will be considered 'selected' upon being updated</param>
         */
        public void SetObjectiveState(int objectiveID, ObjectiveStateType newStateType, bool selectAfter = false)
        {
            int       newStateID = -1;
            Objective objective  = KickStarter.inventoryManager.GetObjective(objectiveID);

            if (objective == null)
            {
                return;
            }

            foreach (ObjectiveState state in objective.states)
            {
                if (state.stateType == newStateType)
                {
                    newStateID = state.ID;
                }
            }

            if (newStateID < 0)
            {
                return;
            }

            foreach (ObjectiveInstance objectiveInstance in playerObjectiveInstances)
            {
                if (objectiveInstance.Objective.ID == objectiveID)
                {
                    objectiveInstance.CurrentStateID = newStateID;
                    if (selectAfter)
                    {
                        SelectedObjective = objectiveInstance;
                    }
                    return;
                }
            }

            foreach (ObjectiveInstance objectiveInstance in globalObjectiveInstances)
            {
                if (objectiveInstance.Objective.ID == objectiveID)
                {
                    objectiveInstance.CurrentStateID = newStateID;
                    if (selectAfter)
                    {
                        SelectedObjective = objectiveInstance;
                    }
                    return;
                }
            }

            ObjectiveInstance newObjectiveInstance = new ObjectiveInstance(objectiveID, newStateID);

            if (newObjectiveInstance.Objective != null)
            {
                if (newObjectiveInstance.Objective.perPlayer && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    playerObjectiveInstances.Add(newObjectiveInstance);
                }
                else
                {
                    globalObjectiveInstances.Add(newObjectiveInstance);
                }
                if (selectAfter)
                {
                    SelectedObjective = newObjectiveInstance;
                }
                KickStarter.eventManager.Call_OnObjectiveUpdate(newObjectiveInstance);
            }
            else
            {
                ACDebug.LogWarning("Cannot set the state of objective " + objectiveID + " because that ID does not exist!");
            }
        }