The Scripts

  There I share the scripts that I've written while making this little game of mine. You can inspect, analyze or even use them. There is no copyright or anything like that ;)

//GAME ENGINE SCRIPT


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class GameEngine : MonoBehaviour
{
    public Text finalScoreText;

    GameObject button1;
    GameObject button2;
    GameObject button3;

    public int health;
    public int morale;
    public int stamina;
    public int focus;
    public int finalScore;
   
    public Text healthText;
    public Text moraleText;
    public Text staminaText;
    public Text focusText;

    bool gameOverScreen = false;

    public static bool familyMan = false;
    public static bool coldAsIce = false;
    public static bool vIP = false;
    public static bool menOfThePeople = false;
    public static bool lifeGiver = false;
    public static bool decisionMaker = false;

    private int currentSceneIndex;

    private int sceneToContinue;



    public void firstStatementC1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        familyMan = true;
        PlayerPrefs.SetInt("familyman", (familyMan ? 1 : 0));

        morale++;
        focus--;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(9);
    }

    public void firstStatementC2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        coldAsIce = true;
        PlayerPrefs.SetInt("coldasice", (coldAsIce ? 1 : 0));

        morale--;
        focus++;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(10);
    }

    public void firstStatementContinue()
    {
        SceneManager.LoadScene(11);
    }

    public void statement2C1()
    {
        vIP = true;
        PlayerPrefs.SetInt("vip", (vIP ? 1 : 0));
        SceneManager.LoadScene(12);
    }

    public void statement2C2()
    {
        menOfThePeople = true;
        PlayerPrefs.SetInt("menofthepeople", (menOfThePeople ? 1 : 0));
        SceneManager.LoadScene(13);
    }

    public void statement3a()
    {
        SceneManager.LoadScene(14);
    }

    public void statement3b()
    {
        SceneManager.LoadScene(15);
    }

    public void statement4Continue()
    {
        SceneManager.LoadScene(16);
    }

    public void statement4C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        morale++;
        health++;
        stamina = stamina - 2;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(17);
    }

    public void statement4C2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        morale--;
        health = health - 2;
        stamina = stamina + 2;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(18);
    }

    public void statement5Continue()
    {
        SceneManager.LoadScene(19);
    }

    public void statement5C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        morale++;
        stamina = stamina - 5;
        focus = focus - 2;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(20);
    }

    public void statement5C2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        health = health - 2;
        morale--;
        stamina = stamina - 3;
        focus = focus - 2;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(21);
    }

    public void statement6Continue()
    {
        SceneManager.LoadScene(22);
    }

    public void statement6C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        morale++;
        stamina--;
        health--;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(23);
    }

    public void statement6C2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        morale = morale - 2;
        stamina = stamina - 3;
        health = health - 3;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(24);
    }

    public void statement7Continue()
    {
        SceneManager.LoadScene(25);
    }

    public void statement7C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        stamina = stamina - 3;
        health = health - 2;
        morale++;
        focus--;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(26);
    }

    public void statement7C2()
    {
        SceneManager.LoadScene(27);
        PlayerPrefs.DeleteAll();
    }

    public void statement7C3()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        stamina = stamina - 5;
        health = health - 5;
        morale--;
        focus = focus - 2;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(28);
    }

    public void statement8Continue()
    {
        SceneManager.LoadScene(29);
    }

    public void statement8C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        lifeGiver = true;
        PlayerPrefs.SetInt("lifegiver", (lifeGiver ? 1 : 0));

        stamina = stamina - 3;
        health--;
        morale++;
        focus--;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(30);
    }

    public void statement8C2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        decisionMaker = true;
        PlayerPrefs.SetInt("decisionmaker", (decisionMaker ? 1 : 0));

        stamina--;
        health= health-2;
        morale--;
        focus = focus - 2;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(31);
    }

    public void statement9Continue()
    {
        SceneManager.LoadScene(32);
    }

    public void statement10Continue()
    {
        SceneManager.LoadScene(33);
    }

    public void statement10C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        stamina = stamina - 2;
        health = health - 2;
        morale++;
        focus++;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(34);
    }

    public void statement10C2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        stamina--;
        morale = morale - 2;
        focus--;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(35);
    }

    public void statement11Continue()
    {
        SceneManager.LoadScene(36);
    }

    public void statement11C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        stamina--;
        morale--;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(37);
    }

    public void statement11C2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        morale++;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(38);
    }

    public void statement12Continue()
    {
        SceneManager.LoadScene(39);
    }

    public void statement12C1()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        stamina--;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(40);
    }

    public void statement12C2()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        stamina--;
        morale++;
        focus++;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(41);
    }

    public void statement13Continue()
    {
        SceneManager.LoadScene(42);
    }

    public void STWVol1FinishScene()
    {
        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;

        SaveLoadManager.SavePlayer(this);

        SceneManager.LoadScene(43);
    }



    public void gameOver()
    {
        gameOverScreen = true;

        if (gameOverScreen)
        {
            SceneManager.LoadScene(7);

            PlayerPrefs.DeleteAll();
        }
    }

    public void mainMenu()
    {
        SceneManager.LoadScene(0);
    }

    public void restart()
    {
        PlayerPrefs.DeleteAll();

        health = 10;
        morale = 10;
        stamina = 15;
        focus = 10;

        SceneManager.LoadScene(8);
    }

    public void startGame()
    {
        PlayerPrefs.DeleteAll();

        health = 10;
        morale = 10;
        stamina = 15;
        focus = 10;

        SceneManager.LoadScene(8);
    }

    public void continueButton()
    {
        sceneToContinue = PlayerPrefs.GetInt("SavedScene");

        if (sceneToContinue != 0 & sceneToContinue != 1 & sceneToContinue != 2 & sceneToContinue != 3
            & sceneToContinue != 4 & sceneToContinue != 5 & sceneToContinue != 6 & sceneToContinue != 7
            & sceneToContinue != 8)
            SceneManager.LoadScene(sceneToContinue);
        else
            return;

        PlayerData data = SaveLoadManager.LoadPlayer();

        health = data.health;
        morale = data.morale;
        stamina = data.stamina;
        focus = data.focus;
    }

    public void gameOverMainMenu()
    {
        SceneManager.LoadScene(0);

        PlayerPrefs.DeleteAll();
    }

    public void reputations()
    {
        SceneManager.LoadScene(6);
    }

    public void HelpButton()
    {
        SceneManager.LoadScene(1);
    }

    public void gameGuideButton()
    {
        SceneManager.LoadScene(1);
    }

    public void storiesGameplayButton()
    {
        SceneManager.LoadScene(2);
    }

    public void dictionary()
    {
        SceneManager.LoadScene(3);
    }

    public void dictionaryNext()
    {
        SceneManager.LoadScene(4);
    }

    public void aboutMe()
    {
        SceneManager.LoadScene(5);
    }

    public void quitButton()
    {
        Application.Quit();

        Debug.Log("QUIT");
    }

    public void Start()
    {
        //PlayerPrefs.DeleteAll();

        Scene currentScene = SceneManager.GetActiveScene();
        string sceneName = currentScene.name;

        button1 = GameObject.Find("1");
        button2 = GameObject.Find("2");
        button3 = GameObject.Find("3");

        if (sceneName == "New State 1")
        {
            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName=="Choice 1")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            familyMan = true;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName=="Choice 2")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            vIP = true;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="New State 2")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 3")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            vIP = true;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 4")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            menOfThePeople = true;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="New State 3a")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "New State 3b")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="New State 4")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 5")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 6")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName=="New State 5")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            if (stamina < 5)
            {
                button1.transform.GetComponent<Button>().interactable = false;
            }

            if (focus < 2)
            {
                button1.transform.GetComponent<Button>().interactable = false;
            }

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 7")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName =="Choice 8")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="New State 6")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 9")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 10")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="New State 7")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            if (stamina < 3)
            {
                button1.transform.GetComponent<Button>().interactable = false;
            }

            if (focus < 1)
            {
                button1.transform.GetComponent<Button>().interactable = false;
            }

            if (stamina < 5)
            {
                button3.transform.GetComponent<Button>().interactable = false;
            }

            if (focus < 2)
            {
                button3.transform.GetComponent<Button>().interactable = false;
            }

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 11")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 13")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="New State 8")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            if (stamina < 3)
            {
                button1.transform.GetComponent<Button>().interactable = false;
            }

            if (focus < 1)
            {
                button1.transform.GetComponent<Button>().interactable = false;
            }

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if(sceneName=="Choice 14")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            lifeGiver = true;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 15")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            decisionMaker = true;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "New State 9")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "New State 10")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 16")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 17")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "New State 11")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 18")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 19")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "New State 12")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 20")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "Choice 21")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "New State 13")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        if (sceneName == "STWVol1FinishScene")
        {
            PlayerData data = SaveLoadManager.LoadPlayer();

            health = data.health;
            morale = data.morale;
            stamina = data.stamina;
            focus = data.focus;

            finalScore = (health + morale + stamina + focus) * 6;

            while (health <= 0)
            {
                gameOver();
                break;
            }

            currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
            PlayerPrefs.SetInt("SavedScene", currentSceneIndex);

            SaveLoadManager.SavePlayer(this);
        }

        moraleText.text = "Morale: " + morale;
        healthText.text = "Health: " + health;
        staminaText.text = "Stamina: " + stamina;
        focusText.text = "Focus: " + focus;
        finalScoreText.text = "Your final score is: " + finalScore;

    }
}

