Skip to content

Commit

Permalink
Added many new things, changed some others.
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeChef committed May 3, 2021
1 parent ecd7d9c commit fece5e4
Show file tree
Hide file tree
Showing 13 changed files with 2,231 additions and 325 deletions.
2,412 changes: 2,091 additions & 321 deletions Ghostrunner Speedrun Randomizer/Assets/Scenes/SampleScene.unity

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,36 @@
public class EmptyRandomizations : MonoBehaviour
{

public float holdDuration = 1f;
public Slider holdDisplay;
public KeyCode emptyKey = KeyCode.Backspace;

[Space]
public Text levelText;
public Text restrictionText;
public Text killsText;
public Text collectiblesText;
public KeyCode emptyKey = KeyCode.Backspace;
public Text boundsText;

private float holdTimer;

void Update()
{
if (Input.GetKeyDown(emptyKey))
holdDisplay.maxValue = holdDuration;
holdDisplay.value = holdTimer;

if (Input.GetKey(emptyKey))
holdTimer += Time.deltaTime;
else
holdTimer = 0f;

if (holdTimer >= holdDuration)
{
levelText.text = string.Empty;
restrictionText.text = string.Empty;
killsText.text = string.Empty;
collectiblesText.text = string.Empty;
boundsText.text = string.Empty;
}
}
}
14 changes: 14 additions & 0 deletions Ghostrunner Speedrun Randomizer/Assets/Scripts/Randomize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ public class Randomize : MonoBehaviour
public Text restrictionText;
public Text killsText;
public Text collectiblesText;
public Text boundsText;

[Space]
public AudioSource[] sounds;
public string[] levels;
public string[] restrictions;
public string[] kills;
public string[] collectibles;
public string[] bounds;

void Update()
{
Expand All @@ -30,6 +32,9 @@ void Update()

if (collectiblesText.color != Color.white)
collectiblesText.color = Color.Lerp(collectiblesText.color, Color.white, colorLerpTime * Time.deltaTime);

if (boundsText.color != Color.white)
boundsText.color = Color.Lerp(boundsText.color, Color.white, colorLerpTime * Time.deltaTime);
}

public void RandomizeLevel()
Expand Down Expand Up @@ -67,4 +72,13 @@ public void RandomizeCollectibles()

sounds[Random.Range(0, sounds.Length)].Play();
}

public void RandomizeBounds()
{
int bound = Random.Range(0, bounds.Length);
boundsText.text = bounds[bound];
boundsText.color = Color.yellow;

sounds[Random.Range(0, sounds.Length)].Play();
}
}
13 changes: 13 additions & 0 deletions Ghostrunner Speedrun Randomizer/Assets/Scripts/ReadInputFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ public class ReadInputFile : MonoBehaviour
public string restrictionsFileName = "Restrictions.txt";
public string killsFileName = "Kills.txt";
public string collectiblesFileName = "Collectibles.txt";
public string boundsFileName = "Bounds.txt";

void Update()
{
string levelsPath = Path.Combine(Application.streamingAssetsPath, levelsFileName);
string restrictionsPath = Path.Combine(Application.streamingAssetsPath, restrictionsFileName);
string killsPath = Path.Combine(Application.streamingAssetsPath, killsFileName);
string collectiblesPath = Path.Combine(Application.streamingAssetsPath, collectiblesFileName);
string boundsPath = Path.Combine(Application.streamingAssetsPath, boundsFileName);

if (File.Exists(levelsPath))
{
Expand Down Expand Up @@ -62,5 +64,16 @@ void Update()
randomize.collectibles[i] = lines[i];
}
}

if (File.Exists(boundsPath))
{
string[] lines = File.ReadAllLines(boundsPath);

randomize.bounds = new string[lines.Length];
for (int i = 0; i < randomize.bounds.Length; i++)
{
randomize.bounds[i] = lines[i];
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public class ResetRandomizer : MonoBehaviour
public string restrictionsFileName = "Restrictions.txt";
public string killsFileName = "Kills.txt";
public string collectiblesFileName = "Collectibles.txt";
public string boundsFileName = "Bounds.txt";

[Space]
public string[] defaultLevels;
public string[] defaultRestrictions;
public string[] defaultKills;
public string[] defaultCollectibles;
public string[] defaultBounds;

private float resetTimer;

Expand Down Expand Up @@ -51,6 +53,10 @@ void Update()
string collectiblesPath = Path.Combine(Application.streamingAssetsPath, collectiblesFileName);
if (File.Exists(collectiblesPath))
File.WriteAllLines(collectiblesPath, defaultCollectibles);

string boundsPath = Path.Combine(Application.streamingAssetsPath, boundsFileName);
if (File.Exists(boundsPath))
File.WriteAllLines(boundsPath, defaultBounds);
}
}
}
47 changes: 47 additions & 0 deletions Ghostrunner Speedrun Randomizer/Assets/Scripts/VolumeAdjust.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.IO;
using UnityEngine;
using UnityEngine.UI;

public class VolumeAdjust : MonoBehaviour
{

public Slider soundEffectSlider;
public Slider musicSlider;
public string fileName;

[Space]
public AudioSource[] soundEffects;
public AudioSource[] music;

private void Start()
{
string path = Path.Combine(Application.streamingAssetsPath, fileName);
if (File.Exists(path))
{
string[] contents = File.ReadAllLines(path);
soundEffectSlider.value = float.Parse(contents[0]);
musicSlider.value = float.Parse(contents[1]);
}
}

void Update()
{
string path = Path.Combine(Application.streamingAssetsPath, fileName);

string[] contents = new string[2];
contents[0] = soundEffectSlider.value.ToString();
contents[1] = musicSlider.value.ToString();

File.WriteAllLines(path, contents);

foreach (AudioSource source in soundEffects)
{
source.volume = soundEffectSlider.value;
}

foreach (AudioSource source in music)
{
source.volume = musicSlider.value;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
In-Bounds
Out of Bounds
Any Bounds
Either One

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
All Kills
No Kills (Not including required)
Any
No Kills (Unless Required)
Any Kills
1 Kill per Room (Required kills allowed)
All Kills (Includes Crawlers)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ No Slide (Unless required)
No Jump (Unless required)
No Ledge-Boost
No Wall-Dash
No Uplinks (Unless Required)
No Tetris Upgrades
No Flying
No Blink (Allowed for CV)
No Tempest (Allowed for CV)
No Surge (Allowed for CV)
No Overlord (Allowed for CV)
None
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.2
0.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fece5e4

Please sign in to comment.