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

123 lines
3.9 KiB
C#
Raw Normal View History

2021-12-21 01:10:49 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-03-14 14:21:05 +00:00
using HeavenStudio.Util;
2021-12-21 01:10:49 +00:00
2021-12-23 00:08:35 +00:00
using DG.Tweening;
namespace HeavenStudio.Games.Loaders
{
using static Minigames;
public static class RvlForkLoader
{
public static Minigame AddGame(EventCaller eventCaller) {
return new Minigame("forkLifter", "Fork Lifter", "f1f1f1", false, false, new List<GameAction>()
{
2022-08-21 03:13:52 +00:00
new GameAction("flick", "Flick Food")
{
function = delegate { var e = eventCaller.currentEntity; ForkLifter.instance.Flick(e.beat, e["type"]); },
2022-08-21 03:13:52 +00:00
defaultLength = 3,
parameters = new List<Param>()
{
new Param("type", ForkLifter.FlickType.Pea, "Object", "The object to be flicked")
}
},
new GameAction("prepare", "Prepare Hand")
{
function = delegate { ForkLifter.instance.ForkLifterHand.Prepare(); },
defaultLength = 0.5f
},
new GameAction("gulp", "Swallow")
{
function = delegate { ForkLifter.playerInstance.Eat(); }
},
new GameAction("sigh", "Sigh")
{
function = delegate { Jukebox.PlayOneShot("games/forkLifter/sigh"); }
},
// These are still here for backwards-compatibility but are hidden in the editor
2022-08-21 03:13:52 +00:00
new GameAction("pea", "")
{
function = delegate { ForkLifter.instance.Flick(eventCaller.currentEntity.beat, 0); },
defaultLength = 3,
hidden = true
},
new GameAction("topbun", "")
{
function = delegate { ForkLifter.instance.Flick(eventCaller.currentEntity.beat, 1); },
defaultLength = 3,
hidden = true
},
new GameAction("burger", "")
{
function = delegate { ForkLifter.instance.Flick(eventCaller.currentEntity.beat, 2); },
defaultLength = 3,
hidden = true
},
new GameAction("bottombun", "")
{
function = delegate { ForkLifter.instance.Flick(eventCaller.currentEntity.beat, 3); },
defaultLength = 3,
hidden = true
},
});
}
}
}
2022-03-14 14:21:05 +00:00
namespace HeavenStudio.Games
2021-12-21 01:10:49 +00:00
{
2022-03-12 04:10:13 +00:00
using Scripts_ForkLifter;
2021-12-24 03:36:16 +00:00
public class ForkLifter : Minigame
2021-12-21 01:10:49 +00:00
{
2022-03-01 19:27:08 +00:00
public enum FlickType
{
Pea,
TopBun,
Burger,
BottomBun
}
2021-12-21 01:10:49 +00:00
public static ForkLifter instance;
public static ForkLifterPlayer playerInstance => ForkLifterPlayer.instance;
2021-12-21 01:10:49 +00:00
2021-12-23 00:08:35 +00:00
[Header("References")]
public ForkLifterHand ForkLifterHand;
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;
private void Awake()
{
instance = this;
}
public override void OnGameSwitch(float beat)
2021-12-24 03:36:16 +00:00
{
base.OnGameSwitch(beat);
2021-12-24 03:36:16 +00:00
ForkLifterHand.CheckNextFlick();
}
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.transform.parent = flickedObject.transform.parent;
2022-02-03 22:20:26 +00:00
Pea pea = fo.GetComponent<Pea>();
pea.startBeat = beat;
pea.type = type;
2021-12-21 01:10:49 +00:00
fo.SetActive(true);
}
}
}