Fork Lifter Spaghetti Code

This commit is contained in:
Starpelly
2021-12-18 23:10:43 -05:00
parent e20cf19e11
commit 33bd99bbc1
502 changed files with 66320 additions and 0 deletions

View File

@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GoForAPerfect : MonoBehaviour
{
public static GoForAPerfect instance { get; set; }
private Animator pAnim;
private bool active = false;
public bool perfect;
private void Awake()
{
instance = this;
}
private void Start()
{
pAnim = transform.GetChild(0).GetChild(0).GetComponent<Animator>();
perfect = true;
}
public void Hit()
{
if (!active) return;
pAnim.Play("PerfectIcon_Hit", 0, 0);
}
public void Miss()
{
if (!active) return;
perfect = false;
GameProfiler.instance.perfect = false;
transform.GetChild(0).GetChild(1).gameObject.SetActive(false);
this.GetComponent<Animator>().Play("GoForAPerfect_Miss");
Jukebox.PlayOneShot("perfectMiss");
}
public void Enable()
{
SetActive();
transform.GetChild(0).gameObject.SetActive(true);
}
public void Disable()
{
SetInactive();
transform.GetChild(0).gameObject.SetActive(false);
}
public void SetActive()
{
active = true;
}
public void SetInactive()
{
active = false;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9e5c7679bb002f04980d7554b101f24b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Prologue : MonoBehaviour
{
[SerializeField] private float waitSeconds;
public GameObject Holder;
public GameObject pressAny;
bool inPrologue = false;
private void Update()
{
if (Input.anyKeyDown && !inPrologue)
{
pressAny.SetActive(false);
Holder.SetActive(true);
StartCoroutine(Wait());
inPrologue = true;
}
}
IEnumerator Wait()
{
transform.GetChild(0).gameObject.SetActive(false);
yield return new WaitForSeconds(1);
transform.GetChild(0).gameObject.SetActive(true);
yield return new WaitForSeconds(waitSeconds);
transform.GetChild(0).gameObject.SetActive(false);
yield return new WaitForSeconds(2);
UnityEngine.SceneManagement.SceneManager.LoadScene(1);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35da130f5b96d034885c14ed6ac9a2cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

139
Assets/Scripts/UI/Rating.cs Normal file
View File

@ -0,0 +1,139 @@
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using DG.Tweening;
public class Rating : MonoBehaviour
{
public GameObject Title;
public GameObject Desc;
public GameObject Rank;
public GameObject Epilogue;
public GameObject Perfect;
public GameObject RankingHolder;
public GameObject Fade;
private string rank;
private int rankId;
public Sprite[] epilogueSprites;
public Image epilogueImage;
public TMP_Text epilogueText;
private void Start()
{
float score = GameProfiler.instance.score;
TMP_Text desc = Desc.GetComponent<TMP_Text>();
if (GameProfiler.instance.perfect)
{
Perfect.SetActive(true);
Jukebox.PlayOneShot("Rankings/ranking_perfect");
StartCoroutine(PerfectIE());
}
else
{
if (score < 59)
{
// try again
desc.text = "Your fork technique was rather uncouth. \nYour consecutive stabs needed work.";
rank = "Rankings/ranking_tryagain";
rankId = 2;
}
else if (score >= 59 && score < 79)
{
// ok
desc.text = "Eh. Good enough.";
rank = "Rankings/ranking_ok";
rankId = 1;
}
else if (score >= 79)
{
// superb
desc.text = "Your fork technique was quite elegant. \nYour consecutive stabs were excellent. \nYour triple-stab technique was sublime.";
rank = "Rankings/ranking_superb";
rankId = 0;
}
StartCoroutine(ShowRank());
}
}
private IEnumerator ShowRank()
{
// Title
yield return new WaitForSeconds(0.5f);
Jukebox.PlayOneShot("Rankings/ranking_title_show");
Title.SetActive(true);
// Desc
yield return new WaitForSeconds(2f);
Jukebox.PlayOneShot("Rankings/ranking_desc_show");
Desc.SetActive(true);
// Rating
yield return new WaitForSeconds(2f);
Jukebox.PlayOneShot(rank);
Rank.transform.GetChild(rankId).gameObject.SetActive(true);
// Epilogue
yield return new WaitForSeconds(5f);
Fade.GetComponent<Image>().DOColor(Color.black, 0.75f).OnComplete(delegate
{
StartCoroutine(ShowEpilogue());
});
}
private IEnumerator ShowEpilogue()
{
epilogueImage.sprite = epilogueSprites[rankId];
switch (rankId)
{
case 2:
epilogueText.text = "Blood sugar...so...low...";
break;
case 1:
epilogueText.text = "I could eat two more dinners!";
break;
case 0:
epilogueText.text = "So full! So satisfied!";
break;
}
yield return new WaitForSeconds(1);
Fade.GetComponent<Image>().color = new Color(0, 0, 0, 0);
RankingHolder.SetActive(false);
Epilogue.SetActive(true);
switch (rankId)
{
case 0:
Jukebox.PlayOneShot("Rankings/epilogue_superb");
break;
case 1:
Jukebox.PlayOneShot("Rankings/epilogue_ok");
break;
case 2:
Jukebox.PlayOneShot("Rankings/epilogue_tryagain");
break;
}
yield return new WaitForSeconds(8);
GlobalGameManager.LoadScene(0);
}
private IEnumerator PerfectIE()
{
yield return new WaitForSeconds(8);
GlobalGameManager.LoadScene(0);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c00b45746e9b68744b76eb77268a0c61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: