mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 15:17:36 +02:00
Merge pull request #42 from CarsonKompon/mr-upbeat-2
Fully functional and animated Mr. Upbeat
This commit is contained in:
@ -13,11 +13,11 @@ namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
[Header("References")]
|
||||
public GameObject metronome;
|
||||
public UpbeatMan man;
|
||||
public GameObject bt;
|
||||
|
||||
public GameEvent beat = new GameEvent();
|
||||
public GameEvent offbeat = new GameEvent();
|
||||
public bool canGo = false;
|
||||
private int beatCount = 0;
|
||||
public int beatCount = 0;
|
||||
|
||||
public static MrUpbeat instance;
|
||||
|
||||
@ -26,15 +26,19 @@ namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
canGo = false;
|
||||
man.stepTimes = 0;
|
||||
SetInterval(0);
|
||||
var pos = Conductor.instance.songPositionInBeats;
|
||||
StartCoroutine(Upbeat(pos - Mathf.Round(pos)));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (canGo)
|
||||
metronome.transform.eulerAngles = new Vector3(0, 0, 270 - Mathf.Cos(Mathf.PI * Conductor.instance.songPositionInBeats) * 75);
|
||||
//else
|
||||
// metronome.transform.eulerAngles = new Vector3(0, 0, 200);
|
||||
|
||||
List<Beatmap.Entity> gos = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "mrUpbeat/go");
|
||||
for(int i=0; i<gos.Count; i++)
|
||||
for (int i = 0; i < gos.Count; i++)
|
||||
{
|
||||
if ((gos[i].beat - 0.15f) <= Conductor.instance.songPositionInBeats && (gos[i].beat + gos[i].length) - 0.15f > Conductor.instance.songPositionInBeats)
|
||||
{
|
||||
@ -46,35 +50,29 @@ namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat) && canGo)
|
||||
if (canGo)
|
||||
{
|
||||
if(beatCount % 2 == 0)
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight");
|
||||
else
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft");
|
||||
|
||||
beatCount++;
|
||||
metronome.transform.eulerAngles = new Vector3(0, 0, 270 - Mathf.Cos(Mathf.PI * Conductor.instance.songPositionInBeats) * 75);
|
||||
}
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref offbeat.lastReportedBeat, 0.25f, true))
|
||||
if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat))
|
||||
{
|
||||
man.Blip();
|
||||
if(canGo) man.targetBeat = offbeat.lastReportedBeat + 1f;
|
||||
}
|
||||
}
|
||||
StartCoroutine(Upbeat());
|
||||
if (canGo)
|
||||
{
|
||||
if (beatCount % 2 == 0)
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight");
|
||||
else
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft");
|
||||
|
||||
public override void OnGameSwitch()
|
||||
{
|
||||
base.OnGameSwitch();
|
||||
canGo = false;
|
||||
man.stepTimes = 0;
|
||||
SetInterval(0);
|
||||
Beat(Mathf.Round(Conductor.instance.songPositionInBeats));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInterval(float beat)
|
||||
{
|
||||
beatCount = 0;
|
||||
offbeat.startBeat = beat;
|
||||
man.targetBeat = beat + 320f;
|
||||
man.Idle();
|
||||
}
|
||||
@ -83,7 +81,30 @@ namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
{
|
||||
beatCount = 0;
|
||||
}
|
||||
|
||||
|
||||
public void Ding(bool applause)
|
||||
{
|
||||
if(applause)
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/applause");
|
||||
else
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/ding");
|
||||
}
|
||||
|
||||
public void Beat(float beat)
|
||||
{
|
||||
beatCount++;
|
||||
|
||||
GameObject _beat = Instantiate(bt);
|
||||
_beat.transform.parent = bt.transform.parent;
|
||||
_beat.SetActive(true);
|
||||
UpbeatStep s = _beat.GetComponent<UpbeatStep>();
|
||||
s.startBeat = beat;
|
||||
}
|
||||
|
||||
private IEnumerator Upbeat(float offset = 0)
|
||||
{
|
||||
yield return new WaitForSeconds(Conductor.instance.secPerBeat * 0.5f - offset);
|
||||
man.Blip();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
{
|
||||
public class UpbeatMan : PlayerActionObject
|
||||
public class UpbeatMan : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
public MrUpbeat game;
|
||||
@ -19,45 +19,18 @@ namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
public float targetBeat = 0.25f;
|
||||
public int stepTimes = 0;
|
||||
private bool stepped = false;
|
||||
private bool onGround = false;
|
||||
|
||||
public GameEvent blip = new GameEvent();
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(targetBeat, 0.5f);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if(game.canGo && normalizedBeat > Minigame.LateTime())
|
||||
{
|
||||
//Fall();
|
||||
targetBeat += 100f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Step();
|
||||
}
|
||||
else if(state.notPerfect())
|
||||
{
|
||||
Fall();
|
||||
}
|
||||
else
|
||||
{
|
||||
Step();
|
||||
}
|
||||
Step();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
if (!game.canGo) return;
|
||||
|
||||
Step();
|
||||
}
|
||||
|
||||
public void Idle()
|
||||
{
|
||||
stepTimes = 0;
|
||||
@ -72,6 +45,29 @@ namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
animator.Play("Step", 0, 0);
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/step");
|
||||
|
||||
onGround = false;
|
||||
CheckShadows();
|
||||
}
|
||||
|
||||
public void Fall()
|
||||
{
|
||||
animator.Play("Fall", 0, 0);
|
||||
Jukebox.PlayOneShot("miss");
|
||||
shadows[0].SetActive(false);
|
||||
shadows[1].SetActive(false);
|
||||
onGround = true;
|
||||
}
|
||||
|
||||
public void Blip()
|
||||
{
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/blip");
|
||||
blipAnimator.Play("Blip", 0, 0);
|
||||
}
|
||||
|
||||
private void CheckShadows()
|
||||
{
|
||||
if (onGround) return;
|
||||
|
||||
if (stepTimes % 2 == 1)
|
||||
{
|
||||
shadows[0].SetActive(false);
|
||||
@ -84,18 +80,6 @@ namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
transform.localScale = new Vector3(1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void Fall()
|
||||
{
|
||||
animator.Play("Fall", 0, 0);
|
||||
Jukebox.PlayOneShot("miss");
|
||||
}
|
||||
|
||||
public void Blip()
|
||||
{
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/blip");
|
||||
blipAnimator.Play("Blip", 0, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
66
Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs
Normal file
66
Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Starpelly;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
{
|
||||
public class UpbeatStep : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
private bool passedFirst = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PlayerActionInit(gameObject, startBeat);
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
Hit(true, true);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 0.35f) >= 1 && !passedFirst)
|
||||
{
|
||||
if(MrUpbeat.instance.man.stepTimes % 2 != startBeat % 2)
|
||||
Hit(false);
|
||||
passedFirst = true;
|
||||
}
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 0.65f) >= 1)
|
||||
Hit(false);
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 0.5f);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Hit(true);
|
||||
} else if (state.notPerfect())
|
||||
{
|
||||
Hit(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Hit(bool hit, bool force = false)
|
||||
{
|
||||
if (force) MrUpbeat.instance.man.Step();
|
||||
else if (!hit) MrUpbeat.instance.man.Fall();
|
||||
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
public void CleanUp()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs.meta
Normal file
11
Assets/Scripts/Games/MrUpbeat/UpbeatStep.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 671722aab5d7ff34da139a076534caf4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -374,10 +374,14 @@ namespace RhythmHeavenMania
|
||||
new GameAction("start interval", delegate { WizardsWaltz.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 4f, true),
|
||||
new GameAction("plant", delegate { WizardsWaltz.instance.SpawnFlower(eventCaller.currentEntity.beat); }, 0.5f, false),
|
||||
}),
|
||||
new Minigame("mrUpbeat", "Mr. Upbeat \n<color=#eb5454>[WIP don't use]</color>", "FFFFFF", false, false, new List<GameAction>()
|
||||
new Minigame("mrUpbeat", "Mr. Upbeat", "FFFFFF", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("prepare", delegate { MrUpbeat.instance.SetInterval(eventCaller.currentEntity.beat); }, 0.5f, true),
|
||||
new GameAction("go", delegate { MrUpbeat.instance.Go(eventCaller.currentEntity.beat); }, 4f, true),
|
||||
new GameAction("ding!", delegate { MrUpbeat.instance.Ding(eventCaller.currentEntity.toggle); }, 0.5f, parameters: new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Applause")
|
||||
}),
|
||||
}),
|
||||
/*new Minigame("spaceDance", "Space Dance", "B888F8", new List<GameAction>()
|
||||
{
|
||||
|
Reference in New Issue
Block a user