2022-01-24 02:15:23 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
2022-03-12 04:10:13 +00:00
|
|
|
namespace RhythmHeavenMania.Games
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
2022-03-12 04:10:13 +00:00
|
|
|
using Scripts_SpaceSoccer;
|
|
|
|
|
2022-01-24 02:15:23 +00:00
|
|
|
public class SpaceSoccer : Minigame
|
|
|
|
{
|
|
|
|
[Header("Components")]
|
|
|
|
[SerializeField] private GameObject ballRef;
|
2022-02-02 08:36:20 +00:00
|
|
|
[SerializeField] private List<Kicker> kickers;
|
2022-01-30 23:40:12 +00:00
|
|
|
[SerializeField] private GameObject Background;
|
|
|
|
[SerializeField] private Sprite[] backgroundSprite;
|
2022-01-24 02:15:23 +00:00
|
|
|
|
|
|
|
[Header("Properties")]
|
2022-02-26 23:38:27 +00:00
|
|
|
[SerializeField] private bool ballDispensed; //unused
|
2022-01-24 02:15:23 +00:00
|
|
|
|
|
|
|
public static SpaceSoccer instance { get; private set; }
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
2022-01-30 23:40:12 +00:00
|
|
|
private void Start()
|
|
|
|
{
|
2022-02-02 08:36:20 +00:00
|
|
|
/*for (int x = 0; x < Random.Range(9, 12); x++)
|
2022-01-30 23:40:12 +00:00
|
|
|
{
|
|
|
|
for (int y = 0; y < Random.Range(6, 9); y++)
|
|
|
|
{
|
|
|
|
GameObject test = new GameObject("test");
|
|
|
|
test.transform.parent = Background.transform;
|
|
|
|
test.AddComponent<SpriteRenderer>().sprite = backgroundSprite[Random.Range(0, 2)];
|
|
|
|
test.GetComponent<SpriteRenderer>().sortingOrder = -50;
|
|
|
|
test.transform.localPosition = new Vector3(Random.Range(-15f, 15f), Random.Range(-15f, 15f));
|
|
|
|
test.transform.localScale = new Vector3(0.52f, 0.52f);
|
|
|
|
}
|
2022-02-02 08:36:20 +00:00
|
|
|
}*/
|
2022-01-30 23:40:12 +00:00
|
|
|
}
|
|
|
|
|
2022-01-24 02:15:23 +00:00
|
|
|
private void Update()
|
|
|
|
{
|
2022-02-26 07:27:51 +00:00
|
|
|
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
|
2022-03-08 04:46:49 +00:00
|
|
|
public override void OnGameSwitch(float beat)
|
|
|
|
{
|
|
|
|
foreach(Beatmap.Entity entity in GameManager.instance.Beatmap.entities)
|
|
|
|
{
|
|
|
|
if(entity.beat > beat) //the list is sorted based on the beat of the entity, so this should work fine.
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(entity.datamodel != "spaceSoccer/ball dispense" || entity.beat + entity.length <= beat) //check for dispenses that happen right before the switch
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Dispense(entity.beat, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispense(float beat, bool playSound = true)
|
2022-01-24 02:15:23 +00:00
|
|
|
{
|
2022-03-02 21:59:35 +00:00
|
|
|
ballDispensed = true;
|
2022-02-02 08:36:20 +00:00
|
|
|
for (int i = 0; i < kickers.Count; i++)
|
|
|
|
{
|
|
|
|
Kicker kicker = kickers[i];
|
|
|
|
if (i == 0) kicker.player = true;
|
|
|
|
|
|
|
|
if (kicker.ball != null) return;
|
2022-01-24 02:15:23 +00:00
|
|
|
|
2022-02-02 08:36:20 +00:00
|
|
|
GameObject ball = Instantiate(ballRef, transform);
|
2022-02-26 07:27:51 +00:00
|
|
|
ball.SetActive(true);
|
2022-02-02 08:36:20 +00:00
|
|
|
Ball ball_ = ball.GetComponent<Ball>();
|
2022-02-26 07:27:51 +00:00
|
|
|
ball_.Init(kicker, beat);
|
2022-03-08 04:46:49 +00:00
|
|
|
if (kicker.player && playSound)
|
2022-03-02 21:59:35 +00:00
|
|
|
{
|
|
|
|
DispenseSound(beat);
|
|
|
|
}
|
2022-02-02 08:36:20 +00:00
|
|
|
}
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
2022-03-02 21:59:35 +00:00
|
|
|
|
|
|
|
public static void DispenseSound(float beat)
|
|
|
|
{
|
|
|
|
MultiSound.Play(new MultiSound.Sound[]
|
|
|
|
{
|
2022-03-08 04:46:49 +00:00
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseNoise", beat),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble1", beat + 0.25f),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble2", beat + 0.5f),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble2B",beat + 0.5f),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble3", beat + 0.75f),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble4", beat + 1f),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble5", beat + 1.25f),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble6", beat + 1.5f),
|
|
|
|
new MultiSound.Sound("spaceSoccer/dispenseTumble6B",beat + 1.75f),
|
|
|
|
}, forcePlay:true);
|
2022-03-02 21:59:35 +00:00
|
|
|
}
|
2022-01-24 02:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|