//MAIN MENU SOUND CONTROL SCRIPT

using System.Collections;

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenuSoundControl : MonoBehaviour
{
    private AudioSource mainMenuSoundtrack;

    public static MainMenuSoundControl instance;

    private void Awake()
    {
        if (instance == null)
            instance = this;
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(transform.gameObject);
        mainMenuSoundtrack = GetComponent<AudioSource>();
    }

    public void Update()
    {
        Scene currentScene = SceneManager.GetActiveScene();
        string sceneName = currentScene.name;

        if (sceneName == "New State 1")
            Destroy(gameObject);

        else if (sceneName != "New Main Menu" & sceneName != "New Reputations"
                 & sceneName != "New Game Guide Menu" & sceneName != "New About Me" & sceneName != "New Stories Gameplay"
                 & sceneName != "New Dictionary" & sceneName != "New Dictionary 1")
            Destroy(gameObject);
    }
}

//PAUSE MENU SCRIPT

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PauseMenu : MonoBehaviour
{

    public static bool gameIsPaused = false;

    public GameObject pauseMenuUI;
   

    public void Resume()
    {
        pauseMenuUI.SetActive(false);
        Time.timeScale = 1f;
        gameIsPaused = false;
    }

    public void Pause()
    {
        pauseMenuUI.SetActive(true);
        Time.timeScale = 0f;
        gameIsPaused = true;
    }

    public void onPlayMainMenu()
    {
        SceneManager.LoadScene("Main Menu");
    }
}

                                 //REPUTATIONS SCRIPT

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class Reputations : MonoBehaviour
{
    public GameObject familyManButton;
    public GameObject coldAsIceButton;
    public GameObject vIPButton;
    public GameObject menOfThePeopleButton;
    public GameObject lifeGiverButton;
    public GameObject decisionMakerButton;

    void Start()
    {
        GameEngine.familyMan = (PlayerPrefs.GetInt("familyman") !=0);
        GameEngine.coldAsIce = (PlayerPrefs.GetInt("coldasice") != 0);
        GameEngine.vIP = (PlayerPrefs.GetInt("vip") != 0);
        GameEngine.menOfThePeople = (PlayerPrefs.GetInt("menofthepeople") != 0);
        GameEngine.lifeGiver = (PlayerPrefs.GetInt("lifegiver") != 0);
        GameEngine.decisionMaker = (PlayerPrefs.GetInt("decisionmaker") != 0);

        if (GameEngine.familyMan == true)
        {
            familyManButton.GetComponent<Button>().interactable = true;
        }

        if (GameEngine.coldAsIce == true)
        {
            coldAsIceButton.GetComponent<Button>().interactable = true;
        }

        if (GameEngine.vIP == true)
        {
            vIPButton.GetComponent<Button>().interactable = true;
        }

        if (GameEngine.menOfThePeople == true)
        {
            menOfThePeopleButton.GetComponent<Button>().interactable = true;
        }

        if (GameEngine.lifeGiver == true)
        {
            lifeGiverButton.GetComponent<Button>().interactable = true;
        }

        if (GameEngine.decisionMaker == true)
        {
            decisionMakerButton.GetComponent<Button>().interactable = true;
        }
    }
}

