Merge branch 'megaminerjenny:master' into main

This commit is contained in:
Slaith12
2022-03-06 19:00:57 -08:00
committed by GitHub
12 changed files with 1049 additions and 132 deletions

View File

@ -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();
}
}
}

View File

@ -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);
}
}

View 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);
}
}
}

View File

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

View File

@ -23,14 +23,14 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
void Update()
{
songPos = Conductor.instance.songPositionInBeats;
songPos = Conductor.instance.songPositionInBeats - game.wizardBeatOffset;
var am = game.beatInterval / 2f;
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6;
var y = Mathf.Cos(Mathf.PI * songPos / am) * 1.5f;
var y = Mathf.Cos(Mathf.PI * songPos / am);
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
transform.position = new Vector3(x, 1.5f + y, 0);
shadow.transform.position = new Vector3(x, -3f + y, 0);
transform.position = new Vector3(x, 3f - y * 0.5f, 0);
shadow.transform.position = new Vector3(x, -3f + y * 1.5f, 0);
var xscale = scale;
if (y > 0) xscale *= -1;

View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using System;
using Starpelly;
@ -33,6 +34,17 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
instance = this;
}
private void Start()
{
List<float> starts = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "wizardsWaltz/start interval").Select(c => c.beat).ToList();
if (starts.Count > 0)
{
var nextInterval = starts.IndexOf(Mathp.GetClosestInList(starts, Conductor.instance.songPositionInBeats));
wizardBeatOffset = starts[nextInterval];
}
}
private void Update()
{
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused && intervalStarted)
@ -45,15 +57,15 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
{
if (timer % 8 == 0 || UnityEngine.Random.Range(0,8) == 0)
{
var songPos = Conductor.instance.songPositionInBeats;
var songPos = Conductor.instance.songPositionInBeats - wizardBeatOffset;
var am = beatInterval / 2f;
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6 + UnityEngine.Random.Range(-0.5f, 0.5f);
var y = Mathf.Cos(Mathf.PI * songPos / am) * 2f + UnityEngine.Random.Range(-0.5f, 0.5f); ;
var y = Mathf.Cos(Mathf.PI * songPos / am) * 0.5f + UnityEngine.Random.Range(-0.5f, 0.5f);
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f + UnityEngine.Random.Range(-0.2f, 0.2f); ;
MagicFX magic = Instantiate(fxBase, fxHolder.transform).GetComponent<MagicFX>();
magic.transform.position = new Vector3(x, 0.5f + y, 0);
magic.transform.position = new Vector3(x, 2f + y, 0);
magic.transform.localScale = wizard.gameObject.transform.localScale;
magic.gameObject.SetActive(true);
}
@ -70,6 +82,7 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
intervalStarted = true;
}
wizardBeatOffset = beat;
intervalStartBeat = beat;
beatInterval = interval;
}
@ -83,7 +96,7 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
Jukebox.PlayOneShotGame("wizardsWaltz/plant", beat);
Plant plant = Instantiate(plantBase, plantHolder.transform).GetComponent<Plant>();
var songPos = Conductor.instance.songPositionInBeats;
var songPos = Conductor.instance.songPositionInBeats - wizardBeatOffset;
var am = (beatInterval / 2f);
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6;
var y = -3f + Mathf.Cos(Mathf.PI * songPos / am) * 1.5f;

View File

@ -392,10 +392,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>()
{