mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 13:37:40 +02:00
Fork Lifter Spaghetti Code
This commit is contained in:
58
Assets/Scripts/$dd_Invert.shader
Normal file
58
Assets/Scripts/$dd_Invert.shader
Normal file
@ -0,0 +1,58 @@
|
||||
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
|
||||
Shader "ddShaders/dd_Invert" {
|
||||
Properties
|
||||
{
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" }
|
||||
|
||||
Pass
|
||||
{
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
}
|
||||
Blend OneMinusDstColor OneMinusSrcAlpha //invert blending, so long as FG color is 1,1,1,1
|
||||
BlendOp Add
|
||||
|
||||
Pass
|
||||
{
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
uniform float4 _Color;
|
||||
|
||||
struct vertexInput
|
||||
{
|
||||
float4 vertex: POSITION;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct fragmentInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
fragmentInput vert( vertexInput i )
|
||||
{
|
||||
fragmentInput o;
|
||||
o.pos = UnityObjectToClipPos(i.vertex);
|
||||
o.color = _Color;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag( fragmentInput i ) : COLOR
|
||||
{
|
||||
return i.color;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
10
Assets/Scripts/$dd_Invert.shader.meta
Normal file
10
Assets/Scripts/$dd_Invert.shader.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 186aee7e6d6053f4f8f0cca0ed3d25ac
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/CircleCursor.cs
Normal file
29
Assets/Scripts/CircleCursor.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CircleCursor : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool follow = false;
|
||||
[SerializeField] private float mouseMoveSpeed;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
if (follow)
|
||||
{
|
||||
Vector2 direction = (pos - transform.position).normalized;
|
||||
this.GetComponent<Rigidbody2D>().velocity = new Vector2(direction.x * mouseMoveSpeed, direction.y * mouseMoveSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gameObject.transform.position = new Vector3(pos.x, pos.y, 0);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/CircleCursor.cs.meta
Normal file
11
Assets/Scripts/CircleCursor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df1a2eb4f3722f44c954427fe95d8dbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/Scripts/CommonAnimEvents.cs
Normal file
11
Assets/Scripts/CommonAnimEvents.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CommonAnimEvents : MonoBehaviour
|
||||
{
|
||||
public void Destroy()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
11
Assets/Scripts/CommonAnimEvents.cs.meta
Normal file
11
Assets/Scripts/CommonAnimEvents.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aae9454ad2ee24c4e9988472183c51fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
167
Assets/Scripts/Conductor.cs
Normal file
167
Assets/Scripts/Conductor.cs
Normal file
@ -0,0 +1,167 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Starpelly;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class Conductor : MonoBehaviour
|
||||
{
|
||||
//Song beats per minute
|
||||
//This is determined by the song you're trying to sync up to
|
||||
public float songBpm;
|
||||
|
||||
//The number of seconds for each song beat
|
||||
public float secPerBeat;
|
||||
|
||||
//Current song position, in seconds
|
||||
public float songPosition;
|
||||
|
||||
//Current song position, in beats
|
||||
public float songPositionInBeats;
|
||||
|
||||
//How many seconds have passed since the song started
|
||||
public float dspSongTime;
|
||||
|
||||
//an AudioSource attached to this GameObject that will play the music.
|
||||
public AudioSource musicSource;
|
||||
|
||||
//The offset to the first beat of the song in seconds
|
||||
public float firstBeatOffset;
|
||||
|
||||
//the number of beats in each loop
|
||||
public float beatsPerLoop;
|
||||
|
||||
//the total number of loops completed since the looping clip first started
|
||||
public int completedLoops = 0;
|
||||
|
||||
//The current position of the song within the loop in beats.
|
||||
public float loopPositionInBeats;
|
||||
|
||||
//The current relative position of the song within the loop measured between 0 and 1.
|
||||
public float loopPositionInAnalog;
|
||||
|
||||
//Conductor instance
|
||||
public static Conductor instance;
|
||||
|
||||
//Pause times
|
||||
private int pauseTime = 0;
|
||||
|
||||
public float beatThreshold;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
//Load the AudioSource attached to the Conductor GameObject
|
||||
musicSource = GetComponent<AudioSource>();
|
||||
|
||||
//Calculate the number of seconds in each beat
|
||||
secPerBeat = 60f / songBpm;
|
||||
|
||||
//Record the time when the music starts
|
||||
dspSongTime = (float)musicSource.time;
|
||||
|
||||
//Start the music
|
||||
// musicSource.Play();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Conductor.instance.musicSource.pitch = Time.timeScale;
|
||||
|
||||
/*if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
pauseTime++;
|
||||
if (pauseTime == 1)
|
||||
musicSource.Pause();
|
||||
else if (pauseTime > 1) { musicSource.UnPause(); pauseTime = 0; }
|
||||
}*/
|
||||
|
||||
//determine how many seconds since the song started
|
||||
songPosition = (float)(musicSource.time - dspSongTime - firstBeatOffset);
|
||||
|
||||
//determine how many beats since the song started
|
||||
songPositionInBeats = songPosition / secPerBeat;
|
||||
|
||||
//calculate the loop position
|
||||
if (songPositionInBeats >= (completedLoops + 1) * beatsPerLoop)
|
||||
completedLoops++;
|
||||
loopPositionInBeats = songPositionInBeats - completedLoops * beatsPerLoop;
|
||||
|
||||
loopPositionInAnalog = loopPositionInBeats / beatsPerLoop;
|
||||
}
|
||||
|
||||
public float GetLoopPositionFromBeat(float startBeat, float length)
|
||||
{
|
||||
float final = Starpelly.Mathp.Normalize(songPositionInBeats, startBeat, startBeat + length);
|
||||
|
||||
return final;
|
||||
}
|
||||
|
||||
public bool InThreshold(float beat)
|
||||
{
|
||||
//Check if the beat sent falls within beatThreshold
|
||||
//Written to handle the looping
|
||||
if (beat <= beatThreshold + 1)
|
||||
{
|
||||
//Debug.Log("Case 1, beat is close to 1");
|
||||
if (loopPositionInBeats > beat + beatThreshold)
|
||||
{
|
||||
if (loopPositionInBeats >= (beat + songPositionInBeats - 1) + beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just below loop point");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("LoopPos not within beat threshold");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("Case 1, loopPos between loop point and beat threshold");
|
||||
}
|
||||
}
|
||||
else if (beat < (songPositionInBeats + 1 - beatThreshold))
|
||||
{
|
||||
//Debug.Log("Case 2, beat is far from loop point.");
|
||||
if (loopPositionInBeats >= beat - beatThreshold && loopPositionInBeats <= beat + beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos within threshold");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (beat >= (songPositionInBeats + 1 - beatThreshold))
|
||||
{
|
||||
//Debug.Log("Case 3, beat is close to loop point");
|
||||
if (loopPositionInBeats < beat)
|
||||
{
|
||||
if (loopPositionInBeats >= beat - beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just below beat");
|
||||
return true;
|
||||
}
|
||||
else if (loopPositionInBeats < (beat - songPositionInBeats + 1) - beatThreshold)
|
||||
{
|
||||
//Debug.Log("LoopPos just above loop point");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("LoopPos just above beat");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Strange Case. Where is this beat? This should never happen");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Conductor.cs.meta
Normal file
11
Assets/Scripts/Conductor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 066f6ce2bdafdfb45a8df77dfb111c22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/ForkLifter.meta
Normal file
8
Assets/Scripts/ForkLifter.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 373ee08aa0fe85c4bab62e3c895bc952
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
38
Assets/Scripts/ForkLifter/ForkLifter.cs
Normal file
38
Assets/Scripts/ForkLifter/ForkLifter.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ForkLifter : MonoBehaviour
|
||||
{
|
||||
public static ForkLifter instance;
|
||||
|
||||
GameManager GameManager;
|
||||
|
||||
[Header("Objects")]
|
||||
public Animator handAnim;
|
||||
public GameObject flickedObject;
|
||||
public SpriteRenderer peaPreview;
|
||||
|
||||
public Sprite[] peaSprites;
|
||||
public Sprite[] peaHitSprites;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager = GameManager.instance;
|
||||
}
|
||||
|
||||
public void Flick(float beat, int type)
|
||||
{
|
||||
Jukebox.PlayOneShot("flick");
|
||||
handAnim.Play("Hand_Flick", 0, 0);
|
||||
GameObject fo = Instantiate(flickedObject);
|
||||
fo.GetComponent<Pea>().startBeat = beat;
|
||||
fo.GetComponent<Pea>().type = type;
|
||||
fo.SetActive(true);
|
||||
}
|
||||
}
|
11
Assets/Scripts/ForkLifter/ForkLifter.cs.meta
Normal file
11
Assets/Scripts/ForkLifter/ForkLifter.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b91bd072f874c8746bee1afaf6dac3b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
58
Assets/Scripts/ForkLifter/ForkLifterHand.cs
Normal file
58
Assets/Scripts/ForkLifter/ForkLifterHand.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ForkLifterHand : MonoBehaviour
|
||||
{
|
||||
public SpriteRenderer fastSprite;
|
||||
|
||||
public Sprite[] fastSprites;
|
||||
|
||||
List<GameManager.Event> allPlayerActions;
|
||||
|
||||
public static ForkLifterHand instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void CheckNextFlick()
|
||||
{
|
||||
allPlayerActions = GameManager.instance.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare");
|
||||
|
||||
if (GameManager.instance.currentEventPlayer < allPlayerActions.Count)
|
||||
{
|
||||
switch (allPlayerActions[GameManager.instance.currentEventPlayer].eventName)
|
||||
{
|
||||
case "pea":
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[0];
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
break;
|
||||
case "topbun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[1];
|
||||
break;
|
||||
case "burger":
|
||||
fastSprite.sprite = fastSprites[1];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[2];
|
||||
break;
|
||||
case "bottombun":
|
||||
fastSprite.sprite = fastSprites[0];
|
||||
ForkLifter.instance.peaPreview.sprite = ForkLifter.instance.peaSprites[3];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ForkLifter.instance.peaPreview.sprite = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Prepare()
|
||||
{
|
||||
Jukebox.PlayOneShot("flickPrepare");
|
||||
GetComponent<Animator>().Play("Hand_Prepare");
|
||||
}
|
||||
}
|
11
Assets/Scripts/ForkLifter/ForkLifterHand.cs.meta
Normal file
11
Assets/Scripts/ForkLifter/ForkLifterHand.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ca556e1a095c3a41b6f45fdee56dea4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
312
Assets/Scripts/ForkLifter/ForkLifterPlayer.cs
Normal file
312
Assets/Scripts/ForkLifter/ForkLifterPlayer.cs
Normal file
@ -0,0 +1,312 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using DG.Tweening;
|
||||
|
||||
public class ForkLifterPlayer : MonoBehaviour
|
||||
{
|
||||
[Header("Objects")]
|
||||
public GameObject fork;
|
||||
public Sprite peaSprite;
|
||||
public Sprite hitFX;
|
||||
public Sprite hitFXG;
|
||||
public Sprite hitFXMiss;
|
||||
public Sprite hitFX2;
|
||||
public Transform early, perfect, late;
|
||||
|
||||
[SerializeField]
|
||||
private BoxCollider2D col;
|
||||
|
||||
private Animator anim;
|
||||
|
||||
public List<Eligible> EligibleHits = new List<Eligible>();
|
||||
private int currentHitInList = 0;
|
||||
|
||||
public static ForkLifterPlayer instance { get; set; }
|
||||
|
||||
public float timescale = 1;
|
||||
|
||||
private int currentEarlyPeasOnFork;
|
||||
private int currentPerfectPeasOnFork;
|
||||
private int currentLatePeasOnFork;
|
||||
|
||||
private bool isEating = false;
|
||||
|
||||
// Burger shit
|
||||
|
||||
private bool topbun, middleburger, bottombun;
|
||||
|
||||
// -----------
|
||||
|
||||
[System.Serializable]
|
||||
public class Eligible
|
||||
{
|
||||
public Pea pea;
|
||||
public bool early;
|
||||
public bool perfect;
|
||||
public bool late;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Time.timeScale = timescale;
|
||||
|
||||
if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
Stab();
|
||||
}
|
||||
|
||||
if (EligibleHits.Count == 0)
|
||||
{
|
||||
currentHitInList = 0;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.A))
|
||||
{
|
||||
Conductor.instance.musicSource.time += 3;
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
Conductor.instance.musicSource.time -= 3;
|
||||
GameManager.instance.SetCurrentEventToClosest();
|
||||
}
|
||||
}
|
||||
|
||||
public void Eat()
|
||||
{
|
||||
if (currentEarlyPeasOnFork != 0 || currentPerfectPeasOnFork != 0 || currentLatePeasOnFork != 0)
|
||||
{
|
||||
anim.Play("Player_Eat", 0, 0);
|
||||
isEating = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void EatConfirm()
|
||||
{
|
||||
if (topbun && middleburger && bottombun)
|
||||
{
|
||||
Jukebox.PlayOneShot("burger");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentEarlyPeasOnFork > 0 || currentLatePeasOnFork > 0)
|
||||
{
|
||||
Jukebox.PlayOneShot($"cough_{Random.Range(1, 3)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("gulp");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < early.transform.childCount; i++)
|
||||
{
|
||||
Destroy(early.transform.GetChild(i).gameObject);
|
||||
}
|
||||
for (int i = 0; i < perfect.transform.childCount; i++)
|
||||
{
|
||||
Destroy(perfect.transform.GetChild(i).gameObject);
|
||||
}
|
||||
for (int i = 0; i < late.transform.childCount; i++)
|
||||
{
|
||||
Destroy(late.transform.GetChild(i).gameObject);
|
||||
}
|
||||
currentEarlyPeasOnFork = 0;
|
||||
currentPerfectPeasOnFork = 0;
|
||||
currentLatePeasOnFork = 0;
|
||||
|
||||
isEating = false;
|
||||
|
||||
topbun = false; middleburger = false; bottombun = false;
|
||||
}
|
||||
|
||||
public void Stab()
|
||||
{
|
||||
if (isEating) return;
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
|
||||
if (canHit)
|
||||
{
|
||||
GameObject pea = new GameObject();
|
||||
|
||||
if (EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
pea.transform.parent = perfect.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < perfect.transform.childCount; i++)
|
||||
{
|
||||
perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
switch (EligibleHits[currentHitInList].pea.type)
|
||||
{
|
||||
case 0:
|
||||
psprite.sortingOrder = 101;
|
||||
break;
|
||||
case 1:
|
||||
psprite.sortingOrder = 104;
|
||||
break;
|
||||
case 2:
|
||||
psprite.sortingOrder = 103;
|
||||
break;
|
||||
case 3:
|
||||
psprite.sortingOrder = 102;
|
||||
break;
|
||||
}
|
||||
|
||||
GameObject hitFXo = new GameObject();
|
||||
hitFXo.transform.localPosition = new Vector3(1.9969f, -3.7026f);
|
||||
hitFXo.transform.localScale = new Vector3(3.142196f, 3.142196f);
|
||||
SpriteRenderer hfxs = hitFXo.AddComponent<SpriteRenderer>();
|
||||
hfxs.sprite = hitFX;
|
||||
hfxs.sortingOrder = 100;
|
||||
hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); });
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("stab");
|
||||
|
||||
currentPerfectPeasOnFork++;
|
||||
|
||||
if (EligibleHits[currentHitInList].pea.type == 1)
|
||||
{
|
||||
topbun = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 2)
|
||||
{
|
||||
middleburger = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 3)
|
||||
{
|
||||
bottombun = true;
|
||||
}
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Hit();
|
||||
GameProfiler.instance.IncreaseScore();
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].early)
|
||||
{
|
||||
pea.transform.parent = early.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
pea.transform.localRotation = Quaternion.Euler(0, 0, 90);
|
||||
|
||||
for (int i = 0; i < early.transform.childCount; i++)
|
||||
{
|
||||
early.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentEarlyPeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
|
||||
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
|
||||
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
|
||||
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentEarlyPeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].late)
|
||||
{
|
||||
pea.transform.parent = late.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
pea.transform.localRotation = Quaternion.Euler(0, 0, 90);
|
||||
|
||||
for (int i = 0; i < late.transform.childCount; i++)
|
||||
{
|
||||
late.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentLatePeasOnFork);
|
||||
}
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
|
||||
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
|
||||
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
|
||||
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
|
||||
|
||||
FastEffectHit(EligibleHits[currentHitInList].pea.type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentLatePeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("stabnohit");
|
||||
}
|
||||
|
||||
anim.Play("Player_Stab", 0, 0);
|
||||
}
|
||||
|
||||
private void FastEffectHit(int type)
|
||||
{
|
||||
GameObject hitFX2o = new GameObject();
|
||||
hitFX2o.transform.localPosition = new Vector3(0.11f, -2.15f);
|
||||
hitFX2o.transform.localScale = new Vector3(5.401058f, 1.742697f);
|
||||
hitFX2o.transform.localRotation = Quaternion.Euler(0, 0, -38.402f);
|
||||
SpriteRenderer hfx2s = hitFX2o.AddComponent<SpriteRenderer>();
|
||||
if (type == 2)
|
||||
hfx2s.sprite = hitFXG;
|
||||
else
|
||||
hfx2s.sprite = hitFX2;
|
||||
hfx2s.sortingOrder = -5;
|
||||
hfx2s.DOColor(new Color(1, 1, 1, 0), 0.07f).OnComplete(delegate { Destroy(hitFX2o); });
|
||||
}
|
||||
|
||||
private void HitFXMiss(Vector2 pos, Vector2 size)
|
||||
{
|
||||
GameObject hitFXo = new GameObject();
|
||||
hitFXo.transform.localPosition = new Vector3(pos.x, pos.y);
|
||||
hitFXo.transform.localScale = new Vector3(size.x, size.y);
|
||||
SpriteRenderer hfxs = hitFXo.AddComponent<SpriteRenderer>();
|
||||
hfxs.sprite = hitFXMiss;
|
||||
hfxs.sortingOrder = 100;
|
||||
hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); });
|
||||
}
|
||||
|
||||
private void RemovePea()
|
||||
{
|
||||
if (currentHitInList < EligibleHits.Count)
|
||||
{
|
||||
Destroy(EligibleHits[currentHitInList].pea.gameObject);
|
||||
EligibleHits.Remove(EligibleHits[currentHitInList]);
|
||||
currentHitInList++;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/ForkLifter/ForkLifterPlayer.cs.meta
Normal file
11
Assets/Scripts/ForkLifter/ForkLifterPlayer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9c51533490c0324d82d217287adee49
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
112
Assets/Scripts/ForkLifter/Pea.cs
Normal file
112
Assets/Scripts/ForkLifter/Pea.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Pea : MonoBehaviour
|
||||
{
|
||||
[Header("Latency")]
|
||||
public float earlyTime;
|
||||
public float perfectTime;
|
||||
public float lateTime;
|
||||
public float endTime;
|
||||
|
||||
private Animator anim;
|
||||
|
||||
public float startBeat;
|
||||
|
||||
private bool inList = false;
|
||||
|
||||
public int type;
|
||||
|
||||
private ForkLifterPlayer.Eligible e = new ForkLifterPlayer.Eligible();
|
||||
|
||||
public int estate, pstate, lstate, endstate;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
Jukebox.PlayOneShot("zoom");
|
||||
GetComponentInChildren<SpriteRenderer>().sprite = ForkLifter.instance.peaSprites[type];
|
||||
|
||||
e = new ForkLifterPlayer.Eligible();
|
||||
e.pea = this;
|
||||
|
||||
for (int i = 0; i < transform.GetChild(0).childCount; i++)
|
||||
{
|
||||
transform.GetChild(0).GetChild(i).GetComponent<SpriteRenderer>().sprite = transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(startBeat, 2.5f));
|
||||
anim.Play("Flicked_Object", -1, normalizedBeat);
|
||||
anim.speed = 0;
|
||||
|
||||
// Early State
|
||||
if (normalizedBeat > earlyTime && normalizedBeat < perfectTime && estate <= 1)
|
||||
{
|
||||
estate++;
|
||||
MakeEligible(true, false, false);
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > perfectTime && normalizedBeat < lateTime && pstate <= 1)
|
||||
{
|
||||
pstate++;
|
||||
MakeEligible(false, true, false);
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > lateTime && normalizedBeat < endTime && lstate <= 1)
|
||||
{
|
||||
lstate++;
|
||||
MakeEligible(false, false, true);
|
||||
}
|
||||
else if (normalizedBeat < earlyTime || normalizedBeat > endTime)
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
|
||||
if (normalizedBeat > endTime && endstate <= 1)
|
||||
{
|
||||
endstate++;
|
||||
Jukebox.PlayOneShot("disappointed");
|
||||
GoForAPerfect.instance.Miss();
|
||||
}
|
||||
|
||||
if (normalizedBeat > 1.35f)
|
||||
{
|
||||
MakeInEligible();
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeEligible(bool early, bool perfect, bool late)
|
||||
{
|
||||
// print($"{early}, {perfect}, {late}");
|
||||
|
||||
if (!inList)
|
||||
{
|
||||
e.early = early;
|
||||
e.perfect = perfect;
|
||||
e.late = late;
|
||||
|
||||
ForkLifterPlayer.instance.EligibleHits.Add(e);
|
||||
inList = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ForkLifterPlayer.Eligible es = ForkLifterPlayer.instance.EligibleHits[ForkLifterPlayer.instance.EligibleHits.IndexOf(e)];
|
||||
es.early = early;
|
||||
es.perfect = perfect;
|
||||
es.late = late;
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeInEligible()
|
||||
{
|
||||
if (!inList) return;
|
||||
|
||||
ForkLifterPlayer.instance.EligibleHits.Remove(e);
|
||||
inList = false;
|
||||
}
|
||||
}
|
11
Assets/Scripts/ForkLifter/Pea.cs.meta
Normal file
11
Assets/Scripts/ForkLifter/Pea.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cdbd028573cd4841b9c1d04402b370f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
182
Assets/Scripts/GameManager.cs
Normal file
182
Assets/Scripts/GameManager.cs
Normal file
@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
using Starpelly;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager instance;
|
||||
|
||||
public List<Event> Events = new List<Event>();
|
||||
public List<float> AutoPlay = new List<float>();
|
||||
public List<Event> allPlayerActions = new List<Event>();
|
||||
|
||||
public int currentEvent, currentEventAutoplay, currentEventPlayer;
|
||||
|
||||
public TextAsset txt;
|
||||
|
||||
public bool autoplay = false;
|
||||
|
||||
public float startOffset;
|
||||
|
||||
[Serializable]
|
||||
public class Event : ICloneable
|
||||
{
|
||||
public float spawnTime;
|
||||
public string eventName;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SortEventsList();
|
||||
|
||||
string json = txt.text;
|
||||
Events = JsonConvert.DeserializeObject<List<Event>>(json);
|
||||
|
||||
SortEventsList();
|
||||
|
||||
allPlayerActions = Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end");
|
||||
AutoPlay = allPlayerActions.Select(c => c.spawnTime + 2).ToList();
|
||||
|
||||
/*List<Event> temp = new List<Event>();
|
||||
for (int i = 0; i < allPlayerActions.Count; i++)
|
||||
{
|
||||
if (i - 1 > 0)
|
||||
{
|
||||
if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime))
|
||||
{
|
||||
// do nothing lul
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Event e = (Event)allPlayerActions[i].Clone();
|
||||
e.spawnTime = allPlayerActions[i].spawnTime - 1;
|
||||
e.eventName = "prepare";
|
||||
|
||||
temp.Add(e);
|
||||
}
|
||||
|
||||
string s = JsonConvert.SerializeObject(temp);
|
||||
print(s);*/
|
||||
|
||||
StartCoroutine(Begin());
|
||||
|
||||
GlobalGameManager.Init();
|
||||
}
|
||||
|
||||
private IEnumerator Begin()
|
||||
{
|
||||
yield return new WaitForSeconds(startOffset);
|
||||
Conductor.instance.musicSource.Play();
|
||||
GoForAPerfect.instance.Enable();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Q))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 0);
|
||||
if (Input.GetKeyDown(KeyCode.W))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 1);
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 2);
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
ForkLifter.instance.Flick(Conductor.instance.songPositionInBeats, 3);
|
||||
|
||||
if (Events.Count < 1)
|
||||
return;
|
||||
|
||||
List<float> floats = Events.Select(c => c.spawnTime).ToList();
|
||||
|
||||
if (currentEvent < Events.Count && currentEvent >= 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= floats[currentEvent])
|
||||
{
|
||||
|
||||
switch (Events[currentEvent].eventName)
|
||||
{
|
||||
case "pea":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 0);
|
||||
break;
|
||||
case "topbun":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 1);
|
||||
break;
|
||||
case "burger":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 2);
|
||||
break;
|
||||
case "bottombun":
|
||||
currentEventPlayer++;
|
||||
ForkLifter.instance.Flick(Events[currentEvent].spawnTime, 3);
|
||||
break;
|
||||
case "gulp":
|
||||
ForkLifterPlayer.instance.Eat();
|
||||
break;
|
||||
case "sigh":
|
||||
Jukebox.PlayOneShot("sigh");
|
||||
break;
|
||||
case "prepare":
|
||||
ForkLifterHand.instance.Prepare();
|
||||
break;
|
||||
case "end":
|
||||
GlobalGameManager.LoadScene(2, 0.45f);
|
||||
break;
|
||||
|
||||
}
|
||||
currentEvent++;
|
||||
}
|
||||
}
|
||||
|
||||
if (autoplay)
|
||||
{
|
||||
if (currentEventAutoplay < AutoPlay.Count && currentEventAutoplay >= 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= AutoPlay[currentEventAutoplay])
|
||||
{
|
||||
ForkLifterPlayer.instance.Stab();
|
||||
currentEventAutoplay++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SortEventsList()
|
||||
{
|
||||
Events.Sort((x, y) => x.spawnTime.CompareTo(y.spawnTime));
|
||||
}
|
||||
|
||||
public void SetCurrentEventToClosest()
|
||||
{
|
||||
if (Events.Count > 0)
|
||||
{
|
||||
List<float> floats = Events.Select(c => c.spawnTime).ToList();
|
||||
currentEvent = floats.IndexOf(Mathp.GetClosestInList(floats, Conductor.instance.songPositionInBeats));
|
||||
}
|
||||
if (AutoPlay.Count > 0)
|
||||
{
|
||||
currentEvent = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats));
|
||||
currentEventPlayer = AutoPlay.IndexOf(Mathp.GetClosestInList(AutoPlay, Conductor.instance.songPositionInBeats));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
// GUI.Box(new Rect(0, 0, 300, 50), $"SongPosInBeats: {Conductor.instance.songPositionInBeats}");
|
||||
}
|
||||
}
|
11
Assets/Scripts/GameManager.cs.meta
Normal file
11
Assets/Scripts/GameManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd86589935fb46c4db0d3d23d52743a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
34
Assets/Scripts/GameProfiler.cs
Normal file
34
Assets/Scripts/GameProfiler.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameProfiler : MonoBehaviour
|
||||
{
|
||||
public float score = 0;
|
||||
public int totalHits = 0;
|
||||
|
||||
public bool perfect = false;
|
||||
|
||||
public static GameProfiler instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
perfect = true;
|
||||
}
|
||||
|
||||
public void IncreaseScore()
|
||||
{
|
||||
totalHits++;
|
||||
score = GetPercent(totalHits, GameManager.instance.allPlayerActions.Count);
|
||||
}
|
||||
|
||||
public float GetPercent(float value, float totalValue)
|
||||
{
|
||||
return (value / totalValue) * 100;
|
||||
}
|
||||
}
|
11
Assets/Scripts/GameProfiler.cs.meta
Normal file
11
Assets/Scripts/GameProfiler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33342192dd0c8b848bb026ad6e515b08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
92
Assets/Scripts/GlobalGameManager.cs
Normal file
92
Assets/Scripts/GlobalGameManager.cs
Normal file
@ -0,0 +1,92 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
public class GlobalGameManager : MonoBehaviour
|
||||
{
|
||||
public static GlobalGameManager instance { get; set; }
|
||||
|
||||
public static int loadedScene;
|
||||
public int lastLoadedScene;
|
||||
public static float fadeDuration;
|
||||
|
||||
public GameObject loadScenePrefab;
|
||||
public GameObject hourGlass;
|
||||
|
||||
public static string levelLocation;
|
||||
public static bool officialLevel;
|
||||
|
||||
public enum Scenes : int
|
||||
{
|
||||
SplashScreen = 0,
|
||||
Menu = 1,
|
||||
Editor = 2,
|
||||
Game = 3
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
public static void Init()
|
||||
{
|
||||
BasicCheck();
|
||||
|
||||
loadedScene = 0;
|
||||
fadeDuration = 0;
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
Init();
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
instance = this;
|
||||
Starpelly.OS.Windows.ChangeWindowTitle($"Rhythm Heaven Mania DEMO");
|
||||
}
|
||||
|
||||
public static GameObject CreateFade()
|
||||
{
|
||||
GameObject fade = new GameObject();
|
||||
DontDestroyOnLoad(fade);
|
||||
fade.transform.localScale = new Vector3(4000, 4000);
|
||||
SpriteRenderer sr = fade.AddComponent<SpriteRenderer>();
|
||||
sr.sprite = Resources.Load<Sprite>("Sprites/GeneralPurpose/Square");
|
||||
sr.sortingOrder = 20000;
|
||||
fade.layer = 5;
|
||||
return fade;
|
||||
}
|
||||
|
||||
|
||||
public static void BasicCheck()
|
||||
{
|
||||
if (FindGGM() == null)
|
||||
{
|
||||
GameObject GlobalGameManager = new GameObject("GlobalGameManager");
|
||||
GlobalGameManager.name = "GlobalGameManager";
|
||||
GlobalGameManager.AddComponent<GlobalGameManager>();
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindGGM()
|
||||
{
|
||||
if (GameObject.Find("GlobalGameManager") != null)
|
||||
return GameObject.Find("GlobalGameManager");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void LoadScene(int sceneIndex, float duration = 0.35f)
|
||||
{
|
||||
print("bruh");
|
||||
BasicCheck();
|
||||
loadedScene = sceneIndex;
|
||||
fadeDuration = duration;
|
||||
|
||||
// DOTween.Clear(true);
|
||||
// SceneManager.LoadScene(sceneIndex);
|
||||
|
||||
GameObject fade = CreateFade();
|
||||
fade.GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, 0);
|
||||
fade.GetComponent<SpriteRenderer>().DOColor(Color.black, fadeDuration).OnComplete(() => { SceneManager.LoadScene(loadedScene); fade.GetComponent<SpriteRenderer>().DOColor(new Color(0, 0, 0, 0), fadeDuration).OnComplete(() => { Destroy(fade); }); });
|
||||
}
|
||||
}
|
11
Assets/Scripts/GlobalGameManager.cs.meta
Normal file
11
Assets/Scripts/GlobalGameManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9e6bf5853df00845a49c00f2b31b054
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
78
Assets/Scripts/Invert.mat
Normal file
78
Assets/Scripts/Invert.mat
Normal file
@ -0,0 +1,78 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Invert
|
||||
m_Shader: {fileID: 4800000, guid: 186aee7e6d6053f4f8f0cca0ed3d25ac, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
8
Assets/Scripts/Invert.mat.meta
Normal file
8
Assets/Scripts/Invert.mat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fb136ac36a1e6e4aa95f4bb00b10a01
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
49
Assets/Scripts/Jukebox.cs
Normal file
49
Assets/Scripts/Jukebox.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Jukebox
|
||||
{
|
||||
public enum AudioType
|
||||
{
|
||||
OGG,
|
||||
WAV
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is me just idiot-proofing.
|
||||
/// </summary>
|
||||
public static void BasicCheck()
|
||||
{
|
||||
if (FindJukebox() == null)
|
||||
{
|
||||
GameObject Jukebox = new GameObject("Jukebox");
|
||||
Jukebox.AddComponent<AudioSource>();
|
||||
Jukebox.tag = "Jukebox";
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject FindJukebox()
|
||||
{
|
||||
if (GameObject.FindGameObjectWithTag("Jukebox") != null)
|
||||
return GameObject.FindGameObjectWithTag("Jukebox");
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SetVolume(float volume)
|
||||
{
|
||||
BasicCheck();
|
||||
FindJukebox().GetComponent<AudioSource>().volume = volume;
|
||||
}
|
||||
|
||||
public static void PlayOneShot(string name)
|
||||
{
|
||||
GameObject oneShot = new GameObject("oneShot");
|
||||
AudioSource aus = oneShot.AddComponent<AudioSource>();
|
||||
aus.playOnAwake = false;
|
||||
Sound snd = oneShot.AddComponent<Sound>();
|
||||
snd.clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
}
|
||||
}
|
11
Assets/Scripts/Jukebox.cs.meta
Normal file
11
Assets/Scripts/Jukebox.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 629209fbc93bc61419ccc4f63396a1bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Scripts/Sound.cs
Normal file
24
Assets/Scripts/Sound.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Sound : MonoBehaviour
|
||||
{
|
||||
public AudioClip clip;
|
||||
public float pitch;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
audioSource.PlayOneShot(clip);
|
||||
StartCoroutine(play());
|
||||
}
|
||||
|
||||
private IEnumerator play()
|
||||
{
|
||||
yield return new WaitForSeconds(clip.length);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Sound.cs.meta
Normal file
11
Assets/Scripts/Sound.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4491600ce62d8f648bd831f49934c90d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Transform.meta
Normal file
8
Assets/Scripts/Transform.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 764451b7ae71fc543bac6a366d11dbce
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Scripts/Transform/ForceRotationIdentity.cs
Normal file
9
Assets/Scripts/Transform/ForceRotationIdentity.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ForceRotationIdentity : MonoBehaviour
|
||||
{
|
||||
private void Update ()
|
||||
{
|
||||
transform.rotation = Quaternion.identity;
|
||||
}
|
||||
}
|
13
Assets/Scripts/Transform/ForceRotationIdentity.cs.meta
Normal file
13
Assets/Scripts/Transform/ForceRotationIdentity.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f613584f5ba8a27439601850428fea72
|
||||
timeCreated: 1522985111
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Scripts/Transform/ForceScaleIdentity.cs
Normal file
9
Assets/Scripts/Transform/ForceScaleIdentity.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ForceScaleIdentity : MonoBehaviour
|
||||
{
|
||||
void Update()
|
||||
{
|
||||
transform.localScale = new Vector3(1f / transform.parent.localScale.x, 1f / transform.parent.localScale.y);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Transform/ForceScaleIdentity.cs.meta
Normal file
11
Assets/Scripts/Transform/ForceScaleIdentity.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee82b1d7764597d42b0f53500bddf703
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
Assets/Scripts/Transform/LookAlongVelocity.cs
Normal file
23
Assets/Scripts/Transform/LookAlongVelocity.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class LookAlongVelocity : MonoBehaviour
|
||||
{
|
||||
public float minVelocity = 0.01f;
|
||||
public new Rigidbody2D rigidbody;
|
||||
|
||||
private void Update ()
|
||||
{
|
||||
if (rigidbody == null)
|
||||
return;
|
||||
|
||||
if (rigidbody.velocity.magnitude < minVelocity)
|
||||
return;
|
||||
|
||||
var rotation = transform.eulerAngles;
|
||||
|
||||
var angle = Vector2.SignedAngle (Vector2.up, rigidbody.velocity);
|
||||
rotation.z = angle;
|
||||
|
||||
transform.eulerAngles = rotation;
|
||||
}
|
||||
}
|
13
Assets/Scripts/Transform/LookAlongVelocity.cs.meta
Normal file
13
Assets/Scripts/Transform/LookAlongVelocity.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 141a2c65793e39943a8304c67905de70
|
||||
timeCreated: 1522985184
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Assets/Scripts/Transform/Rotate.cs
Normal file
11
Assets/Scripts/Transform/Rotate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Rotate : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float rotateSpeed;
|
||||
|
||||
void Update()
|
||||
{
|
||||
transform.Rotate(Vector3.forward * rotateSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Transform/Rotate.cs.meta
Normal file
11
Assets/Scripts/Transform/Rotate.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a761d8a407e1d9d49afaed94b793ed75
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Assets/Scripts/Transform/ScaleByVelocity.cs
Normal file
43
Assets/Scripts/Transform/ScaleByVelocity.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ScaleByVelocity : MonoBehaviour
|
||||
{
|
||||
public enum Axis { X, Y }
|
||||
|
||||
public float bias = 1f;
|
||||
public float strength = 1f;
|
||||
public Axis axis = Axis.Y;
|
||||
public float size;
|
||||
|
||||
public new Rigidbody2D rigidbody;
|
||||
|
||||
private Vector2 startScale;
|
||||
|
||||
private void Start ()
|
||||
{
|
||||
startScale = transform.localScale;
|
||||
}
|
||||
|
||||
private void Update ()
|
||||
{
|
||||
var velocity = rigidbody.velocity.magnitude;
|
||||
|
||||
/*if (Mathf.Approximately (velocity, 0f))
|
||||
return;*/
|
||||
|
||||
var amount = velocity * strength + bias;
|
||||
var inverseAmount = 1.0f;
|
||||
if (velocity > 0.4f)
|
||||
inverseAmount = (1f / amount) * startScale.magnitude;
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case Axis.X:
|
||||
transform.localScale = new Vector3 (amount - 0.414214f, inverseAmount, 1f);
|
||||
return;
|
||||
case Axis.Y:
|
||||
transform.localScale = new Vector3 (Mathf.Clamp(inverseAmount, 0.6f, 1f), amount, 1f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
13
Assets/Scripts/Transform/ScaleByVelocity.cs.meta
Normal file
13
Assets/Scripts/Transform/ScaleByVelocity.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5421f511c7f44364cb7a8b3c23a9cf19
|
||||
timeCreated: 1522985385
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/UI.meta
Normal file
8
Assets/Scripts/UI.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bbef7258e2d1844b9d52fc833b3e498
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
64
Assets/Scripts/UI/GoForAPerfect.cs
Normal file
64
Assets/Scripts/UI/GoForAPerfect.cs
Normal 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;
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/GoForAPerfect.cs.meta
Normal file
11
Assets/Scripts/UI/GoForAPerfect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e5c7679bb002f04980d7554b101f24b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
35
Assets/Scripts/UI/Prologue.cs
Normal file
35
Assets/Scripts/UI/Prologue.cs
Normal 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);
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/Prologue.cs.meta
Normal file
11
Assets/Scripts/UI/Prologue.cs.meta
Normal 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
139
Assets/Scripts/UI/Rating.cs
Normal 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);
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/Rating.cs.meta
Normal file
11
Assets/Scripts/UI/Rating.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c00b45746e9b68744b76eb77268a0c61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/WTF.cs
Normal file
18
Assets/Scripts/WTF.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WTF : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/WTF.cs.meta
Normal file
11
Assets/Scripts/WTF.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 490e729f742a40644a3a2abd88fce1a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user