2022-04-10 21:37:37 +00:00
|
|
|
using DG.Tweening;
|
|
|
|
using NaughtyBezierCurves;
|
2022-06-22 22:42:22 +00:00
|
|
|
using System;
|
2022-04-04 14:48:37 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2022-04-10 21:37:37 +00:00
|
|
|
using HeavenStudio.Util;
|
|
|
|
|
2022-04-13 14:14:13 +00:00
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
|
|
{
|
|
|
|
using static Minigames;
|
|
|
|
public static class MobTrickLoader
|
|
|
|
{
|
|
|
|
public static Minigame AddGame(EventCaller eventCaller) {
|
2023-03-12 22:20:28 +00:00
|
|
|
return new Minigame("trickClass", "Trick on the Class", "ecede4", false, false, new List<GameAction>()
|
2022-04-13 14:14:13 +00:00
|
|
|
{
|
2023-02-14 16:31:51 +00:00
|
|
|
new GameAction("toss", "Paper Ball")
|
2022-04-13 14:14:13 +00:00
|
|
|
{
|
2023-02-14 16:31:51 +00:00
|
|
|
preFunction = delegate
|
2022-08-20 23:03:51 +00:00
|
|
|
{
|
2023-02-14 16:31:51 +00:00
|
|
|
TrickClass.PreTossObject(eventCaller.currentEntity.beat, (int)TrickClass.TrickObjType.Ball);
|
2022-08-20 23:03:51 +00:00
|
|
|
},
|
2023-02-14 16:31:51 +00:00
|
|
|
defaultLength = 2,
|
|
|
|
},
|
|
|
|
new GameAction("plane", "Plane")
|
|
|
|
{
|
|
|
|
preFunction = delegate
|
2022-08-20 23:03:51 +00:00
|
|
|
{
|
2023-02-14 16:31:51 +00:00
|
|
|
TrickClass.PreTossObject(eventCaller.currentEntity.beat, (int)TrickClass.TrickObjType.Plane);
|
|
|
|
},
|
|
|
|
defaultLength = 3,
|
2022-08-20 23:03:51 +00:00
|
|
|
},
|
2023-03-07 17:22:32 +00:00
|
|
|
new GameAction("bop", "Bop")
|
2023-03-07 17:19:41 +00:00
|
|
|
{
|
2023-03-07 17:22:32 +00:00
|
|
|
function = delegate { var e = eventCaller.currentEntity; TrickClass.instance.Bop(e.beat, e.length, e["bop"], e["autoBop"]); },
|
2022-08-20 23:03:51 +00:00
|
|
|
resizable = true,
|
2023-03-07 17:22:32 +00:00
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
|
|
|
new Param("bop", true, "Bop", "Should the girl and boy bop?"),
|
|
|
|
new Param("autoBop", false, "Bop (Auto)", "Should the girl and boy auto bop?")
|
|
|
|
}
|
|
|
|
},
|
2023-05-28 17:34:44 +00:00
|
|
|
},
|
|
|
|
new List<string>() {"mob", "normal"},
|
|
|
|
"mobtrick", "en",
|
|
|
|
new List<string>() {}
|
|
|
|
);
|
2022-04-13 14:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-04 14:48:37 +00:00
|
|
|
namespace HeavenStudio.Games
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
mob_Trick
|
|
|
|
**/
|
2022-04-10 21:37:37 +00:00
|
|
|
|
|
|
|
using Scripts_TrickClass;
|
2022-06-20 02:29:21 +00:00
|
|
|
public class TrickClass : Minigame
|
2022-04-04 14:48:37 +00:00
|
|
|
{
|
2022-04-10 21:37:37 +00:00
|
|
|
public enum TrickObjType {
|
|
|
|
Ball,
|
2022-06-22 22:42:22 +00:00
|
|
|
Plane,
|
2022-04-10 21:37:37 +00:00
|
|
|
}
|
2023-02-14 16:31:51 +00:00
|
|
|
public struct QueuedObject
|
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
public double beat;
|
2023-02-14 16:31:51 +00:00
|
|
|
public int type;
|
|
|
|
}
|
|
|
|
public static List<QueuedObject> queuedInputs = new List<QueuedObject>();
|
2022-04-10 21:37:37 +00:00
|
|
|
|
2022-06-22 22:42:22 +00:00
|
|
|
[Header("Objects")]
|
|
|
|
public Animator playerAnim;
|
|
|
|
public Animator girlAnim;
|
2022-06-24 01:28:17 +00:00
|
|
|
public Animator warnAnim;
|
2022-06-22 22:42:22 +00:00
|
|
|
|
2022-04-10 21:37:37 +00:00
|
|
|
[Header("References")]
|
|
|
|
public GameObject ballPrefab;
|
|
|
|
public GameObject planePrefab;
|
|
|
|
public GameObject shockPrefab;
|
|
|
|
public Transform objHolder;
|
|
|
|
|
|
|
|
[Header("Curves")]
|
|
|
|
public BezierCurve3D ballTossCurve;
|
|
|
|
public BezierCurve3D ballMissCurve;
|
|
|
|
public BezierCurve3D planeTossCurve;
|
|
|
|
public BezierCurve3D planeMissCurve;
|
|
|
|
public BezierCurve3D shockTossCurve;
|
2022-04-04 14:48:37 +00:00
|
|
|
|
|
|
|
public static TrickClass instance;
|
2022-04-11 13:56:37 +00:00
|
|
|
public GameEvent bop = new GameEvent();
|
2023-03-07 17:22:32 +00:00
|
|
|
bool goBop = true;
|
2022-04-04 14:48:37 +00:00
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public double playerCanDodge = double.MinValue;
|
|
|
|
double playerBopStart = double.MinValue;
|
|
|
|
double girlBopStart = double.MinValue;
|
2023-03-07 17:19:41 +00:00
|
|
|
bool showBubble = true;
|
2022-06-22 22:42:22 +00:00
|
|
|
|
2023-02-14 16:31:51 +00:00
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
{
|
|
|
|
if (queuedInputs.Count > 0) queuedInputs.Clear();
|
2023-06-03 23:30:17 +00:00
|
|
|
foreach (var evt in scheduledInputs)
|
|
|
|
{
|
|
|
|
evt.Disable();
|
|
|
|
}
|
2023-02-14 16:31:51 +00:00
|
|
|
}
|
|
|
|
|
2022-04-04 14:48:37 +00:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
2022-04-10 21:37:37 +00:00
|
|
|
|
2022-04-11 01:05:33 +00:00
|
|
|
private void Update()
|
|
|
|
{
|
2022-04-11 13:56:37 +00:00
|
|
|
var cond = Conductor.instance;
|
2023-03-07 17:22:32 +00:00
|
|
|
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1) && goBop)
|
2022-04-11 13:56:37 +00:00
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
if (cond.songPositionInBeatsAsDouble > playerBopStart)
|
2022-06-22 22:42:22 +00:00
|
|
|
playerAnim.DoScaledAnimationAsync("Bop");
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
if (cond.songPositionInBeatsAsDouble > girlBopStart)
|
2022-06-22 22:42:22 +00:00
|
|
|
girlAnim.DoScaledAnimationAsync("Bop");
|
2022-04-11 13:56:37 +00:00
|
|
|
}
|
|
|
|
|
2023-02-14 16:31:51 +00:00
|
|
|
if (cond.isPlaying && !cond.isPaused)
|
2022-04-11 01:05:33 +00:00
|
|
|
{
|
2023-02-14 16:31:51 +00:00
|
|
|
if (queuedInputs.Count > 0)
|
2022-06-24 01:28:17 +00:00
|
|
|
{
|
2023-02-14 16:31:51 +00:00
|
|
|
foreach (var input in queuedInputs)
|
2022-06-24 01:28:17 +00:00
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-02-14 16:31:51 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(input.beat - 1f, delegate
|
|
|
|
{
|
|
|
|
switch (input.type)
|
|
|
|
{
|
|
|
|
case (int)TrickClass.TrickObjType.Ball:
|
|
|
|
warnAnim.Play("WarnBall", 0, 0);
|
|
|
|
break;
|
|
|
|
case (int)TrickClass.TrickObjType.Plane:
|
|
|
|
warnAnim.Play("WarnPlane", 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
new BeatAction.Action(input.beat, delegate
|
|
|
|
{
|
|
|
|
warnAnim.Play("NoPose", 0, 0);
|
|
|
|
TossObject(input.beat, input.type);
|
|
|
|
})
|
|
|
|
});
|
2022-06-24 01:28:17 +00:00
|
|
|
}
|
2023-02-14 16:31:51 +00:00
|
|
|
queuedInputs.Clear();
|
2022-06-24 01:28:17 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-14 16:31:51 +00:00
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
if (PlayerInput.Pressed() && !IsExpectingInputNow() && (playerCanDodge <= Conductor.instance.songPositionInBeatsAsDouble))
|
2023-02-14 16:31:51 +00:00
|
|
|
{
|
|
|
|
PlayerDodge(true);
|
2023-06-10 19:13:29 +00:00
|
|
|
playerCanDodge = Conductor.instance.songPositionInBeatsAsDouble + 0.6f;
|
2023-02-14 16:31:51 +00:00
|
|
|
}
|
2022-04-11 01:05:33 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public void Bop(double beat, float length, bool shouldBop, bool autoBop)
|
2022-04-11 13:56:37 +00:00
|
|
|
{
|
2023-03-07 17:22:32 +00:00
|
|
|
var cond = Conductor.instance;
|
|
|
|
goBop = autoBop;
|
|
|
|
if (shouldBop)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < length; i++)
|
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-03-07 17:22:32 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + i, delegate
|
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
if (cond.songPositionInBeatsAsDouble > playerBopStart)
|
2023-03-07 17:22:32 +00:00
|
|
|
playerAnim.DoScaledAnimationAsync("Bop");
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
if (cond.songPositionInBeatsAsDouble > girlBopStart)
|
2023-03-07 17:22:32 +00:00
|
|
|
girlAnim.DoScaledAnimationAsync("Bop");
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 13:56:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-07 17:19:41 +00:00
|
|
|
public void BubbleToggle()
|
|
|
|
{
|
|
|
|
instance.showBubble = !instance.showBubble;
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public static void PreTossObject(double beat, int type)
|
2023-02-14 16:31:51 +00:00
|
|
|
{
|
|
|
|
if (GameManager.instance.currentGame == "trickClass")
|
|
|
|
{
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
2023-02-14 16:31:51 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat - 1, delegate
|
2023-03-07 17:19:41 +00:00
|
|
|
{
|
|
|
|
if (instance.showBubble == true)
|
2023-02-14 16:31:51 +00:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case (int)TrickClass.TrickObjType.Ball:
|
|
|
|
instance.warnAnim.Play("WarnBall", 0, 0);
|
|
|
|
break;
|
|
|
|
case (int)TrickClass.TrickObjType.Plane:
|
|
|
|
instance.warnAnim.Play("WarnPlane", 0, 0);
|
|
|
|
break;
|
|
|
|
}
|
2023-03-07 17:19:41 +00:00
|
|
|
}
|
|
|
|
}),
|
2023-02-14 16:31:51 +00:00
|
|
|
new BeatAction.Action(beat, delegate
|
|
|
|
{
|
|
|
|
instance.warnAnim.Play("NoPose", 0, 0);
|
|
|
|
instance.TossObject(beat, type);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
queuedInputs.Add(new QueuedObject
|
|
|
|
{
|
|
|
|
beat = beat,
|
|
|
|
type = type,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public void TossObject(double beat, int type)
|
2022-04-10 21:37:37 +00:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case (int) TrickObjType.Plane:
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("trickClass/girl_toss_plane");
|
2022-04-10 21:37:37 +00:00
|
|
|
break;
|
|
|
|
default:
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("trickClass/girl_toss_ball");
|
2022-04-10 21:37:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
SpawnObject(beat, type);
|
2022-06-22 22:42:22 +00:00
|
|
|
|
|
|
|
girlAnim.DoScaledAnimationAsync("Throw");
|
2023-06-10 19:13:29 +00:00
|
|
|
girlBopStart = Conductor.instance.songPositionInBeatsAsDouble + 0.75f;
|
2022-04-10 21:37:37 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public void SpawnObject(double beat, int type)
|
2022-04-10 21:37:37 +00:00
|
|
|
{
|
|
|
|
GameObject objectToSpawn;
|
|
|
|
BezierCurve3D curve;
|
|
|
|
bool isPlane = false;
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case (int) TrickObjType.Plane:
|
|
|
|
objectToSpawn = planePrefab;
|
|
|
|
curve = planeTossCurve;
|
|
|
|
isPlane = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
objectToSpawn = ballPrefab;
|
|
|
|
curve = ballTossCurve;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
var mobj = GameObject.Instantiate(objectToSpawn, objHolder);
|
|
|
|
var thinker = mobj.GetComponent<MobTrickObj>();
|
|
|
|
|
|
|
|
thinker.startBeat = beat;
|
|
|
|
thinker.flyType = isPlane;
|
|
|
|
thinker.curve = curve;
|
2022-04-11 01:05:33 +00:00
|
|
|
thinker.type = type;
|
2022-04-10 22:29:31 +00:00
|
|
|
|
|
|
|
mobj.SetActive(true);
|
2022-04-10 21:37:37 +00:00
|
|
|
}
|
2022-04-11 01:05:33 +00:00
|
|
|
|
2022-06-22 22:42:22 +00:00
|
|
|
public void PlayerDodge(bool slow = false)
|
2022-04-11 01:05:33 +00:00
|
|
|
{
|
2023-06-10 19:13:29 +00:00
|
|
|
if (playerCanDodge > Conductor.instance.songPositionInBeatsAsDouble) return;
|
2022-06-22 22:42:22 +00:00
|
|
|
|
2022-04-11 01:05:33 +00:00
|
|
|
//anim
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("trickClass/player_dodge");
|
2022-06-22 22:42:22 +00:00
|
|
|
playerAnim.DoScaledAnimationAsync("Dodge", slow ? 0.6f : 1f);
|
2023-06-10 19:13:29 +00:00
|
|
|
playerBopStart = Conductor.instance.songPositionInBeatsAsDouble + 0.75f;
|
2022-06-22 22:42:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayerDodgeNg()
|
|
|
|
{
|
|
|
|
playerAnim.DoScaledAnimationAsync("DodgeNg");
|
2023-06-10 19:13:29 +00:00
|
|
|
playerBopStart = Conductor.instance.songPositionInBeatsAsDouble + 0.75f;
|
|
|
|
playerCanDodge = Conductor.instance.songPositionInBeatsAsDouble + 0.15f;
|
2022-06-22 22:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayerThrough()
|
|
|
|
{
|
|
|
|
playerAnim.DoScaledAnimationAsync("Through");
|
2023-06-10 19:13:29 +00:00
|
|
|
playerBopStart = Conductor.instance.songPositionInBeatsAsDouble + 0.75f;
|
|
|
|
playerCanDodge = Conductor.instance.songPositionInBeatsAsDouble + 0.15f;
|
2022-04-11 01:05:33 +00:00
|
|
|
}
|
2022-04-04 14:48:37 +00:00
|
|
|
}
|
|
|
|
}
|