mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-12 20:55:08 +00:00
bf7d7110bc
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.
71 lines
No EOL
1.6 KiB
C#
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];
|
|
}
|
|
}
|
|
} |