Ejemplo n.º 1
0
        public static void SetGameEngine(GameObject _gameEngine = null)
        {
            if (_gameEngine != null)
            {
                gameEnginePrefab = _gameEngine;

                menuSystemComponent        = null;
                playerCursorComponent      = null;
                playerInputComponent       = null;
                playerInteractionComponent = null;
                playerMovementComponent    = null;
                playerMenusComponent       = null;
                playerQTEComponent         = null;
                kickStarterComponent       = null;
                sceneSettingsComponent     = null;
                dialogComponent            = null;
                menuPreviewComponent       = null;
                navigationManagerComponent = null;
                actionListManagerComponent = null;
                localVariablesComponent    = null;
                eventManagerComponent      = null;

                return;
            }

            if (gameEnginePrefab == null)
            {
                SceneSettings sceneSettings = UnityVersionHandler.GetKickStarterComponent <SceneSettings>();
                if (sceneSettings != null)
                {
                    gameEnginePrefab = sceneSettings.gameObject;
                }
            }
        }
Ejemplo n.º 2
0
 /**
  * Alerts the StateHandler that a Game Engine prefab is no longer present in the scene.
  * This is called from KickStarter's OnDestroy function.
  */
 public void Unregister(KickStarter kickStarter)
 {
     if (kickStarter != null && activeKickStarter == kickStarter)
     {
         activeKickStarter = null;
     }
 }
Ejemplo n.º 3
0
        public override float Run()
        {
            switch (endGameType)
            {
            case AC_EndGameType.QuitGame:
                                        #if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
                                        #else
                Application.Quit();
                                        #endif
                break;

            case AC_EndGameType.LoadAutosave:
                SaveSystem.LoadAutoSave();
                break;

            case AC_EndGameType.RestartGame:
                int _sceneIndex = (chooseSceneBy == ChooseSceneBy.Name) ? KickStarter.sceneChanger.NameToIndex(sceneName) : sceneNumber;
                KickStarter.RestartGame(resetMenus, _sceneIndex);
                break;

            case AC_EndGameType.ResetScene:
                KickStarter.sceneChanger.ResetCurrentScene();
                break;

            default:
                break;
            }

            return(0f);
        }
Ejemplo n.º 4
0
        private void Awake()
        {
            UnityVersionHandler.EnsureSingleScene ();

            if (!UnityVersionHandler.ObjectIsInActiveScene (gameObject))
            {
                return;
            }

            activeKickStarter = FindObjectOfType <KickStarter>();

            if (activeKickStarter != null)
            {
                KickStarter.mainCamera.OnAwake ();
                activeKickStarter.OnAwake ();
                KickStarter.playerInput.OnAwake ();
                KickStarter.playerQTE.OnAwake ();
                KickStarter.sceneSettings.OnAwake ();
                KickStarter.dialog.OnAwake ();
                KickStarter.navigationManager.OnAwake ();
                KickStarter.actionListManager.OnAwake ();

                KickStarter.stateHandler.RegisterWithGameEngine ();
            }
            else
            {
                ACDebug.LogError ("No KickStarter component found in the scene!");
            }
        }
Ejemplo n.º 5
0
        private void Awake()
        {
            UnityVersionHandler.EnsureSingleScene();

            if (!UnityVersionHandler.ObjectIsInActiveScene(gameObject))
            {
                return;
            }

            activeKickStarter = FindObjectOfType <KickStarter>();

            if (activeKickStarter != null)
            {
                KickStarter.mainCamera.OnAwake();
                activeKickStarter.OnAwake();
                KickStarter.playerInput.OnAwake();
                KickStarter.playerQTE.OnAwake();
                KickStarter.sceneSettings.OnAwake();
                KickStarter.dialog.OnAwake();
                KickStarter.navigationManager.OnAwake();
                KickStarter.actionListManager.OnAwake();

                KickStarter.stateHandler.RegisterWithGameEngine();
            }
            else
            {
                ACDebug.LogError("No KickStarter component found in the scene!");
            }
        }
Ejemplo n.º 6
0
        /**
         * <summary>Syncs the component with the correct scene.</summary>
         * <param name = "_multiSceneChecker">The MultiSceneChecker component in the scene for which this component is to sync with.</param>
         */
        public void Initialise(MultiSceneChecker _multiSceneChecker)
        {
            Scene scene = _multiSceneChecker.gameObject.scene;

            kickStarter = _multiSceneChecker.GetComponent <KickStarter>();

            sceneIndex      = scene.buildIndex;
            gameObject.name = "SubScene " + sceneIndex;

            localVariables = _multiSceneChecker.GetComponent <LocalVariables>();
            sceneSettings  = _multiSceneChecker.GetComponent <SceneSettings>();

            UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, scene);

            kickStarter = _multiSceneChecker.GetComponent <KickStarter> ();
            _multiSceneChecker.gameObject.SetActive(false);

            mainCamera = UnityVersionHandler.GetOwnSceneInstance <MainCamera> (gameObject);
            if (mainCamera)
            {
                mainCamera.gameObject.SetActive(false);
            }

            Player ownPlayer = UnityVersionHandler.GetOwnSceneInstance <Player> (gameObject);

            if (ownPlayer)
            {
                ownPlayer.gameObject.SetActive(false);
            }
            if (sceneSettings.OverridesCameraPerspective())
            {
                ACDebug.LogError("The added scene (" + scene.name + ", " + scene.buildIndex + ") overrides the default camera perspective - this feature should not be used in conjunction with multiple-open scenes.", gameObject);
            }
            KickStarter.sceneChanger.RegisterSubScene(this);
        }
        /**
         * Ends all skippable ActionLists.
         * This is triggered when the user presses the "EndCutscene" Input button.
         */
        public void EndCutscene()
        {
            if (!IsGameplayBlocked())
            {
                return;
            }

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

            // 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
            if (KickStarter.player != null && playerIDOnStartQueue != KickStarter.player.ID && playerIDOnStartQueue >= 0)
            {
                Player playerToRevertTo = KickStarter.settingsManager.GetPlayer(playerIDOnStartQueue);
                KickStarter.ResetPlayer(playerToRevertTo, playerIDOnStartQueue, true, Quaternion.identity);
            }

            for (int i = 0; i < activeLists.Count; i++)
            {
                if (!activeLists[i].inSkipQueue && activeLists[i].actionList.IsSkippable())
                {
                    // Kill, but do isolated, to bypass setting GameState etc
                    activeLists[i].Reset(true);
                }
                else
                {
                    activeLists[i].Skip();
                }
            }

            for (int i = 0; i < KickStarter.actionListAssetManager.activeLists.Count; i++)
            {
                if (!KickStarter.actionListAssetManager.activeLists[i].inSkipQueue && KickStarter.actionListAssetManager.activeLists[i].actionList.IsSkippable())
                {
                    // Kill, but do isolated, to bypass setting GameState etc
                    KickStarter.actionListAssetManager.activeLists[i].Reset(true);
                }
                else
                {
                    KickStarter.actionListAssetManager.activeLists[i].Skip();
                }
            }
        }
