private static void HierarchyItemCB(int instanceID, Rect selectionRect)
        {
            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& !AdvGame.GetReferences().settingsManager.showHierarchyIcons)
            {
                return;
            }

            // place the icon to the right of the list:
            Rect r = new Rect(selectionRect);

            r.x     = r.width + defaultOffset + ACEditorPrefs.HierarchyIconOffset;
            r.width = iconWidth;

            if (actionListIDs != null && actionListIDs.Contains(instanceID))
            {
                foreach (ActionList actionList in actionLists)
                {
                    if (actionList != null && actionList.gameObject.GetInstanceID() == instanceID)
                    {
                        if (GUI.Button(r, string.Empty, CustomStyles.IconNodes))
                        {
                            ActionListEditorWindow.Init(actionList);

                            if (actionList.gameObject.GetComponents <ActionList>().Length > 1)
                            {
                                ACDebug.Log("Multiple ActionLists are attached to the GameObject '" + actionList.gameObject.name + "' - only the first-found will be opened when clicking the Hierarchy node icon.", actionList.gameObject);
                            }
                            return;
                        }
                    }
                }
            }

            r.x -= rememberOffset;
            if (rememberIDs != null && rememberIDs.Contains(instanceID))
            {
                foreach (ConstantID constantID in constantIDs)
                {
                    if (constantID != null && constantID.gameObject.GetInstanceID() == instanceID)
                    {
                        GUI.Label(r, string.Empty, CustomStyles.IconSave);
                        return;
                    }
                }
            }
        }
