public override void OnInspectorGUI()
        {
            if (_target == null || settingsManager == null)
            {
                return;
            }

            if (settingsManager.IsUnity2D())
            {
                if (_target.GetComponent <Collider2D>() == null)
                {
                    EditorGUILayout.HelpBox("A 2D Collider component must be placed on this object.", MessageType.Warning);
                }
                else if (_target.GetComponent <Collider2D>() != null && !_target.GetComponent <Collider2D>().isTrigger)
                {
                    EditorGUILayout.HelpBox("This object's 2D Collider component must have 'Is Trigger?' set.", MessageType.Warning);
                }

                if (_target.GetComponent <Rigidbody2D>() == null && _target.GetComponentInParent <Rigidbody2D>() == null)
                {
                    EditorGUILayout.HelpBox("A 2D Rigidbody component must be placed on this object.", MessageType.Warning);
                }
            }
            else
            {
                if (_target.GetComponent <Collider>() == null)
                {
                    EditorGUILayout.HelpBox("A Collider component must be placed on this object.", MessageType.Warning);
                }
                else if (_target.GetComponent <Collider>() != null && !_target.GetComponent <Collider>().isTrigger)
                {
                    EditorGUILayout.HelpBox("This object's Collider component must have 'Is Trigger?' set.", MessageType.Warning);
                }

                if (_target.GetComponent <Rigidbody>() == null && _target.GetComponentInParent <Rigidbody>() == null)
                {
                    EditorGUILayout.HelpBox("A Rigidbody component must be placed on this object.", MessageType.Warning);
                }
            }
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            if (!sideIcon)
            {
                sideIcon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D));
            }

            if (AdvGame.GetReferences() == null)
            {
                Debug.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 (_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);

                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.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);
                }
                EditorGUILayout.Space();

                UseInteractionGUI();

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

                EditorGUILayout.Space();
                InvInteractionGUI();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        private void DeclareScenePrefabs()
        {
            scenePrefabs = new List <ScenePrefab>();
            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            if (settingsManager == null || settingsManager.cameraPerspective == CameraPerspective.ThreeD)
            {
                scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera", "Camera/GameCamera", "_GameCameras", "The standard camera type for 3D games.", "GameCamera"));
                scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera Animated", "Camera/GameCameraAnimated", "_GameCameras", "Plays an Animation Clip when active, or syncs it with its target's position.", "GameCameraAnimated"));
                scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera Third-person", "Camera/GameCameraThirdPerson", "_GameCameras", "Rigidly follows its target, but can still be rotated.", "GameCameraThirdPerson"));
                scenePrefabs.Add(new ScenePrefab("Camera", "SimpleCamera", "Camera/SimpleCamera", "_GameCameras", "A stationary but lightweight 3D camera.", "GameCamera"));
            }
            else
            {
                if (settingsManager.cameraPerspective == CameraPerspective.TwoD)
                {
                    scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera 2D", "Camera/GameCamera2D", "_GameCameras", "The standard camera type for 2D games.", "GameCamera2D"));
                }
                else
                {
                    scenePrefabs.Add(new ScenePrefab("Camera", "GameCamera 2.5D", "Camera/GameCamera2.5D", "_GameCameras", "A stationary camera that can display images in the background.", "GameCamera25D"));
                    scenePrefabs.Add(new ScenePrefab("Camera", "Background Image", "SetGeometry/BackgroundImage", "_BackgroundImages", "A container for a 2.5D camera's background image.", "BackgroundImage"));
                    scenePrefabs.Add(new ScenePrefab("Camera", "Scene sprite", "SetGeometry/SceneSprite", "_SetGeometry", "An in-scene sprite for 2.5D games.", "", "SceneSprite"));
                }
            }

            scenePrefabs.Add(new ScenePrefab("Logic", "Arrow prompt", "Logic/ArrowPrompt", "_ArrowPrompts", "An on-screen directional prompt for the player.", "ArrowPrompt"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Conversation", "Logic/Conversation", "_Conversations", "Stores a list of Dialogue Options, from which the player can choose.", "Conversation"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Container", "Logic/Container", "_Containers", "Can store a list of Inventory Items, for the player to retrieve and add to.", "Container"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Cutscene", "Logic/Cutscene", "_Cutscenes", "A sequence of Actions that can form a cinematic.", "Cutscene"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Dialogue Option", "Logic/DialogueOption", "_DialogueOptions", "An option available to the player when a Conversation is active.", "DialogueOption"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Hotspot 2D", "Logic/Hotspot2D", "_Hotspots", "A portion of the scene that can be interacted with.", "Hotspot"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Hotspot", "Logic/Hotspot", "_Hotspots", "A portion of the scene that can be interacted with.", "Hotspot"));
            }

            scenePrefabs.Add(new ScenePrefab("Logic", "Interaction", "Logic/Interaction", "_Interactions", "A sequence of Actions that run when a Hotspot is activated.", "Interaction"));
            scenePrefabs.Add(new ScenePrefab("Logic", "Sound", "Logic/Sound", "_Sounds", "An audio source that syncs with AC's sound levels.", "Sound"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Trigger 2D", "Logic/Trigger2D", "_Triggers", "A portion of the scene that responds to objects entering it.", "AC_Trigger"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Logic", "Trigger", "Logic/Trigger", "_Triggers", "A portion of the scene that responds to objects entering it.", "AC_Trigger"));
            }

            scenePrefabs.Add(new ScenePrefab("Moveable", "Draggable", "Moveable/Draggable", "_Moveables", "Can move along pre-defined Tracks, along planes, or be rotated about its centre.", "Moveable_Drag"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "PickUp", "Moveable/PickUp", "_Moveables", "Can be grabbed, rotated and thrown freely in 3D space.", "Moveable_PickUp"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "Straight Track", "Moveable/StraightTrack", "_Tracks", "Constrains a Drag object along a straight line, optionally adding rolling or screw effects.", "DragTrack_Straight"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "Curved Track", "Moveable/CurvedTrack", "_Tracks", "Constrains a Drag object along a circular line.", "DragTrack_Curved"));
            scenePrefabs.Add(new ScenePrefab("Moveable", "Hinge Track", "Moveable/HingeTrack", "_Tracks", "Constrains a Drag object's position, only allowing it to rotate in a circular motion.", "DragTrack_Hinge"));

            scenePrefabs.Add(new ScenePrefab("Navigation", "SortingMap", "Navigation/SortingMap", "_SortingMaps", "Defines how sprites are scaled and sorted relative to one another.", "SortingMap"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "Collision Cube 2D", "Navigation/CollisionCube2D", "_CollisionCubes", "Blocks Character movement, as well as cursor clicks if placed on the Default layer.", "_Collision"));
                scenePrefabs.Add(new ScenePrefab("Navigation", "Marker 2D", "Navigation/Marker2D", "_Markers", "A point in the scene used by Characters and objects.", "Marker"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "Collision Cube", "Navigation/CollisionCube", "_CollisionCubes", "Blocks Character movement, as well as cursor clicks if placed on the Default layer.", "_Collision"));
                scenePrefabs.Add(new ScenePrefab("Navigation", "Collision Cylinder", "Navigation/CollisionCylinder", "_CollisionCylinders", "Blocks Character movement, as well as cursor clicks if placed on the Default layer.", "_Collision"));
                scenePrefabs.Add(new ScenePrefab("Navigation", "Marker", "Navigation/Marker", "_Markers", "A point in the scene used by Characters and objects.", "Marker"));
            }

            if (KickStarter.sceneSettings)
            {
                AC_NavigationMethod engine = KickStarter.sceneSettings.navigationMethod;
                if (engine == AC_NavigationMethod.meshCollider)
                {
                    scenePrefabs.Add(new ScenePrefab("Navigation", "NavMesh", "Navigation/NavMesh", "_NavMesh", "A mesh that defines the area that Characters can move in.", "NavigationMesh"));
                }
                else if (engine == AC_NavigationMethod.PolygonCollider)
                {
                    scenePrefabs.Add(new ScenePrefab("Navigation", "NavMesh 2D", "Navigation/NavMesh2D", "_NavMesh", "A polygon that defines the area that Characters can move in.", "NavigationMesh"));
                }
                else if (engine == AC_NavigationMethod.UnityNavigation)
                {
                    scenePrefabs.Add(new ScenePrefab("Navigation", "NavMesh segment", "Navigation/NavMeshSegment", "_NavMeshSegments", "A plane that defines a portion of the area that Characters can move in.", "NavMeshSegment"));
                    scenePrefabs.Add(new ScenePrefab("Navigation", "Static obstacle", "Navigation/StaticObstacle", "_NavMeshSegments", "A cube that defines a portion of the area that Characters cannot move in.", "", "StaticObstacle"));
                }
            }

            scenePrefabs.Add(new ScenePrefab("Navigation", "Path", "Navigation/Path", "_Paths", "A sequence of points that describe a Character's movement.", "Paths"));

            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "PlayerStart 2D", "Navigation/PlayerStart2D", "_PlayerStarts", "A point in the scene from which the Player begins.", "PlayerStart"));
            }
            else
            {
                scenePrefabs.Add(new ScenePrefab("Navigation", "PlayerStart", "Navigation/PlayerStart", "_PlayerStarts", "A point in the scene from which the Player begins.", "PlayerStart"));
            }
        }
Exemple #5
0
        public void ShowGUI()
        {
            GUILayout.Label("Basic structure", EditorStyles.boldLabel);

            if (GUILayout.Button("Organise room objects"))
            {
                InitialiseObjects();
            }

            if (AdvGame.GetReferences().settingsManager == null)
            {
                EditorGUILayout.HelpBox("No Settings Manager defined - cannot display full Editor without it!", MessageType.Warning);
                return;
            }

            if (KickStarter.sceneSettings == null)
            {
                return;
            }

            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            EditorGUILayout.BeginHorizontal();
            newFolderName = EditorGUILayout.TextField(newFolderName);

            if (GUILayout.Button("Create new folder", buttonWidth))
            {
                if (newFolderName != "")
                {
                    GameObject newFolder = new GameObject();

                    if (!newFolderName.StartsWith("_"))
                    {
                        newFolder.name = "_" + newFolderName;
                    }
                    else
                    {
                        newFolder.name = newFolderName;
                    }

                    Undo.RegisterCreatedObjectUndo(newFolder, "Create folder " + newFolder.name);

                    if (Selection.activeGameObject)
                    {
                        newFolder.transform.parent = Selection.activeGameObject.transform;
                    }

                    Selection.activeObject = newFolder;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            GUILayout.Label("Scene settings", EditorStyles.boldLabel);
            KickStarter.sceneSettings.navigationMethod = (AC_NavigationMethod)EditorGUILayout.EnumPopup("Pathfinding method:", KickStarter.sceneSettings.navigationMethod);
            KickStarter.navigationManager.ResetEngine();
            if (KickStarter.navigationManager.navigationEngine != null)
            {
                KickStarter.navigationManager.navigationEngine.SceneSettingsGUI();
            }

            if (settingsManager.IsUnity2D() && KickStarter.sceneSettings.navigationMethod != AC_NavigationMethod.PolygonCollider)
            {
                EditorGUILayout.HelpBox("This pathfinding method is not compatible with 'Unity 2D'.", MessageType.Warning);
            }

            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.defaultPlayerStart = (PlayerStart)EditorGUILayout.ObjectField("Default PlayerStart:", KickStarter.sceneSettings.defaultPlayerStart, typeof(PlayerStart), true);
            if (KickStarter.sceneSettings.defaultPlayerStart == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    PlayerStart newPlayerStart = AddPrefab("Navigation", "PlayerStart", true, false, true).GetComponent <PlayerStart>();
                    newPlayerStart.gameObject.name = "Default PlayerStart";
                    KickStarter.sceneSettings.defaultPlayerStart = newPlayerStart;
                }
            }
            EditorGUILayout.EndHorizontal();
            if (KickStarter.sceneSettings.defaultPlayerStart)
            {
                EditorGUILayout.BeginHorizontal();
                KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = (_Camera)EditorGUILayout.ObjectField("Default Camera:", KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart, typeof(_Camera), true);
                if (KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        if (settingsManager == null || settingsManager.cameraPerspective == CameraPerspective.ThreeD)
                        {
                            GameCamera newCamera = AddPrefab("Camera", "GameCamera", true, false, true).GetComponent <GameCamera>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                        else if (settingsManager.cameraPerspective == CameraPerspective.TwoD)
                        {
                            GameCamera2D newCamera = AddPrefab("Camera", "GameCamera2D", true, false, true).GetComponent <GameCamera2D>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                        else if (settingsManager.cameraPerspective == CameraPerspective.TwoPointFiveD)
                        {
                            GameCamera25D newCamera = AddPrefab("Camera", "GameCamera2.5D", true, false, true).GetComponent <GameCamera25D>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.sortingMap = (SortingMap)EditorGUILayout.ObjectField("Default Sorting map:", KickStarter.sceneSettings.sortingMap, typeof(SortingMap), true);
            if (KickStarter.sceneSettings.sortingMap == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    SortingMap newSortingMap = AddPrefab("Navigation", "SortingMap", true, false, true).GetComponent <SortingMap>();
                    newSortingMap.gameObject.name        = "Default SortingMap";
                    KickStarter.sceneSettings.sortingMap = newSortingMap;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.defaultSound = (Sound)EditorGUILayout.ObjectField("Default Sound prefab:", KickStarter.sceneSettings.defaultSound, typeof(Sound), true);
            if (KickStarter.sceneSettings.defaultSound == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Sound newSound = AddPrefab("Logic", "Sound", true, false, true).GetComponent <Sound>();
                    newSound.gameObject.name = "Default Sound";
                    KickStarter.sceneSettings.defaultSound = newSound;
                    newSound.playWhilePaused = true;
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Label("Scene cutscenes", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnStart = (Cutscene)EditorGUILayout.ObjectField("On start:", KickStarter.sceneSettings.cutsceneOnStart, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnStart == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnStart";
                    KickStarter.sceneSettings.cutsceneOnStart = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnLoad = (Cutscene)EditorGUILayout.ObjectField("On load:", KickStarter.sceneSettings.cutsceneOnLoad, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnLoad == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnLoad";
                    KickStarter.sceneSettings.cutsceneOnLoad = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnVarChange = (Cutscene)EditorGUILayout.ObjectField("On variable change:", KickStarter.sceneSettings.cutsceneOnVarChange, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnVarChange == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnVarChange";
                    KickStarter.sceneSettings.cutsceneOnVarChange = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.Label("Visibility", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Triggers", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetTriggerVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetTriggerVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Collision", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetCollisionVisiblity(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetCollisionVisiblity(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Hotspots", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetHotspotVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetHotspotVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("NavMesh", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                KickStarter.navigationManager.navigationEngine.SetVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                KickStarter.navigationManager.navigationEngine.SetVisibility(false);
            }
            GUILayout.EndHorizontal();

            ListPrefabs();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(KickStarter.sceneSettings);
                EditorUtility.SetDirty(KickStarter.playerMovement);
                if (KickStarter.sceneSettings.defaultPlayerStart)
                {
                    EditorUtility.SetDirty(KickStarter.sceneSettings.defaultPlayerStart);
                }
            }
        }
Exemple #6
0
        public void InitialiseObjects()
        {
            CreateFolder("_Cameras");
            CreateFolder("_Cutscenes");
            CreateFolder("_DialogueOptions");
            CreateFolder("_Interactions");
            CreateFolder("_Lights");
            CreateFolder("_Logic");
            CreateFolder("_Moveables");
            CreateFolder("_Navigation");
            CreateFolder("_NPCs");
            CreateFolder("_Sounds");
            CreateFolder("_SetGeometry");
            CreateFolder("_UI");

            // Create subfolders
            CreateSubFolder("_Cameras", "_GameCameras");

            CreateSubFolder("_Logic", "_ArrowPrompts");
            CreateSubFolder("_Logic", "_Conversations");
            CreateSubFolder("_Logic", "_Containers");
            CreateSubFolder("_Logic", "_Hotspots");
            CreateSubFolder("_Logic", "_Triggers");

            CreateSubFolder("_Moveables", "_Tracks");

            CreateSubFolder("_Navigation", "_CollisionCubes");
            CreateSubFolder("_Navigation", "_CollisionCylinders");
            CreateSubFolder("_Navigation", "_Markers");
            CreateSubFolder("_Navigation", "_NavMeshSegments");
            CreateSubFolder("_Navigation", "_NavMesh");
            CreateSubFolder("_Navigation", "_Paths");
            CreateSubFolder("_Navigation", "_PlayerStarts");
            CreateSubFolder("_Navigation", "_SortingMaps");

            // Delete default main camera
            if (GameObject.FindWithTag(Tags.mainCamera))
            {
                GameObject mainCam = GameObject.FindWithTag(Tags.mainCamera);
                if (mainCam.GetComponent <MainCamera>() == null)
                {
                    DestroyImmediate(mainCam);
                }
            }

            // Create main camera
            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;
            GameObject      mainCamOb       = AddPrefab("Automatic", "MainCamera", false, false, false);

            PrefabUtility.DisconnectPrefabInstance(mainCamOb);
            PutInFolder(GameObject.FindWithTag(Tags.mainCamera), "_Cameras");
            if (settingsManager && settingsManager.IsUnity2D())
            {
                Camera.main.orthographic = true;
            }

            // Create Background Camera (if 2.5D)
            if (settingsManager && settingsManager.cameraPerspective == CameraPerspective.TwoPointFiveD)
            {
                CreateSubFolder("_SetGeometry", "_BackgroundImages");
                GameObject newOb = AddPrefab("Automatic", "BackgroundCamera", false, false, false);
                PutInFolder(newOb, "_Cameras");
            }

            // Create Game engine
            AddPrefab("Automatic", "GameEngine", false, false, false);

            // Assign Player Start
            if (KickStarter.sceneSettings && KickStarter.sceneSettings.defaultPlayerStart == null)
            {
                string playerStartPrefab = "PlayerStart";
                if (settingsManager != null && settingsManager.IsUnity2D())
                {
                    playerStartPrefab += "2D";
                }

                PlayerStart playerStart = AddPrefab("Navigation", playerStartPrefab, true, false, true).GetComponent <PlayerStart>();
                KickStarter.sceneSettings.defaultPlayerStart = playerStart;
            }

            // Pathfinding method
            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                KickStarter.sceneSettings.navigationMethod = AC_NavigationMethod.PolygonCollider;
                KickStarter.navigationManager.ResetEngine();
            }
        }
Exemple #7
0
        public void InitialiseObjects(bool createFolders = true)
        {
            if (createFolders)
            {
                CreateFolder("_Cameras");
                CreateFolder("_Cutscenes");
                CreateFolder("_DialogueOptions");
                CreateFolder("_Interactions");
                CreateFolder("_Lights");
                CreateFolder("_Logic");
                CreateFolder("_Moveables");
                CreateFolder("_Navigation");
                CreateFolder("_NPCs");
                CreateFolder("_Sounds");
                CreateFolder("_SetGeometry");
                CreateFolder("_UI");

                // Create subfolders
                CreateSubFolder("_Cameras", "_GameCameras");

                CreateSubFolder("_Logic", "_ArrowPrompts");
                CreateSubFolder("_Logic", "_Conversations");
                CreateSubFolder("_Logic", "_Containers");
                CreateSubFolder("_Logic", "_Hotspots");
                CreateSubFolder("_Logic", "_Triggers");

                CreateSubFolder("_Moveables", "_Tracks");

                CreateSubFolder("_Navigation", "_CollisionCubes");
                CreateSubFolder("_Navigation", "_CollisionCylinders");
                CreateSubFolder("_Navigation", "_Markers");
                CreateSubFolder("_Navigation", "_NavMeshSegments");
                CreateSubFolder("_Navigation", "_NavMesh");
                CreateSubFolder("_Navigation", "_Paths");
                CreateSubFolder("_Navigation", "_PlayerStarts");
                CreateSubFolder("_Navigation", "_SortingMaps");
            }

            // Delete default main camera
            if (GameObject.FindWithTag(Tags.mainCamera))
            {
                GameObject oldMainCam = GameObject.FindWithTag(Tags.mainCamera);

                // Untag UFPS Camera
                if (UltimateFPSIntegration.IsUFPSCamera(oldMainCam.GetComponent <Camera>()))
                {
                    oldMainCam.tag = "Untagged";
                    Debug.Log("Untagged UFPS camera '" + oldMainCam.name + "' as MainCamera, to make way for Adventure Creator MainCamera.");
                }
                else if (oldMainCam.GetComponent <MainCamera>() == null)
                {
                    if (oldMainCam.GetComponent <Camera>())
                    {
                        oldMainCam.AddComponent <MainCamera>();

                        string     camPrefabfileName = assetFolder + "Automatic" + Path.DirectorySeparatorChar.ToString() + "MainCamera.prefab";
                        GameObject camPrefab         = (GameObject)AssetDatabase.LoadAssetAtPath(camPrefabfileName, typeof(GameObject));
                        Texture2D  prefabFadeTexture = camPrefab.GetComponent <MainCamera>().fadeTexture;

                        oldMainCam.GetComponent <MainCamera>().Initialise(prefabFadeTexture);

                        PutInFolder(GameObject.FindWithTag(Tags.mainCamera), "_Cameras");
                        Debug.Log("'" + oldMainCam.name + "' has been converted to an Adventure Creator MainCamera.");
                    }
                    else
                    {
                        Debug.Log("Removed old MainCamera '" + oldMainCam.name + "' from scene, as it had no Camera component.");
                        DestroyImmediate(oldMainCam);
                    }
                }
            }

            // Create main camera if none exists
            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            if (!GameObject.FindWithTag(Tags.mainCamera))
            {
                GameObject mainCamOb = AddPrefab("Automatic", "MainCamera", false, false, false);
                PrefabUtility.DisconnectPrefabInstance(mainCamOb);
                PutInFolder(mainCamOb, "_Cameras");
                if (settingsManager && settingsManager.IsUnity2D())
                {
                    Camera.main.orthographic = true;
                }
            }

            // Create Background Camera (if 2.5D)
            if (settingsManager && settingsManager.cameraPerspective == CameraPerspective.TwoPointFiveD)
            {
                CreateSubFolder("_SetGeometry", "_BackgroundImages");
                GameObject newOb = AddPrefab("Automatic", "BackgroundCamera", false, false, false);
                PutInFolder(newOb, "_Cameras");
            }

            // Create Game engine
            AddPrefab("Automatic", "GameEngine", false, false, false);

            // Assign Player Start
            if (KickStarter.sceneSettings && KickStarter.sceneSettings.defaultPlayerStart == null)
            {
                string playerStartPrefab = "PlayerStart";
                if (settingsManager != null && settingsManager.IsUnity2D())
                {
                    playerStartPrefab += "2D";
                }

                PlayerStart playerStart = AddPrefab("Navigation", playerStartPrefab, true, false, true).GetComponent <PlayerStart>();
                KickStarter.sceneSettings.defaultPlayerStart = playerStart;
            }

            // Pathfinding method
            if (settingsManager != null && settingsManager.IsUnity2D())
            {
                KickStarter.sceneSettings.navigationMethod = AC_NavigationMethod.PolygonCollider;
                KickStarter.navigationManager.ResetEngine();
            }
        }
Exemple #8
0
        public static void ResetPlayer(Player ref_player, int ID, bool resetReferences, Quaternion _rotation)
        {
            // Delete current player
            if (GameObject.FindWithTag(Tags.player))
            {
                DestroyImmediate(GameObject.FindWithTag(Tags.player));
            }

            // Load new player
            if (ref_player)
            {
                SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

                Player newPlayer = (Player)Instantiate(ref_player, Vector3.zero, _rotation);
                newPlayer.ID   = ID;
                newPlayer.name = ref_player.name;
                playerPrefab   = newPlayer;
                DontDestroyOnLoad(newPlayer);

                if (KickStarter.runtimeInventory)
                {
                    KickStarter.runtimeInventory.SetNull();
                    KickStarter.runtimeInventory.RemoveRecipes();

                    // Clear inventory
                    if (!settingsManager.shareInventory)
                    {
                        KickStarter.runtimeInventory.localItems.Clear();
                    }

                    if (KickStarter.saveSystem != null && KickStarter.saveSystem.DoesPlayerDataExist(ID, false))
                    {
                        saveSystem.AssignPlayerData(ID, !settingsManager.shareInventory);
                    }

                    // Menus
                    foreach (AC.Menu menu in PlayerMenus.GetMenus())
                    {
                        foreach (MenuElement element in menu.elements)
                        {
                            if (element is MenuInventoryBox)
                            {
                                MenuInventoryBox invBox = (MenuInventoryBox)element;
                                invBox.ResetOffset();
                            }
                        }
                    }
                }

                if (newPlayer.GetComponent <Animation>())
                {
                    // Hack: Force idle of Legacy characters
                    AdvGame.PlayAnimClip(newPlayer.GetComponent <Animation>(), AdvGame.GetAnimLayerInt(AnimLayer.Base), newPlayer.idleAnim, AnimationBlendMode.Blend, WrapMode.Loop, 0f, null, false);
                }
                else if (newPlayer.spriteChild)
                {
                    // Hack: update 2D sprites
                    if (newPlayer.spriteChild.GetComponent <FollowSortingMap>())
                    {
                        newPlayer.spriteChild.GetComponent <FollowSortingMap>().UpdateSortingMap();
                    }
                    newPlayer.UpdateSpriteChild(settingsManager.IsTopDown(), settingsManager.IsUnity2D());
                }
                newPlayer.animEngine.PlayIdle();
            }

            // Reset player references
            if (resetReferences)
            {
                KickStarter.sceneSettings.ResetPlayerReference();
                KickStarter.playerMovement.AssignFPCamera();
                KickStarter.stateHandler.IgnoreNavMeshCollisions();
                KickStarter.stateHandler.GatherObjects(false);
                _Camera[] cameras = FindObjectsOfType(typeof(_Camera)) as _Camera[];
                foreach (_Camera camera in cameras)
                {
                    camera.ResetTarget();
                }
            }
        }