Ejemplo n.º 8
0
        public override float Run()
        {
            if (endGameType == AC_EndGameType.QuitGame)
            {
                                #if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
                                #else
                Application.Quit();
                                #endif
            }
            else if (endGameType == AC_EndGameType.LoadAutosave)
            {
                SaveSystem.LoadAutoSave();
            }
            else
            {
                KickStarter.runtimeInventory.SetNull();
                KickStarter.runtimeInventory.RemoveRecipes();

                if (KickStarter.player)
                {
                    DestroyImmediate(KickStarter.player.gameObject);
                }

                if (endGameType == AC_EndGameType.RestartGame)
                {
                    KickStarter.ResetPlayer(KickStarter.settingsManager.GetDefaultPlayer(), KickStarter.settingsManager.GetDefaultPlayerID(), false, Quaternion.identity);

                    KickStarter.saveSystem.ClearAllData();
                    KickStarter.levelStorage.ClearAllLevelData();
                    KickStarter.runtimeInventory.OnStart();
                    KickStarter.runtimeDocuments.OnStart();
                    KickStarter.runtimeVariables.OnStart();

                    if (resetMenus)
                    {
                        KickStarter.playerMenus.RebuildMenus();
                    }

                    KickStarter.eventManager.Call_OnRestartGame();

                    KickStarter.stateHandler.CanGlobalOnStart();
                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(chooseSceneBy, sceneName, sceneNumber), false, true);
                }
                else if (endGameType == AC_EndGameType.ResetScene)
                {
                    sceneNumber = UnityVersionHandler.GetCurrentSceneNumber();
                    KickStarter.levelStorage.ClearCurrentLevelData();
                    KickStarter.sceneChanger.ChangeScene(new SceneInfo("", sceneNumber), false, true);
                }
            }

            return(0f);
        }
Ejemplo n.º 9
0
        /**
         * Ends all skippable ActionLists.
         * This is triggered when the user presses the "EndCutscene" Input button.
         */
        public void EndCutscene()
        {
            if (!IsGameplayBlocked())
            {
                return;
            }

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

            // 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();
                    }
                }
            }

            for (int i = 0; i < activeLists.Count; i++)
            {
                if (!ListIsInSkipQueue(activeLists[i]) && activeLists[i].IsSkippable())
                {
                    // Kill, but do isolated, to bypass setting GameState etc
                    ActionList listToRemove = activeLists[i];
                    listToRemove.ResetList();
                    activeLists.RemoveAt(i);
                    i -= 1;

                    if (listToRemove is RuntimeActionList)
                    {
                        Destroy(listToRemove.gameObject);
                    }
                }
            }

            // Set correct Player prefab
            if (KickStarter.player != null && playerIDOnStartQueue != KickStarter.player.ID && playerIDOnStartQueue >= 0)
            {
                Player playerToRevertTo = KickStarter.settingsManager.GetPlayer(playerIDOnStartQueue);
                KickStarter.ResetPlayer(playerToRevertTo, playerIDOnStartQueue, true, Quaternion.identity);
            }

            for (int i = 0; i < skipQueue.Count; i++)
            {
                skipQueue[i].Skip();
            }
        }
        private void Awake()
        {
            if (!UnityVersionHandler.ObjectIsInActiveScene(gameObject))
            {
                // Register self as a "sub-scene"

                GameObject subSceneOb  = new GameObject();
                SubScene   newSubScene = subSceneOb.AddComponent <SubScene>();
                newSubScene.Initialise(this);
                return;
            }

            ownKickStarter = GetComponent <KickStarter>();

            GameObject taggedMainCamera = GameObject.FindWithTag(Tags.mainCamera);

            if (taggedMainCamera == null)
            {
                ACDebug.LogError("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one.");
            }
            else
            {
                if (taggedMainCamera.GetComponent <MainCamera>() == null &&
                    taggedMainCamera.GetComponentInParent <MainCamera>() == null)
                {
                    ACDebug.LogError("MainCamera has no MainCamera component.");
                }
            }

            if (ownKickStarter != null)
            {
                KickStarter.mainCamera.OnAwake();
                ownKickStarter.OnAwake();
                KickStarter.playerInput.OnAwake();
                KickStarter.playerQTE.OnAwake();
                KickStarter.sceneSettings.OnAwake();
                KickStarter.dialog.OnAwake();
                KickStarter.navigationManager.OnAwake();
                KickStarter.actionListManager.OnAwake();

                KickStarter.stateHandler.RegisterWithGameEngine();
            }
            else
            {
                ACDebug.LogError("No KickStarter component found in the scene!");
            }
        }
Ejemplo n.º 11
0
        /**
         * Prepares the sub-scene to become the new active scene, due to the active scene being removed.  The gameobject will be destroyed afterwards.
         */
        public void MakeMain()
        {
                        #if UNITY_5_3 || UNITY_5_4 || UNITY_5_3_OR_NEWER
            if (mainCamera)
            {
                mainCamera.gameObject.SetActive(true);
            }
            if (kickStarter)
            {
                kickStarter.gameObject.SetActive(true);
            }

            KickStarter.SetGameEngine(gameObject);
            KickStarter.mainCamera = mainCamera;

            UnityEngine.SceneManagement.SceneManager.SetActiveScene(gameObject.scene);
            Destroy(gameObject);
                        #endif
        }
Ejemplo n.º 12
0
        /**
         * Prepares the sub-scene to become the new active scene, due to the active scene being removed.  The gameobject will be destroyed afterwards.
         */
        public void MakeMain()
        {
            if (mainCamera)
            {
                mainCamera.gameObject.SetActive(true);
                if (KickStarter.settingsManager.blackOutWhenInitialising)
                {
                    mainCamera.ForceOverlayForFrames(4);
                }
            }
            if (kickStarter)
            {
                kickStarter.gameObject.SetActive(true);
                KickStarter.SetGameEngine(kickStarter.gameObject);
            }

            KickStarter.sceneChanger.SubScenes.Remove(this);
            Destroy(gameObject);
        }
Ejemplo n.º 13
0
        /**
         * Prepares the sub-scene to become the new active scene, due to the active scene being removed.  The gameobject will be destroyed afterwards.
         */
        public void MakeMain()
        {
            if (mainCamera)
            {
                mainCamera.gameObject.SetActive(true);
                mainCamera.OnAwake(false);
                mainCamera.OnStart();
            }
            if (kickStarter)
            {
                kickStarter.gameObject.SetActive(true);
            }

            KickStarter.SetGameEngine(gameObject);
            KickStarter.mainCamera = mainCamera;

            UnityEngine.SceneManagement.SceneManager.SetActiveScene(gameObject.scene);
            Destroy(gameObject);
        }
Ejemplo n.º 14
0
        private void Awake()
        {
            UnityVersionHandler.EnsureSingleScene();

            if (!UnityVersionHandler.ObjectIsInActiveScene(gameObject))
            {
                return;
            }

            activeKickStarter = FindObjectOfType <KickStarter>();

            if (GameObject.FindWithTag(Tags.mainCamera) == null)
            {
                ACDebug.LogError("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one.");
            }
            else
            {
                if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null &&
                    GameObject.FindWithTag(Tags.mainCamera).GetComponentInParent <MainCamera>() == null)
                {
                    ACDebug.LogError("MainCamera has no MainCamera component.");
                }
            }

            if (activeKickStarter != null)
            {
                KickStarter.mainCamera.OnAwake();
                activeKickStarter.OnAwake();
                KickStarter.playerInput.OnAwake();
                KickStarter.playerQTE.OnAwake();
                KickStarter.sceneSettings.OnAwake();
                KickStarter.dialog.OnAwake();
                KickStarter.navigationManager.OnAwake();
                KickStarter.actionListManager.OnAwake();

                KickStarter.stateHandler.RegisterWithGameEngine();
            }
            else
            {
                ACDebug.LogError("No KickStarter component found in the scene!");
            }
        }
