Init repository
This commit is contained in:
Executable file
+28
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class TimeText3D : MonoBehaviour
|
||||
{
|
||||
public TMP_Text TextObject;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (TextObject)
|
||||
{
|
||||
string Time = TimeController.PublicFormattedTimeOfDay;
|
||||
TextObject.text = "In-game time: " + Time;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTimeFormat(bool is24hour)
|
||||
{
|
||||
TimeController.MilitaryTime = is24hour;
|
||||
}
|
||||
|
||||
private void OnMouseDown()
|
||||
{
|
||||
SetTimeFormat(!TimeController.MilitaryTime);
|
||||
}
|
||||
}
|
||||
Executable file
+33
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class AdvLevelMan : MonoBehaviour
|
||||
{
|
||||
public Slider loadingBar;
|
||||
public TMP_Text loadingText;
|
||||
|
||||
public void SwitchSceneAdv(string levelName)
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync(levelName));
|
||||
}
|
||||
|
||||
IEnumerator LoadSceneAsync(string levelName)
|
||||
{
|
||||
Debug.Log($"Loading scene {levelName}");
|
||||
AsyncOperation op = SceneManager.LoadSceneAsync(levelName);
|
||||
while (!op.isDone)
|
||||
{
|
||||
float progress = Mathf.Clamp01(op.progress / .9f);
|
||||
//Debug.Log(op.progress);
|
||||
loadingBar.value = progress;
|
||||
loadingText.text = $"<align=center>{(progress * 100f).ToString("0.00")}%";
|
||||
if ((progress * 100f) >= 98)
|
||||
loadingText.text = "Doing stuff...";
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable file
+75
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class BigWorld : MonoBehaviour
|
||||
{
|
||||
public bool useAudioBundle = false;
|
||||
public AudioBundleLoader BundleLoader;
|
||||
public List<string> AudioClipNames = new() {
|
||||
"Gion3.ogg",
|
||||
"OriginStation.ogg",
|
||||
"TrainToTheFuture.ogg",
|
||||
"Finality.ogg"
|
||||
};
|
||||
public AssetBundle AudioBundle;
|
||||
public AudioSource ambientAudioSource;
|
||||
public AudioClip CurrentAmbient;
|
||||
public bool AutoPlayAmbient = true;
|
||||
private readonly System.Random random = new();
|
||||
[ShowOnly] public float AudioChangesOn = 0f;
|
||||
[ShowOnly] public bool AudioIsPlaying = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (BundleLoader)
|
||||
{
|
||||
AudioBundle = BundleLoader.AudioAssetBundle;
|
||||
}
|
||||
if (AutoPlayAmbient)
|
||||
{
|
||||
Debug.Log("Automatically playing ambient...");
|
||||
PlayAmbient();
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayAmbient()
|
||||
{
|
||||
if (useAudioBundle)
|
||||
{
|
||||
string AudioClipName = AudioClipNames[random.Next(AudioClipNames.Count)];
|
||||
Debug.Log("Attempting to load audiobundle...");
|
||||
if (ambientAudioSource)
|
||||
{
|
||||
AudioClip clip = BundleLoader.GetAudioClipFromAssetBundle(/*"Default/" + */AudioClipName);
|
||||
if (!clip)
|
||||
Debug.LogError($"AudioClip {AudioClipName} could not be loaded.");
|
||||
else
|
||||
{
|
||||
ambientAudioSource.clip = clip;
|
||||
ambientAudioSource.Play();
|
||||
ambientAudioSource.clip = clip;
|
||||
AudioChangesOn = clip.length;
|
||||
Debug.LogError($"Tried playing ambience: {clip.name} with a length of {clip.length}");
|
||||
AudioIsPlaying = true;
|
||||
//TimesAmbientSet++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (AutoPlayAmbient)
|
||||
{
|
||||
if (ambientAudioSource.isPlaying)
|
||||
{
|
||||
AudioChangesOn -= Time.fixedDeltaTime;
|
||||
}
|
||||
if (AudioChangesOn <= 0f && AudioIsPlaying)
|
||||
{
|
||||
Debug.LogError("Clip has finished playing. Choosing a random clip...");
|
||||
PlayAmbient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable file
+123
@@ -0,0 +1,123 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HomeWorld_Initialize : MonoBehaviour
|
||||
{
|
||||
public AudioSource audioSource;
|
||||
public AudioClip OpenMenuClip1;
|
||||
public float PlayVolume = 0.8f;
|
||||
public string StartingClipName = "UI_OpenMenu_Start.wav";
|
||||
|
||||
private readonly System.Random random = new();
|
||||
//[ShowOnly] public float AudioElapsedTimePlaying = 0;
|
||||
[ShowOnly] public float AudioChangesOn = 0f;
|
||||
[ShowOnly] public bool AudioIsPlaying = false;
|
||||
public List<string> AudioClipNames = new() {
|
||||
"Gion3.ogg",
|
||||
"OriginStation.ogg",
|
||||
"TrainToTheFuture.ogg",
|
||||
"AsBefore.ogg"
|
||||
//"Finality-HOYO-MiX.ogg"
|
||||
};
|
||||
public bool useAssetBundle = false;
|
||||
public AudioBundleLoader BundleLoader;
|
||||
public AssetBundle AudioBundle;
|
||||
public RectTransform SettingsPanel;
|
||||
private Resolution GameResolutionPre;
|
||||
public Toggle FullscreenToggle;
|
||||
|
||||
private async void Start()
|
||||
{
|
||||
if (useAssetBundle)
|
||||
{
|
||||
/*BundleLoader.InitializeAudioAssetBundle();
|
||||
new WaitForSeconds(2);*/
|
||||
AudioBundle = BundleLoader.GetAudioAssetBundle();
|
||||
OpenMenuClip1 = BundleLoader.GetAudioClipFromAssetBundle(StartingClipName);
|
||||
}
|
||||
else if (!OpenMenuClip1)
|
||||
OpenMenuClip1 = await JTN.Utils.LoadClip(Path.Combine(Application.streamingAssetsPath, StartingClipName));
|
||||
if (audioSource && OpenMenuClip1)
|
||||
audioSource.PlayOneShot(OpenMenuClip1, PlayVolume);
|
||||
/* if (SettingsPanel)
|
||||
{
|
||||
if (Screen.currentResolution.height != GameResolutionPre.height)
|
||||
{
|
||||
SettingsPanel.sizeDelta = new Vector2(SettingsPanel.sizeDelta.x, Screen.currentResolution.height);
|
||||
GameResolutionPre = Screen.currentResolution;
|
||||
}
|
||||
if (Screen.currentResolution.width != GameResolutionPre.width)
|
||||
{
|
||||
SettingsPanel.sizeDelta = new Vector2(Screen.currentResolution.width, SettingsPanel.sizeDelta.y);
|
||||
GameResolutionPre = Screen.currentResolution;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (PlayerPrefs.HasKey("FullscreenState") && FullscreenToggle)
|
||||
{
|
||||
if (PlayerPrefs.GetInt("FullscreenState") == 1)
|
||||
{
|
||||
FullscreenToggle.isOn = true;
|
||||
} else
|
||||
{
|
||||
FullscreenToggle.isOn = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (BundleLoader.AudioAssetBundle)
|
||||
{
|
||||
if (!audioSource.isPlaying)
|
||||
PlayBGM();
|
||||
else
|
||||
{
|
||||
AudioChangesOn -= Time.fixedDeltaTime;
|
||||
}
|
||||
if (AudioChangesOn <= 0f && AudioIsPlaying)
|
||||
{
|
||||
Debug.LogError("Clip has finished playing. Choosing a random clip...");
|
||||
PlayBGM();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*private void Update()
|
||||
{
|
||||
if (SettingsPanel)
|
||||
{
|
||||
if (Screen.currentResolution.height != GameResolutionPre.height &&
|
||||
Screen.currentResolution.width != GameResolutionPre.width)
|
||||
{
|
||||
SettingsPanel.sizeDelta = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);
|
||||
}
|
||||
GameResolutionPre = Screen.currentResolution;
|
||||
}
|
||||
}*/
|
||||
public void PlayBGM()
|
||||
{
|
||||
string AudioClipName = AudioClipNames[random.Next(AudioClipNames.Count)];
|
||||
Debug.Log("Attempting to load audiobundle...");
|
||||
if (audioSource)
|
||||
{
|
||||
AudioClip clip = BundleLoader.GetAudioClipFromAssetBundle(/*"Default/" + */AudioClipName);
|
||||
if (!clip)
|
||||
Debug.LogError($"AudioClip {AudioClipName} could not be loaded.");
|
||||
else
|
||||
{
|
||||
audioSource.clip = clip;
|
||||
audioSource.Play();
|
||||
audioSource.clip = clip;
|
||||
AudioChangesOn = clip.length;
|
||||
Debug.LogError($"Tried playing ambience: {clip.name} with a length of {clip.length}");
|
||||
AudioIsPlaying = true;
|
||||
//TimesAmbientSet++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Executable file
+117
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TimeController : MonoBehaviour
|
||||
{
|
||||
public TMP_Text TODIndicator;
|
||||
public Slider TODSlider;
|
||||
[HideInInspector]
|
||||
public GameObject sun;
|
||||
[HideInInspector]
|
||||
public Light sunLight;
|
||||
|
||||
[Range(0, 24)]
|
||||
public float timeOfDay = 12;
|
||||
|
||||
public float secondsPerMinute = 60;
|
||||
[HideInInspector]
|
||||
public float secondsPerHour;
|
||||
[HideInInspector]
|
||||
public float secondsPerDay;
|
||||
|
||||
// Realistic - 1
|
||||
// Normal - 2400
|
||||
public float timeMultiplier = 2400;
|
||||
|
||||
public static string PublicFormattedTimeOfDay = "00:00";
|
||||
|
||||
[ShowOnly]
|
||||
public string StringTimeOfDay = "00:00";
|
||||
public static bool MilitaryTime = false;
|
||||
public float MinutesBy = 60;
|
||||
|
||||
void Start()
|
||||
{
|
||||
sun = gameObject;
|
||||
sunLight = gameObject.GetComponent<Light>();
|
||||
|
||||
secondsPerHour = secondsPerMinute * 60;
|
||||
secondsPerDay = secondsPerHour * 24;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
SunUpdate();
|
||||
|
||||
timeOfDay += (Time.deltaTime / secondsPerDay) * timeMultiplier;
|
||||
StringTimeOfDay = FormatTime(timeOfDay, MilitaryTime);
|
||||
PublicFormattedTimeOfDay = StringTimeOfDay;
|
||||
|
||||
if (timeOfDay >= 24)
|
||||
timeOfDay = 0;
|
||||
|
||||
|
||||
if (TODIndicator)
|
||||
TODIndicator.text = StringTimeOfDay;
|
||||
if (TODSlider)
|
||||
{
|
||||
TODSlider.onValueChanged.RemoveAllListeners();
|
||||
TODSlider.onValueChanged.AddListener(delegate { UpdateTime(TODSlider.value); });
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateTime(Single ResultTime)
|
||||
{
|
||||
if (TODSlider)
|
||||
timeOfDay = ResultTime;
|
||||
}
|
||||
public string FormatTime(float TimeOfDay, bool military = true)
|
||||
{
|
||||
TimeSpan timeSpan = TimeSpan.FromHours(TimeOfDay);
|
||||
string hours = timeSpan.Hours.ToString();
|
||||
string minutes = timeSpan.Minutes.ToString();
|
||||
|
||||
if (minutes == "0")
|
||||
minutes += "0";
|
||||
if (timeSpan.Minutes <= 9)
|
||||
minutes = "0" + timeSpan.Minutes;
|
||||
if (timeSpan.Hours < 10 && military)
|
||||
{
|
||||
if (hours == "0")
|
||||
hours += "0";
|
||||
else
|
||||
hours = "0" + hours;
|
||||
}
|
||||
if (!military)
|
||||
{
|
||||
var IntHours = int.Parse(hours);
|
||||
|
||||
if (IntHours <= 12)
|
||||
{
|
||||
if (hours == "0")
|
||||
hours = "12";
|
||||
|
||||
minutes += " AM";
|
||||
}
|
||||
else
|
||||
{
|
||||
minutes += " PM";
|
||||
hours = (IntHours - 12).ToString();
|
||||
}
|
||||
};
|
||||
|
||||
var output = String.Format("{0}:{1}", hours, minutes);
|
||||
return output;
|
||||
}
|
||||
public void SunUpdate()
|
||||
{
|
||||
if (TODSlider)
|
||||
TODSlider.value = timeOfDay;
|
||||
sun.transform.localRotation = Quaternion.Euler(((timeOfDay / 24) * 360f) - 90, 90, 0);
|
||||
}
|
||||
}
|
||||
Executable file
+50
@@ -0,0 +1,50 @@
|
||||
using JTN;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PausePanel : MonoBehaviour
|
||||
{
|
||||
public GameObject PauseMenuPanel;
|
||||
public GameObject PauseButton;
|
||||
public KeyCode PauseKey = KeyCode.Escape;
|
||||
public bool Paused;
|
||||
public FirstPersonController PlayerController;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (PauseMenuPanel && PauseButton)
|
||||
{
|
||||
if (Input.GetKeyDown(PauseKey))
|
||||
{
|
||||
Debug.Log("Paused with " + PauseKey.ToString());
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
Debug.Log("Pause state: " + Paused);
|
||||
if (!Paused)
|
||||
{
|
||||
PlayerController.enabled = false;
|
||||
PauseButton.SetActive(false);
|
||||
PauseMenuPanel.SetActive(true);
|
||||
|
||||
Paused = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Time.timeScale = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerController.enabled = true;
|
||||
PauseButton.SetActive(true);
|
||||
PauseMenuPanel.SetActive(false);
|
||||
|
||||
Paused = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Time.timeScale = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable file
+45
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DropDownScenePopulator : MonoBehaviour
|
||||
{
|
||||
public List<Dropdown.OptionData> optionDataList;
|
||||
public Dropdown scenenavigator;
|
||||
public string SelectedSceneName = "";
|
||||
void Start()
|
||||
{
|
||||
if (scenenavigator)
|
||||
{
|
||||
optionDataList = new List<Dropdown.OptionData>();
|
||||
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; ++i)
|
||||
{
|
||||
string name = System.IO.Path.GetFileNameWithoutExtension(SceneUtility.GetScenePathByBuildIndex(i));
|
||||
optionDataList.Add(new Dropdown.OptionData(name));
|
||||
}
|
||||
scenenavigator.ClearOptions();
|
||||
scenenavigator.AddOptions(optionDataList);
|
||||
scenenavigator.onValueChanged.AddListener((t) => {
|
||||
//SetSceneOptionData(optionDataList[scenenavigator.value]);
|
||||
SelectedSceneName = optionDataList[scenenavigator.value].text;
|
||||
Debug.LogError("Selected scene in navigator: " + optionDataList[scenenavigator.value].text);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchScene()
|
||||
{
|
||||
Time.timeScale = 1;
|
||||
Debug.Log(SelectedSceneName);
|
||||
Debug.Log(string.Format("Setting current scene to {0}", SelectedSceneName));
|
||||
SceneManager.LoadScene(SelectedSceneName);
|
||||
}
|
||||
|
||||
public void ReloadScene()
|
||||
{
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||
}
|
||||
}
|
||||
Executable file
+47
@@ -0,0 +1,47 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
|
||||
public class SettingsPanel : MonoBehaviour
|
||||
{
|
||||
public GameObject settingsPanel;
|
||||
public GameObject settingsPanelDeactivator;
|
||||
public bool DisableSettingsPanelWhenLinkedGameobjectIsActivated = false;
|
||||
public TMP_Dropdown GraphicsQualityDropdown;
|
||||
public PostProcessVolume PostProcessVolume;
|
||||
private void Update()
|
||||
{
|
||||
if (settingsPanel && DisableSettingsPanelWhenLinkedGameobjectIsActivated && settingsPanelDeactivator.activeInHierarchy)
|
||||
{
|
||||
settingsPanel.SetActive(false);
|
||||
settingsPanelDeactivator.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (GraphicsQualityDropdown)
|
||||
{
|
||||
string[] QualityNames = QualitySettings.names;
|
||||
List<TMP_Dropdown.OptionData> Options = new();
|
||||
GraphicsQualityDropdown.ClearOptions();
|
||||
foreach (string QualityName in QualityNames)
|
||||
{
|
||||
Options.Add(new TMP_Dropdown.OptionData(QualityName));
|
||||
}
|
||||
|
||||
GraphicsQualityDropdown.AddOptions(Options);
|
||||
GraphicsQualityDropdown.value = QualitySettings.GetQualityLevel();
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchQualitySettings(int index)
|
||||
{
|
||||
if (GraphicsQualityDropdown)
|
||||
{
|
||||
QualitySettings.SetQualityLevel(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable file
+5
@@ -0,0 +1,5 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ShowOnlyAttribute : PropertyAttribute
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user