mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:07:41 +02:00
Merge branch 'master' of https://github.com/megaminerjenny/HeavenStudio
This commit is contained in:
8
Assets/Scripts/Games/MrUpbeat.meta
Normal file
8
Assets/Scripts/Games/MrUpbeat.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f22d820fe1dee4e469a337fa3e97fe7b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
89
Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs
Normal file
89
Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Starpelly;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.MrUpbeat
|
||||
{
|
||||
public class MrUpbeat : Minigame
|
||||
{
|
||||
[Header("References")]
|
||||
public GameObject metronome;
|
||||
public UpbeatMan man;
|
||||
|
||||
public GameEvent beat = new GameEvent();
|
||||
public GameEvent offbeat = new GameEvent();
|
||||
public bool canGo = false;
|
||||
private int beatCount = 0;
|
||||
|
||||
public static MrUpbeat instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref beat.lastReportedBeat) && canGo)
|
||||
{
|
||||
if(beatCount % 2 == 0)
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeRight");
|
||||
else
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/metronomeLeft");
|
||||
|
||||
beatCount++;
|
||||
}
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref offbeat.lastReportedBeat, 0.25f, true))
|
||||
{
|
||||
man.Blip();
|
||||
if(canGo) man.targetBeat = offbeat.lastReportedBeat + 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnGameSwitch()
|
||||
{
|
||||
base.OnGameSwitch();
|
||||
canGo = false;
|
||||
man.stepTimes = 0;
|
||||
SetInterval(0);
|
||||
}
|
||||
|
||||
public void SetInterval(float beat)
|
||||
{
|
||||
beatCount = 0;
|
||||
offbeat.startBeat = beat;
|
||||
man.targetBeat = beat + 320f;
|
||||
man.Idle();
|
||||
}
|
||||
|
||||
public void Go(float beat)
|
||||
{
|
||||
beatCount = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs.meta
Normal file
11
Assets/Scripts/Games/MrUpbeat/MrUpbeat.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a258517e5332c824a8b81a03036fc2a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
102
Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs
Normal file
102
Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs
Normal file
@ -0,0 +1,102 @@
|
||||
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 float targetBeat = 0.25f;
|
||||
public int stepTimes = 0;
|
||||
private bool stepped = 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
if (!game.canGo) return;
|
||||
|
||||
Step();
|
||||
}
|
||||
|
||||
public void Idle()
|
||||
{
|
||||
stepTimes = 0;
|
||||
transform.localScale = new Vector3(1, 1);
|
||||
animator.Play("Idle", 0, 0);
|
||||
}
|
||||
|
||||
public void Step()
|
||||
{
|
||||
stepTimes++;
|
||||
|
||||
animator.Play("Step", 0, 0);
|
||||
Jukebox.PlayOneShotGame("mrUpbeat/step");
|
||||
|
||||
if (stepTimes % 2 == 1)
|
||||
{
|
||||
shadows[0].SetActive(false);
|
||||
shadows[1].SetActive(true);
|
||||
transform.localScale = new Vector3(-1, 1);
|
||||
} else
|
||||
{
|
||||
shadows[0].SetActive(true);
|
||||
shadows[1].SetActive(false);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs.meta
Normal file
11
Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4fa18aec69a2e949a7e2d4e33bdd2b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
36
Assets/Scripts/Games/WizardsWaltz/Girl.cs
Normal file
36
Assets/Scripts/Games/WizardsWaltz/Girl.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
{
|
||||
public class Girl : MonoBehaviour
|
||||
{
|
||||
|
||||
public Animator animator;
|
||||
|
||||
public GameObject[] flowers;
|
||||
private int flowerCount = 0;
|
||||
|
||||
public void Happy()
|
||||
{
|
||||
animator.Play("Happy", 0, 0);
|
||||
SetFlowers(1);
|
||||
}
|
||||
|
||||
public void Sad()
|
||||
{
|
||||
animator.Play("Sad", 0, 0);
|
||||
SetFlowers(-1);
|
||||
}
|
||||
|
||||
public void SetFlowers(int add = 0)
|
||||
{
|
||||
flowerCount = Mathf.Clamp(flowerCount + add, 0, flowers.Length);
|
||||
for (int i = 0; i < flowers.Length; i++)
|
||||
{
|
||||
flowers[i].SetActive(i < flowerCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/WizardsWaltz/Girl.cs.meta
Normal file
11
Assets/Scripts/Games/WizardsWaltz/Girl.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e25ab9ffcdb4c945ace0b7c8db5bd9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/Games/WizardsWaltz/MagicFX.cs
Normal file
33
Assets/Scripts/Games/WizardsWaltz/MagicFX.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using RhythmHeavenMania.Util;
|
||||
using System;
|
||||
|
||||
namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
{
|
||||
public class MagicFX : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public SpriteRenderer spriteRenderer;
|
||||
public GameObject shimmer;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
int order = (int)Math.Round((transform.position.z - 2) * 1000);
|
||||
spriteRenderer.sortingOrder = order;
|
||||
shimmer.GetComponent<SpriteRenderer>().sortingOrder = order;
|
||||
animator.Play("Magic", 0, 0);
|
||||
|
||||
Rigidbody2D rb2d = gameObject.AddComponent<Rigidbody2D>();
|
||||
rb2d.gravityScale = 2.5f;
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
Destroy(shimmer);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/WizardsWaltz/MagicFX.cs.meta
Normal file
11
Assets/Scripts/Games/WizardsWaltz/MagicFX.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b107d57be99ffe34ea2d14c49c15ff80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -8,6 +8,7 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
public class Plant : PlayerActionObject
|
||||
{
|
||||
public Animator animator;
|
||||
public SpriteRenderer spriteRenderer;
|
||||
public float createBeat;
|
||||
|
||||
private WizardsWaltz game;
|
||||
@ -21,6 +22,7 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
|
||||
private void Start()
|
||||
{
|
||||
spriteRenderer.sortingOrder = (int)Math.Round((transform.position.z - 2) * 1000);
|
||||
animator.Play("Appear", 0, 0);
|
||||
}
|
||||
|
||||
@ -55,6 +57,16 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
animator.Play("Hit", 0, 0);
|
||||
}
|
||||
|
||||
public void IdlePlant()
|
||||
{
|
||||
animator.Play("IdlePlant", 0, 0);
|
||||
}
|
||||
|
||||
public void IdleFlower()
|
||||
{
|
||||
animator.Play("IdleFlower", 0, 0);
|
||||
}
|
||||
|
||||
public void Eat()
|
||||
{
|
||||
animator.Play("Eat", 0, 0);
|
||||
|
@ -7,8 +7,12 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
{
|
||||
public class Wizard : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public GameObject shadow;
|
||||
|
||||
private float newBeat = 0;
|
||||
private int beats = 0;
|
||||
|
||||
private WizardsWaltz game;
|
||||
private float songPos;
|
||||
|
||||
@ -22,11 +26,11 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
songPos = Conductor.instance.songPositionInBeats;
|
||||
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 scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.25f;
|
||||
var y = Mathf.Cos(Mathf.PI * songPos / am) * 2f;
|
||||
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
|
||||
|
||||
transform.position = new Vector3(x, 2 + y, -scale);
|
||||
shadow.transform.position = new Vector3(x, -2.5f + y, -scale + 0.1f);
|
||||
transform.position = new Vector3(x, 1f + y, scale * 2);
|
||||
shadow.transform.position = new Vector3(x, -3.5f + y, scale * 2 + 0.1f);
|
||||
|
||||
var xscale = scale;
|
||||
if (y > 0) xscale *= -1;
|
||||
@ -34,8 +38,23 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
shadow.transform.localScale = new Vector3(scale, scale, 1);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (PlayerInput.Pressed(true))
|
||||
{
|
||||
animator.Play("Magic", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void Idle()
|
||||
{
|
||||
animator.Play("Idle", 0, 0);
|
||||
}
|
||||
|
||||
public void Magic(Plant plant, bool hit)
|
||||
{
|
||||
animator.Play("Magic", 0, 0);
|
||||
|
||||
if(plant == null)
|
||||
{
|
||||
// TODO: Play empty A press sound
|
||||
@ -45,11 +64,13 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
{
|
||||
Jukebox.PlayOneShotGame("wizardsWaltz/grow");
|
||||
plant.Bloom();
|
||||
game.girl.Happy();
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShot("miss");
|
||||
plant.Eat();
|
||||
game.girl.Sad();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,13 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
{
|
||||
[Header("References")]
|
||||
public Wizard wizard;
|
||||
public Girl girl;
|
||||
public GameObject plantHolder;
|
||||
public GameObject plantBase;
|
||||
public GameObject fxHolder;
|
||||
public GameObject fxBase;
|
||||
|
||||
private int timer = 0;
|
||||
public float beatInterval = 4f;
|
||||
float intervalStartBeat;
|
||||
bool intervalStarted;
|
||||
@ -37,6 +41,26 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
}
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (timer % 8 == 0 || UnityEngine.Random.Range(0,8) == 0)
|
||||
{
|
||||
var songPos = Conductor.instance.songPositionInBeats;
|
||||
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 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, scale * 2);
|
||||
magic.transform.localScale = wizard.gameObject.transform.localScale;
|
||||
magic.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
timer++;
|
||||
}
|
||||
|
||||
public void SetIntervalStart(float beat, float interval = 4f)
|
||||
{
|
||||
// Don't do these things if the interval was already started.
|
||||
@ -62,12 +86,12 @@ namespace RhythmHeavenMania.Games.WizardsWaltz
|
||||
var songPos = Conductor.instance.songPositionInBeats;
|
||||
var am = (beatInterval / 2f);
|
||||
var x = Mathf.Sin(Mathf.PI * songPos / am) * 6;
|
||||
var y = -2.5f + Mathf.Cos(Mathf.PI * songPos / am) * 1.5f;
|
||||
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.25f;
|
||||
var y = -3.5f + Mathf.Cos(Mathf.PI * songPos / am) * 2f;
|
||||
var scale = 1 - Mathf.Cos(Mathf.PI * songPos / am) * 0.35f;
|
||||
var xscale = scale;
|
||||
if (y > -2.5f) xscale *= -1;
|
||||
if (y > -3.5f) xscale *= -1;
|
||||
|
||||
plant.transform.localPosition = new Vector3(x, y, -scale);
|
||||
plant.transform.localPosition = new Vector3(x, y, scale * 2);
|
||||
plant.transform.localScale = new Vector3(xscale, scale, 1);
|
||||
|
||||
plant.gameObject.SetActive(true);
|
||||
|
@ -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,11 @@ 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("prepare", delegate { MrUpbeat.instance.SetInterval(eventCaller.currentEntity.beat); }, 0.5f, true),
|
||||
new GameAction("go", delegate { MrUpbeat.instance.Go(eventCaller.currentEntity.beat); }, 4f, true),
|
||||
}),
|
||||
/*new Minigame("spaceDance", "Space Dance", "B888F8", new List<GameAction>()
|
||||
{
|
||||
}),
|
||||
|
Reference in New Issue
Block a user