Ejemplo n.º 15
0
        /**
         * <summary>Syncs the component with the correct scene.</summary>
         * <param name = "_multiSceneChecker">The MultiSceneChecker component in the scene for which this component is to sync with.</param>
         */
        public void Initialise(MultiSceneChecker _multiSceneChecker)
        {
                        #if UNITY_5_3 || UNITY_5_4 || UNITY_5_3_OR_NEWER
            UnityEngine.SceneManagement.Scene scene = _multiSceneChecker.gameObject.scene;
            gameObject.name = "SubScene " + scene.buildIndex;

            kickStarter = _multiSceneChecker.GetComponent <KickStarter>();

            sceneInfo = new SceneInfo(scene.name, scene.buildIndex);

            localVariables = _multiSceneChecker.GetComponent <LocalVariables>();
            sceneSettings  = _multiSceneChecker.GetComponent <SceneSettings>();

            UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, scene);

            kickStarter = UnityVersionHandler.GetOwnSceneInstance <KickStarter> (gameObject);
            if (kickStarter != null)
            {
                kickStarter.gameObject.SetActive(false);
            }

            mainCamera = UnityVersionHandler.GetOwnSceneInstance <MainCamera> (gameObject);
            if (mainCamera != null)
            {
                mainCamera.gameObject.SetActive(false);
            }

            Player ownPlayer = UnityVersionHandler.GetOwnSceneInstance <Player> (gameObject);
            if (ownPlayer != null)
            {
                ownPlayer.gameObject.SetActive(false);
            }

            KickStarter.sceneChanger.RegisterSubScene(this);
                        #endif
        }
        override public float Run()
        {
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (KickStarter.sceneChanger.GetSubScenes().Length > 0)
                {
                    //	ACDebug.LogWarning ("Cannot switch players while multiple scenes are open!");
                    //	return 0f;
                }

                if (KickStarter.settingsManager.players.Count > 0 && KickStarter.settingsManager.players.Count > playerNumber && playerNumber > -1)
                {
                    if (KickStarter.player != null && KickStarter.player.ID == playerID)
                    {
                        ACDebug.Log("Cannot switch player - already controlling the desired prefab.");
                        return(0f);
                    }

                    if (KickStarter.settingsManager.players[playerNumber].playerOb != null)
                    {
                        KickStarter.saveSystem.SaveCurrentPlayerData();

                        Vector3    oldPlayerPosition = Vector3.zero;
                        Quaternion oldPlayerRotation = new Quaternion();
                        Vector3    oldPlayerScale    = Vector3.one;

                        if (KickStarter.player != null)
                        {
                            oldPlayerPosition = KickStarter.player.transform.position;
                            oldPlayerRotation = KickStarter.player.TransformRotation;
                            oldPlayerScale    = KickStarter.player.transform.localScale;
                        }

                        if (newPlayerPosition != NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            if (oldPlayer == OldPlayer.ReplaceWithAssociatedNPC && (oldPlayerNPC == null || !oldPlayerNPC.gameObject.activeInHierarchy) && KickStarter.player.associatedNPCPrefab != null)
                            {
                                GameObject newObject = (GameObject)Instantiate(KickStarter.player.associatedNPCPrefab.gameObject);
                                newObject.name = KickStarter.player.associatedNPCPrefab.gameObject.name;
                                oldPlayerNPC   = newObject.GetComponent <NPC>();
                            }

                            if ((oldPlayer == OldPlayer.ReplaceWithNPC || oldPlayer == OldPlayer.ReplaceWithAssociatedNPC) &&
                                oldPlayerNPC != null && oldPlayerNPC.gameObject.activeInHierarchy)
                            {
                                oldPlayerNPC.transform.position   = oldPlayerPosition;
                                oldPlayerNPC.TransformRotation    = oldPlayerRotation;
                                oldPlayerNPC.transform.localScale = oldPlayerScale;

                                // Force the rotation / sprite child to update
                                oldPlayerNPC._Update();
                            }
                        }

                        if (newPlayerNPC == null || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                        {
                            // Try to find from associated NPC prefab

                            if (KickStarter.settingsManager.players[playerNumber].playerOb.associatedNPCPrefab != null)
                            {
                                ConstantID prefabID = KickStarter.settingsManager.players[playerNumber].playerOb.associatedNPCPrefab.GetComponent <ConstantID>();
                                if (prefabID != null && prefabID.constantID != 0)
                                {
                                    newPlayerNPC_ID = prefabID.constantID;
                                    newPlayerNPC    = AssignFile <NPC> (prefabID.constantID, null);
                                }
                            }
                        }

                        Quaternion newRotation = Quaternion.identity;
                        if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            newRotation = oldPlayerRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC && newPlayerNPC)
                        {
                            newRotation = newPlayerNPC.TransformRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker && newPlayerMarker)
                        {
                            newRotation = newPlayerMarker.transform.rotation;
                        }

                        bool replacesOldPlayer = newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer &&
                                                 (!restorePreviousData || !KickStarter.saveSystem.DoesPlayerDataExist(playerID, true));

                        KickStarter.ResetPlayer(KickStarter.settingsManager.players[playerNumber].playerOb, playerID, true, newRotation, keepInventory, false, replacesOldPlayer);
                        Player newPlayer = KickStarter.player;
                        PlayerMenus.ResetInventoryBoxes();

                        if (restorePreviousData && KickStarter.saveSystem.DoesPlayerDataExist(playerID, true))
                        {
                            if (newPlayerNPC)
                            {
                                newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                            }

                            int sceneToLoad = KickStarter.saveSystem.GetPlayerScene(playerID);
                            if (sceneToLoad >= 0 && sceneToLoad != UnityVersionHandler.GetCurrentSceneNumber())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo("", sceneToLoad), true, false, newPlayerNPC_ID);
                            }
                            else
                            {
                                string sceneToLoadName = KickStarter.saveSystem.GetPlayerSceneName(playerID);
                                if (sceneToLoadName != "" && sceneToLoadName != UnityVersionHandler.GetCurrentSceneName())
                                {
                                    KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(sceneToLoadName, -1), true, false, newPlayerNPC_ID);
                                }
                            }
                        }
                        else
                        {
                            // No data to restore

                            if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                            {
                                newPlayer.Teleport(oldPlayerPosition);
                                newPlayer.SetRotation(oldPlayerRotation);
                                newPlayer.transform.localScale = oldPlayerScale;
                            }
                            else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                            {
                                if (newPlayerNPC)
                                {
                                    newPlayer.Teleport(newPlayerNPC.transform.position);
                                    newPlayer.SetRotation(newPlayerNPC.TransformRotation);
                                    newPlayer.transform.localScale = newPlayerNPC.transform.localScale;

                                    newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                            {
                                if (newPlayerMarker)
                                {
                                    newPlayer.Teleport(newPlayerMarker.transform.position);
                                    newPlayer.SetRotation(newPlayerMarker.transform.rotation);
                                    newPlayer.transform.localScale = newPlayerMarker.transform.localScale;
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
                            {
                                if (chooseNewSceneBy == ChooseSceneBy.Name && newPlayerSceneName == UnityVersionHandler.GetCurrentSceneName() ||
                                    (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == UnityVersionHandler.GetCurrentSceneNumber()))
                                {
                                    // Already in correct scene
                                    if (newPlayerNPC && newPlayerNPC.gameObject.activeInHierarchy)
                                    {
                                        newPlayer.Teleport(newPlayerNPC.transform.position);
                                        newPlayer.SetRotation(newPlayerNPC.TransformRotation);
                                        newPlayer.transform.localScale = newPlayerNPC.transform.localScale;

                                        newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                                    }
                                }
                                else
                                {
                                    if (newPlayerNPC && newPlayerNPC.gameObject.activeInHierarchy)
                                    {
                                        newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                                    }

                                    //KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(chooseNewSceneBy, newPlayerSceneName, newPlayerScene), true, false, newPlayerNPC_ID, true);
                                }
                            }
                        }

                        if (KickStarter.mainCamera.attachedCamera)
                        {
                            KickStarter.mainCamera.attachedCamera.MoveCameraInstant();
                        }

                        AssetLoader.UnloadAssets();
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot switch player - no player prefabs is defined.");
                    }
                }
            }

            return(0f);
        }
        override public float Run()
        {
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                PlayerPrefab newPlayerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);

                if (newPlayerPrefab != null)
                {
                    if (KickStarter.player != null && KickStarter.player.ID == playerID)
                    {
                        Log("Cannot switch player - already controlling the desired prefab.");
                        return(0f);
                    }

                    if (newPlayerPrefab.playerOb != null)
                    {
                        KickStarter.saveSystem.SaveCurrentPlayerData();

                        Vector3    oldPlayerPosition = Vector3.zero;
                        Quaternion oldPlayerRotation = new Quaternion();
                        Vector3    oldPlayerScale    = Vector3.one;

                        PlayerData oldPlayerData         = new PlayerData();
                        NPCData    oldNPCData            = new NPCData();
                        bool       recordedOldPlayerData = false;
                        bool       recordedOldNPCData    = false;

                        if (KickStarter.player != null)
                        {
                            oldPlayerPosition = KickStarter.player.transform.position;
                            oldPlayerRotation = KickStarter.player.TransformRotation;
                            oldPlayerScale    = KickStarter.player.transform.localScale;

                            oldPlayerData         = KickStarter.player.SavePlayerData(oldPlayerData);
                            recordedOldPlayerData = true;
                        }

                        if (newPlayerPosition != NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            if (oldPlayer == OldPlayer.ReplaceWithAssociatedNPC &&
                                (runtimeOldPlayerNPC == null || !runtimeOldPlayerNPC.gameObject.activeInHierarchy) &&
                                KickStarter.player.associatedNPCPrefab != null)
                            {
                                GameObject newObject = (GameObject)Instantiate(KickStarter.player.associatedNPCPrefab.gameObject);
                                newObject.name      = KickStarter.player.associatedNPCPrefab.gameObject.name;
                                runtimeOldPlayerNPC = newObject.GetComponent <NPC>();
                            }

                            if ((oldPlayer == OldPlayer.ReplaceWithNPC || oldPlayer == OldPlayer.ReplaceWithAssociatedNPC) &&
                                runtimeOldPlayerNPC != null && runtimeOldPlayerNPC.gameObject.activeInHierarchy)
                            {
                                runtimeOldPlayerNPC.Teleport(oldPlayerPosition);
                                runtimeOldPlayerNPC.TransformRotation    = oldPlayerRotation;
                                runtimeOldPlayerNPC.transform.localScale = oldPlayerScale;

                                if (recordedOldPlayerData)
                                {
                                    ApplyRenderData(runtimeOldPlayerNPC, oldPlayerData);
                                }

                                // Force the rotation / sprite child to update
                                runtimeOldPlayerNPC._Update();
                            }
                        }

                        if (runtimeNewPlayerNPC == null || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                        {
                            // Try to find from associated NPC prefab

                            if (newPlayerPrefab.playerOb.associatedNPCPrefab != null)
                            {
                                ConstantID prefabID = newPlayerPrefab.playerOb.associatedNPCPrefab.GetComponent <ConstantID>();
                                if (prefabID != null && prefabID.constantID != 0)
                                {
                                    newPlayerNPC_ID     = prefabID.constantID;
                                    runtimeNewPlayerNPC = AssignFile <NPC> (prefabID.constantID, null);
                                }
                            }
                        }

                        Quaternion newRotation = Quaternion.identity;
                        if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            newRotation = oldPlayerRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC && runtimeNewPlayerNPC != null)
                        {
                            newRotation = runtimeNewPlayerNPC.TransformRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker && runtimeNewPlayerMarker != null)
                        {
                            newRotation = runtimeNewPlayerMarker.transform.rotation;
                        }

                        if (runtimeNewPlayerNPC != null)
                        {
                            oldNPCData = runtimeNewPlayerNPC.SaveData(oldNPCData);
                        }

                        bool replacesOldPlayer = newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer &&
                                                 (!restorePreviousData || !KickStarter.saveSystem.DoesPlayerDataExist(playerID, true));
                        KickStarter.ResetPlayer(newPlayerPrefab.playerOb, playerID, true, newRotation, keepInventory, false, replacesOldPlayer, alwaysSnapCamera);
                        Player newPlayer = KickStarter.player;
                        PlayerMenus.ResetInventoryBoxes();

                        if (replacesOldPlayer && recordedOldPlayerData)
                        {
                            ApplyRenderData(newPlayer, oldPlayerData);
                        }

                        if (restorePreviousData && KickStarter.saveSystem.DoesPlayerDataExist(playerID, true))
                        {
                            int    sceneToLoad     = KickStarter.saveSystem.GetPlayerScene(playerID);
                            string sceneToLoadName = KickStarter.saveSystem.GetPlayerSceneName(playerID);

                            if (sceneToLoad >= 0 && sceneToLoad != UnityVersionHandler.GetCurrentSceneNumber())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo(string.Empty, sceneToLoad), true, false);
                            }
                            else if (!string.IsNullOrEmpty(sceneToLoadName) && sceneToLoadName != UnityVersionHandler.GetCurrentSceneName())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo(sceneToLoadName, -1), true, false);
                            }
                            else
                            {
                                // Same scene
                                if (runtimeNewPlayerNPC != null)
                                {
                                    newPlayer.RepositionToTransform(runtimeNewPlayerNPC.transform);
                                    runtimeNewPlayerNPC.HideFromView(newPlayer);
                                }
                            }
                        }
                        else
                        {
                            // No data to restore

                            if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                            {
                                newPlayer.Teleport(oldPlayerPosition);
                                newPlayer.SetRotation(oldPlayerRotation);
                                newPlayer.transform.localScale = oldPlayerScale;
                            }
                            else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.ReplaceAssociatedNPC)
                            {
                                if (runtimeNewPlayerNPC != null)
                                {
                                    newPlayer.RepositionToTransform(runtimeNewPlayerNPC.transform);
                                    runtimeNewPlayerNPC.HideFromView(newPlayer);

                                    if (recordedOldNPCData)
                                    {
                                        ApplyRenderData(newPlayer, oldNPCData);
                                    }
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                            {
                                if (runtimeNewPlayerMarker)
                                {
                                    newPlayer.RepositionToTransform(runtimeNewPlayerMarker.transform);
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
                            {
                                if (chooseNewSceneBy == ChooseSceneBy.Name && newPlayerSceneName == UnityVersionHandler.GetCurrentSceneName() ||
                                    (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == UnityVersionHandler.GetCurrentSceneNumber()))
                                {
                                    // Already in correct scene
                                    if (runtimeNewPlayerNPC && runtimeNewPlayerNPC.gameObject.activeInHierarchy)
                                    {
                                        newPlayer.RepositionToTransform(runtimeNewPlayerNPC.transform);
                                        runtimeNewPlayerNPC.HideFromView(newPlayer);
                                    }
                                }
                                else
                                {
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(chooseNewSceneBy, newPlayerSceneName, newPlayerScene), true, false, true);
                                }
                            }
                        }

                        if (KickStarter.mainCamera.attachedCamera && alwaysSnapCamera)
                        {
                            KickStarter.mainCamera.attachedCamera.MoveCameraInstant();
                        }

                        AssetLoader.UnloadAssets();
                    }
                    else
                    {
                        LogWarning("Cannot switch player - no player prefabs is defined.");
                    }
                }
            }

            return(0f);
        }
