3002e48350
* add mouse controller * support different control styles in options deprecate old input check methods * fully functional input actions system * btsds InputAction * blue bear InputAction * more games fix bugs with some input related systems * coin toss re-toss * cheer readers touch * dog ninja touch * multiple games * last of the easy games' touch * more specialized games * specialized games 2 * finish ktb games * remove legacy settings disclaimer * "only" two games left * karate man touch * rockers touch still needs fixes and bad judge strum * DSGuy flicking animation * playstyle chart property * improve performance of minigame preloading * improve look of cursor make assetbundles use chunk-based compression refactor assetbundle loading methods a bit * prime conductor stream playback to stabilize seeking operations * fix air rally swing on pad release * use virtual mouse pointer * add UniTask * make BeatAction use UniTask * implement UniTask to replace some coroutines * add touch style UI elements and effects games now support the ability to define two cursor colours if they need split screen touch inputs * update plugins and buildscript * implement thresholded pointer position clipping * fix clamping * instant show / hide fix discord game SDK crashes
90 lines
2.3 KiB
C#
90 lines
2.3 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.GetIsAction(Spaceball.InputAction_BasicPress, out _))
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
} |