Esempio n. 1
0
        public override ActionEnd End(List <Action> actions)
        {
            if (numSockets <= 1)
            {
                return(GenerateStopActionEnd());
            }

            Objective objective = KickStarter.inventoryManager.GetObjective(objectiveID);

            if (objective != null)
            {
                int _playerID = (setPlayer && KickStarter.inventoryManager.ObjectiveIsPerPlayer(objectiveID)) ? playerID : -1;

                ObjectiveState currentObjectiveState = KickStarter.runtimeObjectives.GetObjectiveState(objectiveID, _playerID);
                if (currentObjectiveState != null)
                {
                    int stateIndex = objective.states.IndexOf(currentObjectiveState);
                    return(ProcessResult(stateIndex + 1, actions));
                }
                else
                {
                    return(ProcessResult(0, actions));
                }
            }
            return(GenerateStopActionEnd());
        }
Esempio n. 2
0
        protected void SwapStates(int a1, int a2)
        {
            ObjectiveState tempState = states[a1];

            states[a1] = states[a2];
            states[a2] = tempState;
        }
Esempio n. 3
0
        protected void MoveStateToBottom(int a1)
        {
            ObjectiveState tempState = states[a1];

            states.Add(tempState);
            states.RemoveAt(a1);
        }
Esempio n. 4
0
        protected void MoveStateToTop(int a1)
        {
            ObjectiveState tempState = states[a1];

            states.Insert(1, tempState);
            states.RemoveAt(a1 + 1);
        }
        public override ActionEnd End(List <Action> actions)
        {
            Objective objective = KickStarter.inventoryManager.GetObjective(objectiveID);

            if (objective != null)
            {
                int _playerID = (setPlayer && KickStarter.inventoryManager.ObjectiveIsPerPlayer(objectiveID)) ? playerID : -1;

                ObjectiveState currentObjectiveState = KickStarter.runtimeObjectives.GetObjectiveState(objectiveID, _playerID);
                if (currentObjectiveState != null)
                {
                    return(ProcessResult((int)currentObjectiveState.stateType, actions));
                }
            }
            return(ProcessResult(0, actions));
        }
Esempio n. 6
0
        public void ShowGUI(string apiPrefix)
        {
            if (Application.isPlaying && KickStarter.runtimeObjectives != null)
            {
                ObjectiveState currentState = KickStarter.runtimeObjectives.GetObjectiveState(ID);
                if (currentState != null)
                {
                    EditorGUILayout.LabelField("Current state::", currentState.ID + ": " + currentState.Label, EditorStyles.boldLabel);
                }
                else
                {
                    EditorGUILayout.LabelField("Current state:", "INACTIVE", EditorStyles.boldLabel);
                }
                EditorGUILayout.Space();
            }

            title = CustomGUILayout.TextField("Title:", title, apiPrefix + ".title");
            if (titleLineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", titleLineID.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());
            }

            if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                perPlayer = CustomGUILayout.Toggle("Per-Player?", perPlayer, apiPrefix + ".perPlayer");
            }

            texture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> ("Texture:", texture, false, apiPrefix + ".texture");
            lockStateWhenComplete = CustomGUILayout.Toggle("Lock state when complete?", lockStateWhenComplete, apiPrefix + ".lockStateWhenComplete");
            lockStateWhenFail     = CustomGUILayout.Toggle("Lock state when fail?", lockStateWhenFail, apiPrefix + ".lockStateWhenFail");

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Objective states:");

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(states.Count * 21, 185f) + 5));
            for (int i = 0; i < states.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();

                ObjectiveState thisState = states[i];
                if (GUILayout.Toggle(selectedState == i, thisState.ID.ToString() + ": " + thisState.Label, "Button"))
                {
                    if (selectedState != i)
                    {
                        selectedState = i;
                        EditorGUIUtility.editingTextField = false;
                    }
                }

                if (GUILayout.Button(string.Empty, CustomStyles.IconCog))
                {
                    sideState = i;
                    EditorGUIUtility.editingTextField = false;
                    SideStateMenu();
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("Create new state"))
            {
                Undo.RecordObject(KickStarter.inventoryManager, "Add Objective state");
                states.Add(new ObjectiveState(GetStateIDArray()));
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            if (selectedState >= 0 && states.Count > selectedState)
            {
                EditorGUILayout.BeginVertical("Button");
                showStateGUI = CustomGUILayout.ToggleHeader(showStateGUI, "State #" + states[selectedState].ID.ToString() + ": " + states[selectedState].Label);
                if (showStateGUI)
                {
                    states[selectedState].ShowGUI(apiPrefix + ".states[" + selectedState.ToString() + "].");
                }
                EditorGUILayout.EndVertical();
            }
        }