Ejemplo n.º 18
0
        override public float Run()
        {
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
            {
                if (KickStarter.sceneChanger.GetSubScenes().Length > 0)
                {
                    //	ACDebug.LogWarning ("Cannot switch players while multiple scenes are open!");
                    //	return 0f;
                }

                if (KickStarter.settingsManager.players.Count > 0 && KickStarter.settingsManager.players.Count > playerNumber && playerNumber > -1)
                {
                    if (KickStarter.player != null && KickStarter.player.ID == playerID)
                    {
                        ACDebug.Log("Cannot switch player - already controlling the desired prefab.");
                        return(0f);
                    }

                    if (KickStarter.settingsManager.players[playerNumber].playerOb != null)
                    {
                        KickStarter.saveSystem.SaveCurrentPlayerData();

                        Vector3    oldPlayerPosition = Vector3.zero;
                        Quaternion oldPlayerRotation = new Quaternion();
                        Vector3    oldPlayerScale    = Vector3.one;

                        if (KickStarter.player != null)
                        {
                            oldPlayerPosition = KickStarter.player.transform.position;
                            oldPlayerRotation = KickStarter.player.transform.rotation;
                            oldPlayerScale    = KickStarter.player.transform.localScale;
                        }

                        if (oldPlayer == OldPlayer.ReplaceWithNPC && oldPlayerNPC != null &&
                            (newPlayerPosition == NewPlayerPosition.ReplaceNPC || newPlayerPosition == NewPlayerPosition.AppearAtMarker))
                        {
                            oldPlayerNPC.transform.position   = oldPlayerPosition;
                            oldPlayerNPC.transform.rotation   = oldPlayerRotation;
                            oldPlayerNPC.transform.localScale = oldPlayerScale;
                        }

                        Quaternion newRotation = Quaternion.identity;
                        if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                        {
                            newRotation = oldPlayerRotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC && newPlayerNPC)
                        {
                            newRotation = newPlayerNPC.transform.rotation;
                        }
                        else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker && newPlayerMarker)
                        {
                            newRotation = newPlayerMarker.transform.rotation;
                        }

                        KickStarter.ResetPlayer(KickStarter.settingsManager.players[playerNumber].playerOb, playerID, true, newRotation, keepInventory);
                        Player newPlayer = KickStarter.player;
                        PlayerMenus.ResetInventoryBoxes();

                        int sceneToLoad = UnityVersionHandler.GetCurrentSceneNumber();
                        if (restorePreviousData && KickStarter.saveSystem.DoesPlayerDataExist(playerID, true))
                        {
                            sceneToLoad = KickStarter.saveSystem.GetPlayerScene(playerID);

                            if (sceneToLoad != UnityVersionHandler.GetCurrentSceneNumber())
                            {
                                KickStarter.saveSystem.loadingGame = LoadingGame.JustSwitchingPlayer;
                                KickStarter.sceneChanger.ChangeScene(new SceneInfo("", sceneToLoad), true);
                            }
                        }
                        else
                        {
                            if (newPlayerPosition == NewPlayerPosition.ReplaceCurrentPlayer)
                            {
                                newPlayer.Teleport(oldPlayerPosition);
                                newPlayer.SetRotation(oldPlayerRotation);
                                newPlayer.transform.localScale = oldPlayerScale;
                            }
                            else if (newPlayerPosition == NewPlayerPosition.ReplaceNPC)
                            {
                                if (newPlayerNPC)
                                {
                                    newPlayer.Teleport(newPlayerNPC.transform.position);
                                    newPlayer.SetRotation(newPlayerNPC.transform.rotation);
                                    newPlayer.transform.localScale = newPlayerNPC.transform.localScale;

                                    newPlayerNPC.transform.position += new Vector3(100f, -100f, 100f);
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearAtMarker)
                            {
                                if (newPlayerMarker)
                                {
                                    newPlayer.Teleport(newPlayerMarker.transform.position);
                                    newPlayer.SetRotation(newPlayerMarker.transform.rotation);
                                    newPlayer.transform.localScale = newPlayerMarker.transform.localScale;
                                }
                            }
                            else if (newPlayerPosition == NewPlayerPosition.AppearInOtherScene)
                            {
                                if (chooseNewSceneBy == ChooseSceneBy.Name && newPlayerSceneName == UnityVersionHandler.GetCurrentSceneName())
                                {
                                }
                                else if (chooseNewSceneBy == ChooseSceneBy.Number && newPlayerScene == UnityVersionHandler.GetCurrentSceneNumber())
                                {
                                }
                                else
                                {
                                    KickStarter.sceneChanger.ChangeScene(new SceneInfo(chooseNewSceneBy, newPlayerSceneName, newPlayerScene), true);
                                }
                            }
                        }

                        if (KickStarter.mainCamera.attachedCamera)
                        {
                            KickStarter.mainCamera.attachedCamera.MoveCameraInstant();
                        }

                        AssetLoader.UnloadAssets();
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot switch player - no player prefabs is defined.");
                    }
                }
            }

            return(0f);
        }
