bb2ae74339
* add Jukebox library todo: - saving / loading of new format - inferrence of unknown data like past versions - move the temporary float casts to proper use of double - make sound related functions take double for timing - inform people that the Jukebox sound player was renamed to SoundByte lol * make sound, input scheduling, and super curve use double precision * successfully load charts * editor works again v1 riqs can be saved and loaded * first tempo and volume markers are unmovable fix loading of charts' easing values * use gsync / freesync * update Jukebox refs to SoundByte * game events use double part 1 Air Rally - Glee Club converted * don't load song if chart load fails * finish conversion of all minigames * remove editor waveform toggle * timeline now respects added song offset length clear cache files on app close prepped notes for dsp sync * update timeline length when offset changed * update to latest Jukebox * make error panel object in global game manager * improve conductor music scheduling * added error message box fix first game events sometimes not playing
90 lines
2.2 KiB
C#
90 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
namespace HeavenStudio.Games.Scripts_Spaceball
|
|
{
|
|
public class SpaceballPlayer : MonoBehaviour
|
|
{
|
|
private Animator _anim;
|
|
private int _currentCostume;
|
|
|
|
public SpriteRenderer PlayerSprite;
|
|
public SpriteRenderer Hat;
|
|
|
|
public HatSprite HatSprites1 = new HatSprite();
|
|
public HatSprite HatSprites2 = new HatSprite();
|
|
|
|
[Serializable]
|
|
public struct HatSprite
|
|
{
|
|
public List<Vector2> Offsets;
|
|
public List<Sprite> Sprites;
|
|
}
|
|
|
|
public static SpaceballPlayer instance { get; set; }
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
_anim = GetComponent<Animator>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (PlayerInput.Pressed())
|
|
{
|
|
Swing(null);
|
|
}
|
|
}
|
|
|
|
public void SetCostume(Material mat, int costumeIndex)
|
|
{
|
|
PlayerSprite.material = mat;
|
|
_currentCostume = costumeIndex;
|
|
_anim.Play("Idle", 0, 0);
|
|
}
|
|
|
|
public void Swing(SpaceballBall b)
|
|
{
|
|
if (b == null)
|
|
{
|
|
SoundByte.PlayOneShotGame("spaceball/swing");
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
_anim.Play("Swing", 0, 0);
|
|
}
|
|
|
|
public void SetHatFrame(int frame)
|
|
{
|
|
// Unity can't serialize lists inside lists in this version, so that's annoying.
|
|
var sprites = new HatSprite();
|
|
switch (_currentCostume)
|
|
{
|
|
case 0:
|
|
Hat.sprite = null;
|
|
return;
|
|
case 1:
|
|
sprites = HatSprites1;
|
|
break;
|
|
case 2:
|
|
sprites = HatSprites2;
|
|
break;
|
|
}
|
|
if (sprites.Sprites.Count - 1 < frame)
|
|
frame = 0;
|
|
Hat.sprite = sprites.Sprites[frame];
|
|
|
|
var offset = Vector2.zero;
|
|
if (sprites.Offsets.Count - 1 >= frame)
|
|
offset = sprites.Offsets[frame];
|
|
Hat.transform.localPosition = offset;
|
|
}
|
|
}
|
|
} |