Mr Upbeat Programming progress

Autoplay works but it doesn't work otherwise
This commit is contained in:
Carson Kompon
2022-03-04 17:03:57 -05:00
parent 035fbc818b
commit 063c144e44
8 changed files with 485 additions and 19 deletions

View File

@ -12,9 +12,11 @@ namespace RhythmHeavenMania.Games.MrUpbeat
{
[Header("References")]
public GameObject metronome;
public Animator animator;
public Animator blipAnimator;
public GameObject[] shadows;
public UpbeatMan man;
public float nextBeat;
public bool canGo = false;
public static MrUpbeat instance;
@ -23,6 +25,29 @@ namespace RhythmHeavenMania.Games.MrUpbeat
instance = this;
}
private void Update()
{
List<Beatmap.Entity> gos = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "mrUpbeat/go");
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)
{
canGo = true;
break;
} else
{
canGo = false;
}
}
float normalizedBeat = Conductor.instance.GetPositionFromBeat(nextBeat, 0.5f);
//StateCheck(normalizedBeat);
}
public void SetInterval(float beat)
{
nextBeat = beat;
}
}

View File

@ -0,0 +1,92 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Starpelly;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.MrUpbeat
{
public class UpbeatMan : PlayerActionObject
{
[Header("References")]
public MrUpbeat game;
public Animator animator;
public Animator blipAnimator;
public GameObject[] shadows;
public int stepTimes = 0;
public GameEvent blip = new GameEvent();
private void Update()
{
float normalizedBeat = Conductor.instance.GetPositionFromBeat(game.nextBeat, 0.5f);
StateCheck(normalizedBeat);
CheckIfFall(normalizedBeat);
if (PlayerInput.Pressed(true))
{
if (state.perfect)
{
Step();
} else if (state.notPerfect())
{
Fall();
}
}
}
public void ProgressBeat()
{
game.nextBeat += 1f;
Blip();
}
public override void OnAce()
{
Step();
}
public void Step()
{
if (!game.canGo) return;
stepTimes++;
Jukebox.PlayOneShotGame("mrUpbeat/step");
if (stepTimes % 2 == 1)
transform.localScale = new Vector3(-1, 1);
else
transform.localScale = new Vector3(1, 1);
ProgressBeat();
}
public void Fall()
{
if (!game.canGo) return;
Jukebox.PlayOneShot("miss");
}
private void CheckIfFall(float normalizedBeat)
{
if (normalizedBeat > Minigame.LateTime())
{
Fall();
ProgressBeat();
}
}
public void Blip()
{
Jukebox.PlayOneShotGame("mrUpbeat/blip");
blipAnimator.Play("Blip", 0, 0);
}
}
}

View File

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

View File

@ -17,6 +17,7 @@ using RhythmHeavenMania.Games.BuiltToScaleDS;
using RhythmHeavenMania.Games.TapTrial;
using RhythmHeavenMania.Games.CropStomp;
using RhythmHeavenMania.Games.WizardsWaltz;
using RhythmHeavenMania.Games.MrUpbeat;
namespace RhythmHeavenMania
{
@ -373,6 +374,10 @@ 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 GameAction("go", delegate { }, 4f, true),
}),
/*new Minigame("spaceDance", "Space Dance", "B888F8", new List<GameAction>()
{
}),