Ejemplo n.º 19
0
        /**
         * Assigns its various Manager asset files.
         */
        public void AssignManagers()
        {
            if (AdvGame.GetReferences() != null)
            {
                int numAssigned = 0;

                if (sceneManager)
                {
                    AdvGame.GetReferences().sceneManager = sceneManager;
                    numAssigned++;
                }

                if (settingsManager)
                {
                    AdvGame.GetReferences().settingsManager = settingsManager;
                    numAssigned++;
                }

                if (actionsManager)
                {
                    AdvGame.GetReferences().actionsManager = actionsManager;
                    numAssigned++;
                }

                if (variablesManager)
                {
                    AdvGame.GetReferences().variablesManager = variablesManager;
                    numAssigned++;
                }

                if (inventoryManager)
                {
                    AdvGame.GetReferences().inventoryManager = inventoryManager;
                    numAssigned++;
                }

                if (speechManager)
                {
                    AdvGame.GetReferences().speechManager = speechManager;
                    numAssigned++;
                }

                if (cursorManager)
                {
                    AdvGame.GetReferences().cursorManager = cursorManager;
                    numAssigned++;
                }

                if (menuManager)
                {
                    AdvGame.GetReferences().menuManager = menuManager;
                    numAssigned++;
                }

                                #if UNITY_EDITOR
                if (!Application.isPlaying)
                {
                    KickStarter.ClearManagerCache();
                }

                if (KickStarter.sceneManager)
                {
                    KickStarter.sceneManager.GetPrefabsInScene();
                }

                UnityVersionHandler.CustomSetDirty(AdvGame.GetReferences(), true);
                AssetDatabase.SaveAssets();
                                #endif

                if (this)
                {
                    if (numAssigned == 0)
                    {
                        ACDebug.Log(this.name + " No Mangers assigned.");
                    }
                    else if (numAssigned == 1)
                    {
                        ACDebug.Log(this.name + " - (" + numAssigned.ToString() + ") Manager assigned.", this);
                    }
                    else
                    {
                        ACDebug.Log(this.name + " - (" + numAssigned.ToString() + ") Managers assigned.", this);
                    }
                }
            }
            else
            {
                                #if UNITY_EDITOR
                string intendedDirectory = Resource.MainFolderPathRelativeToAssets + System.IO.Path.DirectorySeparatorChar.ToString() + "Resources";

                bool canProceed = EditorUtility.DisplayDialog("Error - missing References", "A 'References' file must be present in the directory '" + intendedDirectory + "'. Create one?", "OK", "Cancel");
                if (!canProceed)
                {
                    return;
                }

                CustomAssetUtility.CreateAsset <References> ("References", intendedDirectory);

                if (AdvGame.GetReferences() != null)
                {
                    AssignManagers();
                }
                                #else
                ACDebug.LogError("Can't assign managers - no References file found in Resources folder.");
                                #endif
            }
        }
Ejemplo n.º 20
0
 /**
  * Alerts the StateHandler that a Game Engine prefab is present in the scene.
  * This is called from KickStarter when the game begins - the StateHandler will not run until this is done.
  */
 public void Register(KickStarter kickStarter)
 {
     activeKickStarter = kickStarter;
 }
