HeavenStudioPlus/Assets/Scripts/Games/Spaceball/SpaceballPlayer.cs
Braedon bf7d7110bc Dynamic editor theme (WIP), read desc for more info
Spaceball has been improved, you can now hit multiple balls at a time. Fork Lifter and Karate Man need this update soon as well. No idea why I did it the way I did.

Time jumping also has been improved by pausing.

Dynamic editor themes for custom theme support, however that won't be implemented until later.
2022-01-13 21:33:51 -05:00

71 lines
No EOL
1.6 KiB
C#

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 int costume;
public SpriteRenderer PlayerSprite;
public List<SpriteSheet> PlayerSpriteSheets = new List<SpriteSheet>();
[System.Serializable]
public class SpriteSheet
{
public List<Sprite> sprites;
}
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 SetCostume(int costume)
{
this.costume = costume;
anim.Play("Idle", 0, 0);
}
public void Swing()
{
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
Jukebox.PlayOneShotGame("spaceball/swing");
anim.Play("Swing", 0, 0);
}
public void SetSprite(int id)
{
PlayerSprite.sprite = PlayerSpriteSheets[costume].sprites[id];
}
}
}