Open-sourced some code

This commit is contained in:
2019-03-08 09:54:14 +11:00
commit 645272872c
142 changed files with 3028 additions and 0 deletions
@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Startups {
public class Debugger : MonoBehaviour {
AudioController audioController;
void Start() {
audioController = Object.FindObjectOfType(typeof(AudioController)) as AudioController;
audioController.Load("rockstar", "Audio/Music/EngineTest");
audioController.Load("forest_ambience", "Audio/Music/Forest_Ambience");
audioController.Load("forest_background", "Audio/Music/Forest_Background");
audioController.Play("rockstar", AudioController.Mode.JUMP, 5f, 15);
// StartCoroutine(DebugLoopMusic(10f));
}
IEnumerator DebugLoopMusic(float duration) {
for(;;) {
audioController.PauseFadeOutAll(3f, new List<string> {"forest_background"});
audioController.UnpauseFadeIn("forest_background", 3f, AudioController.Mode.LOOP);
yield return new WaitForSeconds(duration);
audioController.PauseFadeOutAll(3f, new List<string> {"forest_ambience"});
audioController.UnpauseFadeIn("forest_ambience", 3f, AudioController.Mode.LOOP);
yield return new WaitForSeconds(duration);
}
}
}
}
@@ -0,0 +1,29 @@
using UnityEngine;
using System.Collections;
//DOCS: http://wiki.unity3d.com/index.php/FramesPerSecond
namespace Startups {
public class FPSDisplay : MonoBehaviour {
float deltaTime = 0.0f;
void Update() {
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
}
void OnGUI() {
int w = Screen.width, h = Screen.height;
GUIStyle style = new GUIStyle();
Rect rect = new Rect(0, 0, w, h * 2 / 100);
style.alignment = TextAnchor.UpperLeft;
style.fontSize = h * 2 / 100;
style.normal.textColor = new Color (0.0f, 0.0f, 0.5f, 1.0f);
float msec = deltaTime * 1000.0f;
float fps = 1.0f / deltaTime;
string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
GUI.Label(rect, text, style);
}
}
}
@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Startups {
public class PauseMenuHandler : MonoBehaviour {
public Canvas pauseMenuCanvas;
public Canvas optionsMenuCanvas;
public Canvas saveMenuCanvas;
PauseManager pauseManager;
void Start() {
pauseManager = PauseManager.Instance;
pauseManager.Paused = false;
pauseManager.PushOnPaused(() => {
pauseMenuCanvas.gameObject.SetActive(true);
Time.timeScale = 0f;
});
pauseManager.PushOnResume(() => {
pauseMenuCanvas.gameObject.SetActive(false);
optionsMenuCanvas.gameObject.SetActive(false);
saveMenuCanvas.gameObject.SetActive(false);
Time.timeScale = 1f;
});
}
void OnDestroy() {
pauseManager.PurgeLists();
}
void Update() {
if (GamePad.GetState().Pressed(CButton.Start)) {
pauseManager.Paused = !pauseManager.Paused;
}
}
}
}
@@ -0,0 +1,37 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class SaveHandler : MonoBehaviour {
public GameObject playerObject;
public Dictionary<string, Structures.Pedestal> pedestalDictionary = new Dictionary<string, Structures.Pedestal>();
public bool saveMenuAvailable = false;
public float startTime = 0f;
void Start() {
//create the save file if it doesn't exist
if (SaveFileManager.LoadedSaveSlot == null) {
SaveFileManager.saveSlotFileName = Path.Combine(Application.persistentDataPath, DateTime.Now.ToString("yyyyMMddTHHmmss") + ".sav");
SaveFileManager.LoadedSaveSlot = SaveFileManager.CreateBlankSaveSlot();
// SaveFileManager.SaveData(SaveFileManager.LoadedSaveSlot, SaveFileManager.saveSlotFileName);
}
//initialize the game world with the given save data
startTime = Time.time;
//convert the array into a quick-search dictionary
Structures.Pedestal[] pedestals = GameObject.FindObjectsOfType<Structures.Pedestal>();
foreach(Structures.Pedestal pedestal in pedestals) {
pedestal.SaveHandler = this;
pedestalDictionary[pedestal.name] = pedestal;
}
//place the player on their saved pedestal
playerObject.transform.position = pedestalDictionary[SaveFileManager.LoadedSaveSlot.currentLocation].gameObject.transform.position;
}
}