Ejemplo n.º 21
0
        /**
         * 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.HideScene();
            }

            // 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 (KickStarter.player != null && !noPlayerOnStartQueue && playerIDOnStartQueue != KickStarter.player.ID && playerIDOnStartQueue >= 0)
                {
                    Player playerToRevertTo = KickStarter.settingsManager.GetPlayer(playerIDOnStartQueue);
                    KickStarter.ResetPlayer(playerToRevertTo, playerIDOnStartQueue, true, Quaternion.identity, false, true);
                }
                else if (KickStarter.player != null && noPlayerOnStartQueue)
                {
                    KickStarter.ResetPlayer(null, KickStarter.settingsManager.GetEmptyPlayerID(), true, Quaternion.identity, false, true);
                }
                else if (KickStarter.player == null && !noPlayerOnStartQueue && playerIDOnStartQueue >= 0)
                {
                    Player playerToRevertTo = KickStarter.settingsManager.GetPlayer(playerIDOnStartQueue);
                    KickStarter.ResetPlayer(playerToRevertTo, playerIDOnStartQueue, true, Quaternion.identity, false, true);
                }
            }

            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();
            }
        }
Ejemplo n.º 22
0
        public void OnAwake()
        {
            ClearVariables();

            // Test for key imports
            References references = (References)Resources.Load(Resource.references);

            if (references)
            {
                SceneManager     sceneManager     = AdvGame.GetReferences().sceneManager;
                SettingsManager  settingsManager  = AdvGame.GetReferences().settingsManager;
                ActionsManager   actionsManager   = AdvGame.GetReferences().actionsManager;
                InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager;
                VariablesManager variablesManager = AdvGame.GetReferences().variablesManager;
                SpeechManager    speechManager    = AdvGame.GetReferences().speechManager;
                CursorManager    cursorManager    = AdvGame.GetReferences().cursorManager;
                MenuManager      menuManager      = AdvGame.GetReferences().menuManager;

                if (sceneManager == null)
                {
                    ACDebug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard");
                }

                if (settingsManager == null)
                {
                    ACDebug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard");
                }
                else
                {
                    if (settingsManager.IsInLoadingScene())
                    {
                        ACDebug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene.");
                        SetPersistentEngine();
                        return;
                    }

                    // Unity 5.3 has a bug whereby a modified Player prefab is placed in the scene when editing, but not visible
                    // This causes the Player to not load properly, so try to detect this remnant and delete it!
                    GameObject existingPlayer = GameObject.FindGameObjectWithTag(Tags.player);
                    if (existingPlayer != null)
                    {
                        if (settingsManager.GetDefaultPlayer() != null && existingPlayer.name == (settingsManager.GetDefaultPlayer().name + "(Clone)"))
                        {
                            DestroyImmediate(GameObject.FindGameObjectWithTag(Tags.player));
                            ACDebug.LogWarning("Player clone found in scene - this may have been hidden by a Unity bug, and has been destroyed.");
                        }
                    }

                    if (!GameObject.FindGameObjectWithTag(Tags.player))
                    {
                        KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity);
                    }
                    else
                    {
                        KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>();

                        if (sceneChanger == null || sceneChanger.GetPlayerOnTransition() == null)
                        {
                            // New local player
                            if (KickStarter.playerPrefab != null)
                            {
                                KickStarter.playerPrefab.Initialise();
                            }
                        }

                        AssignLocalPlayer();
                    }
                }

                if (actionsManager == null)
                {
                    ACDebug.LogError("No Actions Manager found - please set one using the main Adventure Creator window");
                }

                if (inventoryManager == null)
                {
                    ACDebug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window");
                }

                if (variablesManager == null)
                {
                    ACDebug.LogError("No Variables Manager found - please set one using the main Adventure Creator window");
                }

                if (speechManager == null)
                {
                    ACDebug.LogError("No Speech Manager found - please set one using the main Adventure Creator window");
                }

                if (cursorManager == null)
                {
                    ACDebug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window");
                }

                if (menuManager == null)
                {
                    ACDebug.LogError("No Menu Manager found - please set one using the main Adventure Creator window");
                }

                if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None)
                {
                    ACDebug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder");
                }
            }
            else
            {
                ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window");
            }

            SetPersistentEngine();

            if (persistentEnginePrefab == null)
            {
                ACDebug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine");
            }
            else
            {
                if (persistentEnginePrefab.GetComponent <Options>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no Options component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached.");
                }
                if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached.");
                }
                if (persistentEnginePrefab.GetComponent <StateHandler>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached.");
                }
                if (persistentEnginePrefab.GetComponent <SceneChanger>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached.");
                }
                if (persistentEnginePrefab.GetComponent <SaveSystem>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached.");
                }
                if (persistentEnginePrefab.GetComponent <LevelStorage>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeLanguages>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no RuntimeLanguages component attached.");
                }
                if (persistentEnginePrefab.GetComponent <ActionListAssetManager>() == null)
                {
                    ACDebug.LogError(persistentEnginePrefab.name + " has no ActionListAssetManager component attached.");
                }
            }

            if (this.GetComponent <MenuSystem>() == null)
            {
                ACDebug.LogError(this.name + " has no MenuSystem component attached.");
            }
            if (this.GetComponent <Dialog>() == null)
            {
                ACDebug.LogError(this.name + " has no Dialog component attached.");
            }
            if (this.GetComponent <PlayerInput>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerInput component attached.");
            }
            if (this.GetComponent <PlayerInteraction>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerInteraction component attached.");
            }
            if (this.GetComponent <PlayerMovement>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerMovement component attached.");
            }
            if (this.GetComponent <PlayerCursor>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerCursor component attached.");
            }
            if (this.GetComponent <PlayerQTE>() == null)
            {
                ACDebug.LogError(this.name + " has no PlayerQTE component attached.");
            }
            if (this.GetComponent <SceneSettings>() == null)
            {
                ACDebug.LogError(this.name + " has no SceneSettings component attached.");
            }
            else
            {
                if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null)
                {
                    // No NavMesh, are there Characters in the scene?
                    AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[];
                    if (allChars.Length > 0)
                    {
                        ACDebug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager.");
                    }
                }

                if (this.GetComponent <SceneSettings>().defaultPlayerStart == null)
                {
                    if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.GetDefaultPlayer() != null)
                    {
                        ACDebug.LogWarning("No default PlayerStart set.  The game may not be able to begin if one is not defined - please choose one using the Scene Manager.");
                    }
                }
            }
            if (this.GetComponent <NavigationManager>() == null)
            {
                ACDebug.LogError(this.name + " has no NavigationManager component attached.");
            }
            if (this.GetComponent <ActionListManager>() == null)
            {
                ACDebug.LogError(this.name + " has no ActionListManager component attached.");
            }
            if (this.GetComponent <EventManager>() == null)
            {
                ACDebug.LogError(this.name + " has no EventManager component attached.");
            }
        }
Ejemplo n.º 23
0
        /**
         * Assigns its various Manager asset files.
         */
        public void AssignManagers()
        {
            if (AdvGame.GetReferences() != null)
            {
                int numAssigned = 0;

                if (sceneManager)
                {
                    AdvGame.GetReferences().sceneManager = sceneManager;
                    numAssigned++;
                }

                if (settingsManager)
                {
                    AdvGame.GetReferences().settingsManager = settingsManager;
                    numAssigned++;
                }

                if (actionsManager)
                {
                    AdvGame.GetReferences().actionsManager = actionsManager;
                    numAssigned++;
                }

                if (variablesManager)
                {
                    AdvGame.GetReferences().variablesManager = variablesManager;
                    numAssigned++;
                }

                if (inventoryManager)
                {
                    AdvGame.GetReferences().inventoryManager = inventoryManager;
                    numAssigned++;
                }

                if (speechManager)
                {
                    AdvGame.GetReferences().speechManager = speechManager;
                    numAssigned++;
                }

                if (cursorManager)
                {
                    AdvGame.GetReferences().cursorManager = cursorManager;
                    numAssigned++;
                }

                if (menuManager)
                {
                    AdvGame.GetReferences().menuManager = menuManager;
                    numAssigned++;
                }

                                #if UNITY_EDITOR
                if (!Application.isPlaying)
                {
                    KickStarter.ClearManagerCache();
                }

                if (KickStarter.sceneManager)
                {
                    KickStarter.sceneManager.GetPrefabsInScene();
                }

                UnityVersionHandler.CustomSetDirty(AdvGame.GetReferences(), true);
                AssetDatabase.SaveAssets();
                                #endif

                if (this)
                {
                    if (numAssigned == 0)
                    {
                        ACDebug.Log(this.name + " No Mangers assigned.");
                    }
                    else if (numAssigned == 1)
                    {
                        ACDebug.Log(this.name + " - (" + numAssigned.ToString() + ") Manager assigned.");
                    }
                    else
                    {
                        ACDebug.Log(this.name + " - (" + numAssigned.ToString() + ") Managers assigned.");
                    }
                }
            }
            else
            {
                ACDebug.LogError("Can't assign managers - no References file found in Resources folder.");
            }
        }
