mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 20:47:39 +02:00
Merge branch 'master' of https://github.com/megaminerjenny/HeavenStudio into megaminerjenny-master
This commit is contained in:
@ -184,5 +184,16 @@ namespace RhythmHeavenMania.Games.BuiltToScaleDS
|
||||
shooterAnim.Play("Shoot", 0, 0);
|
||||
elevatorAnim.Play("MakeRod", 0, 0);
|
||||
}
|
||||
|
||||
public void PlayPiano(float beat, float length, int semiTones)
|
||||
{
|
||||
var pianoPitch = Mathf.Pow(2f, (1f / 12f) * semiTones) *Conductor.instance.musicSource.pitch;
|
||||
var pianoSource = Jukebox.PlayOneShotGame("builtToScaleDS/Piano", -1, pianoPitch, 0.8f, true);
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + length, delegate { Jukebox.KillLoop(pianoSource, 0.1f); })
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Scripts/Games/DrummingPractice.meta
Normal file
8
Assets/Scripts/Games/DrummingPractice.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39009c40d5d76d24e8f1afa560d30ea8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
88
Assets/Scripts/Games/DrummingPractice/Drummer.cs
Normal file
88
Assets/Scripts/Games/DrummingPractice/Drummer.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Starpelly;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.DrummingPractice
|
||||
{
|
||||
public class Drummer : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("References")]
|
||||
public Animator animator;
|
||||
public List<MiiFace> miiFaces;
|
||||
public SpriteRenderer face;
|
||||
|
||||
public bool player = false;
|
||||
|
||||
public int mii = 0;
|
||||
public int count = 0;
|
||||
|
||||
private bool hitting = false;
|
||||
|
||||
[System.Serializable]
|
||||
public class MiiFace
|
||||
{
|
||||
public List<Sprite> Sprites;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (player && PlayerInput.Pressed())
|
||||
{
|
||||
Hit(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFace(int type)
|
||||
{
|
||||
face.sprite = miiFaces[mii].Sprites[type];
|
||||
}
|
||||
|
||||
public void Bop()
|
||||
{
|
||||
if (animator.IsAnimationNotPlaying())
|
||||
animator.Play("Bop", 0, 0);
|
||||
}
|
||||
|
||||
public void Prepare(int type)
|
||||
{
|
||||
count = type;
|
||||
if (count % 2 == 0)
|
||||
animator.Play("PrepareLeft", 0, 0);
|
||||
else
|
||||
animator.Play("PrepareRight", 0, 0);
|
||||
}
|
||||
|
||||
public void Hit(bool hit)
|
||||
{
|
||||
if (!hitting)
|
||||
{
|
||||
if (count % 2 == 0)
|
||||
animator.Play("HitLeft", 0, 0);
|
||||
else
|
||||
animator.Play("HitRight", 0, 0);
|
||||
count++;
|
||||
|
||||
if (player)
|
||||
{
|
||||
if (hit)
|
||||
Jukebox.PlayOneShotGame("drummingPractice/hit");
|
||||
else
|
||||
Jukebox.PlayOneShotGame("drummingPractice/miss");
|
||||
}
|
||||
|
||||
hitting = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void EndHit()
|
||||
{
|
||||
hitting = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/DrummingPractice/Drummer.cs.meta
Normal file
11
Assets/Scripts/Games/DrummingPractice/Drummer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78423096340cc9740b0a87870976098f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
77
Assets/Scripts/Games/DrummingPractice/DrummerHit.cs
Normal file
77
Assets/Scripts/Games/DrummingPractice/DrummerHit.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.DrummingPractice
|
||||
{
|
||||
public class DrummerHit : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
private bool hit = false;
|
||||
private bool hasHit = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
PlayerActionInit(gameObject, startBeat);
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
Hit(true);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, 2) >= 1)
|
||||
{
|
||||
DrummingPractice.instance.SetFaces(0);
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
if (!hit && Conductor.instance.GetPositionFromBeat(startBeat, 1) >= 1)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("drummingPractice/drum");
|
||||
DrummingPractice.instance.leftDrummer.Hit(true);
|
||||
DrummingPractice.instance.rightDrummer.Hit(true);
|
||||
hit = true;
|
||||
if (hasHit) CleanUp();
|
||||
}
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 1f);
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (state.perfect)
|
||||
{
|
||||
Hit(true);
|
||||
} else if (state.notPerfect())
|
||||
{
|
||||
Hit(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Hit(bool _hit)
|
||||
{
|
||||
if (!hasHit)
|
||||
{
|
||||
DrummingPractice.instance.player.Hit(_hit);
|
||||
DrummingPractice.instance.SetFaces(_hit ? 1 : 2);
|
||||
|
||||
hasHit = true;
|
||||
|
||||
if (hit) CleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void CleanUp()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/DrummingPractice/DrummerHit.cs.meta
Normal file
11
Assets/Scripts/Games/DrummingPractice/DrummerHit.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a4698fb27db1ad4995391c5b6cd1ddb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
125
Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs
Normal file
125
Assets/Scripts/Games/DrummingPractice/DrummingPractice.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using Starpelly;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.DrummingPractice
|
||||
{
|
||||
public class DrummingPractice : Minigame
|
||||
{
|
||||
public enum MiiType
|
||||
{
|
||||
GuestA,
|
||||
GuestB,
|
||||
GuestC,
|
||||
GuestD,
|
||||
GuestE,
|
||||
GuestF,
|
||||
Matt,
|
||||
Tsunku,
|
||||
Marshal
|
||||
}
|
||||
|
||||
[Header("References")]
|
||||
public SpriteRenderer backgroundGradient;
|
||||
public Drummer player;
|
||||
public Drummer leftDrummer;
|
||||
public Drummer rightDrummer;
|
||||
public GameObject hitPrefab;
|
||||
|
||||
public GameEvent bop = new GameEvent();
|
||||
public int count = 0;
|
||||
|
||||
public static DrummingPractice instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// TODO: Move this to OnGameSwitch() when functional?
|
||||
private void Start()
|
||||
{
|
||||
SetMiis(UnityEngine.Random.Range(0, player.miiFaces.Count));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= bop.startBeat && Conductor.instance.songPositionInBeats < bop.startBeat + bop.length)
|
||||
{
|
||||
Bop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBop(float beat, float length)
|
||||
{
|
||||
bop.startBeat = beat;
|
||||
bop.length = length;
|
||||
}
|
||||
|
||||
public void Bop()
|
||||
{
|
||||
player.Bop();
|
||||
leftDrummer.Bop();
|
||||
rightDrummer.Bop();
|
||||
}
|
||||
|
||||
public void Prepare(float beat)
|
||||
{
|
||||
int type = count % 2;
|
||||
player.Prepare(type);
|
||||
leftDrummer.Prepare(type);
|
||||
rightDrummer.Prepare(type);
|
||||
count++;
|
||||
|
||||
SetFaces(0);
|
||||
Jukebox.PlayOneShotGame("drummingPractice/prepare");
|
||||
|
||||
GameObject hit = Instantiate(hitPrefab);
|
||||
hit.transform.parent = hitPrefab.transform.parent;
|
||||
hit.SetActive(true);
|
||||
DrummerHit h = hit.GetComponent<DrummerHit>();
|
||||
h.startBeat = beat;
|
||||
}
|
||||
|
||||
public void SetFaces(int type)
|
||||
{
|
||||
player.SetFace(type);
|
||||
leftDrummer.SetFace(type);
|
||||
rightDrummer.SetFace(type);
|
||||
}
|
||||
|
||||
public void SetMiis(int playerFace, bool all = false)
|
||||
{
|
||||
player.mii = playerFace;
|
||||
|
||||
if (all)
|
||||
{
|
||||
leftDrummer.mii = playerFace;
|
||||
rightDrummer.mii = playerFace;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
leftDrummer.mii = UnityEngine.Random.Range(0, leftDrummer.miiFaces.Count);
|
||||
}
|
||||
while (leftDrummer.mii == player.mii);
|
||||
do
|
||||
{
|
||||
rightDrummer.mii = UnityEngine.Random.Range(0, rightDrummer.miiFaces.Count);
|
||||
}
|
||||
while (rightDrummer.mii == leftDrummer.mii || rightDrummer.mii == player.mii);
|
||||
}
|
||||
|
||||
SetFaces(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7db5828bf6ab644c92395762a28c7a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -27,7 +27,7 @@ namespace RhythmHeavenMania.Games.Global
|
||||
private void Start()
|
||||
{
|
||||
this.gameObject.transform.SetParent(GameManager.instance.gameObject.transform);
|
||||
this.gameObject.layer = 3;
|
||||
gameObject.layer = LayerMask.NameToLayer("Flash");
|
||||
this.gameObject.transform.localScale = new Vector3(1, 1);
|
||||
|
||||
spriteRenderer = this.gameObject.AddComponent<SpriteRenderer>();
|
||||
|
Reference in New Issue
Block a user