Example #1
0
		public static References GetReferences ()
		{
			if (references == null)
			{
				references = (References) Resources.Load (Resource.references);
			}
			return references;
		}
 private void GetReferences()
 {
     references = (References) Resources.Load (Resource.references);
 }
Example #3
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.");
            }
        }
Example #4
0
 private void GetReferences()
 {
     references = (References)Resources.Load(Resource.references);
 }
Example #5
0
        private void OnGUI()
        {
            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", EditorStyles.largeLabel);

                    references.sceneManager = (SceneManager)EditorGUILayout.ObjectField("Asset file: ", references.sceneManager, typeof(SceneManager), false);

                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.sceneManager)
                    {
                        AskToCreate <SceneManager> ("SceneManager");
                    }
                    else
                    {
                        references.sceneManager.ShowGUI();
                    }
                }

                else if (showSettings)
                {
                    GUILayout.Label("Settings manager", EditorStyles.largeLabel);

                    references.settingsManager = (SettingsManager)EditorGUILayout.ObjectField("Asset file: ", references.settingsManager, typeof(SettingsManager), false);

                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.settingsManager)
                    {
                        AskToCreate <SettingsManager> ("SettingsManager");
                    }
                    else
                    {
                        references.settingsManager.ShowGUI();
                    }
                }

                else if (showActions)
                {
                    GUILayout.Label("Actions manager", EditorStyles.largeLabel);

                    references.actionsManager = (ActionsManager)EditorGUILayout.ObjectField("Asset file: ", references.actionsManager, typeof(ActionsManager), false);

                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.actionsManager)
                    {
                        AskToCreate <ActionsManager> ("ActionsManager");
                    }
                    else
                    {
                        references.actionsManager.ShowGUI();
                    }
                }

                else if (showGVars)
                {
                    GUILayout.Label("Variables manager", EditorStyles.largeLabel);

                    references.variablesManager = (VariablesManager)EditorGUILayout.ObjectField("Asset file: ", references.variablesManager, typeof(VariablesManager), false);

                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.variablesManager)
                    {
                        AskToCreate <VariablesManager> ("VariablesManager");
                    }
                    else
                    {
                        references.variablesManager.ShowGUI();
                    }
                }

                else if (showInvItems)
                {
                    GUILayout.Label("Inventory items manager", EditorStyles.largeLabel);

                    references.inventoryManager = (InventoryManager)EditorGUILayout.ObjectField("Asset file: ", references.inventoryManager, typeof(InventoryManager), false);

                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.inventoryManager)
                    {
                        AskToCreate <InventoryManager> ("InventoryManager");
                    }
                    else
                    {
                        references.inventoryManager.ShowGUI();
                    }
                }

                else if (showSpeech)
                {
                    GUILayout.Label("Speech manager", EditorStyles.largeLabel);


                    references.speechManager = (SpeechManager)EditorGUILayout.ObjectField("Asset file: ", references.speechManager, typeof(SpeechManager), false);
                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.speechManager)
                    {
                        AskToCreate <SpeechManager> ("SpeechManager");
                    }
                    else
                    {
                        references.speechManager.ShowGUI();
                    }
                }

                else if (showCursor)
                {
                    GUILayout.Label("Cursor manager", EditorStyles.largeLabel);


                    references.cursorManager = (CursorManager)EditorGUILayout.ObjectField("Asset file: ", references.cursorManager, typeof(CursorManager), false);
                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.cursorManager)
                    {
                        AskToCreate <CursorManager> ("CursorManager");
                    }
                    else
                    {
                        references.cursorManager.ShowGUI();
                    }
                }

                else if (showMenu)
                {
                    GUILayout.Label("Menu manager", EditorStyles.largeLabel);


                    references.menuManager = (MenuManager)EditorGUILayout.ObjectField("Asset file: ", references.menuManager, typeof(MenuManager), false);
                    EditorGUILayout.Separator();
                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                    if (!references.menuManager)
                    {
                        AskToCreate <MenuManager> ("MenuManager");
                    }
                    else
                    {
                        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);
            }
        }
Example #6
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);
            }
        }
Example #7
0
        protected bool TestManagerPresence()
        {
            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;

                string missingManagers = string.Empty;
                if (sceneManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Scene";
                }
                if (settingsManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Settings";
                }
                if (actionsManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Actions";
                }
                if (variablesManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Variables";
                }
                if (inventoryManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Inventory";
                }
                if (speechManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Speech";
                }
                if (cursorManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Cursor";
                }
                if (menuManager == null)
                {
                    if (!string.IsNullOrEmpty(missingManagers))
                    {
                        missingManagers += ", ";
                    }
                    missingManagers += "Menu";
                }

                if (!string.IsNullOrEmpty(missingManagers))
                {
                    ACDebug.LogError("Unassigned AC Manager(s): " + missingManagers + " - all Managers must be assigned in the AC Game Editor window for AC to initialise");
                    return(false);
                }
            }
            else
            {
                ACDebug.LogError("No References object found. Please set one using the main Adventure Creator window");
                return(false);
            }

            return(true);
        }
Example #8
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.");
            }
        }