//SAVE LOAD MANAGER SCRIPT


using UnityEngine;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

public static class SaveLoadManager
{

    public static void SavePlayer(GameEngine player)
    {
        BinaryFormatter bf = new BinaryFormatter();
        string path = Application.persistentDataPath + "/player.sav";
        FileStream stream = new FileStream(path, FileMode.Create);
       
        PlayerData data = new PlayerData(player);

        bf.Serialize(stream, data);
        stream.Close();
    }

    public static PlayerData LoadPlayer ()
    {
        string path = Application.persistentDataPath + "/player.sav";
        if (File.Exists(path))
        {
            BinaryFormatter bf = new BinaryFormatter();
            FileStream stream = new FileStream(path, FileMode.Open);

            PlayerData data= bf.Deserialize(stream) as PlayerData;
            stream.Close();

            return data;
        }
        else
        {
            Debug.LogError("Save file not found in" + path);
            return null;
        }

       
    }
}

    [System.Serializable]
    public class PlayerData
    {  

    public int health;
    public int morale;
    public int stamina;
    public int focus;
    public int finalScore;

        public PlayerData(GameEngine player)
        {
        health = player.health;
        morale = player.morale;
        stamina = player.stamina;
        focus = player.focus;
        finalScore = player.finalScore;
        }

}
  

