Exemplo n.º 1
0
    // Debugger menu
    public void OnGUI()
    {
        // Turn on debugger only if Debugger is true
        if (!Debugger)
        {
            return;
        }

        GUILayout.BeginArea(new Rect(0, 0, Screen.width / 6, Screen.height));

        GUILayout.Label("Dungeon");
        GUILayout.Label("Current floor: " + DataMain.Current.playerData.currentFloorLevel);
        GUILayout.Space(10);

        if (GUILayout.Button("Next"))
        {
            if (DataMain.Current.playerData.UpdateCurrentFloor(true))
            {
                sceneFader.FadeToLevel(DataMain.Current.playerData.GetSceneIndex());
            }
        }

        if (GUILayout.Button("Previous"))
        {
            if (DataMain.Current.playerData.UpdateCurrentFloor(false))
            {
                sceneFader.FadeToLevel(DataMain.Current.playerData.GetSceneIndex());
            }
        }

        if (GUILayout.Button("Town"))
        {
            DataMain.Current.playerData.WrapToFloor(0);
            sceneFader.FadeToLevel(DataMain.Current.playerData.GetSceneIndex());
        }

        if (GUILayout.Button("Add exp"))
        {
            DataMain.Current.playerData.GainExp(10);
            Debug.Log("Current: " + DataMain.Current.playerData.exp +
                      " Needed: " + DataMain.Current.playerData.expLeft +
                      " Ratio: " + DataMain.Current.playerData.expRatio);
        }

        GUILayout.Label("Saving and quiting");
        GUILayout.Space(10);

        if (GUILayout.Button("Save"))
        {
            // Update player position in player data and save player stats
            DataMain.Current.playerData.UpdateCurrentPosition(playerAgent.transform.position);
            DataMain.Current.playerData.SaveStats();

            GameSystemUtilities.Save();
        }

        GUILayout.EndArea();
    }
Exemplo n.º 2
0
    // Go back to main menu
    public void GoToMenu()
    {
        Time.timeScale = 1.0f;

        DataMain.Current.IsLoadedGame = true;
        GameSystemUtilities.Save();

        sceneFader.FadeToLevel(0);
    }
    // Continue game
    public void ContinueSaveGame()
    {
        // Load save game from save file
        GameSystemUtilities.Load();

        // Get correct scene index then load that scene
        // 1 being town and 2 being
        sceneFader.FadeToLevel(DataMain.Current.playerData.GetSceneIndex());

        Debug.Log("Continue");
    }
Exemplo n.º 4
0
    // Debugger menu
    public void OnGUI()
    {
        // Turn on debugger only if Debugger is true
        if (!Debugger)
        {
            return;
        }

        GUILayout.BeginArea(new Rect(0, 0, Screen.width / 6, Screen.height));

        GUILayout.Label("Town");
        GUILayout.Label("Current floor: " + DataMain.Current.playerData.currentFloorLevel);
        GUILayout.Space(10);

        if (GUILayout.Button("Next"))
        {
            if (DataMain.Current.playerData.UpdateCurrentFloor(true))
            {
                sceneFader.FadeToLevel(DataMain.Current.playerData.GetSceneIndex());
            }
        }

        if (GUILayout.Button("Previous"))
        {
            if (DataMain.Current.playerData.UpdateCurrentFloor(false))
            {
                sceneFader.FadeToLevel(DataMain.Current.playerData.GetSceneIndex());
            }
        }

        GUILayout.Label("Saving and quiting");
        GUILayout.Space(10);

        if (GUILayout.Button("Save"))
        {
            // Update player position in player data and save player stats
            DataMain.Current.playerData.UpdateCurrentPosition(playerAgent.transform.position);
            DataMain.Current.playerData.SaveStats();

            GameSystemUtilities.Save();
        }

        if (GUILayout.Button("Quit"))
        {
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quite();
#endif
        }

        GUILayout.EndArea();
    }
Exemplo n.º 5
0
    // FUNCTIONS //
    // Save game
    public void SaveGame()
    {
        playerAgent = player.GetComponent <NavMeshAgent>();

        // Update character position to player data and player stats
        DataMain.Current.playerData.UpdateCurrentPosition(playerAgent.transform.position);
        DataMain.Current.playerData.SaveStats();

        // Save enemy spawn position if player is in dungeon scene
        if (SceneManager.GetActiveScene().buildIndex == 2)
        {
            ControllerEnemySpawn.Instance.SaveEnemyPosition();
        }

        GameSystemUtilities.Save();
    }
    // Create new character with given name
    public void CreateNewSave(TextMeshProUGUI input)
    {
        string playerName = input.text;

        if (!(playerName.Length - 1 == 0))
        {
            // Create a new main data. This only happens if a new game is pressed
            DataMain.Current = new DataMain();

            // Set up player name then put index 0 in level array to true
            DataMain.Current.playerData.playerName = playerName;

            // Save main data to save file, then load scene
            GameSystemUtilities.Save();

            // Load Scene
            sceneFader.FadeToLevel(DataMain.Current.playerData.GetSceneIndex());

            Debug.Log("New Game");
        }
    }
Exemplo n.º 7
0
    // When user exits the program, set IsLoadedGame to true
    private void OnApplicationQuit()
    {
        DataMain.Current.IsLoadedGame = true;

        GameSystemUtilities.Save();
    }