Ejemplo n.º 24
0
        private void Awake()
        {
            // Test for key imports
            References references = (References)Resources.Load(Resource.references);

            if (references)
            {
                SceneManager     sceneManager     = AdvGame.GetReferences().sceneManager;
                SettingsManager  settingsManager  = AdvGame.GetReferences().settingsManager;
                ActionsManager   actionsManager   = AdvGame.GetReferences().actionsManager;
                InventoryManager inventoryManager = AdvGame.GetReferences().inventoryManager;
                VariablesManager variablesManager = AdvGame.GetReferences().variablesManager;
                SpeechManager    speechManager    = AdvGame.GetReferences().speechManager;
                CursorManager    cursorManager    = AdvGame.GetReferences().cursorManager;
                MenuManager      menuManager      = AdvGame.GetReferences().menuManager;

                if (sceneManager == null)
                {
                    Debug.LogError("No Scene Manager found - please set one using the Adventure Creator Kit wizard");
                }

                if (settingsManager == null)
                {
                    Debug.LogError("No Settings Manager found - please set one using the Adventure Creator Kit wizard");
                }
                else
                {
                    if (settingsManager.IsInLoadingScene())
                    {
                        Debug.Log("Bypassing regular AC startup because the current scene is the 'Loading' scene.");
                        return;
                    }
                    if (!GameObject.FindGameObjectWithTag(Tags.player))
                    {
                        KickStarter.ResetPlayer(settingsManager.GetDefaultPlayer(), settingsManager.GetDefaultPlayerID(), false, Quaternion.identity);
                    }
                    else
                    {
                        KickStarter.playerPrefab = GameObject.FindWithTag(Tags.player).GetComponent <Player>();

                        if (sceneChanger != null && sceneChanger.GetPlayerOnTransition() != null && settingsManager.playerSwitching == PlayerSwitching.DoNotAllow)
                        {
                            // Replace "prefab" player with a local one if one exists
                            GameObject[] playerObs = GameObject.FindGameObjectsWithTag(Tags.player);
                            foreach (GameObject playerOb in playerObs)
                            {
                                if (playerOb.GetComponent <Player>() && sceneChanger.GetPlayerOnTransition() != playerOb.GetComponent <Player>())
                                {
                                    KickStarter.sceneChanger.DestroyOldPlayer();
                                    KickStarter.playerPrefab = playerOb.GetComponent <Player>();
                                    break;
                                }
                            }
                        }
                    }
                }

                if (actionsManager == null)
                {
                    Debug.LogError("No Actions Manager found - please set one using the main Adventure Creator window");
                }

                if (inventoryManager == null)
                {
                    Debug.LogError("No Inventory Manager found - please set one using the main Adventure Creator window");
                }

                if (variablesManager == null)
                {
                    Debug.LogError("No Variables Manager found - please set one using the main Adventure Creator window");
                }

                if (speechManager == null)
                {
                    Debug.LogError("No Speech Manager found - please set one using the main Adventure Creator window");
                }

                if (cursorManager == null)
                {
                    Debug.LogError("No Cursor Manager found - please set one using the main Adventure Creator window");
                }

                if (menuManager == null)
                {
                    Debug.LogError("No Menu Manager found - please set one using the main Adventure Creator window");
                }

                if (GameObject.FindWithTag(Tags.player) == null && KickStarter.settingsManager.movementMethod != MovementMethod.None)
                {
                    Debug.LogWarning("No Player found - please set one using the Settings Manager, tagging it as Player and placing it in a Resources folder");
                }
            }
            else
            {
                Debug.LogError("No References object found. Please set one using the main Adventure Creator window");
            }

            if (persistentEnginePrefab == null)
            {
                try
                {
                    persistentEnginePrefab      = (GameObject)Instantiate(Resources.Load(Resource.persistentEngine));
                    persistentEnginePrefab.name = AdvGame.GetName(Resource.persistentEngine);
                }
                catch {}
            }

            if (persistentEnginePrefab == null)
            {
                Debug.LogError("No PersistentEngine prefab found - please place one in the Resources directory, and tag it as PersistentEngine");
            }
            else
            {
                if (persistentEnginePrefab.GetComponent <Options>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no Options component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeInventory>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no RuntimeInventory component attached.");
                }
                if (persistentEnginePrefab.GetComponent <RuntimeVariables>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no RuntimeVariables component attached.");
                }
                if (persistentEnginePrefab.GetComponent <PlayerMenus>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no PlayerMenus component attached.");
                }
                if (persistentEnginePrefab.GetComponent <StateHandler>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no StateHandler component attached.");
                }
                if (persistentEnginePrefab.GetComponent <SceneChanger>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no SceneChanger component attached.");
                }
                if (persistentEnginePrefab.GetComponent <SaveSystem>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no SaveSystem component attached.");
                }
                if (persistentEnginePrefab.GetComponent <LevelStorage>() == null)
                {
                    Debug.LogError(persistentEnginePrefab.name + " has no LevelStorage component attached.");
                }
            }

            if (GameObject.FindWithTag(Tags.mainCamera) == null)
            {
                Debug.LogError("No MainCamera found - please click 'Organise room objects' in the Scene Manager to create one.");
            }
            else
            {
                if (GameObject.FindWithTag(Tags.mainCamera).GetComponent <MainCamera>() == null)
                {
                    Debug.LogError("MainCamera has no MainCamera component.");
                }
            }

            if (this.GetComponent <MenuSystem>() == null)
            {
                Debug.LogError(this.name + " has no MenuSystem component attached.");
            }
            if (this.GetComponent <Dialog>() == null)
            {
                Debug.LogError(this.name + " has no Dialog component attached.");
            }
            if (this.GetComponent <PlayerInput>() == null)
            {
                Debug.LogError(this.name + " has no PlayerInput component attached.");
            }
            if (this.GetComponent <PlayerInteraction>() == null)
            {
                Debug.LogError(this.name + " has no PlayerInteraction component attached.");
            }
            if (this.GetComponent <PlayerMovement>() == null)
            {
                Debug.LogError(this.name + " has no PlayerMovement component attached.");
            }
            if (this.GetComponent <PlayerCursor>() == null)
            {
                Debug.LogError(this.name + " has no PlayerCursor component attached.");
            }
            if (this.GetComponent <PlayerQTE>() == null)
            {
                Debug.LogError(this.name + " has no PlayerQTE component attached.");
            }
            if (this.GetComponent <SceneSettings>() == null)
            {
                Debug.LogError(this.name + " has no SceneSettings component attached.");
            }
            else
            {
                if (this.GetComponent <SceneSettings>().navigationMethod == AC_NavigationMethod.meshCollider && this.GetComponent <SceneSettings>().navMesh == null)
                {
                    // No NavMesh, are there Characters in the scene?
                    AC.Char[] allChars = GameObject.FindObjectsOfType(typeof(AC.Char)) as AC.Char[];
                    if (allChars.Length > 0)
                    {
                        Debug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager.");
                    }
                }

                if (this.GetComponent <SceneSettings>().defaultPlayerStart == null)
                {
                    Debug.LogWarning("No default PlayerStart set.  The game may not be able to begin if one is not defined - please choose one using the Scene Manager.");
                }
            }
            if (this.GetComponent <NavigationManager>() == null)
            {
                Debug.LogError(this.name + " has no NavigationManager component attached.");
            }
            if (this.GetComponent <ActionListManager>() == null)
            {
                Debug.LogError(this.name + " has no ActionListManager component attached.");
            }
        }