Exemple #2
0
        private void ShowLocateButton(int languageIndex, bool forLipSync = false)
        {
            if (GUILayout.Button("Ping file"))
            {
                string language = (languageIndex == 0) ? string.Empty : AdvGame.GetReferences().speechManager.languages[languageIndex];
                string fullName = string.Empty;

                Object foundClp = null;

                if (KickStarter.settingsManager != null && SeparatePlayerAudio())
                {
                    foreach (PlayerPrefab player in KickStarter.settingsManager.players)
                    {
                        if (player != null && player.playerOb != null)
                        {
                            fullName = GetAutoAssetPathAndName(language, forLipSync, player.playerOb.name);

                            if (forLipSync)
                            {
                                if (KickStarter.speechManager.lipSyncMode == LipSyncMode.RogoLipSync)
                                {
                                    Object lipSyncFile = RogoLipSyncIntegration.GetObjectToPing(fullName);
                                    if (lipSyncFile != null)
                                    {
                                        foundClp = lipSyncFile;
                                    }
                                }
                                else
                                {
                                    TextAsset textFile = Resources.Load(fullName) as TextAsset;
                                    if (textFile != null)
                                    {
                                        foundClp = textFile;
                                    }
                                }
                            }
                            else
                            {
                                AudioClip clipObj = Resources.Load(fullName) as AudioClip;
                                if (clipObj != null)
                                {
                                    foundClp = clipObj;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    fullName = GetAutoAssetPathAndName(language, forLipSync);

                    if (forLipSync)
                    {
                        if (KickStarter.speechManager.lipSyncMode == LipSyncMode.RogoLipSync)
                        {
                            foundClp = RogoLipSyncIntegration.GetObjectToPing(fullName);
                        }
                        else
                        {
                            TextAsset textFile = Resources.Load(fullName) as TextAsset;
                            foundClp = textFile;
                        }
                    }
                    else
                    {
                        AudioClip clipObj = Resources.Load(fullName) as AudioClip;
                        foundClp = clipObj;
                    }
                }

                if (foundClp != null)
                {
                    EditorGUIUtility.PingObject(foundClp);
                }
                else
                {
                    ACDebug.Log(((forLipSync) ? "Text" : "Audio") + " file '/Resources/" + fullName + "' was found.");
                }
            }
        }
Exemple #3
0
        /**
         * Detects Hotspots in its vicinity. This is public so that it can be called by StateHandler every frame.
         */
        public void _Update()
        {
            if (nearestHotspot && nearestHotspot.gameObject.layer == LayerMask.NameToLayer(AdvGame.GetReferences().settingsManager.deactivatedLayer))
            {
                nearestHotspot = null;
            }

            if (KickStarter.stateHandler != null && KickStarter.stateHandler.IsInGameplay())
            {
                if (KickStarter.playerInput.InputGetButtonDown("CycleHotspotsLeft"))
                {
                    CycleHotspots(false);
                }
                else if (KickStarter.playerInput.InputGetButtonDown("CycleHotspotsRight"))
                {
                    CycleHotspots(true);
                }
                else if (KickStarter.playerInput.InputGetAxis("CycleHotspots") > 0.1f)
                {
                    CycleHotspots(true);
                }
                else if (KickStarter.playerInput.InputGetAxis("CycleHotspots") < -0.1f)
                {
                    CycleHotspots(false);
                }
            }
        }
        private int CreateInventoryGUI(int invID)
        {
            if (AdvGame.GetReferences().inventoryManager == null || AdvGame.GetReferences().inventoryManager.items == null || AdvGame.GetReferences().inventoryManager.items.Count == 0)
            {
                EditorGUILayout.HelpBox("Cannot find any inventory items!", MessageType.Warning);
                return(invID);
            }

            // Create a string List of the field's names (for the PopUp box)
            List <string> labelList = new List <string>();
            int           invNumber = -1;
            int           i         = 0;

            if (AdvGame.GetReferences().inventoryManager.items.Count > 0)
            {
                foreach (InvItem _item in AdvGame.GetReferences().inventoryManager.items)
                {
                    labelList.Add(_item.label);

                    // If a item has been removed, make sure selected variable is still valid
                    if (_item.id == invID)
                    {
                        invNumber = i;
                    }
                    i++;
                }

                if (invNumber == -1)
                {
                    ACDebug.Log("Previously chosen item no longer exists!");
                    invNumber = 0;
                    invID     = 0;
                }
                else
                {
                    invNumber = CustomGUILayout.Popup("Linked inventory item:", invNumber, labelList.ToArray(), "", "The inventory item that the player must be carrying for the option to be active");
                    invID     = AdvGame.GetReferences().inventoryManager.items[invNumber].id;
                }
            }

            return(invID);
        }
Exemple #5
0
        /**
         * <summary>Displays the GUI of the class's entry within the Speech Manager.</summary>
         */
        public void ShowGUI()
        {
            SpeechManager speechManager = AdvGame.GetReferences().speechManager;
            string        apiPrefix     = "KickStarter.speechManager.GetLine (" + lineID + ")";

            if (lineID == speechManager.activeLineID)
            {
                EditorGUILayout.BeginVertical("Button");

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField("ID #:", GUILayout.Width(85f));
                EditorGUILayout.LabelField(lineID.ToString(), GUILayout.MaxWidth(570f));

                if ((textType == AC_TextType.Speech || textType == AC_TextType.DialogueOption) && GUILayout.Button("Locate source", GUILayout.MaxWidth(100)))
                {
                    KickStarter.speechManager.LocateLine(this);
                }
                EditorGUILayout.EndHorizontal();

                ShowField("Type:", textType.ToString(), false, apiPrefix + ".textType", "The type of text this is.");
                ShowField("Original text:", text, true, apiPrefix + ".text", "The original text as recorded during the 'Gather text' process");

                string sceneName = scene.Replace("Assets/", string.Empty);
                sceneName = sceneName.Replace(".unity", string.Empty);
                ShowField("Scene:", sceneName, true, apiPrefix + ".scene", "The name of the scene that the text was found in");

                if (textType == AC_TextType.Speech)
                {
                    ShowField("Speaker:", GetSpeakerName(), false, apiPrefix + ".owner", "The character who says the line");
                }

                if (speechManager.languages != null && speechManager.languages.Count > 1)
                {
                    for (int i = 0; i < speechManager.languages.Count; i++)
                    {
                        if (i == 0)
                        {
                            if (speechManager.languages.Count > 1 && speechManager.translateAudio && !speechManager.ignoreOriginalText && textType == AC_TextType.Speech)
                            {
                                EditorGUILayout.Space();
                                EditorGUILayout.LabelField("Original language:");
                            }
                        }
                        else if (translationText.Count > (i - 1))
                        {
                            translationText [i - 1] = EditField(speechManager.languages[i] + ":", translationText [i - 1], true, "", "The display text in '" + speechManager.languages[i] + "'");
                        }
                        else
                        {
                            ShowField(speechManager.languages[i] + ":", "(Not defined)", false);
                        }

                        if (speechManager.translateAudio && textType == AC_TextType.Speech)
                        {
                            string language = string.Empty;
                            if (i > 0)
                            {
                                language = speechManager.languages[i];
                            }
                            else if (speechManager.ignoreOriginalText && speechManager.languages.Count > 1)
                            {
                                continue;
                            }

                            if (speechManager.autoNameSpeechFiles)
                            {
                                if (SeparatePlayerAudio() && speechManager.placeAudioInSubfolders)
                                {
                                    for (int j = 0; j < KickStarter.settingsManager.players.Count; j++)
                                    {
                                        if (KickStarter.settingsManager.players[j].playerOb)
                                        {
                                            if (speechManager.UseFileBasedLipSyncing())
                                            {
                                                ShowField("Lipsync path " + j.ToString() + ":", GetFolderName(language, true, KickStarter.settingsManager.players[j].playerOb.name), false);
                                            }
                                            ShowField("Audio Path " + j.ToString() + ":", GetFolderName(language, false, KickStarter.settingsManager.players[j].playerOb.name), false);
                                        }
                                    }
                                }
                                else
                                {
                                    if (speechManager.useAssetBundles)
                                    {
                                        if (speechManager.UseFileBasedLipSyncing())
                                        {
                                            if (!string.IsNullOrEmpty(speechManager.languageLipsyncAssetBundles[i]))
                                            {
                                                ShowField(" (Lipsync AB):", "StreamingAssets/" + speechManager.languageLipsyncAssetBundles[i], false);
                                            }
                                        }

                                        if (!string.IsNullOrEmpty(speechManager.languageAudioAssetBundles[i]))
                                        {
                                            ShowField(" (Audio AB):", "StreamingAssets/" + speechManager.languageAudioAssetBundles[i], false);
                                        }
                                    }
                                    else
                                    {
                                        if (speechManager.UseFileBasedLipSyncing())
                                        {
                                            EditorGUILayout.BeginHorizontal();
                                            ShowField(" (Lipsync path):", GetFolderName(language, true), false);
                                            ShowLocateButton(i, true);
                                            EditorGUILayout.EndHorizontal();
                                        }

                                        EditorGUILayout.BeginHorizontal();
                                        ShowField(" (Audio path):", GetFolderName(language), false);
                                        ShowLocateButton(i);
                                        EditorGUILayout.EndHorizontal();
                                    }
                                }
                            }
                            else
                            {
                                if (i > 0)
                                {
                                    SetCustomArraySizes(speechManager.languages.Count - 1);
                                    if (speechManager.UseFileBasedLipSyncing())
                                    {
                                        customTranslationLipsyncFiles[i - 1] = EditField <Object> ("Lipsync file:", customTranslationLipsyncFiles[i - 1], apiPrefix + ".customTranslationLipsyncFiles[i-1]", "The text file to use for lipsyncing when the language is '" + KickStarter.speechManager.languages[i - 1] + "'");
                                    }
                                    customTranslationAudioClips[i - 1] = EditField <AudioClip> ("Audio clip:", customTranslationAudioClips[i - 1], apiPrefix + ".customTranslationAudioClips[i-1]", "The voice AudioClip to play when the language is '" + KickStarter.speechManager.languages[i - 1] + "'");
                                }
                                else
                                {
                                    if (speechManager.UseFileBasedLipSyncing())
                                    {
                                        customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile", "The text file to use for lipsyncing in the original language");
                                    }
                                    customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip", "The voice AudioClip to play in the original language");
                                }
                            }

                            EditorGUILayout.Space();
                        }
                    }
                }

                // Original language
                if (textType == AC_TextType.Speech)
                {
                    if (speechManager.languages == null || speechManager.languages.Count <= 1 || !speechManager.translateAudio)
                    {
                        if (speechManager.autoNameSpeechFiles)
                        {
                            if (SeparatePlayerAudio() && speechManager.placeAudioInSubfolders)
                            {
                                for (int i = 0; i < KickStarter.settingsManager.players.Count; i++)
                                {
                                    if (KickStarter.settingsManager.players[i].playerOb)
                                    {
                                        if (speechManager.UseFileBasedLipSyncing())
                                        {
                                            ShowField("Lipsync path " + i.ToString() + ":", GetFolderName(string.Empty, true, KickStarter.settingsManager.players[i].playerOb.name), false, "", "The filepath to the text asset file to rely on for Lipsyncing");
                                        }
                                        ShowField("Audio Path " + i.ToString() + ":", GetFolderName(string.Empty, false, KickStarter.settingsManager.players[i].playerOb.name), false, "", "The filepath to the voice AudioClip asset file to play");
                                    }
                                }
                            }
                            else
                            {
                                if (speechManager.useAssetBundles)
                                {
                                    if (speechManager.UseFileBasedLipSyncing())
                                    {
                                        if (!string.IsNullOrEmpty(speechManager.languageLipsyncAssetBundles[0]))
                                        {
                                            ShowField("Lipsync AB:", "StreamingAssets/" + speechManager.languageLipsyncAssetBundles[0], false);
                                        }
                                    }

                                    if (!string.IsNullOrEmpty(speechManager.languageAudioAssetBundles[0]))
                                    {
                                        ShowField("Audio AB:", "StreamingAssets/" + speechManager.languageAudioAssetBundles[0], false);
                                    }
                                }
                                else
                                {
                                    if (speechManager.UseFileBasedLipSyncing())
                                    {
                                        EditorGUILayout.BeginHorizontal();
                                        ShowField("Lipsync path:", GetFolderName(string.Empty, true), false);
                                        ShowLocateButton(0, true);
                                        EditorGUILayout.EndHorizontal();
                                    }

                                    EditorGUILayout.BeginHorizontal();
                                    ShowField("Audio Path:", GetFolderName(string.Empty), false);
                                    ShowLocateButton(0);
                                    EditorGUILayout.EndHorizontal();
                                }
                            }
                        }
                        else
                        {
                            if (speechManager.UseFileBasedLipSyncing())
                            {
                                customLipsyncFile = EditField <Object> ("Lipsync file:", customLipsyncFile, apiPrefix + ".customLipsyncFile", "The text file to use for lipsyncing in the original language");
                            }
                            customAudioClip = EditField <AudioClip> ("Audio clip:", customAudioClip, apiPrefix + ".customAudioClip", "The voice AudioClip to play in the original language");
                        }
                    }

                    if (speechManager.autoNameSpeechFiles)
                    {
                        if (SeparatePlayerAudio())
                        {
                            for (int i = 0; i < KickStarter.settingsManager.players.Count; i++)
                            {
                                if (KickStarter.settingsManager.players[i].playerOb)
                                {
                                    ShowField("Filename " + i.ToString() + ":", GetFilename(KickStarter.settingsManager.players[i].playerOb.name) + lineID.ToString(), false);
                                }
                            }
                        }
                        else
                        {
                            ShowField("Filename:", GetFilename() + lineID.ToString(), false);
                        }
                    }

                    if (tagID >= 0 && speechManager.useSpeechTags)
                    {
                        SpeechTag speechTag = speechManager.GetSpeechTag(tagID);
                        if (speechTag != null && speechTag.label.Length > 0)
                        {
                            ShowField("Tag: ", speechTag.label, false, apiPrefix + ".tagID");
                        }
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(new GUIContent("Only say once?", "If True, then this line can only be spoken once. Additional calls to play it will be ignored."), GUILayout.Width(85f));
                    onlyPlaySpeechOnce = CustomGUILayout.Toggle(onlyPlaySpeechOnce, GUILayout.MaxWidth(570f), apiPrefix + ".onlyPlaySpeechOnce");
                    EditorGUILayout.EndHorizontal();
                }

                if (SupportsDescriptions())
                {
                    description = EditField("Description:", description, true, apiPrefix + ".description", "An Editor-only description");
                }

                EditorGUILayout.EndVertical();
            }
            else
            {
                if (GUILayout.Button(lineID.ToString() + ": '" + GetShortText() + "'", EditorStyles.label, GUILayout.MaxWidth(300)))
                {
                    speechManager.activeLineID        = lineID;
                    EditorGUIUtility.editingTextField = false;
                }
                GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));
            }
        }
        public override void OnInspectorGUI()
        {
            if (AdvGame.GetReferences() == null)
            {
                ACDebug.LogError("A References file is required - please use the Adventure Creator window to create one.");
                EditorGUILayout.LabelField("No References file found!");
            }
            else
            {
                if (AdvGame.GetReferences().inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences().inventoryManager;
                }
                if (AdvGame.GetReferences().cursorManager)
                {
                    cursorManager = AdvGame.GetReferences().cursorManager;
                }
                if (AdvGame.GetReferences().settingsManager)
                {
                    settingsManager = AdvGame.GetReferences().settingsManager;
                }

                if (Application.isPlaying)
                {
                    if (_target.gameObject.layer != LayerMask.NameToLayer(settingsManager.hotspotLayer))
                    {
                        EditorGUILayout.HelpBox("Current state: OFF", MessageType.Info);
                    }
                }

                if (_target.lineID > -1)
                {
                    EditorGUILayout.LabelField("Speech Manager ID:", _target.lineID.ToString());
                }

                _target.interactionSource = (InteractionSource)EditorGUILayout.EnumPopup("Interaction source:", _target.interactionSource);
                _target.hotspotName       = EditorGUILayout.TextField("Label (if not name):", _target.hotspotName);
                _target.highlight         = (Highlight)EditorGUILayout.ObjectField("Object to highlight:", _target.highlight, typeof(Highlight), true);
                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.hotspotDrawing == ScreenWorld.WorldSpace)
                {
                    _target.iconSortingLayer = EditorGUILayout.TextField("Icon sorting layer:", _target.iconSortingLayer);
                    _target.iconSortingOrder = EditorGUILayout.IntField("Icon sprite order:", _target.iconSortingOrder);
                }

                EditorGUILayout.BeginHorizontal();
                _target.centrePoint = (Transform)EditorGUILayout.ObjectField("Centre point (override):", _target.centrePoint, typeof(Transform), true);

                if (_target.centrePoint == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string     prefabName = "Hotspot centre: " + _target.gameObject.name;
                        GameObject go         = SceneManager.AddPrefab("Navigation", "HotspotCentre", true, false, false);
                        go.name = prefabName;
                        go.transform.position = _target.transform.position;
                        _target.centrePoint   = go.transform;
                        if (GameObject.Find("_Markers"))
                        {
                            go.transform.parent = GameObject.Find("_Markers").transform;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                _target.walkToMarker = (Marker)EditorGUILayout.ObjectField("Walk-to marker:", _target.walkToMarker, typeof(Marker), true);

                if (_target.walkToMarker == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        string prefabName = "Marker";
                        if (settingsManager && settingsManager.IsUnity2D())
                        {
                            prefabName += "2D";
                        }
                        Marker newMarker = SceneManager.AddPrefab("Navigation", prefabName, true, false, true).GetComponent <Marker>();
                        newMarker.gameObject.name   += (": " + _target.gameObject.name);
                        newMarker.transform.position = _target.transform.position;
                        _target.walkToMarker         = newMarker;
                    }
                }
                EditorGUILayout.EndHorizontal();

                _target.limitToCamera = (_Camera)EditorGUILayout.ObjectField("Limit to camera:", _target.limitToCamera, typeof(_Camera), true);
                _target.drawGizmos    = EditorGUILayout.Toggle("Draw yellow cube?", _target.drawGizmos);

                if (settingsManager != null && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive)
                {
                    _target.oneClick = EditorGUILayout.Toggle("Single 'Use' Interaction?", _target.oneClick);
                }
                if (_target.oneClick || (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive))
                {
                    _target.doubleClickingHotspot = (DoubleClickingHotspot)EditorGUILayout.EnumPopup("Double-clicking:", _target.doubleClickingHotspot);
                }
                if (settingsManager != null && settingsManager.playerFacesHotspots)
                {
                    _target.playerTurnsHead = EditorGUILayout.Toggle("Turn head active?", _target.playerTurnsHead);
                }

                EditorGUILayout.Space();

                UseInteractionGUI();

                if (settingsManager == null || settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                {
                    EditorGUILayout.Space();
                    LookInteractionGUI();
                }

                EditorGUILayout.Space();
                InvInteractionGUI();

                EditorGUILayout.Space();
                UnhandledInvInteractionGUI();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
        private void Export()
        {
                        #if UNITY_WEBPLAYER
            ACDebug.LogWarning("Game text cannot be exported in WebPlayer mode - please switch platform and try again.");
                        #else
            if (speechManager == null || exportColumns == null || exportColumns.Count == 0 || speechManager.lines == null || speechManager.lines.Count == 0)
            {
                return;
            }

            string suggestedFilename = string.Empty;
            if (AdvGame.GetReferences().settingsManager)
            {
                suggestedFilename = AdvGame.GetReferences().settingsManager.saveFileName + " - ";
            }
            suggestedFilename += "GameText.csv";

            string fileName = EditorUtility.SaveFilePanel("Export game text", "Assets", suggestedFilename, "csv");
            if (fileName.Length == 0)
            {
                return;
            }

            List <SpeechLine> exportLines = new List <SpeechLine>();
            foreach (SpeechLine line in speechManager.lines)
            {
                if (filterByType)
                {
                    if (line.textType != typeFilter)
                    {
                        continue;
                    }
                }
                if (filterByScene)
                {
                    if (sceneNames != null && sceneNames.Length > sceneFilter)
                    {
                        string selectedScene      = sceneNames[sceneFilter] + ".unity";
                        string scenePlusExtension = (string.IsNullOrEmpty(line.scene)) ? string.Empty : (line.scene + ".unity");

                        if ((string.IsNullOrEmpty(line.scene) && sceneFilter == 0) ||
                            sceneFilter == 1 ||
                            (!string.IsNullOrEmpty(line.scene) && sceneFilter > 1 && line.scene.EndsWith(selectedScene)) ||
                            (!string.IsNullOrEmpty(line.scene) && sceneFilter > 1 && scenePlusExtension.EndsWith(selectedScene)))
                        {
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                if (filterByText)
                {
                    if (!line.Matches(textFilter, filterSpeechLine))
                    {
                        continue;
                    }
                }
                if (filterByTag)
                {
                    if (tagFilter == -1 ||
                        (tagFilter < speechManager.speechTags.Count && line.tagID == speechManager.speechTags[tagFilter].ID))
                    {
                    }
                    else
                    {
                        continue;
                    }
                }

                exportLines.Add(new SpeechLine(line));
            }

            if (doRowSorting)
            {
                switch (rowSorting)
                {
                case RowSorting.ByID:
                    exportLines.Sort((a, b) => a.lineID.CompareTo(b.lineID));
                    break;

                case RowSorting.ByDescription:
                    exportLines.Sort((a, b) => string.Compare(a.description, b.description, System.StringComparison.Ordinal));
                    break;

                case RowSorting.ByType:
                    exportLines.Sort((a, b) => string.Compare(a.textType.ToString(), b.textType.ToString(), System.StringComparison.Ordinal));
                    break;

                case RowSorting.ByAssociatedObject:
                    exportLines.Sort((a, b) => string.Compare(a.owner, b.owner, System.StringComparison.Ordinal));
                    break;

                case RowSorting.ByScene:
                    exportLines.Sort((a, b) => string.Compare(a.scene, b.scene, System.StringComparison.Ordinal));
                    break;

                default:
                    break;
                }
            }

            List <string[]> output = new List <string[]>();

            string[]      languagesArray = speechManager.languages.ToArray();
            List <string> headerList     = new List <string>();
            headerList.Add("ID");
            foreach (ExportColumn exportColumn in exportColumns)
            {
                headerList.Add(exportColumn.GetHeader(languagesArray));
            }
            output.Add(headerList.ToArray());

            foreach (SpeechLine line in exportLines)
            {
                List <string> rowList = new List <string>();
                rowList.Add(line.lineID.ToString());
                foreach (ExportColumn exportColumn in exportColumns)
                {
                    string cellText = exportColumn.GetCellText(line);
                    rowList.Add(cellText);
                }
                output.Add(rowList.ToArray());
            }

            string fileContents = CSVReader.CreateCSVGrid(output);
            if (!string.IsNullOrEmpty(fileContents) && Serializer.SaveFile(fileName, fileContents))
            {
                int numLines = exportLines.Count;
                ACDebug.Log(numLines.ToString() + " line" + ((numLines != 1) ? "s" : string.Empty) + " exported.");
            }
                        #endif
        }
Exemple #8
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters", EditorStyles.boldLabel);

            character.moveSpeedParameter = CustomGUILayout.TextField("Move speed float:", character.moveSpeedParameter, "", "The name of the Animator float parameter set to the movement speed");
            character.turnParameter      = CustomGUILayout.TextField("Turn float:", character.turnParameter, "", "The name of the Animator float parameter set to the turning direction");
            character.talkParameter      = CustomGUILayout.TextField("Talk bool:", character.talkParameter, "", "The name of the Animator bool parameter set to True while talking");

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    character.phonemeParameter = CustomGUILayout.TextField("Phoneme integer:", character.phonemeParameter, "", "The name of the Animator integer parameter set to the lip-syncing phoneme integer");
                    if (character.GetShapeable())
                    {
                        character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                        character.lipSyncBlendShapeSpeedFactor = CustomGUILayout.Slider("Shapeable speed factor:", character.lipSyncBlendShapeSpeedFactor, 0f, 1f, "", "The rate at which Blendshapes will be animated when using a Shapeable component, with 1 = normal speed and lower = faster speed");
                    }
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (!character.ikHeadTurning)
            {
                character.headYawParameter   = CustomGUILayout.TextField("Head yaw float:", character.headYawParameter, "", "The name of the Animator float parameter set to the head yaw");
                character.headPitchParameter = CustomGUILayout.TextField("Head pitch float:", character.headPitchParameter, "", "The name of the Animator float parameter set to the head pitch");
            }

            character.verticalMovementParameter = CustomGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter, "", "The name of the Animator float parameter set to the vertical movement speed");
            character.isGroundedParameter       = CustomGUILayout.TextField("'Is grounded' bool:", character.isGroundedParameter, "", "The name of the Animator boolean parameter set to the 'Is Grounded' check");
            if (character is Player)
            {
                Player player = (Player)character;
                player.jumpParameter = CustomGUILayout.TextField("Jump bool:", player.jumpParameter, "", "The name of the Animator boolean parameter to set to 'True' when jumping");
            }
            character.talkingAnimation = TalkingAnimation.Standard;

            if (character.useExpressions)
            {
                character.expressionParameter = CustomGUILayout.TextField("Expression ID integer:", character.expressionParameter, "", "The name of the Animator integer parameter set to the active Expression ID number");
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim settings", EditorStyles.boldLabel);

            if (SceneSettings.IsTopDown())
            {
                character.spriteChild = (Transform)CustomGUILayout.ObjectField <Transform> ("Animator child:", character.spriteChild, true, "", "The Animator, which should be on a child GameObject");
            }
            else
            {
                character.spriteChild    = null;
                character.customAnimator = (Animator)CustomGUILayout.ObjectField <Animator> ("Animator (optional):", character.customAnimator, true, "", "The Animator, if not on the root GameObject");
            }

            character.headLayer  = CustomGUILayout.IntField("Head layer #:", character.headLayer, "", "The Animator layer used to play head animations while talking");
            character.mouthLayer = CustomGUILayout.IntField("Mouth layer #:", character.mouthLayer, "", "The Animator layer used to play mouth animations while talking");

            character.ikHeadTurning = CustomGUILayout.Toggle("IK head-turning?", character.ikHeadTurning, "", "If True, then inverse-kinematics will be used to turn the character's head dynamically, rather than playing pre-made animations");
            if (character.ikHeadTurning)
            {
                if (character.neckBone == null && character.GetComponent <CapsuleCollider>() == null && character.GetComponent <CharacterController>())
                {
                    EditorGUILayout.HelpBox("For IK head-turning, a 'Neck bone' must be defined, or a Capsule Collider / Character Controller must be placed on this GameObject.", MessageType.Warning);
                }
                character.headIKTurnFactor = CustomGUILayout.Slider("Head-turn factor:", character.headIKTurnFactor, 0f, 1f, "", "How much the head is influenced by IK head-turning.");
                character.bodyIKTurnFactor = CustomGUILayout.Slider("Body-turn factor:", character.bodyIKTurnFactor, 0f, 1f, "", "How much the body is influenced by IK head-turning.");
                character.eyesIKTurnFactor = CustomGUILayout.Slider("Eyes-turn factor:", character.eyesIKTurnFactor, 0f, 1f, "", "How much the eyes is influenced by IK head-turning.");
                EditorGUILayout.HelpBox("'IK Pass' must be enabled for this character's Base layer.", MessageType.Info);
            }

            if (!Application.isPlaying)
            {
                character.ResetAnimator();
            }
            Animator charAnimator = character.GetAnimator();
            if (charAnimator != null && charAnimator.applyRootMotion)
            {
                character.rootTurningFactor = CustomGUILayout.Slider("Root Motion turning:", character.rootTurningFactor, 0f, 1f, "", "The factor by which the job of turning is left to Mecanim root motion");
            }
            character.doWallReduction = CustomGUILayout.Toggle("Slow movement near walls?", character.doWallReduction, "", "If True, then characters will slow down when walking into walls");
            if (character.doWallReduction)
            {
                character.wallLayer    = CustomGUILayout.TextField("Wall collider layer:", character.wallLayer, "", "The layer that walls are expected to be placed on");
                character.wallDistance = CustomGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f, "", "The distance to keep away from walls");
                character.wallReductionOnlyParameter = CustomGUILayout.Toggle("Only affects Mecanim parameter?", character.wallReductionOnlyParameter, "", "If True, then the wall reduction factor will only affect the Animator move speed float parameter, and not character's actual speed");
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Bone transforms", EditorStyles.boldLabel);

            character.neckBone      = (Transform)CustomGUILayout.ObjectField <Transform> ("Neck bone:", character.neckBone, true, "", "The 'Neck bone' Transform");
            character.leftHandBone  = (Transform)CustomGUILayout.ObjectField <Transform> ("Left hand:", character.leftHandBone, true, "", "The 'Left hand bone' transform");
            character.rightHandBone = (Transform)CustomGUILayout.ObjectField <Transform> ("Right hand:", character.rightHandBone, true, "", "The 'Right hand bone' transform");
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Exemple #9
0
        override public void ShowGUI()
        {
            if (!settingsManager)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            if (!settingsManager)
            {
                return;
            }

            if (settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
            {
                EditorGUILayout.HelpBox("This Action requires Player Switching to be allowed, as set in the Settings Manager.", MessageType.Info);
                return;
            }

            // Create a string List of the field's names (for the PopUp box)
            List <string> labelList = new List <string>();

            int i = 0;

            playerNumber = -1;

            if (settingsManager.players.Count > 0)
            {
                foreach (PlayerPrefab playerPrefab in settingsManager.players)
                {
                    if (playerPrefab.playerOb != null)
                    {
                        labelList.Add(playerPrefab.playerOb.name);
                    }
                    else
                    {
                        labelList.Add("(Undefined prefab)");
                    }

                    // If a player has been removed, make sure selected player is still valid
                    if (playerPrefab.ID == playerID)
                    {
                        playerNumber = i;
                    }

                    i++;
                }

                if (playerNumber == -1)
                {
                    // Wasn't found (item was possibly deleted), so revert to zero
                    ACDebug.LogWarning("Previously chosen Player no longer exists!");

                    playerNumber = 0;
                    playerID     = 0;
                }

                playerNumber = EditorGUILayout.Popup("New Player:", playerNumber, labelList.ToArray());
                playerID     = settingsManager.players[playerNumber].ID;

                if (AdvGame.GetReferences().settingsManager == null || !AdvGame.GetReferences().settingsManager.shareInventory)
                {
                    keepInventory = EditorGUILayout.Toggle("Transfer inventory?", keepInventory);
                }
                restorePreviousData = EditorGUILayout.Toggle("Restore position?", restorePreviousData);
                if (restorePreviousData)
                {
                    EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                    EditorGUILayout.LabelField("If first time in game:", EditorStyles.boldLabel);
                }

                newPlayerPosition = (NewPlayerPosition)EditorGUILayout.EnumPopup("New Player position:", newPlayerPosition);

                if (newPlayerPosition == NewPlayerPosition.ReplaceNPC)
                {
                    newPlayerNPC = (NPC)EditorGUILayout.ObjectField("NPC to be replaced:", newPlayerNPC, typeof(NPC), true);

                    newPlayerNPC_ID = FieldToID <NPC> (newPlayerNPC, newPlayerNPC_ID);
                    newPlayerNPC    = IDToField <NPC> (newPlayerNPC, newPlayerNPC_ID, false);
                }
                else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                {
                    newPlayerMarker = (Marker)EditorGUILayout.ObjectField("Marker to appear at:", newPlayerMarker, typeof(Marker), true);

                    newPlayerMarker_ID = FieldToID <Marker> (newPlayerMarker, newPlayerMarker_ID);
                    newPlayerMarker    = IDToField <Marker> (newPlayerMarker, newPlayerMarker_ID, false);
                }
                else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
                {
                    chooseNewSceneBy = (ChooseSceneBy)EditorGUILayout.EnumPopup("Choose scene by:", chooseNewSceneBy);
                    if (chooseNewSceneBy == ChooseSceneBy.Name)
                    {
                        newPlayerSceneName = EditorGUILayout.TextField("Scene to appear in:", newPlayerSceneName);
                    }
                    else
                    {
                        newPlayerScene = EditorGUILayout.IntField("Scene to appear in:", newPlayerScene);
                    }

                    newPlayerNPC = (NPC)EditorGUILayout.ObjectField("NPC to be replaced:", newPlayerNPC, typeof(NPC), true);

                    newPlayerNPC_ID = FieldToID <NPC> (newPlayerNPC, newPlayerNPC_ID);
                    newPlayerNPC    = IDToField <NPC> (newPlayerNPC, newPlayerNPC_ID, false);

                    EditorGUILayout.HelpBox("If the Player has an Associated NPC defined, it will be used if none is defined here.", MessageType.Info);
                }
                else if (newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                {
                    EditorGUILayout.HelpBox("A Player's 'Associated NPC' is defined in the Player Inspector.", MessageType.Info);
                }

                if (restorePreviousData)
                {
                    EditorGUILayout.EndVertical();
                }

                if (newPlayerPosition == NewPlayerPosition.ReplaceNPC ||
                    newPlayerPosition == NewPlayerPosition.AppearAtMarker ||
                    newPlayerPosition == NewPlayerPosition.AppearInOtherScene ||
                    newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                {
                    EditorGUILayout.Space();
                    oldPlayer = (OldPlayer)EditorGUILayout.EnumPopup("Old Player:", oldPlayer);

                    if (oldPlayer == OldPlayer.ReplaceWithNPC)
                    {
                        oldPlayerNPC = (NPC)EditorGUILayout.ObjectField("NPC to replace old Player:", oldPlayerNPC, typeof(NPC), true);

                        oldPlayerNPC_ID = FieldToID <NPC> (oldPlayerNPC, oldPlayerNPC_ID);
                        oldPlayerNPC    = IDToField <NPC> (oldPlayerNPC, oldPlayerNPC_ID, false);

                        EditorGUILayout.HelpBox("This NPC must be already be present in the scene - either within the scene file itself, or spawned at runtime with the 'Object: Add or remove' Action.", MessageType.Info);
                    }
                    else if (oldPlayer == OldPlayer.ReplaceWithAssociatedNPC)
                    {
                        EditorGUILayout.HelpBox("A Player's 'Associated NPC' is defined in the Player Inspector.", MessageType.Info);
                    }
                }
            }

            else
            {
                EditorGUILayout.LabelField("No players exist!");
                playerID     = -1;
                playerNumber = -1;
            }

            EditorGUILayout.Space();

            AfterRunningOption();
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            saveHandling = (SaveHandling)EditorGUILayout.EnumPopup("Method:", saveHandling);

            if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave)
            {
                string _action = "load";
                if (saveHandling == SaveHandling.OverwriteExistingSave)
                {
                    _action = "overwrite";
                }

                selectSaveType = (SelectSaveType)EditorGUILayout.EnumPopup("Save to " + _action + ":", selectSaveType);
                if (selectSaveType == SelectSaveType.SetSlotIndex)
                {
                    saveIndexParameterID = Action.ChooseParameterGUI("Slot index to " + _action + ":", parameters, saveIndexParameterID, ParameterType.Integer);
                    if (saveIndexParameterID == -1)
                    {
                        saveIndex = EditorGUILayout.IntField("Slot index to " + _action + ":", saveIndex);
                    }
                }
                else if (selectSaveType == SelectSaveType.SlotIndexFromVariable)
                {
                    slotVarID = AdvGame.GlobalVariableGUI("Integer variable:", slotVarID, VariableType.Integer);
                }

                if (selectSaveType != SelectSaveType.Autosave)
                {
                    EditorGUILayout.Space();
                    menuName    = EditorGUILayout.TextField("Menu with SavesList:", menuName);
                    elementName = EditorGUILayout.TextField("SavesList element:", elementName);
                }
            }

            if ((saveHandling == SaveHandling.OverwriteExistingSave && selectSaveType != SelectSaveType.Autosave) || saveHandling == SaveHandling.SaveNewGame)
            {
                if (saveHandling == SaveHandling.OverwriteExistingSave)
                {
                    EditorGUILayout.Space();
                    updateLabel = EditorGUILayout.Toggle("Update label?", updateLabel);
                }
                if (updateLabel || saveHandling == SaveHandling.SaveNewGame)
                {
                    customLabel = EditorGUILayout.Toggle("With custom label?", customLabel);
                    if (customLabel)
                    {
                        varID = AdvGame.GlobalVariableGUI("Label as String variable:", varID, VariableType.String);
                    }
                }
            }

            if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave)
            {
                doSelectiveLoad = EditorGUILayout.ToggleLeft("Selective loading?", doSelectiveLoad);
                if (doSelectiveLoad)
                {
                    selectiveLoad.ShowGUI();
                }
            }

            if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame)
            {
                AfterRunningOption();
            }
        }
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            if (inventoryManager == null && AdvGame.GetReferences().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }
            if (settingsManager == null && AdvGame.GetReferences().settingsManager)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            if (inventoryManager != null)
            {
                // Create a string List of the field's names (for the PopUp box)
                List <string> labelList = new List <string>();

                int i = 0;
                if (parameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add(_item.label);

                        // If a item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }
                        if (_item.id == invIDReplace)
                        {
                            replaceInvNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        if (invID != 0)
                        {
                            LogWarning("Previously chosen item no longer exists!");
                        }
                        invNumber = 0;
                        invID     = 0;
                    }

                    if (invAction == InvAction.Replace && replaceInvNumber == -1)
                    {
                        if (invIDReplace != 0)
                        {
                            LogWarning("Previously chosen item no longer exists!");
                        }
                        replaceInvNumber = 0;
                        invIDReplace     = 0;
                    }

                    invAction = (InvAction)EditorGUILayout.EnumPopup("Method:", invAction);

                    string label = "Item to add:";
                    if (invAction == InvAction.Remove)
                    {
                        label = "Item to remove:";

                        removeLast = EditorGUILayout.Toggle("Remove last-selected?", removeLast);
                        if (removeLast)
                        {
                            setAmount = false;
                            AfterRunningOption();
                            return;
                        }
                    }

                    parameterID = Action.ChooseParameterGUI(label, parameters, parameterID, ParameterType.InventoryItem);
                    if (parameterID >= 0)
                    {
                        invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                        invID     = -1;
                    }
                    else
                    {
                        invNumber = EditorGUILayout.Popup(label, invNumber, labelList.ToArray());
                        invID     = inventoryManager.items[invNumber].id;
                    }

                    if (inventoryManager.items[invNumber].canCarryMultiple)
                    {
                        setAmount = EditorGUILayout.Toggle("Set amount?", setAmount);

                        if (setAmount)
                        {
                            string _label = (invAction == InvAction.Remove) ? "Reduce count by:" : "Increase count by:";

                            amountParameterID = Action.ChooseParameterGUI(_label, parameters, amountParameterID, ParameterType.Integer);
                            if (amountParameterID < 0)
                            {
                                amount = EditorGUILayout.IntField(_label, amount);
                            }
                        }
                    }

                    if (invAction == InvAction.Replace)
                    {
                        replaceParameterID = Action.ChooseParameterGUI("Item to remove:", parameters, replaceParameterID, ParameterType.InventoryItem);
                        if (replaceParameterID >= 0)
                        {
                            replaceInvNumber = Mathf.Min(replaceInvNumber, inventoryManager.items.Count - 1);
                            invIDReplace     = -1;
                        }
                        else
                        {
                            replaceInvNumber = EditorGUILayout.Popup("Item to remove:", replaceInvNumber, labelList.ToArray());
                            invIDReplace     = inventoryManager.items[replaceInvNumber].id;
                        }
                    }
                    else if (invAction == InvAction.Add)
                    {
                        addToFront = EditorGUILayout.Toggle("Add to front?", addToFront);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                    invID            = -1;
                    invNumber        = -1;
                    invIDReplace     = -1;
                    replaceInvNumber = -1;
                }

                if (settingsManager != null && settingsManager.playerSwitching == PlayerSwitching.Allow && !settingsManager.shareInventory && invAction != InvAction.Replace)
                {
                    EditorGUILayout.Space();

                    setPlayer = EditorGUILayout.Toggle("Affect specific player?", setPlayer);
                    if (setPlayer)
                    {
                        ChoosePlayerGUI();
                    }
                }
                else
                {
                    setPlayer = false;
                }
            }
            else
            {
                EditorGUILayout.HelpBox("An Inventory Manager must be assigned for this Action to work", MessageType.Warning);
            }

            AfterRunningOption();
        }
Exemple #12
0
        public bool ReferencesAsset(ActionListAsset actionListAsset)
        {
            if (KickStarter.settingsManager && KickStarter.settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Multiple && AdvGame.GetReferences().cursorManager)
            {
                foreach (InvInteraction interaction in interactions)
                {
                    if (interaction.actionList == actionListAsset)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                if (useActionList == actionListAsset)
                {
                    return(true);
                }
                if (lookActionList == actionListAsset)
                {
                    return(true);
                }
            }

            if (KickStarter.settingsManager != null && KickStarter.settingsManager.CanSelectItems(false))
            {
                if (unhandledActionList == actionListAsset)
                {
                    return(true);
                }
                if (unhandledCombineActionList == actionListAsset)
                {
                    return(true);
                }
            }

            foreach (ActionListAsset combine in combineActionList)
            {
                if (combine == actionListAsset)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #13
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            numSockets = EditorGUILayout.DelayedIntField("# of possible values:", numSockets);
            numSockets = Mathf.Clamp(numSockets, 1, 100);

            disallowSuccessive = EditorGUILayout.Toggle("Prevent same value twice?", disallowSuccessive);

            if (disallowSuccessive)
            {
                saveToVariable = EditorGUILayout.Toggle("Save last value?", saveToVariable);
                if (saveToVariable)
                {
                    location = (VariableLocation)EditorGUILayout.EnumPopup("Variable source:", location);

                    if (location == VariableLocation.Local && KickStarter.localVariables == null)
                    {
                        EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                    }
                    else if (location == VariableLocation.Local && isAssetFile)
                    {
                        EditorGUILayout.HelpBox("Local variables cannot be accessed in ActionList assets.", MessageType.Info);
                    }

                    if ((location == VariableLocation.Global && AdvGame.GetReferences().variablesManager != null) ||
                        (location == VariableLocation.Local && KickStarter.localVariables != null && !isAssetFile) ||
                        (location == VariableLocation.Component))
                    {
                        ParameterType _parameterType = ParameterType.GlobalVariable;
                        if (location == VariableLocation.Local)
                        {
                            _parameterType = ParameterType.LocalVariable;
                        }
                        else if (location == VariableLocation.Component)
                        {
                            _parameterType = ParameterType.ComponentVariable;
                        }

                        parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, _parameterType);
                        if (parameterID >= 0)
                        {
                            if (location == VariableLocation.Component)
                            {
                                variablesConstantID = 0;
                                variables           = null;
                            }

                            variableID = ShowVarGUI(variableID, false);
                        }
                        else
                        {
                            if (location == VariableLocation.Component)
                            {
                                variables           = (Variables)EditorGUILayout.ObjectField("Component:", variables, typeof(Variables), true);
                                variablesConstantID = FieldToID <Variables> (variables, variablesConstantID);
                                variables           = IDToField <Variables> (variables, variablesConstantID, false);

                                if (variables != null)
                                {
                                    variableID = ShowVarGUI(variableID, true);
                                }
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                variableID = ShowVarGUI(variableID, true);

                                if (GUILayout.Button(string.Empty, CustomStyles.IconCog))
                                {
                                    SideMenu();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }
                }
            }
        }
        public override void OnInspectorGUI()
        {
            Moveable_PickUp _target = (Moveable_PickUp)target;

            GetReferences();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Movment settings:", EditorStyles.boldLabel);
            _target.maxSpeed = EditorGUILayout.FloatField("Max speed:", _target.maxSpeed);
            _target.playerMovementReductionFactor = EditorGUILayout.Slider("Player movement reduction:", _target.playerMovementReductionFactor, 0f, 1f);
            _target.invertInput = EditorGUILayout.Toggle("Invert input?", _target.invertInput);
            _target.breakForce  = EditorGUILayout.FloatField("Break force:", _target.breakForce);

            EditorGUILayout.BeginHorizontal();
            _target.interactionOnGrab = (Interaction)EditorGUILayout.ObjectField("Interaction on grab:", _target.interactionOnGrab, typeof(Interaction), true);

            if (_target.interactionOnGrab == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Undo.RecordObject(_target, "Create Interaction");
                    Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();
                    newInteraction.gameObject.name = AdvGame.UniqueName("Move : " + _target.gameObject.name);
                    _target.interactionOnGrab      = newInteraction;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Rotation settings:", EditorStyles.boldLabel);
            _target.allowRotation = EditorGUILayout.Toggle("Allow rotation?", _target.allowRotation);
            if (_target.allowRotation)
            {
                _target.rotationFactor = EditorGUILayout.FloatField("Rotation factor:", _target.rotationFactor);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Zoom settings:", EditorStyles.boldLabel);
            _target.allowZooming = EditorGUILayout.Toggle("Allow zooming?", _target.allowZooming);
            if (_target.allowZooming)
            {
                _target.zoomSpeed = EditorGUILayout.FloatField("Zoom speed:", _target.zoomSpeed);
                _target.minZoom   = EditorGUILayout.FloatField("Closest distance:", _target.minZoom);
                _target.maxZoom   = EditorGUILayout.FloatField("Farthest distance:", _target.maxZoom);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Throw settings:", EditorStyles.boldLabel);
            _target.allowThrow = EditorGUILayout.Toggle("Allow throwing?", _target.allowThrow);
            if (_target.allowThrow)
            {
                _target.throwForce       = EditorGUILayout.FloatField("Force scale:", _target.throwForce);
                _target.chargeTime       = EditorGUILayout.FloatField("Charge time:", _target.chargeTime);
                _target.pullbackDistance = EditorGUILayout.FloatField("Pull-back distance:", _target.pullbackDistance);
            }
            EditorGUILayout.EndVertical();

            SharedGUI(_target, false);

            UnityVersionHandler.CustomSetDirty(_target);
        }
Exemple #15
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            if (AdvGame.GetReferences().inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }

            if (inventoryManager)
            {
                // Create a string List of the field's names (for the PopUp box)
                List <string> labelList = new List <string>();

                int i = 0;
                if (invParameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add(_item.label);

                        // If a item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        ACDebug.LogWarning("Previously chosen item no longer exists!");
                        invNumber = 0;
                        invID     = 0;
                    }

                    useActive = EditorGUILayout.Toggle("Affect active container?", useActive);
                    if (!useActive)
                    {
                        parameterID = Action.ChooseParameterGUI("Container:", parameters, parameterID, ParameterType.GameObject);
                        if (parameterID >= 0)
                        {
                            constantID = 0;
                            container  = null;
                        }
                        else
                        {
                            container = (Container)EditorGUILayout.ObjectField("Container:", container, typeof(Container), true);

                            constantID = FieldToID <Container> (container, constantID);
                            container  = IDToField <Container> (container, constantID, false);
                        }
                    }

                    containerAction = (ContainerAction)EditorGUILayout.EnumPopup("Method:", containerAction);

                    if (containerAction == ContainerAction.RemoveAll)
                    {
                        transferToPlayer = EditorGUILayout.Toggle("Transfer to Player?", transferToPlayer);
                    }
                    else
                    {
                        //
                        invParameterID = Action.ChooseParameterGUI("Inventory item:", parameters, invParameterID, ParameterType.InventoryItem);
                        if (invParameterID >= 0)
                        {
                            invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                            invID     = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                            invID     = inventoryManager.items[invNumber].id;
                        }
                        //

                        if (containerAction == ContainerAction.Remove)
                        {
                            transferToPlayer = EditorGUILayout.Toggle("Transfer to Player?", transferToPlayer);
                        }

                        if (inventoryManager.items[invNumber].canCarryMultiple)
                        {
                            setAmount = EditorGUILayout.Toggle("Set amount?", setAmount);

                            if (setAmount)
                            {
                                string _label = (containerAction == ContainerAction.Add) ? "Increase count by:" : "Reduce count by:";

                                amountParameterID = Action.ChooseParameterGUI(_label, parameters, amountParameterID, ParameterType.Integer);
                                if (amountParameterID < 0)
                                {
                                    amount = EditorGUILayout.IntField(_label, amount);
                                }
                            }
                        }
                    }

                    AfterRunningOption();
                }

                else
                {
                    EditorGUILayout.LabelField("No inventory items exist!");
                    invID     = -1;
                    invNumber = -1;
                }
            }
        }
        private void Export()
        {
                        #if UNITY_WEBPLAYER
            ACDebug.LogWarning("Game text cannot be exported in WebPlayer mode - please switch platform and try again.");
                        #else
            if (speechManager == null || exportColumns == null || exportColumns.Count == 0 || speechManager.lines == null || speechManager.lines.Count == 0)
            {
                return;
            }

            string suggestedFilename = "";
            if (AdvGame.GetReferences().settingsManager)
            {
                suggestedFilename = AdvGame.GetReferences().settingsManager.saveFileName + " - ";
            }
            suggestedFilename += "GameText.csv";

            string fileName = EditorUtility.SaveFilePanel("Export game text", "Assets", suggestedFilename, "csv");
            if (fileName.Length == 0)
            {
                return;
            }

            string[]          sceneNames  = speechManager.GetSceneNames();
            List <SpeechLine> exportLines = new List <SpeechLine>();
            foreach (SpeechLine line in speechManager.lines)
            {
                if (filterByType)
                {
                    if (line.textType != typeFilter)
                    {
                        continue;
                    }
                }
                if (filterByScene)
                {
                    if (sceneNames != null && sceneNames.Length > sceneFilter)
                    {
                        string selectedScene      = sceneNames[sceneFilter] + ".unity";
                        string scenePlusExtension = (line.scene != "") ? (line.scene + ".unity") : "";

                        if ((line.scene == "" && sceneFilter == 0) ||
                            sceneFilter == 1 ||
                            (line.scene != "" && sceneFilter > 1 && line.scene.EndsWith(selectedScene)) ||
                            (line.scene != "" && sceneFilter > 1 && scenePlusExtension.EndsWith(selectedScene)))
                        {
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                if (filterByText)
                {
                    if (!line.Matches(textFilter, filterSpeechLine))
                    {
                        continue;
                    }
                }
                if (filterByTag)
                {
                    if (tagFilter == -1 ||
                        (tagFilter < speechManager.speechTags.Count && line.tagID == speechManager.speechTags[tagFilter].ID))
                    {
                    }
                    else
                    {
                        continue;
                    }
                }

                exportLines.Add(new SpeechLine(line));
            }

            if (doRowSorting)
            {
                if (rowSorting == RowSorting.ByID)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.lineID.CompareTo(b.lineID)); });
                }
                else if (rowSorting == RowSorting.ByDescription)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.description.CompareTo(b.description)); });
                }
                else if (rowSorting == RowSorting.ByType)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.textType.ToString().CompareTo(b.textType.ToString())); });
                }
                else if (rowSorting == RowSorting.ByAssociatedObject)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.owner.CompareTo(b.owner)); });
                }
                else if (rowSorting == RowSorting.ByScene)
                {
                    exportLines.Sort(delegate(SpeechLine a, SpeechLine b) { return(a.scene.CompareTo(b.owner)); });
                }
            }

            bool            fail   = false;
            List <string[]> output = new List <string[]>();

            string[]      languagesArray = speechManager.languages.ToArray();
            List <string> headerList     = new List <string>();
            headerList.Add("ID");
            foreach (ExportColumn exportColumn in exportColumns)
            {
                headerList.Add(exportColumn.GetHeader(languagesArray));
            }
            output.Add(headerList.ToArray());

            foreach (SpeechLine line in exportLines)
            {
                List <string> rowList = new List <string>();
                rowList.Add(line.lineID.ToString());
                foreach (ExportColumn exportColumn in exportColumns)
                {
                    string cellText = exportColumn.GetCellText(line);
                    rowList.Add(cellText);

                    if (cellText.Contains(CSVReader.csvDelimiter))
                    {
                        fail = true;
                        ACDebug.LogError("Cannot export translation since line " + line.lineID.ToString() + " (" + line.text + ") contains the character '" + CSVReader.csvDelimiter + "'.");
                    }
                }
                output.Add(rowList.ToArray());
            }

            if (!fail)
            {
                int length = output.Count;

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                for (int j = 0; j < length; j++)
                {
                    sb.AppendLine(string.Join(CSVReader.csvDelimiter, output[j]));
                }

                if (Serializer.SaveFile(fileName, sb.ToString()))
                {
                    int numLines = exportLines.Count;
                    ACDebug.Log(numLines.ToString() + " line" + ((numLines != 1) ? "s" : "") + " exported.");
                }
            }

            //this.Close ();
                        #endif
        }
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters:", EditorStyles.boldLabel);

            character.spriteChild = (Transform)CustomGUILayout.ObjectField <Transform> ("Sprite child:", character.spriteChild, true, "", "The sprite Transform, which should be a child GameObject");

            if (character.spriteChild != null && character.spriteChild.GetComponent <Animator>() == null)
            {
                character.customAnimator = (Animator)CustomGUILayout.ObjectField <Animator> ("Animator (if not on s.c.):", character.customAnimator, true, "", "The Animator component, which will be assigned automatically if not set manually.");
            }

            character.moveSpeedParameter = CustomGUILayout.TextField("Move speed float:", character.moveSpeedParameter, "", "The name of the Animator float parameter set to the movement speed");
            character.turnParameter      = CustomGUILayout.TextField("Turn float:", character.turnParameter, "", "The name of the Animator float parameter set to the turning direction");

            if (character.spriteDirectionData.HasDirections())
            {
                character.directionParameter = CustomGUILayout.TextField("Direction integer:", character.directionParameter, "", "The name of the Animator integer parameter set to the sprite direction. This is set to 0 for down, 1 for left, 2 for right, 3 for up, 4 for down-left, 5 for down-right, 6 for up-left, and 7 for up-right");
            }
            character.angleParameter   = CustomGUILayout.TextField("Body angle float:", character.angleParameter, "", "The name of the Animator float parameter set to the facing angle");
            character.headYawParameter = CustomGUILayout.TextField("Head angle float:", character.headYawParameter, "", "The name of the Animator float parameter set to the head yaw");

            if (!string.IsNullOrEmpty(character.angleParameter) || !string.IsNullOrEmpty(character.headYawParameter))
            {
                character.angleSnapping = (AngleSnapping)CustomGUILayout.EnumPopup("Angle snapping:", character.angleSnapping, "", "The snapping method for the 'Body angle float' and 'Head angle float' parameters");
            }

            character.talkParameter = CustomGUILayout.TextField("Talk bool:", character.talkParameter, "", "The name of the Animator bool parameter set to True while talking");

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    character.phonemeParameter = CustomGUILayout.TextField("Phoneme integer:", character.phonemeParameter, "", "The name of the Animator integer parameter set to the lip-syncing phoneme integer");
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (character.useExpressions)
            {
                character.expressionParameter = CustomGUILayout.TextField("Expression ID integer:", character.expressionParameter, "", "The name of the Animator integer parameter set to the active Expression ID number");
            }

            character.verticalMovementParameter = CustomGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter, "", "The name of the Animator float parameter set to the vertical movement speed");
            character.talkingAnimation          = TalkingAnimation.Standard;

            character.spriteDirectionData.ShowGUI();
            if (character.spriteDirectionData.HasDirections())
            {
                EditorGUILayout.HelpBox("The above field affects the 'Direction integer' parameter only.", MessageType.Info);
            }

            Animator charAnimator = character.GetAnimator();
            if (charAnimator == null || !charAnimator.applyRootMotion)
            {
                character.antiGlideMode = EditorGUILayout.ToggleLeft("Only move when sprite changes?", character.antiGlideMode);

                if (character.antiGlideMode)
                {
                    if (character.GetComponent <Rigidbody2D>())
                    {
                        EditorGUILayout.HelpBox("This feature will disable use of the Rigidbody2D component.", MessageType.Warning);
                    }
                    if (character is Player && AdvGame.GetReferences() != null && AdvGame.GetReferences().settingsManager != null)
                    {
                        if (AdvGame.GetReferences().settingsManager.movementMethod != MovementMethod.PointAndClick && AdvGame.GetReferences().settingsManager.movementMethod != MovementMethod.None)
                        {
                            EditorGUILayout.HelpBox("This feature will not work with collision - it is not recommended for " + AdvGame.GetReferences().settingsManager.movementMethod.ToString() + " movement.", MessageType.Warning);
                        }
                    }
                }
            }

            character.doWallReduction            = EditorGUILayout.BeginToggleGroup("Slow movement near walls?", character.doWallReduction);
            character.wallLayer                  = EditorGUILayout.TextField("Wall collider layer:", character.wallLayer);
            character.wallDistance               = EditorGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f);
            character.wallReductionOnlyParameter = EditorGUILayout.Toggle("Only affects Mecanim parameter?", character.wallReductionOnlyParameter);
            EditorGUILayout.EndToggleGroup();

            if (SceneSettings.CameraPerspective != CameraPerspective.TwoD)
            {
                character.rotateSprite3D = (RotateSprite3D)EditorGUILayout.EnumPopup("Rotate sprite to:", character.rotateSprite3D);
            }

            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
		public override void CharSettingsGUI ()
		{
			#if UNITY_EDITOR
			
			EditorGUILayout.BeginVertical ("Button");
			EditorGUILayout.LabelField ("Standard 3D animations:", EditorStyles.boldLabel);

			if (AdvGame.GetReferences () && AdvGame.GetReferences ().settingsManager && AdvGame.GetReferences ().settingsManager.IsTopDown ())
			{
				character.spriteChild = (Transform) EditorGUILayout.ObjectField ("Animation child:", character.spriteChild, typeof (Transform), true);
			}
			else
			{
				character.spriteChild = null;
			}

			character.talkingAnimation = (TalkingAnimation) EditorGUILayout.EnumPopup ("Talk animation style:", character.talkingAnimation);
			character.idleAnim = (AnimationClip) EditorGUILayout.ObjectField ("Idle:", character.idleAnim, typeof (AnimationClip), false);
			character.walkAnim = (AnimationClip) EditorGUILayout.ObjectField ("Walk:", character.walkAnim, typeof (AnimationClip), false);
			character.runAnim = (AnimationClip) EditorGUILayout.ObjectField ("Run:", character.runAnim, typeof (AnimationClip), false);
			if (character.talkingAnimation == TalkingAnimation.Standard)
			{
				character.talkAnim = (AnimationClip) EditorGUILayout.ObjectField ("Talk:", character.talkAnim, typeof (AnimationClip), false);
			}

			if (AdvGame.GetReferences () && AdvGame.GetReferences ().speechManager)
			{
				if (AdvGame.GetReferences () && AdvGame.GetReferences ().speechManager &&
				    AdvGame.GetReferences ().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences ().speechManager.lipSyncMode != LipSyncMode.FaceFX)
				{
					if (AdvGame.GetReferences ().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
					{
						if (character.GetShapeable ())
						{
							character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI ("Phoneme shape group:", character.GetShapeable ().shapeGroups, character.lipSyncGroupID);
						}
						else
						{
							EditorGUILayout.HelpBox ("Attach a Shapeable script to show phoneme options", MessageType.Info);
						}
					}
					else if (AdvGame.GetReferences ().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
					{
						if (character.GetComponent <LipSyncTexture>() == null)
						{
							EditorGUILayout.HelpBox ("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
						}
					}
				}
			}

			character.turnLeftAnim = (AnimationClip) EditorGUILayout.ObjectField ("Turn left:", character.turnLeftAnim, typeof (AnimationClip), false);
			character.turnRightAnim = (AnimationClip) EditorGUILayout.ObjectField ("Turn right:", character.turnRightAnim, typeof (AnimationClip), false);
			character.headLookLeftAnim = (AnimationClip) EditorGUILayout.ObjectField ("Head look left:", character.headLookLeftAnim, typeof (AnimationClip), false);
			character.headLookRightAnim = (AnimationClip) EditorGUILayout.ObjectField ("Head look right:", character.headLookRightAnim, typeof (AnimationClip), false);
			character.headLookUpAnim = (AnimationClip) EditorGUILayout.ObjectField ("Head look up:", character.headLookUpAnim, typeof (AnimationClip), false);
			character.headLookDownAnim = (AnimationClip) EditorGUILayout.ObjectField ("Head look down:", character.headLookDownAnim, typeof (AnimationClip), false);
			character.headTurnSpeed = EditorGUILayout.Slider ("Head turn speed:", character.headTurnSpeed, 0.1f, 20f);
			if (character is Player)
			{
				Player player = (Player) character;
				player.jumpAnim = (AnimationClip) EditorGUILayout.ObjectField ("Jump:", player.jumpAnim, typeof (AnimationClip), false);
			}
			EditorGUILayout.EndVertical ();
			
			EditorGUILayout.BeginVertical ("Button");
			EditorGUILayout.LabelField ("Bone transforms:", EditorStyles.boldLabel);
			
			character.upperBodyBone = (Transform) EditorGUILayout.ObjectField ("Upper body:", character.upperBodyBone, typeof (Transform), true);
			character.neckBone = (Transform) EditorGUILayout.ObjectField ("Neck bone:", character.neckBone, typeof (Transform), true);
			character.leftArmBone = (Transform) EditorGUILayout.ObjectField ("Left arm:", character.leftArmBone, typeof (Transform), true);
			character.rightArmBone = (Transform) EditorGUILayout.ObjectField ("Right arm:", character.rightArmBone, typeof (Transform), true);
			character.leftHandBone = (Transform) EditorGUILayout.ObjectField ("Left hand:", character.leftHandBone, typeof (Transform), true);
			character.rightHandBone = (Transform) EditorGUILayout.ObjectField ("Right hand:", character.rightHandBone, typeof (Transform), true);
			EditorGUILayout.EndVertical ();

			if (GUI.changed)
			{
				EditorUtility.SetDirty (character);
			}

			#endif
		}
        private void ButtonGUI(Button button, string suffix, InteractionSource source)
        {
            bool isEnabled = !button.isDisabled;

            isEnabled         = EditorGUILayout.Toggle("Enabled:", isEnabled);
            button.isDisabled = !isEnabled;

            if (source == InteractionSource.AssetFile)
            {
                button.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", button.assetFile, typeof(ActionListAsset), false);

                if (button.assetFile != null && button.assetFile.useParameters && button.assetFile.parameters.Count > 0)
                {
                    EditorGUILayout.BeginHorizontal();
                    button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.assetFile.parameters, button.parameterID, ParameterType.GameObject);
                    EditorGUILayout.EndHorizontal();

                    if (button.parameterID >= 0 && _target.GetComponent <ConstantID>() == null)
                    {
                        EditorGUILayout.HelpBox("A Constant ID component must be added to the Hotspot in order for it to be passed as a parameter.", MessageType.Warning);
                    }
                }
            }
            else if (source == InteractionSource.CustomScript)
            {
                button.customScriptObject   = (GameObject)EditorGUILayout.ObjectField("Object with script:", button.customScriptObject, typeof(GameObject), true);
                button.customScriptFunction = EditorGUILayout.TextField("Message to send:", button.customScriptFunction);
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal();
                button.interaction = (Interaction)EditorGUILayout.ObjectField("Interaction:", button.interaction, typeof(Interaction), true);

                if (button.interaction == null)
                {
                    if (GUILayout.Button("Create", autoWidth))
                    {
                        Undo.RecordObject(_target, "Create Interaction");
                        Interaction newInteraction = SceneManager.AddPrefab("Logic", "Interaction", true, false, true).GetComponent <Interaction>();

                        string hotspotName = _target.gameObject.name;
                        if (_target != null && _target.hotspotName != null && _target.hotspotName.Length > 0)
                        {
                            hotspotName = _target.hotspotName;
                        }

                        newInteraction.gameObject.name = AdvGame.UniqueName(hotspotName + ": " + suffix);
                        button.interaction             = newInteraction;
                    }
                }
                EditorGUILayout.EndHorizontal();

                if (button.interaction != null && button.interaction.useParameters && button.interaction.parameters.Count > 0)
                {
                    EditorGUILayout.BeginHorizontal();
                    button.parameterID = Action.ChooseParameterGUI("Hotspot parameter:", button.interaction.parameters, button.parameterID, ParameterType.GameObject);
                    EditorGUILayout.EndHorizontal();
                }
            }

            button.playerAction = (PlayerAction)EditorGUILayout.EnumPopup("Player action:", button.playerAction);

            if (button.playerAction == PlayerAction.WalkTo || button.playerAction == PlayerAction.WalkToMarker)
            {
                if (button.playerAction == PlayerAction.WalkToMarker && _target.walkToMarker == null)
                {
                    EditorGUILayout.HelpBox("You must assign a 'Walk-to marker' above for this option to work.", MessageType.Warning);
                }
                button.isBlocking = EditorGUILayout.Toggle("Cutscene while moving?", button.isBlocking);
                button.faceAfter  = EditorGUILayout.Toggle("Face after moving?", button.faceAfter);

                if (button.playerAction == PlayerAction.WalkTo)
                {
                    button.setProximity = EditorGUILayout.Toggle("Set minimum distance?", button.setProximity);
                    if (button.setProximity)
                    {
                        button.proximity = EditorGUILayout.FloatField("Proximity:", button.proximity);
                    }
                }
            }
        }
		public override void ActionCharAnimSkip (ActionCharAnim action)
		{
			if (action.animChar == null)
			{
				return;
			}
			
			Animation animation = null;

			if (action.animChar.spriteChild && action.animChar.spriteChild.GetComponent <Animation>())
			{
				animation = action.animChar.spriteChild.GetComponent <Animation>();
			}
			if (character.GetAnimation ())
			{
				animation = action.animChar.GetAnimation ();
			}

			if (action.method == ActionCharAnim.AnimMethodChar.PlayCustom && action.clip)
			{
				if (action.layer == AnimLayer.Base)
				{
					action.animChar.charState = CharState.Custom;
					action.blendMode = AnimationBlendMode.Blend;
					action.playMode = (AnimPlayMode) action.playModeBase;
				}

				if (action.playMode == AnimPlayMode.PlayOnce)
				{
					if (action.layer == AnimLayer.Base && action.method == ActionCharAnim.AnimMethodChar.PlayCustom)
					{
						action.animChar.charState = CharState.Idle;
						action.animChar.ResetBaseClips ();
					}
				}
				else
				{
					AdvGame.CleanUnusedClips (animation);
					
					WrapMode wrap = WrapMode.Once;
					Transform mixingTransform = null;

					if (action.layer == AnimLayer.UpperBody)
					{
						mixingTransform = action.animChar.upperBodyBone;
					}
					else if (action.layer == AnimLayer.LeftArm)
					{
						mixingTransform = action.animChar.leftArmBone;
					}
					else if (action.layer == AnimLayer.RightArm)
					{
						mixingTransform = action.animChar.rightArmBone;
					}
					else if (action.layer == AnimLayer.Neck || action.layer == AnimLayer.Head || action.layer == AnimLayer.Face || action.layer == AnimLayer.Mouth)
					{
						mixingTransform = action.animChar.neckBone;
					}
					
					if (action.playMode == AnimPlayMode.PlayOnceAndClamp)
					{
						wrap = WrapMode.ClampForever;
					}
					else if (action.playMode == AnimPlayMode.Loop)
					{
						wrap = WrapMode.Loop;
					}

					AdvGame.PlayAnimClipFrame (animation, AdvGame.GetAnimLayerInt (action.layer), action.clip, action.blendMode, wrap, action.fadeTime, mixingTransform, 1f);
				}

				AdvGame.CleanUnusedClips (animation);
			}
			
			else if (action.method == ActionCharAnim.AnimMethodChar.StopCustom && action.clip)
			{
				if (action.clip != action.animChar.idleAnim && action.clip != action.animChar.walkAnim)
				{
					animation.Blend (action.clip.name, 0f, 0f);
				}
			}
			
			else if (action.method == ActionCharAnim.AnimMethodChar.ResetToIdle)
			{
				action.animChar.ResetBaseClips ();
				
				action.animChar.charState = CharState.Idle;
				AdvGame.CleanUnusedClips (animation);
			}
			
			else if (action.method == ActionCharAnim.AnimMethodChar.SetStandard)
			{
				if (action.clip != null)
				{
					if (action.standard == AnimStandard.Idle)
					{
						action.animChar.idleAnim = action.clip;
					}
					else if (action.standard == AnimStandard.Walk)
					{
						action.animChar.walkAnim = action.clip;
					}
					else if (action.standard == AnimStandard.Run)
					{
						action.animChar.runAnim = action.clip;
					}
					else if (action.standard == AnimStandard.Talk)
					{
						action.animChar.talkAnim = action.clip;
					}
				}
				
				if (action.changeSpeed)
				{
					if (action.standard == AnimStandard.Walk)
					{
						action.animChar.walkSpeedScale = action.newSpeed;
					}
					else if (action.standard == AnimStandard.Run)
					{
						action.animChar.runSpeedScale = action.newSpeed;
					}
				}
				
				if (action.changeSound)
				{
					if (action.standard == AnimStandard.Walk)
					{
						if (action.newSound != null)
						{
							action.animChar.walkSound = action.newSound;
						}
						else
						{
							action.animChar.walkSound = null;
						}
					}
					else if (action.standard == AnimStandard.Run)
					{
						if (action.newSound != null)
						{
							action.animChar.runSound = action.newSound;
						}
						else
						{
							action.animChar.runSound = null;
						}
					}
				}
			}
		}
        private void EditOptionGUI(ButtonDialog option, InteractionSource source)
        {
            EditorGUILayout.BeginVertical("Button");

            if (option.lineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString());
            }

            option.label = CustomGUILayout.TextField("Label:", option.label, "", "The option's display label");

            if (source == InteractionSource.AssetFile)
            {
                option.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction:", option.assetFile, false, "", "The ActionListAsset to run");
            }
            else if (source == InteractionSource.CustomScript)
            {
                option.customScriptObject   = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object with script:", option.customScriptObject, true, "", "The GameObject with the custom script to run");
                option.customScriptFunction = CustomGUILayout.TextField("Message to send:", option.customScriptFunction, "", "The name of the function to run");
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal();
                option.dialogueOption = (DialogueOption)CustomGUILayout.ObjectField <DialogueOption> ("DialogOption:", option.dialogueOption, true, "", "The DialogOption to run");
                if (option.dialogueOption == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        Undo.RecordObject(_target, "Auto-create dialogue option");
                        DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                        newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option");
                        newDialogueOption.Initialise();
                        EditorUtility.SetDirty(newDialogueOption);
                        option.dialogueOption = newDialogueOption;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            option.cursorIcon.ShowGUI(false, true, "Icon texture:", CursorRendering.Software, "", "The icon to display in DialogList menu elements");

            option.isOn = CustomGUILayout.Toggle("Is enabled?", option.isOn, "", "If True, the option is enabled, and will be displayed in a MenuDialogList element");
            if (source == InteractionSource.CustomScript)
            {
                EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info);
            }
            else
            {
                option.conversationAction = (ConversationAction)CustomGUILayout.EnumPopup("When finished:", option.conversationAction, "", "What happens when the DialogueOption ActionList has finished");
                if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
                {
                    option.newConversation = (Conversation)CustomGUILayout.ObjectField <Conversation> ("Conversation to run:", option.newConversation, true, "", "The new Conversation to run");
                }
            }

            option.linkToInventory = CustomGUILayout.ToggleLeft("Only show if carrying specific inventory item?", option.linkToInventory, "", " If True, then the option will only be visible if a given inventory item is being carried");
            if (option.linkToInventory)
            {
                option.linkedInventoryID = CreateInventoryGUI(option.linkedInventoryID);
            }

            EditorGUILayout.EndVertical();
        }
		public override float ActionAnimRun (ActionAnim action)
		{
			if (!action.isRunning)
			{
				action.isRunning = true;
				
				if (action.method == AnimMethod.PlayCustom && action._anim && action.clip)
				{
					AdvGame.CleanUnusedClips (action._anim);
					
					WrapMode wrap = WrapMode.Once;
					if (action.playMode == AnimPlayMode.PlayOnceAndClamp)
					{
						wrap = WrapMode.ClampForever;
					}
					else if (action.playMode == AnimPlayMode.Loop)
					{
						wrap = WrapMode.Loop;
					}
					
					AdvGame.PlayAnimClip (action._anim, 0, action.clip, action.blendMode, wrap, action.fadeTime, null, false);
				}
				
				else if (action.method == AnimMethod.StopCustom && action._anim && action.clip)
				{
					AdvGame.CleanUnusedClips (action._anim);
					action._anim.Blend (action.clip.name, 0f, action.fadeTime);
				}
				
				else if (action.method == AnimMethod.BlendShape && action.shapeKey > -1)
				{
					if (action.shapeObject)
					{
						action.shapeObject.Change (action.shapeKey, action.shapeValue, action.fadeTime);

						if (action.willWait)
						{
							return (action.fadeTime);
						}
					}
				}
				
				if (action.willWait)
				{
					return (action.defaultPauseTime);
				}
			}
			else
			{

				if (action.method == AnimMethod.PlayCustom && action._anim && action.clip)
				{
					if (!action._anim.IsPlaying (action.clip.name))
					{
						action.isRunning = false;
						return 0f;
					}
					else
					{
						return action.defaultPauseTime;
					}
				}
				else if (action.method == AnimMethod.BlendShape && action.shapeObject)
				{
					action.isRunning = false;
					return 0f;
				}
			}

			return 0f;
		}
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            numSockets = EditorGUILayout.IntSlider("# of possible values:", numSockets, 1, 100);
            numSockets = Mathf.Max(1, numSockets);

            disallowSuccessive = EditorGUILayout.ToggleLeft("Prevent same value twice?", disallowSuccessive);

            if (disallowSuccessive)
            {
                saveToVariable = EditorGUILayout.Toggle("Save last value?", saveToVariable);
                if (saveToVariable)
                {
                    if (isAssetFile)
                    {
                        location = VariableLocation.Global;
                    }
                    else
                    {
                        location = (VariableLocation)EditorGUILayout.EnumPopup("Variable source:", location);
                    }

                    if (location == VariableLocation.Global)
                    {
                        if (AdvGame.GetReferences().variablesManager)
                        {
                            parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, ParameterType.GlobalVariable);
                            if (parameterID >= 0)
                            {
                                variableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, variableID, false);
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                variableID = ShowVarGUI(AdvGame.GetReferences().variablesManager.vars, variableID, true);
                                if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                                {
                                    SideMenu();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }
                    else if (location == VariableLocation.Local)
                    {
                        if (KickStarter.localVariables)
                        {
                            parameterID = Action.ChooseParameterGUI("Integer variable:", parameters, parameterID, ParameterType.LocalVariable);
                            if (parameterID >= 0)
                            {
                                variableID = ShowVarGUI(KickStarter.localVariables.localVars, variableID, false);
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                variableID = ShowVarGUI(KickStarter.localVariables.localVars, variableID, true);
                                if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                                {
                                    SideMenu();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No 'Local Variables' component found in the scene. Please add an AC GameEngine object from the Scene Manager.", MessageType.Info);
                        }
                    }
                }
            }
        }
		public override void TurnHead (Vector2 angles)
		{
			if (character == null)
			{
				return;
			}

			Animation animation = null;
			
			if (character.spriteChild && character.spriteChild.GetComponent <Animation>())
			{
				animation = character.spriteChild.GetComponent <Animation>();
			}
			if (character.GetComponent <Animation>())
			{
				animation = character.GetComponent <Animation>();
			}

			if (animation == null)
			{
				return;
			}

			// Horizontal
			if (character.headLookLeftAnim && character.headLookRightAnim)
			{
				if (angles.x < 0f)
				{
					animation.Stop (character.headLookRightAnim.name);
					AdvGame.PlayAnimClipFrame (animation, AdvGame.GetAnimLayerInt (AnimLayer.Neck), character.headLookLeftAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
					animation [character.headLookLeftAnim.name].weight = -angles.x;
					animation [character.headLookLeftAnim.name].speed = 0f;
				}
				else if (angles.x > 0f)
				{
					animation.Stop (character.headLookLeftAnim.name);
					AdvGame.PlayAnimClipFrame (animation, AdvGame.GetAnimLayerInt (AnimLayer.Neck), character.headLookRightAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
					animation [character.headLookRightAnim.name].weight = angles.x;
					animation [character.headLookRightAnim.name].speed = 0f;
				}
				else
				{
					animation.Stop (character.headLookLeftAnim.name);
					animation.Stop (character.headLookRightAnim.name);
				}
			}

			// Vertical
			if (character.headLookUpAnim && character.headLookDownAnim)
			{
				if (angles.y < 0f)
				{
					animation.Stop (character.headLookUpAnim.name);
					AdvGame.PlayAnimClipFrame (animation, AdvGame.GetAnimLayerInt (AnimLayer.Neck) +1, character.headLookDownAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
					animation [character.headLookDownAnim.name].weight = -angles.y;
					animation [character.headLookDownAnim.name].speed = 0f;
				}
				else if (angles.y > 0f)
				{
					animation.Stop (character.headLookDownAnim.name);
					AdvGame.PlayAnimClipFrame (animation, AdvGame.GetAnimLayerInt (AnimLayer.Neck) +1, character.headLookUpAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
					animation [character.headLookUpAnim.name].weight = angles.y;
					animation [character.headLookUpAnim.name].speed = 0f;
				}
				else
				{
					animation.Stop (character.headLookDownAnim.name);
					animation.Stop (character.headLookUpAnim.name);
				}
			}
		}
Exemple #25
0
        /**
         * <summary>Combines the class's various fields into a formatted HTML string, for display in exported game text.</summary>
         * <param name = "languageIndex">The index number of the language to display fields for, where 0 = the game's original language</param>
         * <param name = "includeDescriptions">If True, its description will also be included</param>
         * <param name = "removeTokens">If True, text tokens such as [wait] within the text will be removed</param>
         * <returns>A string of the owner, filename, text and description</returns>
         */
        public string Print(int languageIndex = 0, bool includeDescriptions = false, bool removeTokens = false)
        {
            int i = languageIndex;

            string result = "<table>\n";

            result += "<tr><td><b>Line ID:</b></td><td>" + lineID + "</td></tr>\n";
            result += "<tr><td width=150><b>Character:</b></td><td>" + GetSpeakerName() + "</td></tr>\n";

            string lineText = text;

            if (i > 0 && translationText.Count > (i - 1))
            {
                lineText = translationText [i - 1];
            }

            if (removeTokens)
            {
                Speech tempSpeech = new Speech(lineText);
                lineText = tempSpeech.displayText;
            }

            result += "<tr><td><b>Line text:</b></td><td>" + lineText + "</td></tr>\n";

            if (description != null && description.Length > 0 && includeDescriptions)
            {
                result += "<tr><td><b>Description:</b></td><td>" + description + "</td></tr>\n";
            }

            string        language      = string.Empty;
            SpeechManager speechManager = AdvGame.GetReferences().speechManager;

            if (i > 0 && speechManager.translateAudio)
            {
                language = AdvGame.GetReferences().speechManager.languages[i];
            }

            if (speechManager.autoNameSpeechFiles)
            {
                if (SeparatePlayerAudio())
                {
                    if (speechManager.UseFileBasedLipSyncing())
                    {
                        for (int j = 0; j < KickStarter.settingsManager.players.Count; j++)
                        {
                            if (KickStarter.settingsManager.players[j].playerOb != null)
                            {
                                string overrideName = KickStarter.settingsManager.players[j].playerOb.name;
                                result += "<td><b>Lipsync file:</b></td><td>" + GetFolderName(language, true, overrideName) + GetFilename(overrideName) + lineID.ToString() + "</td></tr>\n";
                            }
                        }
                    }

                    for (int j = 0; j < KickStarter.settingsManager.players.Count; j++)
                    {
                        if (KickStarter.settingsManager.players[j].playerOb != null)
                        {
                            string overrideName = KickStarter.settingsManager.players[j].playerOb.name;
                            result += "<tr><td><b>Audio file:</b></td><td>" + GetFolderName(language, false, overrideName) + GetFilename(overrideName) + lineID.ToString() + "</td></tr>\n";
                        }
                    }
                }
                else
                {
                    if (speechManager.UseFileBasedLipSyncing())
                    {
                        result += "<td><b>Lipsync file:</b></td><td>" + GetFolderName(language, true) + GetFilename() + lineID.ToString() + "</td></tr>\n";
                    }
                    result += "<tr><td><b>Audio file:</b></td><td>" + GetFolderName(language, false) + GetFilename() + lineID.ToString() + "</td></tr>\n";
                }
            }
            else
            {
                if (speechManager.UseFileBasedLipSyncing() && customLipsyncFile != null)
                {
                    result += "<td><b>Lipsync file:</b></td><td>" + customLipsyncFile.name + "</td></tr>\n";
                }
                if (customAudioClip != null)
                {
                    result += "<tr><td><b>Audio file:</b></td><td>" + customAudioClip.name + "</td></tr>\n";
                }
            }

            result += "</table>\n\n";
            result += "<br/>\n";
            return(result);
        }
Exemple #26
0
        /**
         * Updates the values of all blendshapes within the group.
         */
        public void UpdateKeys()
        {
            if (smr == null)
            {
                return;
            }

            foreach (ShapeKey shapeKey in shapeKeys)
            {
                if (changeTime > 0f)
                {
                    float newValue = Mathf.Lerp(shapeKey.value, shapeKey.targetValue, AdvGame.Interpolate(startTime, changeTime, moveMethod, timeCurve));
                    shapeKey.SetValue(newValue, smr);
                    if ((startTime + changeTime) < Time.time)
                    {
                        changeTime = 0f;
                    }
                }
                else
                {
                    shapeKey.SetValue(shapeKey.targetValue, smr);
                }
            }
        }
Exemple #27
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            checkNothing = EditorGUILayout.Toggle("Check for none selected?", checkNothing);
            if (!checkNothing)
            {
                if (!inventoryManager)
                {
                    inventoryManager = AdvGame.GetReferences().inventoryManager;
                }

                if (inventoryManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();

                    int i         = 0;
                    int invNumber = 0;
                    if (parameterID == -1)
                    {
                        invNumber = -1;
                    }

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add(_item.label);

                            // If an item has been removed, make sure selected variable is still valid
                            if (_item.id == invID)
                            {
                                invNumber = i;
                            }

                            i++;
                        }

                        if (invNumber == -1)
                        {
                            Debug.LogWarning("Previously chosen item no longer exists!");
                            invID = 0;
                        }

                        parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                        if (parameterID >= 0)
                        {
                            invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                            invID     = -1;
                        }
                        else
                        {
                            invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                            invID     = inventoryManager.items[invNumber].id;
                        }

                        AfterRunningOption();
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                        invID = -1;
                    }
                }
            }
        }
        /**
         * Ends all skippable ActionLists.
         * This is triggered when the user presses the "EndCutscene" Input button.
         */
        public void EndCutscene()
        {
            if (!IsInSkippableCutscene())
            {
                return;
            }

            if (AdvGame.GetReferences().settingsManager.blackOutWhenSkipping)
            {
                KickStarter.mainCamera.ForceOverlayForFrames(4);
            }

            KickStarter.eventManager.Call_OnSkipCutscene();

            // Stop all non-looping sound
            Sound[] sounds = FindObjectsOfType(typeof(Sound)) as Sound[];
            foreach (Sound sound in sounds)
            {
                if (sound.GetComponent <AudioSource>())
                {
                    if (sound.soundType != SoundType.Music && !sound.GetComponent <AudioSource>().loop)
                    {
                        sound.Stop();
                    }
                }
            }

            // Set correct Player prefab before skipping
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (!noPlayerOnStartQueue && playerIDOnStartQueue >= 0)
                {
                    if (KickStarter.player == null || KickStarter.player.ID != playerIDOnStartQueue)
                    {
                        //
                        PlayerPrefab oldPlayerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerIDOnStartQueue);
                        if (oldPlayerPrefab != null)
                        {
                            if (KickStarter.player != null)
                            {
                                KickStarter.player.Halt();
                            }

                            Player oldPlayer = oldPlayerPrefab.GetSceneInstance();
                            KickStarter.player = oldPlayer;
                        }
                    }
                }
            }

            List <ActiveList> listsToSkip  = new List <ActiveList>();
            List <ActiveList> listsToReset = new List <ActiveList>();

            foreach (ActiveList activeList in activeLists)
            {
                if (!activeList.inSkipQueue && activeList.actionList.IsSkippable())
                {
                    listsToReset.Add(activeList);
                }
                else
                {
                    listsToSkip.Add(activeList);
                }
            }

            foreach (ActiveList activeList in KickStarter.actionListAssetManager.ActiveLists)
            {
                if (!activeList.inSkipQueue && activeList.actionList.IsSkippable())
                {
                    listsToReset.Add(activeList);
                }
                else
                {
                    listsToSkip.Add(activeList);
                }
            }

            foreach (ActiveList listToReset in listsToReset)
            {
                // Kill, but do isolated, to bypass setting GameState etc
                listToReset.Reset(true);
            }

            foreach (ActiveList listToSkip in listsToSkip)
            {
                listToSkip.Skip();
            }
        }
Exemple #29
0
        protected void SharedGUIOne(AC.Char _target)
        {
            _target.GetAnimEngine();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Animation settings:", EditorStyles.boldLabel);
            _target.animationEngine = (AnimationEngine)CustomGUILayout.EnumPopup("Animation engine:", _target.animationEngine, "", "The animation engine that the character relies on for animation playback");
            if (_target.animationEngine == AnimationEngine.Custom)
            {
                _target.customAnimationClass = CustomGUILayout.TextField("Script name:", _target.customAnimationClass, "", "The class name of the AnimEngine ScriptableObject subclass that animates the character");
            }
            _target.motionControl = (MotionControl)CustomGUILayout.EnumPopup("Motion control:", _target.motionControl, "", "How motion is controlled");
            EditorGUILayout.EndVertical();

            _target.GetAnimEngine().CharSettingsGUI();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Movement settings:", EditorStyles.boldLabel);

            if (_target.GetMotionControl() == MotionControl.Automatic)
            {
                _target.walkSpeedScale       = CustomGUILayout.FloatField("Walk speed scale:", _target.walkSpeedScale, "", "The movement speed when walking");
                _target.runSpeedScale        = CustomGUILayout.FloatField("Run speed scale:", _target.runSpeedScale, "", "The movement speed when running");
                _target.acceleration         = CustomGUILayout.FloatField("Acceleration:", _target.acceleration, "", "The acceleration factor");
                _target.deceleration         = CustomGUILayout.FloatField("Deceleration:", _target.deceleration, "", "The deceleration factor");
                _target.runDistanceThreshold = CustomGUILayout.FloatField("Minimum run distance:", _target.runDistanceThreshold, "", "The minimum distance between the character and its destination for running to be possible");
            }
            if (_target.GetMotionControl() != MotionControl.Manual)
            {
                _target.turnSpeed = CustomGUILayout.FloatField("Turn speed:", _target.turnSpeed, "", "The turn speed");

                if (_target.GetAnimEngine().isSpriteBased)
                {
                    _target.turn2DCharactersIn3DSpace = CustomGUILayout.Toggle("Turn root object in 3D?", _target.turn2DCharactersIn3DSpace, "", "If True, then the root object of a 2D, sprite-based character will rotate around the Z-axis. Otherwise, turning will be simulated and the actual rotation will be unaffected");
                }
            }
            _target.turnBeforeWalking = CustomGUILayout.Toggle("Turn before walking?", _target.turnBeforeWalking, "", "If True, the character will turn on the spot to face their destination before moving");
            _target.retroPathfinding  = CustomGUILayout.Toggle("Retro-style movement?", _target.retroPathfinding, "", "Enables 'retro-style' movement when pathfinding, where characters ignore Acceleration and Deceleration values, and turn instantly when moving");

            _target.headTurnSpeed = CustomGUILayout.Slider("Head turn speed:", _target.headTurnSpeed, 0.1f, 20f, "", "The speed of head-turning");
            if (_target is Player && AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.PlayerCanReverse())
            {
                _target.reverseSpeedFactor = CustomGUILayout.Slider("Reverse speed factor:", _target.reverseSpeedFactor, 0f, 1f, "", "The factor by which speed is reduced when reversing");
            }

            EditorGUILayout.EndVertical();
        }
Exemple #30
0
        private static void UpdateCB()
        {
            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& !AdvGame.GetReferences().settingsManager.showHierarchyIcons)
            {
                return;
            }

            actionLists = Object.FindObjectsOfType(typeof(ActionList)) as ActionList[];

            actionListIDs = new List <int>();
            foreach (ActionList actionList in actionLists)
            {
                actionListIDs.Add(actionList.gameObject.GetInstanceID());
            }

            constantIDs = Object.FindObjectsOfType(typeof(ConstantID)) as ConstantID[];
            rememberIDs = new List <int>();
            foreach (ConstantID constantID in constantIDs)
            {
                rememberIDs.Add(constantID.gameObject.GetInstanceID());
            }
        }