2021-12-25 12:16:40 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using DG.Tweening;
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Util;
|
2021-12-25 12:16:40 +00:00
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Games.Scripts_Spaceball
|
2021-12-25 12:16:40 +00:00
|
|
|
{
|
|
|
|
public class SpaceballPlayer : MonoBehaviour
|
|
|
|
{
|
|
|
|
private Animator anim;
|
|
|
|
|
2022-01-17 05:00:26 +00:00
|
|
|
private int currentHitInList = 0;
|
2021-12-25 12:16:40 +00:00
|
|
|
|
2021-12-26 07:25:17 +00:00
|
|
|
public int costume;
|
|
|
|
|
|
|
|
public SpriteRenderer PlayerSprite;
|
|
|
|
public List<SpriteSheet> PlayerSpriteSheets = new List<SpriteSheet>();
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
public class SpriteSheet
|
|
|
|
{
|
|
|
|
public List<Sprite> sprites;
|
|
|
|
}
|
|
|
|
|
2021-12-25 12:16:40 +00:00
|
|
|
public static SpaceballPlayer instance { get; set; }
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-01-17 05:00:26 +00:00
|
|
|
if (Spaceball.instance.EligibleHits.Count == 0)
|
2021-12-25 12:16:40 +00:00
|
|
|
currentHitInList = 0;
|
|
|
|
|
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
2022-01-23 07:01:59 +00:00
|
|
|
Swing(null);
|
2021-12-25 12:16:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-26 07:25:17 +00:00
|
|
|
public void SetCostume(int costume)
|
|
|
|
{
|
|
|
|
this.costume = costume;
|
|
|
|
anim.Play("Idle", 0, 0);
|
|
|
|
}
|
|
|
|
|
2022-01-23 07:01:59 +00:00
|
|
|
public void Swing(SpaceballBall b)
|
2021-12-25 12:16:40 +00:00
|
|
|
{
|
2022-01-23 07:01:59 +00:00
|
|
|
if (b == null)
|
2022-01-17 05:00:26 +00:00
|
|
|
{
|
2022-01-21 01:24:30 +00:00
|
|
|
Jukebox.PlayOneShotGame("spaceball/swing");
|
2022-01-23 07:01:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-26 07:25:17 +00:00
|
|
|
|
2022-01-23 07:01:59 +00:00
|
|
|
}
|
2021-12-25 12:16:40 +00:00
|
|
|
anim.Play("Swing", 0, 0);
|
|
|
|
}
|
|
|
|
|
2021-12-26 07:25:17 +00:00
|
|
|
public void SetSprite(int id)
|
|
|
|
{
|
|
|
|
PlayerSprite.sprite = PlayerSpriteSheets[costume].sprites[id];
|
|
|
|
}
|
2021-12-25 12:16:40 +00:00
|
|
|
}
|
|
|
|
}
|