Ejemplo n.º 25
0
        private void OnGUI()
        {
            if (!ACInstaller.IsInstalled())
            {
                ACInstaller.DoInstall();
            }

            if (!references)
            {
                GetReferences();
            }

            if (references)
            {
                GUILayout.Space(10);

                GUILayout.BeginHorizontal();

                if (GUILayout.Toggle(showScene, "Scene", "toolbarbutton", tabWidth))
                {
                    SetTab(0);
                }
                if (GUILayout.Toggle(showSettings, "Settings", "toolbarbutton", tabWidth))
                {
                    SetTab(1);
                }
                if (GUILayout.Toggle(showActions, "Actions", "toolbarbutton", tabWidth))
                {
                    SetTab(2);
                }
                if (GUILayout.Toggle(showGVars, "Variables", "toolbarbutton", tabWidth))
                {
                    SetTab(3);
                }

                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();

                if (GUILayout.Toggle(showInvItems, "Inventory", "toolbarbutton", tabWidth))
                {
                    SetTab(4);
                }
                if (GUILayout.Toggle(showSpeech, "Speech", "toolbarbutton", tabWidth))
                {
                    SetTab(5);
                }
                if (GUILayout.Toggle(showCursor, "Cursor", "toolbarbutton", tabWidth))
                {
                    SetTab(6);
                }
                if (GUILayout.Toggle(showMenu, "Menu", "toolbarbutton", tabWidth))
                {
                    SetTab(7);
                }

                GUILayout.EndHorizontal();
                GUILayout.Space(5);

                scroll = GUILayout.BeginScrollView(scroll);

                if (showScene)
                {
                    GUILayout.Label("Scene manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.sceneManager = (SceneManager)EditorGUILayout.ObjectField("Asset file: ", references.sceneManager, typeof(SceneManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.sceneManager)
                    {
                        AskToCreate <SceneManager> ("SceneManager");
                    }
                    else
                    {
                        if (references.sceneManager.name == "Demo_SceneManager" || references.sceneManager.name == "Demo2D_SceneManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.sceneManager.ShowGUI();
                    }
                }

                else if (showSettings)
                {
                    GUILayout.Label("Settings manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.settingsManager = (SettingsManager)EditorGUILayout.ObjectField("Asset file: ", references.settingsManager, typeof(SettingsManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.settingsManager)
                    {
                        AskToCreate <SettingsManager> ("SettingsManager");
                    }
                    else
                    {
                        if (references.settingsManager.name == "Demo_SettingsManager" || references.settingsManager.name == "Demo2D_SettingsManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.settingsManager.ShowGUI();
                    }
                }

                else if (showActions)
                {
                    GUILayout.Label("Actions manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.actionsManager = (ActionsManager)EditorGUILayout.ObjectField("Asset file: ", references.actionsManager, typeof(ActionsManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.actionsManager)
                    {
                        AskToCreate <ActionsManager> ("ActionsManager");
                    }
                    else
                    {
                        if (references.actionsManager.name == "Demo_ActionsManager" || references.actionsManager.name == "Demo2D_ActionsManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.actionsManager.ShowGUI();
                    }
                }

                else if (showGVars)
                {
                    GUILayout.Label("Variables manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.variablesManager = (VariablesManager)EditorGUILayout.ObjectField("Asset file: ", references.variablesManager, typeof(VariablesManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.variablesManager)
                    {
                        AskToCreate <VariablesManager> ("VariablesManager");
                    }
                    else
                    {
                        if (references.variablesManager.name == "Demo_VariablesManager" || references.variablesManager.name == "Demo2D_VariablesManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.variablesManager.ShowGUI();
                    }
                }

                else if (showInvItems)
                {
                    GUILayout.Label("Inventory manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.inventoryManager = (InventoryManager)EditorGUILayout.ObjectField("Asset file: ", references.inventoryManager, typeof(InventoryManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.inventoryManager)
                    {
                        AskToCreate <InventoryManager> ("InventoryManager");
                    }
                    else
                    {
                        if (references.inventoryManager.name == "Demo_InventoryManager" || references.inventoryManager.name == "Demo2D_InventoryManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.inventoryManager.ShowGUI();
                    }
                }

                else if (showSpeech)
                {
                    GUILayout.Label("Speech manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.speechManager = (SpeechManager)EditorGUILayout.ObjectField("Asset file: ", references.speechManager, typeof(SpeechManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.speechManager)
                    {
                        AskToCreate <SpeechManager> ("SpeechManager");
                    }
                    else
                    {
                        if (references.speechManager.name == "Demo_SpeechManager" || references.speechManager.name == "Demo2D_SpeechManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.speechManager.ShowGUI();
                    }
                }

                else if (showCursor)
                {
                    GUILayout.Label("Cursor manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.cursorManager = (CursorManager)EditorGUILayout.ObjectField("Asset file: ", references.cursorManager, typeof(CursorManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.cursorManager)
                    {
                        AskToCreate <CursorManager> ("CursorManager");
                    }
                    else
                    {
                        if (references.cursorManager.name == "Demo_CursorManager" || references.cursorManager.name == "Demo2D_CursorManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.cursorManager.ShowGUI();
                    }
                }

                else if (showMenu)
                {
                    GUILayout.Label("Menu manager", CustomStyles.managerHeader);
                    EditorGUI.BeginChangeCheck();
                    references.menuManager = (MenuManager)EditorGUILayout.ObjectField("Asset file: ", references.menuManager, typeof(MenuManager), false);
                    if (EditorGUI.EndChangeCheck())
                    {
                        KickStarter.ClearManagerCache();
                    }
                    DrawManagerSpace();

                    if (!references.menuManager)
                    {
                        AskToCreate <MenuManager> ("MenuManager");
                    }
                    else
                    {
                        if (references.menuManager.name == "Demo_MenuManager" || references.menuManager.name == "Demo2D_MenuManager")
                        {
                            EditorGUILayout.HelpBox("The Demo Managers are for demonstration purposes only.  Modifying them to create your game may result in data loss upon upgrading - instead, use the New Game Wizard to create a new set of Managers.", MessageType.Warning);
                        }

                        references.menuManager.ShowGUI();
                    }
                }

                references.viewingMenuManager = showMenu;

                EditorGUILayout.Separator();
                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                GUILayout.Label("Adventure Creator - Version " + AdventureCreator.version, EditorStyles.miniLabel);

                GUILayout.EndScrollView();
            }
            else
            {
                EditorStyles.label.wordWrap = true;
                GUILayout.Label("No 'References' asset found in the resources folder. Please click to create one.", EditorStyles.label);

                if (GUILayout.Button("Create 'References' file"))
                {
                    references = CustomAssetUtility.CreateAsset <References> ("References", "AdventureCreator" + Path.DirectorySeparatorChar.ToString() + "Resources");
                }
            }

            if (GUI.changed)
            {
                if (showActions)
                {
                    RefreshActions();
                }

                EditorUtility.SetDirty(this);
                EditorUtility.SetDirty(references);
            }
        }