mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 18:47:38 +02:00
Spaceball swing + low ball throw + perspective camera
This commit is contained in:
@ -71,6 +71,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
Jukebox.PlayOneShotGame("forkLifter/flick");
|
||||
handAnim.Play("Hand_Flick", 0, 0);
|
||||
GameObject fo = Instantiate(flickedObject);
|
||||
fo.transform.parent = flickedObject.transform.parent;
|
||||
fo.GetComponent<Pea>().startBeat = beat;
|
||||
fo.GetComponent<Pea>().type = type;
|
||||
fo.SetActive(true);
|
||||
|
@ -13,12 +13,10 @@ namespace RhythmHeavenMania.Games.ForkLifter
|
||||
|
||||
public Sprite[] fastSprites;
|
||||
|
||||
List<Beatmap.Entity> allPlayerActions;
|
||||
|
||||
public void CheckNextFlick()
|
||||
{
|
||||
// allPlayerActions = EventCaller.GetAllInGameManagerList("forkLifter", new string[] { "gulp", "sigh", "prepare" });
|
||||
allPlayerActions = EventCaller.GetAllPlayerEntities("forkLifter");
|
||||
var allPlayerActions = EventCaller.GetAllPlayerEntities("forkLifter");
|
||||
int currentPlayerEvent = GameManager.instance.currentPlayerEvent - EventCaller.GetAllPlayerEntitiesExceptBeforeBeat("forkLifter", Conductor.instance.songPositionInBeats).Count;
|
||||
|
||||
if (currentPlayerEvent < allPlayerActions.Count)
|
||||
|
@ -6,7 +6,16 @@ namespace RhythmHeavenMania.Games
|
||||
{
|
||||
public class Minigame : MonoBehaviour
|
||||
{
|
||||
public static float earlyTime = 0.77f, perfectTime = 0.87f, lateTime = 1.09f, endTime = 1.15f;
|
||||
public static float earlyTime = 0.77f, perfectTime = 0.89f, lateTime = 1.09f, endTime = 1.15f;
|
||||
|
||||
[System.Serializable]
|
||||
public class Eligible
|
||||
{
|
||||
public GameObject gameObject;
|
||||
public bool early;
|
||||
public bool perfect;
|
||||
public bool late;
|
||||
}
|
||||
|
||||
// hopefully these will fix the lowbpm problem
|
||||
public static float EarlyTime()
|
||||
|
@ -8,9 +8,46 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||
{
|
||||
public class Spaceball : Minigame
|
||||
{
|
||||
private void Start()
|
||||
public GameObject Ball;
|
||||
|
||||
public GameObject Dispenser;
|
||||
public GameObject Dust;
|
||||
|
||||
public static Spaceball instance { get; set; }
|
||||
|
||||
public override void OnGameSwitch()
|
||||
{
|
||||
Debug.Log("Spaceball");
|
||||
GameManager.instance.GameCamera.orthographic = false;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var allPlayerActions = EventCaller.GetAllPlayerEntities("spaceball");
|
||||
int currentPlayerEvent = GameManager.instance.currentPlayerEvent - EventCaller.GetAllPlayerEntitiesExceptBeforeBeat("spaceball", Conductor.instance.songPositionInBeats).Count;
|
||||
|
||||
if (currentPlayerEvent < allPlayerActions.Count)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats > allPlayerActions[currentPlayerEvent].beat - 1)
|
||||
{
|
||||
Dispenser.GetComponent<Animator>().Play("DispenserPrepare", 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Shoot(float beat)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("spaceball/shoot");
|
||||
GameObject ball = Instantiate(Ball);
|
||||
ball.transform.parent = Ball.transform.parent;
|
||||
ball.SetActive(true);
|
||||
ball.GetComponent<SpaceballBall>().startBeat = beat;
|
||||
|
||||
Dispenser.GetComponent<Animator>().Play("DispenserShoot", 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
96
Assets/Scripts/Games/Spaceball/SpaceballBall.cs
Normal file
96
Assets/Scripts/Games/Spaceball/SpaceballBall.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.Spaceball
|
||||
{
|
||||
public class SpaceballBall : MonoBehaviour
|
||||
{
|
||||
public float startBeat;
|
||||
private Animator anim;
|
||||
private int lastState;
|
||||
private bool inList = false;
|
||||
|
||||
private Minigame.Eligible e = new Minigame.Eligible();
|
||||
|
||||
public GameObject Holder;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
|
||||
e.gameObject = this.gameObject;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float normalizedBeatAnim = Conductor.instance.GetLoopPositionFromBeat(startBeat, 1.25f);
|
||||
anim.Play("BallLow", -1, normalizedBeatAnim);
|
||||
|
||||
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 1f);
|
||||
|
||||
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
|
||||
{
|
||||
MakeEligible(true, false, false);
|
||||
lastState++;
|
||||
}
|
||||
// Perfect State
|
||||
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1)
|
||||
{
|
||||
MakeEligible(false, true, false);
|
||||
lastState++;
|
||||
}
|
||||
// Late State
|
||||
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2)
|
||||
{
|
||||
MakeEligible(false, false, true);
|
||||
lastState++;
|
||||
}
|
||||
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
||||
{
|
||||
MakeInEligible();
|
||||
}
|
||||
|
||||
if (normalizedBeat > 1.25f && lastState == 3)
|
||||
{
|
||||
lastState++;
|
||||
Jukebox.PlayOneShotGame("spaceball/fall");
|
||||
Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeEligible(bool early, bool perfect, bool late)
|
||||
{
|
||||
// print($"{early}, {perfect}, {late}");
|
||||
|
||||
if (!inList)
|
||||
{
|
||||
e.early = early;
|
||||
e.perfect = perfect;
|
||||
e.late = late;
|
||||
|
||||
SpaceballPlayer.instance.EligibleHits.Add(e);
|
||||
inList = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Minigame.Eligible es = SpaceballPlayer.instance.EligibleHits[SpaceballPlayer.instance.EligibleHits.IndexOf(e)];
|
||||
es.early = early;
|
||||
es.perfect = perfect;
|
||||
es.late = late;
|
||||
}
|
||||
}
|
||||
|
||||
public void MakeInEligible()
|
||||
{
|
||||
if (!inList) return;
|
||||
|
||||
SpaceballPlayer.instance.EligibleHits.Remove(e);
|
||||
inList = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/Games/Spaceball/SpaceballBall.cs.meta
Normal file
11
Assets/Scripts/Games/Spaceball/SpaceballBall.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49dd9168d46a2ad41a47802c26b5dbb3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
85
Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs
Normal file
85
Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using DG.Tweening;
|
||||
using RhythmHeavenMania.Util;
|
||||
|
||||
namespace RhythmHeavenMania.Games.Spaceball
|
||||
{
|
||||
public class SpaceballPlayer : MonoBehaviour
|
||||
{
|
||||
private Animator anim;
|
||||
|
||||
public List<Minigame.Eligible> EligibleHits = new List<Minigame.Eligible>();
|
||||
[SerializeField] private int currentHitInList = 0;
|
||||
|
||||
public static SpaceballPlayer instance { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (EligibleHits.Count == 0)
|
||||
currentHitInList = 0;
|
||||
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
Swing();
|
||||
}
|
||||
}
|
||||
|
||||
public void Swing()
|
||||
{
|
||||
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
|
||||
if (canHit)
|
||||
{
|
||||
if (EligibleHits[currentHitInList].perfect)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("spaceball/hit");
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>().Holder.transform.DOMove(new Vector3(Random.Range(5, 25), 0, -600), 5f);
|
||||
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>().enabled = false;
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<Animator>().enabled = false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>().Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -55;
|
||||
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>().enabled = false;
|
||||
EligibleHits[currentHitInList].gameObject.GetComponent<Animator>().enabled = false;
|
||||
|
||||
Rigidbody2D rb = EligibleHits[currentHitInList].gameObject.AddComponent<Rigidbody2D>();
|
||||
rb.bodyType = RigidbodyType2D.Dynamic;
|
||||
rb.AddForce(transform.up * 1100);
|
||||
rb.AddForce(transform.right * 400);
|
||||
rb.gravityScale = 9;
|
||||
|
||||
Jukebox.PlayOneShot("miss");
|
||||
}
|
||||
RemoveBall();
|
||||
}
|
||||
else
|
||||
Jukebox.PlayOneShotGame("spaceball/swing");
|
||||
anim.Play("Swing", 0, 0);
|
||||
}
|
||||
|
||||
private void RemoveBall()
|
||||
{
|
||||
if (currentHitInList < EligibleHits.Count)
|
||||
{
|
||||
EligibleHits.Remove(EligibleHits[currentHitInList]);
|
||||
currentHitInList++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs.meta
Normal file
11
Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d5579033013148498d767bb11e43f60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user