Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- using UnityEngine.SceneManagement;
- using TMPro;
- public class MainMenu : MonoBehaviour
- {
- // Start is called before the first frame update
- public void Start()
- {
- if (!PlayerPrefs.HasKey("VolumeLevel"))
- {
- PlayerPrefs.SetFloat("VolumeLevel", 1f);
- }
- if (!PlayerPrefs.HasKey("DayNightMode"))
- {
- PlayerPrefs.SetString("DayNightMode", "Auto");
- }
- AudioListener.volume = PlayerPrefs.GetFloat("VolumeLevel");
- UpdatePlatformLogo();
- Cursor.lockState = CursorLockMode.None;
- Cursor.visible = true;
- Time.timeScale = 1f;
- if (PlayerPrefs.GetInt("AchStartingOut") == 1 & PlayerPrefs.GetInt("AchNotebookCollectingMachine") == 1 & PlayerPrefs.GetInt("AchBaldiIsBroken") == 1 & PlayerPrefs.GetInt("AchPlaytimeScissorsSad") == 1 & PlayerPrefs.GetInt("AchCampingIsFun") == 1 & PlayerPrefs.GetInt("AchFasterThanTime") == 1) //If the player got every other acheivement
- {
- if (PlayerPrefs.GetInt("AchYouFoundThemAll") == 0) //Unlock the you've found them all achievement
- {
- PlayerPrefs.SetInt("AchYouFoundThemAll", 1);
- achievementManager.EarnAchievement(6);
- mainMenuAudio.PlayOneShot(achievementEarn);
- }
- }
- }
- public void Update()
- {
- if (!mainMenuAudio.isPlaying)
- {
- mainMenuAudio.PlayOneShot(mainMenuMusic);
- }
- }
- public void UpdatePlatformLogo()
- {
- if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor) //If the mod is currently being played on Windows (in either the player or unity editor)
- {
- logoImage.sprite = logoSprites[0]; //Display the Windows edition of the logo
- }
- else if (Application.platform == RuntimePlatform.OSXPlayer) //If the mod is currently being played on MacOS
- {
- logoImage.sprite = logoSprites[1]; //Display the MacOS edition of the logo
- }
- else if (Application.platform == RuntimePlatform.LinuxPlayer) //If the mod is currently being played on Linux
- {
- logoImage.sprite = logoSprites[2]; //Display the Linux edition of the logo
- }
- else if (Application.platform == RuntimePlatform.WebGLPlayer) //If the mod is currently being played on WebGL (browser version)
- {
- logoImage.sprite = logoSprites[3]; //Display the WebGL edition of the logo
- }
- else if (Application.platform == RuntimePlatform.Android) //If the mod is currently being played on a device running Android
- {
- logoImage.sprite = logoSprites[4]; //Display the Android edition of the logo
- }
- else if (Application.platform == RuntimePlatform.XboxOne) //UNUSED If the mod is currently being played on an Xbox One console
- {
- logoImage.sprite = logoSprites[5]; //Display the Xbox One edition of the logo
- }
- else if (Application.platform == RuntimePlatform.PS4) //UNUSED If the mod is currently being played on a Playstation 4 console
- {
- logoImage.sprite = logoSprites[6]; //Display the Playstation 4 edition of the logo
- }
- else if (Application.platform == RuntimePlatform.Switch) //UNUSED If the mod is currently being played on a Nintendo Switch console
- {
- logoImage.sprite = logoSprites[7]; //Display the Nintendo Switch edition of the logo
- }
- }
- public void SetScreenId(int id)
- {
- StartCoroutine(ShowScreenDelay(id));
- }
- public void SetScreenIdAlt(int id)
- {
- StartCoroutine(ShowScreenDelayAlt(id));
- }
- public void PlayCamAnimation(string animClipName)
- {
- menuCamAnim.Play(animClipName);
- }
- public void SetShowDelay(float seconds)
- {
- showDelay = seconds;
- }
- public IEnumerator ShowScreenDelay(int locId)
- {
- mainMenuScreens[0].SetActive(false);
- yield return new WaitForSeconds(showDelay);
- mainMenuScreens[locId].SetActive(true);
- }
- public IEnumerator ShowScreenDelayAlt(int locId)
- {
- mainMenuScreens[locId].SetActive(false);
- yield return new WaitForSeconds(showDelay);
- mainMenuScreens[0].SetActive(true);
- }
- public void QuitGame() //Quit the game
- {
- Application.Quit();
- }
- public void ResetData() //Reset the player's data and quit the game
- {
- Debug.Log("Data Has Been Reset!");
- PlayerPrefs.DeleteKey("BaldiShirtColor");
- PlayerPrefs.DeleteKey("BaldiPantsColor");
- PlayerPrefs.DeleteKey("BaldiEyeColor");
- PlayerPrefs.DeleteKey("BaldiActiveDecal");
- PlayerPrefs.DeleteKey("AchStartingOut");
- PlayerPrefs.DeleteKey("AchNotebookCollectingMachine");
- PlayerPrefs.DeleteKey("AchBaldiIsBroken");
- PlayerPrefs.DeleteKey("AchPlaytimeScissorsSad");
- PlayerPrefs.DeleteKey("AchCampingIsFun");
- PlayerPrefs.DeleteKey("AchFasterThanTime");
- PlayerPrefs.DeleteKey("AchYouFoundThemAll");
- PlayerPrefs.DeleteKey("TurnSensitivity");
- PlayerPrefs.DeleteKey("VolumeLevel");
- PlayerPrefs.DeleteKey("FpsEnabled");
- PlayerPrefs.DeleteKey("MinimapEnabled");
- PlayerPrefs.DeleteKey("DayNightMode");
- PlayerPrefs.DeleteKey("UpdatedFirstPrizeSprites");
- PlayerPrefs.DeleteKey("YctpPlayerPortrait");
- PlayerPrefs.DeleteKey("ForwardKey");
- PlayerPrefs.DeleteKey("BackwardsKey");
- PlayerPrefs.DeleteKey("LeftKey");
- PlayerPrefs.DeleteKey("RightKey");
- PlayerPrefs.DeleteKey("RunningKey");
- PlayerPrefs.DeleteKey("Item1Found");
- PlayerPrefs.DeleteKey("Item2Found");
- PlayerPrefs.DeleteKey("Item3Found");
- PlayerPrefs.DeleteKey("Item4Found");
- PlayerPrefs.DeleteKey("Item5Found");
- PlayerPrefs.DeleteKey("Item6Found");
- PlayerPrefs.DeleteKey("Item7Found");
- PlayerPrefs.DeleteKey("Item8Found");
- PlayerPrefs.DeleteKey("Item9Found");
- PlayerPrefs.DeleteKey("Item10Found");
- PlayerPrefs.DeleteKey("Item11Found");
- PlayerPrefs.DeleteKey("Item12Found");
- PlayerPrefs.DeleteKey("Item13Found");
- PlayerPrefs.DeleteKey("Item14Found");
- PlayerPrefs.DeleteKey("Gamemode");
- PlayerPrefs.DeleteKey("ChosenPlayer");
- PlayerPrefs.DeleteKey("EndlessNotebooks");
- PlayerPrefs.DeleteKey("PlayingAsHacker");
- Application.Quit();
- }
- public void SetGamemode(string gamemode)
- {
- PlayerPrefs.SetString("Gamemode", gamemode);
- chooseText.text = "Choose A Player!";
- for (int i = 0; i < modeButtons.Length; i++)
- {
- modeButtons[i].SetActive(false);
- }
- for (int j = 0; j < playerButtons.Length; j++)
- {
- playerButtons[j].SetActive(true);
- }
- }
- public void SetPlayer(string playerName)
- {
- PlayerPrefs.SetString("ChosenPlayer", playerName);
- }
- public void LoadLevel(string levelName)
- {
- SceneManager.LoadSceneAsync(levelName);
- }
- public void EnableLoadingScreen(int loadScreenId)
- {
- //Enable the set loading screen (5 is school loading screen, 6 is loading screen for other modes)
- mainMenuScreens[loadScreenId].SetActive(true);
- }
- public void ResetPlayScreen()
- {
- for (int i = 0; i < modeButtons.Length; i++)
- {
- modeButtons[i].SetActive(true);
- }
- for (int j = 0; j < playerButtons.Length; j++)
- {
- playerButtons[j].SetActive(false);
- }
- chooseText.text = "Select A Gamemode!";
- }
- public void OpenLink(string url)
- {
- Application.OpenURL(url);
- }
- public Image logoImage;
- public Sprite[] logoSprites;
- public Transform[] cameraTransforms;
- public GameObject[] mainMenuScreens;
- public AudioSource mainMenuAudio;
- public AudioClip mainMenuMusic;
- public GameObject[] modeButtons;
- public GameObject[] playerButtons;
- public TMP_Text chooseText;
- public float showDelay;
- public Animator menuCamAnim;
- public AudioClip achievementEarn;
- public Achievement achievementManager;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement