HeavenStudioPlus/Assets/Scripts/Games/ForkLifter/ForkLifter.cs

80 lines
2.3 KiB
C#
Raw Normal View History

2021-12-21 01:10:49 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RhythmHeavenMania.Util;
2021-12-23 00:08:35 +00:00
using DG.Tweening;
2021-12-21 01:10:49 +00:00
namespace RhythmHeavenMania.Games.ForkLifter
{
2021-12-24 03:36:16 +00:00
public class ForkLifter : Minigame
2021-12-21 01:10:49 +00:00
{
public static ForkLifter instance;
2021-12-23 00:08:35 +00:00
[Header("References")]
public ForkLifterHand ForkLifterHand;
private GameManager GameManager;
2021-12-21 01:10:49 +00:00
2021-12-21 01:10:49 +00:00
[Header("Objects")]
public Animator handAnim;
public GameObject flickedObject;
public SpriteRenderer peaPreview;
public Sprite[] peaSprites;
public Sprite[] peaHitSprites;
2021-12-23 00:08:35 +00:00
private List<Beatmap.Entity> allPlayerActions = new List<Beatmap.Entity>();
2021-12-21 01:10:49 +00:00
private void Awake()
{
instance = this;
}
2021-12-24 03:36:16 +00:00
public override void OnGameSwitch()
{
ForkLifterHand.CheckNextFlick();
ForkLifterPlayer.instance.RemoveObjFromFork();
}
2021-12-21 01:10:49 +00:00
private void Start()
{
GameManager = GameManager.instance;
2021-12-23 00:08:35 +00:00
// allPlayerActions = GameManager.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end");
/*List<Event> temp = new List<Event>();
for (int i = 0; i < allPlayerActions.Count; i++)
{
if (i - 1 > 0)
{
if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime))
{
// do nothing lul
continue;
}
}
Event e = (Event)allPlayerActions[i].Clone();
e.spawnTime = allPlayerActions[i].spawnTime - 1;
e.eventName = "prepare";
temp.Add(e);
}
string s = JsonConvert.SerializeObject(temp);
print(s);*/
2021-12-21 01:10:49 +00:00
}
public void Flick(float beat, int type)
{
2021-12-23 22:39:03 +00:00
Jukebox.PlayOneShotGame("forkLifter/flick");
2021-12-21 01:10:49 +00:00
handAnim.Play("Hand_Flick", 0, 0);
GameObject fo = Instantiate(flickedObject);
fo.GetComponent<Pea>().startBeat = beat;
fo.GetComponent<Pea>().type = type;
fo.SetActive(true);
}
}
}