//SETTINGS SCRIPT

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;

public class Settings : MonoBehaviour
{
    public AudioMixer audioMixer;

    public void SetVolume (float volume)
    {
        audioMixer.SetFloat("volume", volume);
        PlayerPrefs.SetFloat("volumeSliderControl", volume);
    }

    public void settingsMainMenuButton()
    {
        SceneManager.LoadScene("Main Menu");
    }

    public void settingsSettingsButton()
    {
        SceneManager.LoadScene("Settings");
    }

    public void Start()
    {
        PlayerPrefs.GetFloat("volumeSliderControl");
    }
}



//STORY SOUND CONTROL SCRIPT

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class StorySoundControl : MonoBehaviour
{
    private AudioSource storySoundtrack;

    public static StorySoundControl instance;

    private void Awake()
    {
        if (instance == null)
            instance = this;
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(transform.gameObject);
        storySoundtrack = GetComponent<AudioSource>();
    }

    public void Update()
    {
        Scene currentScene = SceneManager.GetActiveScene();
        string sceneName = currentScene.name;

        if (sceneName == "New Main Menu")
            Destroy(gameObject);

        if (sceneName == "New Game Over")
            Destroy(gameObject);

        if (sceneName == "STWVol1FinishScene")
            Destroy(gameObject);

        if (sceneName == "Books Menu")
            Destroy(gameObject);

        if (sceneName == "Start Menu")
            Destroy(gameObject);
    }
}

Yorumlar

Bu blogdaki popüler yayınlar

The Story of a Warrior Download