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) {
|
2022-06-20 02:29:21 +00:00
|
|
|
return new Minigame("trickClass", "Trick on the Class\n<color=#eb5454>[WIP]</color>", "C0171D", false, false, new List<GameAction>()
|
2022-04-13 14:14:13 +00:00
|
|
|
{
|
|
|
|
new GameAction("toss", delegate
|
|
|
|
{
|
|
|
|
TrickClass.instance.TossObject(eventCaller.currentEntity.beat, eventCaller.currentEntity.type);
|
|
|
|
}, 3, false, new List<Param>()
|
|
|
|
{
|
|
|
|
new Param("type", TrickClass.TrickObjType.Ball, "Object", "The object to toss")
|
|
|
|
}),
|
2022-06-20 02:29:21 +00:00
|
|
|
new GameAction("bop", delegate { var e = eventCaller.currentEntity; TrickClass.instance.Bop(e.beat, e.length); }, 1, true, hidden: true),
|
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
|
|
|
}
|
|
|
|
|
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();
|
2022-04-04 14:48:37 +00:00
|
|
|
|
2022-06-22 22:42:22 +00:00
|
|
|
public float playerCanDodge = Single.MinValue;
|
|
|
|
float playerBopStart = Single.MinValue;
|
|
|
|
float girlBopStart = Single.MinValue;
|
|
|
|
|
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;
|
|
|
|
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
|
|
|
{
|
2022-06-22 22:42:22 +00:00
|
|
|
if (cond.songPositionInBeats > playerBopStart)
|
|
|
|
playerAnim.DoScaledAnimationAsync("Bop");
|
|
|
|
|
|
|
|
if (cond.songPositionInBeats > girlBopStart)
|
|
|
|
girlAnim.DoScaledAnimationAsync("Bop");
|
2022-04-11 13:56:37 +00:00
|
|
|
}
|
|
|
|
|
2022-06-22 22:42:22 +00:00
|
|
|
if (PlayerInput.Pressed() && !IsExpectingInputNow() && (playerCanDodge <= Conductor.instance.songPositionInBeats))
|
2022-04-11 01:05:33 +00:00
|
|
|
{
|
2022-06-22 22:42:22 +00:00
|
|
|
PlayerDodge(true);
|
|
|
|
playerCanDodge = Conductor.instance.songPositionInBeats + 0.6f;
|
2022-04-11 01:05:33 +00:00
|
|
|
}
|
2022-06-24 01:28:17 +00:00
|
|
|
|
|
|
|
// bruh
|
|
|
|
var tossEvents = GameManager.instance.Beatmap.entities.FindAll(en => en.datamodel == "trickClass/toss");
|
|
|
|
for (int i = 0; i < tossEvents.Count; i++)
|
|
|
|
{
|
|
|
|
var e = tossEvents[i];
|
|
|
|
float timeToEvent = e.beat - cond.songPositionInBeats;
|
2022-06-26 03:38:40 +00:00
|
|
|
warnAnim.Play("NoPose", -1, 0);
|
2022-06-24 01:28:17 +00:00
|
|
|
if (timeToEvent > 0f && timeToEvent <= 1f)
|
|
|
|
{
|
|
|
|
string anim = "WarnBall";
|
|
|
|
switch (e.type)
|
|
|
|
{
|
|
|
|
case (int) TrickObjType.Plane:
|
|
|
|
anim = "WarnPlane";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
anim = "WarnBall";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
warnAnim.DoScaledAnimation(anim, e.beat - 1f, 1f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 01:05:33 +00:00
|
|
|
}
|
|
|
|
|
2022-04-11 13:56:37 +00:00
|
|
|
public void Bop(float beat, float length)
|
|
|
|
{
|
|
|
|
bop.startBeat = beat;
|
|
|
|
bop.length = length;
|
|
|
|
}
|
|
|
|
|
2022-04-10 21:37:37 +00:00
|
|
|
public void TossObject(float beat, int type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case (int) TrickObjType.Plane:
|
|
|
|
Jukebox.PlayOneShotGame("trickClass/girl_toss_plane");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Jukebox.PlayOneShotGame("trickClass/girl_toss_ball");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SpawnObject(beat, type);
|
2022-06-22 22:42:22 +00:00
|
|
|
|
|
|
|
girlAnim.DoScaledAnimationAsync("Throw");
|
|
|
|
girlBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
2022-04-10 21:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SpawnObject(float beat, int type)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2022-06-22 22:42:22 +00:00
|
|
|
if (playerCanDodge > Conductor.instance.songPositionInBeats) return;
|
|
|
|
|
2022-04-11 01:05:33 +00:00
|
|
|
//anim
|
|
|
|
Jukebox.PlayOneShotGame("trickClass/player_dodge");
|
2022-06-22 22:42:22 +00:00
|
|
|
playerAnim.DoScaledAnimationAsync("Dodge", slow ? 0.6f : 1f);
|
|
|
|
playerBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayerDodgeNg()
|
|
|
|
{
|
|
|
|
playerAnim.DoScaledAnimationAsync("DodgeNg");
|
|
|
|
playerBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
2022-06-24 01:28:17 +00:00
|
|
|
playerCanDodge = Conductor.instance.songPositionInBeats + 0.15f;
|
2022-06-22 22:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void PlayerThrough()
|
|
|
|
{
|
|
|
|
playerAnim.DoScaledAnimationAsync("Through");
|
|
|
|
playerBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
2022-06-24 01:28:17 +00:00
|
|
|
playerCanDodge = Conductor.instance.songPositionInBeats + 0.15f;
|
2022-04-11 01:05:33 +00:00
|
|
|
}
|
2022-04-04 14:48:37 +00:00
|
|
|
}
|
|
|
|
}
|