2021-12-25 06:22:09 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Games.Spaceball
|
|
|
|
{
|
|
|
|
public class Spaceball : Minigame
|
|
|
|
{
|
2021-12-25 12:16:40 +00:00
|
|
|
public GameObject Ball;
|
2021-12-25 13:32:52 +00:00
|
|
|
public GameObject BallsHolder;
|
2021-12-25 12:16:40 +00:00
|
|
|
|
|
|
|
public GameObject Dispenser;
|
|
|
|
public GameObject Dust;
|
|
|
|
|
|
|
|
public static Spaceball instance { get; set; }
|
|
|
|
|
|
|
|
public override void OnGameSwitch()
|
|
|
|
{
|
2021-12-25 13:32:52 +00:00
|
|
|
for (int i = 1; i < BallsHolder.transform.childCount; i++)
|
|
|
|
Destroy(BallsHolder.transform.GetChild(i).gameObject);
|
2021-12-25 12:16:40 +00:00
|
|
|
GameManager.instance.GameCamera.orthographic = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
2021-12-25 06:22:09 +00:00
|
|
|
{
|
2021-12-25 12:16:40 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-25 13:32:52 +00:00
|
|
|
public void Shoot(float beat, string type)
|
2021-12-25 12:16:40 +00:00
|
|
|
{
|
|
|
|
GameObject ball = Instantiate(Ball);
|
|
|
|
ball.transform.parent = Ball.transform.parent;
|
|
|
|
ball.SetActive(true);
|
|
|
|
ball.GetComponent<SpaceballBall>().startBeat = beat;
|
2021-12-25 13:32:52 +00:00
|
|
|
if (type == "high")
|
|
|
|
{
|
|
|
|
ball.GetComponent<SpaceballBall>().high = true;
|
|
|
|
Jukebox.PlayOneShotGame("spaceball/longShoot");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Jukebox.PlayOneShotGame("spaceball/shoot");
|
|
|
|
}
|
2021-12-25 12:16:40 +00:00
|
|
|
|
|
|
|
Dispenser.GetComponent<Animator>().Play("DispenserShoot", 0, 0);
|
2021-12-25 06:22:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|