mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 11:45:09 +00:00
606ad902e7
However the new input system has a bug where if you press with two events eligible for a press, both of them interact. I don't know whether to fix this or not.
74 lines
No EOL
1.6 KiB
C#
74 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;
|
|
|
|
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 (Spaceball.instance.EligibleHits.Count == 0)
|
|
currentHitInList = 0;
|
|
|
|
if (PlayerInput.Pressed())
|
|
{
|
|
Swing(null);
|
|
}
|
|
}
|
|
|
|
public void SetCostume(int costume)
|
|
{
|
|
this.costume = costume;
|
|
anim.Play("Idle", 0, 0);
|
|
}
|
|
|
|
public void Swing(SpaceballBall b)
|
|
{
|
|
if (b == null)
|
|
{
|
|
Jukebox.PlayOneShotGame("spaceball/swing");
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
anim.Play("Swing", 0, 0);
|
|
}
|
|
|
|
public void SetSprite(int id)
|
|
{
|
|
PlayerSprite.sprite = PlayerSpriteSheets[costume].sprites[id];
|
|
}
|
|
}
|
|
} |