mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 08:37:37 +02:00
Improved inputs (A SHIT MORE DYNAMIC BETWEEN GAMES) and a whole lot cleaner code in general
This commit is contained in:
@ -14,8 +14,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
[Header("References")]
|
||||
public ForkLifterHand ForkLifterHand;
|
||||
private GameManager GameManager;
|
||||
|
||||
|
||||
[Header("Objects")]
|
||||
public Animator handAnim;
|
||||
@ -25,9 +23,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
public Sprite[] peaSprites;
|
||||
public Sprite[] peaHitSprites;
|
||||
|
||||
|
||||
private List<Beatmap.Entity> allPlayerActions = new List<Beatmap.Entity>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
@ -38,33 +33,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
ForkLifterHand.CheckNextFlick();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager = GameManager.instance;
|
||||
// allPlayerActions = GameManager.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end");
|
||||
|
||||
/*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);*/
|
||||
}
|
||||
|
||||
public void Flick(float beat, int type)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("forkLifter/flick");
|
||||
|
@ -26,12 +26,8 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
private Animator anim;
|
||||
|
||||
public List<Eligible> EligibleHits = new List<Eligible>();
|
||||
private int currentHitInList = 0;
|
||||
|
||||
|
||||
public float timescale = 1;
|
||||
|
||||
private int currentEarlyPeasOnFork;
|
||||
private int currentPerfectPeasOnFork;
|
||||
private int currentLatePeasOnFork;
|
||||
@ -44,15 +40,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
// -----------
|
||||
|
||||
[System.Serializable]
|
||||
public class Eligible
|
||||
{
|
||||
public Pea pea;
|
||||
public bool early;
|
||||
public bool perfect;
|
||||
public bool late;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
@ -65,14 +52,12 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Time.timeScale = timescale;
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
Stab();
|
||||
}
|
||||
|
||||
if (EligibleHits.Count == 0)
|
||||
if (ForkLifter.instance.EligibleHits.Count == 0)
|
||||
{
|
||||
currentHitInList = 0;
|
||||
}
|
||||
@ -134,136 +119,142 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
public void Stab()
|
||||
{
|
||||
if (isEating) return;
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
var EligibleHits = ForkLifter.instance.EligibleHits;
|
||||
bool canHit = (ForkLifter.instance.EligibleHits.Count > 0) && (currentHitInList < ForkLifter.instance.EligibleHits.Count);
|
||||
|
||||
if (canHit)
|
||||
int events = ForkLifter.instance.MultipleEventsAtOnce();
|
||||
|
||||
for (int pt = 0; pt < events; pt++)
|
||||
{
|
||||
GameObject pea = new GameObject();
|
||||
|
||||
if (EligibleHits[currentHitInList].perfect)
|
||||
if (canHit)
|
||||
{
|
||||
pea.transform.parent = perfect.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
GameObject pea = new GameObject();
|
||||
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
|
||||
for (int i = 0; i < perfect.transform.childCount; i++)
|
||||
if (EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
perfect.transform.GetChild(i).transform.localPosition = new Vector3(0, (-1.67f - (0.15724f * i)) + 0.15724f * currentPerfectPeasOnFork);
|
||||
}
|
||||
pea.transform.parent = perfect.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
|
||||
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
|
||||
psprite.sortingOrder = 20;
|
||||
switch (EligibleHits[currentHitInList].pea.type)
|
||||
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].gameObject.GetComponent<Pea>().type];
|
||||
psprite.sortingOrder = 20;
|
||||
switch (EligibleHits[currentHitInList].gameObject.GetComponent<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(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type);
|
||||
|
||||
Jukebox.PlayOneShotGame("forkLifter/stab");
|
||||
|
||||
currentPerfectPeasOnFork++;
|
||||
|
||||
if (EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type == 1)
|
||||
{
|
||||
topbun = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type == 2)
|
||||
{
|
||||
middleburger = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type == 3)
|
||||
{
|
||||
bottombun = true;
|
||||
}
|
||||
|
||||
RemovePea();
|
||||
|
||||
GameProfiler.instance.IncreaseScore();
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].early)
|
||||
{
|
||||
case 0:
|
||||
psprite.sortingOrder = 101;
|
||||
break;
|
||||
case 1:
|
||||
psprite.sortingOrder = 104;
|
||||
break;
|
||||
case 2:
|
||||
psprite.sortingOrder = 103;
|
||||
break;
|
||||
case 3:
|
||||
psprite.sortingOrder = 102;
|
||||
break;
|
||||
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].gameObject.GetComponent<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(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentEarlyPeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
}
|
||||
|
||||
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.PlayOneShotGame("forkLifter/stab");
|
||||
|
||||
currentPerfectPeasOnFork++;
|
||||
|
||||
if (EligibleHits[currentHitInList].pea.type == 1)
|
||||
else if (EligibleHits[currentHitInList].late)
|
||||
{
|
||||
topbun = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 2)
|
||||
{
|
||||
middleburger = true;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].pea.type == 3)
|
||||
{
|
||||
bottombun = true;
|
||||
}
|
||||
pea.transform.parent = late.transform;
|
||||
pea.transform.localScale = Vector2.one;
|
||||
|
||||
RemovePea();
|
||||
pea.transform.localPosition = Vector3.zero;
|
||||
pea.transform.localRotation = Quaternion.Euler(0, 0, 90);
|
||||
|
||||
GameProfiler.instance.IncreaseScore();
|
||||
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].gameObject.GetComponent<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(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
|
||||
currentLatePeasOnFork++;
|
||||
|
||||
RemovePea();
|
||||
}
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].early)
|
||||
else
|
||||
{
|
||||
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();
|
||||
Jukebox.PlayOneShotGame("forkLifter/stabnohit");
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("forkLifter/stabnohit");
|
||||
}
|
||||
|
||||
anim.Play("Player_Stab", 0, 0);
|
||||
@ -297,12 +288,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
private void RemovePea()
|
||||
{
|
||||
if (currentHitInList < EligibleHits.Count)
|
||||
{
|
||||
Destroy(EligibleHits[currentHitInList].pea.gameObject);
|
||||
EligibleHits.Remove(EligibleHits[currentHitInList]);
|
||||
currentHitInList++;
|
||||
}
|
||||
ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().RemoveObject(currentHitInList, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,34 +6,28 @@ using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.ForkLifter
|
||||
{
|
||||
public class Pea : MonoBehaviour
|
||||
public class Pea : PlayerActionObject
|
||||
{
|
||||
|
||||
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.PlayOneShotGame("forkLifter/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;
|
||||
}
|
||||
|
||||
PlayerActionInit(this.gameObject, startBeat, ForkLifter.instance.EligibleHits);
|
||||
|
||||
isEligible = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -44,70 +38,13 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2f);
|
||||
|
||||
// Early State
|
||||
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && estate <= 1)
|
||||
{
|
||||
MakeEligible(true, false, false);
|
||||
estate++;
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && pstate <= 1)
|
||||
{
|
||||
MakeEligible(false, true, false);
|
||||
pstate++;
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lstate <= 1)
|
||||
{
|
||||
MakeEligible(false, false, true);
|
||||
lstate++;
|
||||
}
|
||||
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
|
||||
if (normalizedBeat > Minigame.EndTime() && endstate <= 1)
|
||||
{
|
||||
endstate++;
|
||||
Jukebox.PlayOneShot("audience/disappointed");
|
||||
}
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if (normalizedBeat > 1.35f)
|
||||
{
|
||||
MakeInEligible();
|
||||
Jukebox.PlayOneShot("audience/disappointed");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -70,104 +70,107 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
|
||||
private void Swing()
|
||||
{
|
||||
// you cant hit two pots at a time like this so i should fix this before a public build is eventually made.
|
||||
|
||||
var EligibleHits = KarateMan.instance.EligibleHits;
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
|
||||
bool punchLeft = true;
|
||||
|
||||
if (canHit)
|
||||
int events = KarateMan.instance.MultipleEventsAtOnce();
|
||||
|
||||
for (int pt = 0; pt < events; pt++)
|
||||
{
|
||||
Pot p = EligibleHits[currentHitInList].gameObject.GetComponent<Pot>();
|
||||
|
||||
if (p.type == 2 || p.type == 3 || p.type == 4)
|
||||
if (canHit)
|
||||
{
|
||||
punchLeft = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
punchLeft = true;
|
||||
}
|
||||
Pot p = EligibleHits[currentHitInList].gameObject.GetComponent<Pot>();
|
||||
|
||||
if (KarateMan.instance.EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
Jukebox.PlayOneShotGame(p.hitSnd);
|
||||
p.Hit();
|
||||
|
||||
HitEffectF(HitEffect.transform.localPosition);
|
||||
|
||||
switch (p.type)
|
||||
if (p.type == 2 || p.type == 3 || p.type == 4)
|
||||
{
|
||||
case 0:
|
||||
// HitParticle.Play();
|
||||
break;
|
||||
case 1:
|
||||
GameObject bulbHit = Instantiate(BulbHit);
|
||||
bulbHit.transform.parent = BulbHit.transform.parent;
|
||||
bulbHit.SetActive(true);
|
||||
Destroy(bulbHit, 0.7f);
|
||||
break;
|
||||
case 2:
|
||||
// RockParticle.Play();
|
||||
break;
|
||||
case 4:
|
||||
if (kickC != null) StopCoroutine(kickC);
|
||||
kickC = StartCoroutine(PrepareKick());
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
GameObject be = new GameObject();
|
||||
be.transform.localPosition = p.transform.localPosition;
|
||||
be.transform.parent = this.transform.parent;
|
||||
BarrelDestroyEffect bde = be.AddComponent<BarrelDestroyEffect>();
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
bde.spriteIndex = 0;
|
||||
break;
|
||||
case 1:
|
||||
bde.spriteIndex = 0;
|
||||
break;
|
||||
case 2:
|
||||
bde.spriteIndex = 1;
|
||||
break;
|
||||
case 3:
|
||||
bde.spriteIndex = 2;
|
||||
break;
|
||||
case 4:
|
||||
bde.spriteIndex = 3;
|
||||
break;
|
||||
case 5:
|
||||
bde.spriteIndex = 3;
|
||||
break;
|
||||
case 6:
|
||||
bde.spriteIndex = 4;
|
||||
break;
|
||||
case 7:
|
||||
bde.spriteIndex = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
punchLeft = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
punchLeft = true;
|
||||
}
|
||||
|
||||
if (KarateMan.instance.EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
Jukebox.PlayOneShotGame(p.hitSnd);
|
||||
p.Hit();
|
||||
|
||||
HitEffectF(HitEffect.transform.localPosition);
|
||||
|
||||
switch (p.type)
|
||||
{
|
||||
case 0:
|
||||
// HitParticle.Play();
|
||||
break;
|
||||
case 1:
|
||||
GameObject bulbHit = Instantiate(BulbHit);
|
||||
bulbHit.transform.parent = BulbHit.transform.parent;
|
||||
bulbHit.SetActive(true);
|
||||
Destroy(bulbHit, 0.7f);
|
||||
break;
|
||||
case 2:
|
||||
// RockParticle.Play();
|
||||
break;
|
||||
case 4:
|
||||
if (kickC != null) StopCoroutine(kickC);
|
||||
kickC = StartCoroutine(PrepareKick());
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
GameObject be = new GameObject();
|
||||
be.transform.localPosition = p.transform.localPosition;
|
||||
be.transform.parent = this.transform.parent;
|
||||
BarrelDestroyEffect bde = be.AddComponent<BarrelDestroyEffect>();
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
bde.spriteIndex = 0;
|
||||
break;
|
||||
case 1:
|
||||
bde.spriteIndex = 0;
|
||||
break;
|
||||
case 2:
|
||||
bde.spriteIndex = 1;
|
||||
break;
|
||||
case 3:
|
||||
bde.spriteIndex = 2;
|
||||
break;
|
||||
case 4:
|
||||
bde.spriteIndex = 3;
|
||||
break;
|
||||
case 5:
|
||||
bde.spriteIndex = 3;
|
||||
break;
|
||||
case 6:
|
||||
bde.spriteIndex = 4;
|
||||
break;
|
||||
case 7:
|
||||
bde.spriteIndex = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("miss");
|
||||
p.Miss();
|
||||
}
|
||||
p.isEligible = false;
|
||||
p.RemoveObject(currentHitInList);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("miss");
|
||||
p.Miss();
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
||||
}
|
||||
p.isEligible = false;
|
||||
p.RemoveObject(currentHitInList, EligibleHits);
|
||||
if (punchLeft)
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
else
|
||||
anim.Play("PunchRight", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("karateman/swingNoHit");
|
||||
}
|
||||
if (punchLeft)
|
||||
anim.Play("PunchLeft", 0, 0);
|
||||
else
|
||||
anim.Play("PunchRight", 0, 0);
|
||||
}
|
||||
|
||||
public void HitEffectF(Vector3 pos)
|
||||
|
@ -38,7 +38,6 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PlayerActionInit(this.gameObject);
|
||||
anim = GetComponent<Animator>();
|
||||
|
||||
Sprite.transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360));
|
||||
@ -48,6 +47,8 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
hitLength = 23.45f;
|
||||
else
|
||||
hitLength = 16f;
|
||||
|
||||
PlayerActionInit(this.gameObject, createBeat, KarateMan.instance.EligibleHits);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -65,7 +66,7 @@ namespace RhythmHeavenMania.Games.KarateMan
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 1);
|
||||
|
||||
StateCheck(normalizedBeat, KarateMan.instance.EligibleHits);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
lastPos = Holder.transform.localPosition;
|
||||
lastShadowX = Shadow.transform.localPosition.x;
|
||||
|
@ -16,6 +16,7 @@ namespace RhythmHeavenMania.Games
|
||||
public bool early;
|
||||
public bool perfect;
|
||||
public bool late;
|
||||
public float createBeat;
|
||||
}
|
||||
|
||||
// hopefully these will fix the lowbpm problem
|
||||
@ -50,5 +51,23 @@ namespace RhythmHeavenMania.Games
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int MultipleEventsAtOnce()
|
||||
{
|
||||
int sameTime = 0;
|
||||
for (int i = 0; i < EligibleHits.Count; i++)
|
||||
{
|
||||
float createBeat = EligibleHits[i].createBeat;
|
||||
if (EligibleHits.FindAll(c => c.createBeat == createBeat).Count > 0)
|
||||
{
|
||||
sameTime += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sameTime == 0 && EligibleHits.Count > 0)
|
||||
sameTime = 1;
|
||||
|
||||
return sameTime;
|
||||
}
|
||||
}
|
||||
}
|
@ -11,39 +11,43 @@ namespace RhythmHeavenMania.Games
|
||||
public Minigame.Eligible state = new Minigame.Eligible();
|
||||
public bool isEligible;
|
||||
|
||||
public void PlayerActionInit(GameObject g)
|
||||
public List<Minigame.Eligible> eligibleHitsList = new List<Minigame.Eligible>();
|
||||
|
||||
public void PlayerActionInit(GameObject g, float createBeat, List<Minigame.Eligible> eligibleHitsList)
|
||||
{
|
||||
state.gameObject = g;
|
||||
state.createBeat = createBeat;
|
||||
this.eligibleHitsList = eligibleHitsList;
|
||||
}
|
||||
|
||||
// could possibly add support for custom early, perfect, and end times if needed.
|
||||
public void StateCheck(float normalizedBeat, List<Minigame.Eligible> eligibleHitsList)
|
||||
public void StateCheck(float normalizedBeat)
|
||||
{
|
||||
if (!isEligible) return;
|
||||
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
|
||||
{
|
||||
MakeEligible(true, false, false, eligibleHitsList);
|
||||
MakeEligible(true, false, false);
|
||||
lastState++;
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1)
|
||||
{
|
||||
MakeEligible(false, true, false, eligibleHitsList);
|
||||
MakeEligible(false, true, false);
|
||||
lastState++;
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2)
|
||||
{
|
||||
MakeEligible(false, false, true, eligibleHitsList);
|
||||
MakeEligible(false, false, true);
|
||||
lastState++;
|
||||
}
|
||||
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
||||
{
|
||||
MakeInEligible(eligibleHitsList);
|
||||
MakeInEligible();
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeEligible(bool early, bool perfect, bool late, List<Minigame.Eligible> eligibleHitsList)
|
||||
public void MakeEligible(bool early, bool perfect, bool late)
|
||||
{
|
||||
if (!inList)
|
||||
{
|
||||
@ -63,7 +67,7 @@ namespace RhythmHeavenMania.Games
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeInEligible(List<Minigame.Eligible> eligibleHitsList)
|
||||
public void MakeInEligible()
|
||||
{
|
||||
if (!inList) return;
|
||||
|
||||
@ -71,12 +75,13 @@ namespace RhythmHeavenMania.Games
|
||||
inList = false;
|
||||
}
|
||||
|
||||
public void RemoveObject(int currentHitInList, List<Minigame.Eligible> EligibleHits)
|
||||
public void RemoveObject(int currentHitInList, bool destroyObject = false)
|
||||
{
|
||||
if (currentHitInList < EligibleHits.Count)
|
||||
if (currentHitInList < eligibleHitsList.Count)
|
||||
{
|
||||
EligibleHits.Remove(EligibleHits[currentHitInList]);
|
||||
eligibleHitsList.Remove(eligibleHitsList[currentHitInList]);
|
||||
currentHitInList++;
|
||||
if (destroyObject) Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,5 +117,10 @@ namespace RhythmHeavenMania.Games
|
||||
state.perfect = perfect;
|
||||
state.late = late;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
}
|
||||
}
|
@ -34,9 +34,9 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||
for (int i = 1; i < BallsHolder.transform.childCount; i++)
|
||||
Destroy(BallsHolder.transform.GetChild(i).gameObject);
|
||||
GameManager.instance.GameCamera.orthographic = false;
|
||||
if (SpaceballPlayer.instance != null)
|
||||
if (SpaceballPlayer.instance.EligibleHits.Count > 0)
|
||||
SpaceballPlayer.instance.EligibleHits.RemoveRange(0, SpaceballPlayer.instance.EligibleHits.Count);
|
||||
|
||||
if (EligibleHits.Count > 0)
|
||||
EligibleHits.RemoveRange(0, EligibleHits.Count);
|
||||
}
|
||||
|
||||
public override void OnTimeChange()
|
||||
|
@ -8,12 +8,10 @@ using DG.Tweening;
|
||||
|
||||
namespace RhythmHeavenMania.Games.Spaceball
|
||||
{
|
||||
public class SpaceballBall : MonoBehaviour
|
||||
public class SpaceballBall : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
private Animator anim;
|
||||
private int lastState;
|
||||
private bool inList = false;
|
||||
public Animator anim;
|
||||
|
||||
public bool high;
|
||||
|
||||
@ -22,6 +20,12 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||
public GameObject Holder;
|
||||
public SpriteRenderer Sprite;
|
||||
|
||||
public bool hit;
|
||||
public float hitBeat;
|
||||
public Vector3 hitPos;
|
||||
public float hitRot;
|
||||
public float randomEndPosX;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
@ -30,120 +34,56 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||
|
||||
float rot = Random.Range(0, 360);
|
||||
Sprite.gameObject.transform.eulerAngles = new Vector3(0, 0, rot);
|
||||
|
||||
|
||||
PlayerActionInit(this.gameObject, startBeat, Spaceball.instance.EligibleHits);
|
||||
|
||||
isEligible = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float beatLength = 1f;
|
||||
if (high) beatLength = 2f;
|
||||
|
||||
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength + 0.15f);
|
||||
// print(normalizedBeatAnim + " " + Time.frameCount);
|
||||
|
||||
if (high)
|
||||
if (hit)
|
||||
{
|
||||
anim.Play("BallHigh", 0, normalizedBeatAnim);
|
||||
float nba = Conductor.instance.GetLoopPositionFromBeat(hitBeat, 14);
|
||||
Holder.transform.localPosition = Vector3.Lerp(hitPos, new Vector3(randomEndPosX, 0f, -600f), nba);
|
||||
Holder.transform.eulerAngles = Vector3.Lerp(new Vector3(0, 0, hitRot), new Vector3(0, 0, -2260), nba);
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.Play("BallLow", 0, normalizedBeatAnim);
|
||||
}
|
||||
float beatLength = 1f;
|
||||
if (high) beatLength = 2f;
|
||||
|
||||
anim.speed = 0;
|
||||
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength + 0.15f);
|
||||
// print(normalizedBeatAnim + " " + Time.frameCount);
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength);
|
||||
|
||||
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
|
||||
{
|
||||
MakeEligible(true, false, false);
|
||||
lastState++;
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1)
|
||||
{
|
||||
MakeEligible(false, true, false);
|
||||
lastState++;
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2)
|
||||
{
|
||||
MakeEligible(false, false, true);
|
||||
lastState++;
|
||||
}
|
||||
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
|
||||
// too lazy to make a proper fix for this
|
||||
float endTime = 1.2f;
|
||||
if (high) endTime = 1.1f;
|
||||
|
||||
if (normalizedBeat > endTime)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("spaceball/fall");
|
||||
Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (e.perfect)
|
||||
if (high)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("spaceball/hit");
|
||||
Holder.transform.DOLocalMove(new Vector3(Random.Range(5, 18), 0, -600), 4f).SetEase(Ease.Linear);
|
||||
Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -245;
|
||||
|
||||
this.enabled = false;
|
||||
gameObject.GetComponent<Animator>().enabled = false;
|
||||
anim.Play("BallHigh", 0, normalizedBeatAnim);
|
||||
}
|
||||
else if (e.late || e.early)
|
||||
else
|
||||
{
|
||||
Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -55;
|
||||
anim.Play("BallLow", 0, normalizedBeatAnim);
|
||||
}
|
||||
|
||||
this.enabled = false;
|
||||
gameObject.GetComponent<Animator>().enabled = false;
|
||||
anim.speed = 0;
|
||||
|
||||
Rigidbody2D rb = gameObject.AddComponent<Rigidbody2D>();
|
||||
rb.bodyType = RigidbodyType2D.Dynamic;
|
||||
rb.AddForce(transform.up * 1100);
|
||||
rb.AddForce(transform.right * 400);
|
||||
rb.gravityScale = 9;
|
||||
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength);
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
// too lazy to make a proper fix for this
|
||||
float endTime = 1.2f;
|
||||
if (high) endTime = 1.1f;
|
||||
|
||||
if (normalizedBeat > endTime)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("spaceball/fall");
|
||||
Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true);
|
||||
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;
|
||||
|
||||
SpaceballPlayer.instance.EligibleHits.Add(e);
|
||||
inList = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Minigame.Eligible es = SpaceballPlayer.instance.EligibleHits[SpaceballPlayer.instance.EligibleHits.IndexOf(e)];
|
||||
es.early = early;
|
||||
es.perfect = perfect;
|
||||
es.late = late;
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeInEligible()
|
||||
{
|
||||
if (!inList) return;
|
||||
|
||||
SpaceballPlayer.instance.EligibleHits.Remove(e);
|
||||
inList = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -11,8 +11,7 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||
{
|
||||
private Animator anim;
|
||||
|
||||
public List<Minigame.Eligible> EligibleHits = new List<Minigame.Eligible>();
|
||||
[SerializeField] private int currentHitInList = 0;
|
||||
private int currentHitInList = 0;
|
||||
|
||||
public int costume;
|
||||
|
||||
@ -39,7 +38,7 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (EligibleHits.Count == 0)
|
||||
if (Spaceball.instance.EligibleHits.Count == 0)
|
||||
currentHitInList = 0;
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
@ -56,9 +55,52 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||
|
||||
public void Swing()
|
||||
{
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
var EligibleHits = Spaceball.instance.EligibleHits;
|
||||
bool canHit = (Spaceball.instance.EligibleHits.Count > 0) && (currentHitInList < Spaceball.instance.EligibleHits.Count);
|
||||
|
||||
Jukebox.PlayOneShotGame("spaceball/swing");
|
||||
int events = Spaceball.instance.MultipleEventsAtOnce();
|
||||
|
||||
for (int eventI = 0; eventI < events; eventI++)
|
||||
{
|
||||
if (canHit)
|
||||
{
|
||||
SpaceballBall ball = EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>();
|
||||
|
||||
if (EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
ball.hit = true;
|
||||
ball.hitBeat = Conductor.instance.songPositionInBeats;
|
||||
ball.hitPos = ball.Holder.transform.localPosition;
|
||||
ball.hitRot = ball.Holder.transform.eulerAngles.z;
|
||||
|
||||
Jukebox.PlayOneShotGame("spaceball/hit");
|
||||
|
||||
ball.randomEndPosX = Random.Range(40f, 55f);
|
||||
|
||||
ball.anim.enabled = false;
|
||||
}
|
||||
else if (EligibleHits[currentHitInList].late || EligibleHits[currentHitInList].early)
|
||||
{
|
||||
ball.Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -55;
|
||||
|
||||
ball.enabled = false;
|
||||
ball.anim.enabled = false;
|
||||
|
||||
Rigidbody2D rb = ball.gameObject.AddComponent<Rigidbody2D>();
|
||||
rb.bodyType = RigidbodyType2D.Dynamic;
|
||||
rb.AddForce(transform.up * 1100);
|
||||
rb.AddForce(transform.right * 400);
|
||||
rb.gravityScale = 9;
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
}
|
||||
|
||||
ball.RemoveObject(currentHitInList);
|
||||
}
|
||||
}
|
||||
|
||||
if (!canHit)
|
||||
Jukebox.PlayOneShotGame("spaceball/swing", false);
|
||||
|
||||
anim.Play("Swing", 0, 0);
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
tempoLayer.GetComponent<Image>().color = theme.properties.TempoLayerCol.Hex2RGB();
|
||||
musicLayer.GetComponent<Image>().color = theme.properties.MusicLayerCol.Hex2RGB();
|
||||
Tooltip.instance.AddTooltip(tempoLayer.gameObject, $"Tempo Track");
|
||||
Tooltip.instance.AddTooltip(musicLayer.gameObject, $"Music Volume Track");
|
||||
|
||||
|
||||
layer.gameObject.SetActive(false);
|
||||
|
||||
@ -36,7 +39,7 @@ namespace RhythmHeavenMania.Editor
|
||||
{
|
||||
GameObject layer = Instantiate(this.layer.gameObject, this.layer.transform.parent);
|
||||
layer.SetActive(true);
|
||||
layer.transform.GetChild(0).GetComponent<TMP_Text>().text = $"Layer {i + 1}";
|
||||
layer.transform.GetChild(0).GetComponent<TMP_Text>().text = $"Track {i + 1}";
|
||||
|
||||
Color c = Color.white;
|
||||
|
||||
@ -57,6 +60,7 @@ namespace RhythmHeavenMania.Editor
|
||||
}
|
||||
|
||||
layer.GetComponent<Image>().color = c;
|
||||
Tooltip.instance.AddTooltip(layer, $"Track {i + 1}");
|
||||
}
|
||||
Destroy(layer);
|
||||
}
|
||||
|
@ -130,7 +130,6 @@ namespace RhythmHeavenMania.Editor
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && CheckIfMouseInTimeline())
|
||||
{
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
|
||||
@ -244,27 +243,33 @@ namespace RhythmHeavenMania.Editor
|
||||
if (playEnabled)
|
||||
{
|
||||
PlayBTN.transform.GetChild(0).GetComponent<Image>().color = Color.green;
|
||||
PlayBTN.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
PlayBTN.enabled = false;
|
||||
}
|
||||
|
||||
if (pauseEnabled)
|
||||
{
|
||||
PauseBTN.enabled = true;
|
||||
PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.blue;
|
||||
}
|
||||
else
|
||||
{ PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
PauseBTN.enabled = false;
|
||||
}
|
||||
|
||||
if (stopEnabled)
|
||||
{
|
||||
StopBTN.enabled = true;
|
||||
StopBTN.transform.GetChild(0).GetComponent<Image>().color = Color.red;
|
||||
}
|
||||
else
|
||||
{
|
||||
StopBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
|
||||
StopBTN.enabled = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -40,21 +40,22 @@ namespace RhythmHeavenMania.Util
|
||||
FindJukebox().GetComponent<AudioSource>().volume = volume;
|
||||
}
|
||||
|
||||
public static void PlayOneShot(string name)
|
||||
public static void PlayOneShot(string name, bool relyOnBeat = true)
|
||||
{
|
||||
GameObject oneShot = new GameObject("oneShot");
|
||||
AudioSource aus = oneShot.AddComponent<AudioSource>();
|
||||
aus.playOnAwake = false;
|
||||
Sound snd = oneShot.AddComponent<Sound>();
|
||||
snd.relyOnBeat = relyOnBeat;
|
||||
AudioClip clip = Resources.Load<AudioClip>($"Sfx/{name}");
|
||||
snd.clip = clip;
|
||||
// snd.pitch = (clip.length / Conductor.instance.secPerBeat);
|
||||
}
|
||||
|
||||
public static void PlayOneShotGame(string name)
|
||||
public static void PlayOneShotGame(string name, bool relyOnBeat = true)
|
||||
{
|
||||
if (GameManager.instance.currentGame == name.Split('/')[0])
|
||||
PlayOneShot($"games/{name}");
|
||||
PlayOneShot($"games/{name}", relyOnBeat);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@ namespace RhythmHeavenMania.Util
|
||||
|
||||
private float startTime;
|
||||
|
||||
public bool relyOnBeat = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
@ -23,32 +25,45 @@ namespace RhythmHeavenMania.Util
|
||||
audioSource.PlayScheduled(Time.time);
|
||||
|
||||
startTime = Conductor.instance.songPosition;
|
||||
|
||||
if (!relyOnBeat)
|
||||
{
|
||||
StartCoroutine(NotRelyOnBeatSound());
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Conductor.instance.isPaused && !Conductor.instance.isPlaying && pauseTimes == 0)
|
||||
if (relyOnBeat)
|
||||
{
|
||||
audioSource.Pause();
|
||||
pauseTimes = 1;
|
||||
print("paused");
|
||||
}
|
||||
else if (Conductor.instance.isPlaying && !Conductor.instance.isPaused && pauseTimes == 1)
|
||||
{
|
||||
audioSource.Play();
|
||||
print("played");
|
||||
pauseTimes = 0;
|
||||
}
|
||||
if (Conductor.instance.isPaused && !Conductor.instance.isPlaying && pauseTimes == 0)
|
||||
{
|
||||
audioSource.Pause();
|
||||
pauseTimes = 1;
|
||||
print("paused");
|
||||
}
|
||||
else if (Conductor.instance.isPlaying && !Conductor.instance.isPaused && pauseTimes == 1)
|
||||
{
|
||||
audioSource.Play();
|
||||
print("played");
|
||||
pauseTimes = 0;
|
||||
}
|
||||
|
||||
else if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
else if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
if (Conductor.instance.songPosition > startTime + clip.length)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.songPosition > startTime + clip.length)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
IEnumerator NotRelyOnBeatSound()
|
||||
{
|
||||
yield return new WaitForSeconds(clip.length);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user