Converted everything to new curves and made playerballs handle themselves input-wise

This commit is contained in:
Rapandrasmus 2023-06-12 18:36:41 +02:00
parent 41157a038c
commit db21d51673
7 changed files with 494 additions and 1900 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,36 +7,190 @@ using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_WorkingDough
{
public class PlayerEnterDoughBall : MonoBehaviour
public class PlayerEnterDoughBall : SuperCurveObject
{
public double startBeat;
public float firstBeatsToTravel = 0.5f;
public float secondBeatsToTravel = 0.5f;
public bool goingDown = false;
public bool deletingAutomatically = true;
[NonSerialized] public BezierCurve3D firstCurve;
[NonSerialized] public BezierCurve3D secondCurve;
private enum State
{
None,
Entering,
Hit,
Barely,
Miss,
Weak
}
private State currentState;
private double startBeat;
private bool big;
private Path enterPath;
private Path hitPath;
private Path barelyPath;
private Path missPath;
private Path weakPath;
private WorkingDough game;
private PlayerActionEvent wrongInput;
private PlayerActionEvent rightInput;
private void Awake()
{
game = WorkingDough.instance;
}
public void Init(double beat, bool isBig)
{
startBeat = beat;
big = isBig;
enterPath = game.GetPath("PlayerEnter");
hitPath = game.GetPath("PlayerHit");
barelyPath = game.GetPath("PlayerBarely");
missPath = game.GetPath("PlayerMiss");
weakPath = game.GetPath("PlayerWeak");
rightInput = game.ScheduleInput(beat, 1, isBig ? InputType.STANDARD_ALT_DOWN : InputType.STANDARD_DOWN, Just, Miss, Empty);
wrongInput = game.ScheduleUserInput(beat, 1, isBig ? InputType.STANDARD_DOWN : InputType.STANDARD_ALT_DOWN, WrongInput, Empty, Empty);
currentState = State.Entering;
Update();
}
private void Update()
{
var cond = Conductor.instance;
float flyPos = 0f;
if (goingDown)
if (cond.isPlaying && !cond.isPaused)
{
flyPos = cond.GetPositionFromBeat(startBeat + firstBeatsToTravel, secondBeatsToTravel);
Vector3 pos = new Vector3();
double beat = cond.songPositionInBeats;
switch (currentState)
{
case State.None:
break;
case State.Entering:
pos = GetPathPositionFromBeat(enterPath, Math.Max(beat, startBeat), startBeat);
break;
case State.Hit:
pos = GetPathPositionFromBeat(hitPath, Math.Max(beat, startBeat), startBeat);
if (beat >= startBeat + 1)
{
Destroy(gameObject);
}
break;
case State.Miss:
pos = GetPathPositionFromBeat(missPath, Math.Max(beat, startBeat), startBeat);
if (beat >= startBeat + 1)
{
Destroy(gameObject);
}
break;
case State.Weak:
pos = GetPathPositionFromBeat(weakPath, Math.Max(beat, startBeat), startBeat);
if (beat >= startBeat + 1)
{
Destroy(gameObject);
}
break;
case State.Barely:
pos = GetPathPositionFromBeat(barelyPath, Math.Max(beat, startBeat), startBeat);
if (beat >= startBeat + 2)
{
Destroy(gameObject);
}
break;
}
transform.position = pos;
}
}
transform.position = secondCurve.GetPoint(flyPos);
if (flyPos > 1f) if (deletingAutomatically) GameObject.Destroy(gameObject);
private void Just(PlayerActionEvent caller, float state)
{
wrongInput.Disable();
double beat = Conductor.instance.songPositionInBeats;
startBeat = beat;
game.playerImpact.SetActive(true);
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.1f, delegate { game.playerImpact.SetActive(false); }),
});
if (state >= 1f || state <= -1f)
{
currentState = State.Barely;
if (big)
{
SoundByte.PlayOneShotGame("workingDough/BigBarely");
game.doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
}
else
{
SoundByte.PlayOneShotGame("workingDough/SmallBarely");
game.doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
}
Update();
return;
}
currentState = State.Hit;
if (big)
{
SoundByte.PlayOneShotGame("workingDough/rightBig");
game.doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
game.backgroundAnimator.Play("BackgroundFlash", 0, 0);
}
else
{
flyPos = cond.GetPositionFromBeat(startBeat, firstBeatsToTravel);
transform.position = firstCurve.GetPoint(flyPos);
if (flyPos > 1f) goingDown = true;
SoundByte.PlayOneShotGame("workingDough/rightSmall");
game.doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
}
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.9f, delegate { game.arrowSRRightPlayer.sprite = game.redArrowSprite; }),
new BeatAction.Action(beat + 1f, delegate { game.arrowSRRightPlayer.sprite = game.whiteArrowSprite; }),
new BeatAction.Action(beat + 2f, delegate { game.SpawnBGBall(beat + 2f, big); }),
});
Update();
}
private void WrongInput(PlayerActionEvent caller, float state)
{
double beat = Conductor.instance.songPositionInBeats;
rightInput.Disable();
game.playerImpact.SetActive(true);
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.1f, delegate { game.playerImpact.SetActive(false); }),
});
if (big)
{
currentState = State.Weak;
startBeat = beat;
game.doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
SoundByte.PlayOneShotGame("workingDough/BigBallTooWeak");
Update();
}
else
{
GameObject.Instantiate(game.breakParticleEffect, game.breakParticleHolder);
game.doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
SoundByte.PlayOneShotGame("workingDough/BreakBall");
Destroy(gameObject);
}
}
private void Miss(PlayerActionEvent caller)
{
double beat = caller.timer + caller.startBeat;
currentState = State.Miss;
startBeat = beat;
Update();
BeatAction.New(game.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.25f, delegate { game.missImpact.SetActive(true); }),
new BeatAction.Action(beat + 0.25f, delegate { SoundByte.PlayOneShotGame("workingDough/BallMiss"); }),
new BeatAction.Action(beat + 0.35f, delegate { game.missImpact.SetActive(false); }),
});
}
private void Empty(PlayerActionEvent caller) { }
}
}

View File

@ -102,9 +102,7 @@ namespace HeavenStudio.Games.Loaders
namespace HeavenStudio.Games
{
using HeavenStudio.Games.Scripts_DoubleDate;
using Scripts_WorkingDough;
using System.Net.Sockets;
public class WorkingDough : Minigame
{
@ -116,22 +114,22 @@ namespace HeavenStudio.Games
[SerializeField] GameObject ballTransporterRightPlayer; //Close and open animations
[SerializeField] GameObject ballTransporterLeftPlayer; //Close and open animations
[SerializeField] GameObject npcImpact;
[SerializeField] GameObject playerImpact;
public GameObject playerImpact;
[SerializeField] GameObject smallBallNPC;
[SerializeField] GameObject bigBallNPC;
[SerializeField] Transform ballHolder;
[SerializeField] SpriteRenderer arrowSRLeftNPC;
[SerializeField] SpriteRenderer arrowSRRightNPC;
[SerializeField] SpriteRenderer arrowSRLeftPlayer;
[SerializeField] SpriteRenderer arrowSRRightPlayer;
public SpriteRenderer arrowSRRightPlayer;
[SerializeField] GameObject NPCBallTransporters;
[SerializeField] GameObject PlayerBallTransporters;
[SerializeField] GameObject playerEnterSmallBall;
[SerializeField] GameObject playerEnterBigBall;
[SerializeField] GameObject missImpact;
[SerializeField] Transform breakParticleHolder;
[SerializeField] GameObject breakParticleEffect;
[SerializeField] Animator backgroundAnimator;
public GameObject missImpact;
public Transform breakParticleHolder;
public GameObject breakParticleEffect;
public Animator backgroundAnimator;
[SerializeField] Animator conveyerAnimator;
[SerializeField] GameObject smallBGBall;
[SerializeField] GameObject bigBGBall;
@ -164,8 +162,6 @@ namespace HeavenStudio.Games
public double beat;
public float interval;
}
private List<GameObject> currentBalls = new List<GameObject>();
public bool shouldMiss = true;
public bool spaceshipRisen = false;
public bool spaceshipRising = false;
bool liftingDoughDudes;
@ -176,16 +172,6 @@ namespace HeavenStudio.Games
string gandwMovingAnimName;
[Header("Curves")]
public BezierCurve3D playerEnterUpCurve;
public BezierCurve3D playerEnterDownCurve;
public BezierCurve3D playerExitUpCurve;
public BezierCurve3D playerExitDownCurve;
public BezierCurve3D playerMissCurveFirst;
public BezierCurve3D playerMissCurveSecond;
public BezierCurve3D playerBarelyCurveFirst;
public BezierCurve3D playerBarelyCurveSecond;
public BezierCurve3D playerWrongInputTooWeakFirstCurve;
public BezierCurve3D playerWrongInputTooWeakSecondCurve;
[SerializeField] SuperCurveObject.Path[] ballBouncePaths;
new void OnDrawGizmos()
{
@ -223,7 +209,6 @@ namespace HeavenStudio.Games
void Start()
{
shouldMiss = true;
ballTriggerSetInterval = true;
conveyerAnimator.Play("ConveyerBelt", 0, 0);
doughDudesHolderAnim.Play("OnGround", 0, 0);
@ -401,11 +386,8 @@ namespace HeavenStudio.Games
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);
var ballComponent = spawnedBall.GetComponent<PlayerEnterDoughBall>();
ballComponent.startBeat = beat;
ballComponent.firstCurve = playerEnterUpCurve;
ballComponent.secondCurve = playerEnterDownCurve;
ballComponent.deletingAutomatically = false;
currentBalls.Add(spawnedBall);
spawnedBall.SetActive(true);
ballComponent.Init(beat, isBig);
if (isBig && !bigModePlayer)
{
@ -413,42 +395,13 @@ namespace HeavenStudio.Games
bigModePlayer = true;
}
//shouldMiss = true;
if (isBig)
{
ScheduleInput(beat, 1, InputType.STANDARD_ALT_DOWN, JustBig, MissBig, Nothing);
ScheduleUserInput(beat, 1, InputType.STANDARD_DOWN, WrongInputBig, Nothing, Nothing);
}
else
{
ScheduleInput(beat, 1, InputType.STANDARD_DOWN, JustSmall, MissSmall, Nothing);
ScheduleUserInput(beat, 1, InputType.STANDARD_ALT_DOWN, WrongInputSmall, Nothing, Nothing);
}
BeatAction.New(doughDudesPlayer, new List<BeatAction.Action>()
{
new BeatAction.Action(beat, delegate { spawnedBall.SetActive(true); }),
new BeatAction.Action(beat, delegate { arrowSRLeftPlayer.sprite = redArrowSprite; }),
new BeatAction.Action(beat + 0.1f, delegate { arrowSRLeftPlayer.sprite = whiteArrowSprite; }),
});
}
public void SpawnPlayerBallResult(double beat, bool isBig, BezierCurve3D firstCurve, BezierCurve3D secondCurve, float firstBeatsToTravel, float secondBeatsToTravel)
{
var objectToSpawn = isBig ? playerEnterBigBall : playerEnterSmallBall;
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);
var ballComponent = spawnedBall.GetComponent<PlayerEnterDoughBall>();
ballComponent.startBeat = beat;
ballComponent.firstCurve = firstCurve;
ballComponent.secondCurve = secondCurve;
ballComponent.firstBeatsToTravel = firstBeatsToTravel;
ballComponent.secondBeatsToTravel = secondBeatsToTravel;
spawnedBall.SetActive(true);
}
public static void PreSetIntervalStart(double beat, float interval)
{
beat -= 1f;
@ -556,170 +509,7 @@ namespace HeavenStudio.Games
}
}
void WrongInputBig(PlayerActionEvent caller, float state)
{
double beat = caller.startBeat + caller.timer;
shouldMiss = false;
if (currentBalls.Count > 0)
{
GameObject currentBall = currentBalls[0];
currentBalls.Remove(currentBall);
GameObject.Destroy(currentBall);
}
doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
SoundByte.PlayOneShotGame("workingDough/BigBallTooWeak");
SpawnPlayerBallResult(beat, true, playerWrongInputTooWeakFirstCurve, playerWrongInputTooWeakSecondCurve, 0.5f, 1f);
playerImpact.SetActive(true);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.1f, delegate { playerImpact.SetActive(false); }),
});
}
void WrongInputSmall(PlayerActionEvent caller, float state)
{
double beat = caller.startBeat + caller.timer;
shouldMiss = false;
if (currentBalls.Count > 0)
{
GameObject currentBall = currentBalls[0];
currentBalls.Remove(currentBall);
GameObject.Destroy(currentBall);
}
GameObject.Instantiate(breakParticleEffect, breakParticleHolder);
doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
SoundByte.PlayOneShotGame("workingDough/BreakBall");
playerImpact.SetActive(true);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.1f, delegate { playerImpact.SetActive(false); }),
});
}
void MissBig(PlayerActionEvent caller)
{
if (!shouldMiss)
{
shouldMiss = true;
return;
}
if (currentBalls.Count > 0)
{
GameObject currentBall = currentBalls[0];
currentBalls.Remove(currentBall);
GameObject.Destroy(currentBall);
}
double beat = caller.startBeat + caller.timer;
SpawnPlayerBallResult(beat, true, playerMissCurveFirst, playerMissCurveSecond, 0.25f, 0.75f);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.25f, delegate { missImpact.SetActive(true); }),
new BeatAction.Action(beat + 0.25f, delegate { SoundByte.PlayOneShotGame("workingDough/BallMiss"); }),
new BeatAction.Action(beat + 0.35f, delegate { missImpact.SetActive(false); }),
});
}
void MissSmall(PlayerActionEvent caller)
{
if (!shouldMiss)
{
shouldMiss = true;
return;
}
if (currentBalls.Count > 0)
{
GameObject currentBall = currentBalls[0];
currentBalls.Remove(currentBall);
GameObject.Destroy(currentBall);
}
double beat = caller.startBeat + caller.timer;
SpawnPlayerBallResult(beat, false, playerMissCurveFirst, playerMissCurveSecond, 0.25f, 0.75f);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.25f, delegate { missImpact.SetActive(true); }),
new BeatAction.Action(beat + 0.25f, delegate { SoundByte.PlayOneShotGame("workingDough/BallMiss"); }),
new BeatAction.Action(beat + 0.35f, delegate { missImpact.SetActive(false); }),
});
}
void JustSmall(PlayerActionEvent caller, float state)
{
if (GameManager.instance.currentGame != "workingDough") return;
double beat = caller.startBeat + caller.timer;
if (currentBalls.Count > 0)
{
GameObject currentBall = currentBalls[0];
currentBalls.Remove(currentBall);
GameObject.Destroy(currentBall);
}
if (state >= 1f || state <= -1f)
{
SoundByte.PlayOneShotGame("workingDough/SmallBarely");
doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
playerImpact.SetActive(true);
SpawnPlayerBallResult(beat, false, playerBarelyCurveFirst, playerBarelyCurveSecond, 0.75f, 1f);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.1f, delegate { playerImpact.SetActive(false); }),
});
return;
}
Success(false, beat);
}
void JustBig(PlayerActionEvent caller, float state)
{
if (GameManager.instance.currentGame != "workingDough") return;
double beat = caller.startBeat + caller.timer;
if (currentBalls.Count > 0)
{
GameObject currentBall = currentBalls[0];
currentBalls.Remove(currentBall);
GameObject.Destroy(currentBall);
}
if (state >= 1f || state <= -1f)
{
SoundByte.PlayOneShotGame("workingDough/BigBarely");
doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
playerImpact.SetActive(true);
SpawnPlayerBallResult(beat, true, playerBarelyCurveFirst, playerBarelyCurveSecond, 0.75f, 1f);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.1f, delegate { playerImpact.SetActive(false); }),
});
return;
}
Success(true, beat);
}
void Success(bool isBig, double beat)
{
if (isBig)
{
SoundByte.PlayOneShotGame("workingDough/rightBig");
doughDudesPlayer.GetComponent<Animator>().Play("BigDoughJump", 0, 0);
backgroundAnimator.Play("BackgroundFlash", 0, 0);
}
else
{
SoundByte.PlayOneShotGame("workingDough/rightSmall");
doughDudesPlayer.GetComponent<Animator>().Play("SmallDoughJump", 0, 0);
}
playerImpact.SetActive(true);
SpawnPlayerBallResult(beat, isBig, playerExitUpCurve, playerExitDownCurve, 0.5f, 0.5f);
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + 0.1f, delegate { playerImpact.SetActive(false); }),
new BeatAction.Action(beat + 0.9f, delegate { arrowSRRightPlayer.sprite = redArrowSprite; }),
new BeatAction.Action(beat + 1f, delegate { arrowSRRightPlayer.sprite = whiteArrowSprite; }),
new BeatAction.Action(beat + 2f, delegate { SpawnBGBall(beat + 2f, isBig); }),
});
}
void SpawnBGBall(double beat, bool isBig)
public void SpawnBGBall(double beat, bool isBig)
{
var objectToSpawn = isBig ? bigBGBall : smallBGBall;
var spawnedBall = GameObject.Instantiate(objectToSpawn, ballHolder);

View File

@ -1,5 +1,5 @@
ManifestFileVersion: 0
CRC: 1415167567
CRC: 1948290001
AssetBundleManifest:
AssetBundleInfos:
Info_0:

View File

@ -1,12 +1,12 @@
ManifestFileVersion: 0
CRC: 3596492217
CRC: 2220090338
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 26fc96c0b54cb5ee3474b9ad21d4b9e0
Hash: 06d5394e1d51faa84944419ebe2ca495
TypeTreeHash:
serializedVersion: 2
Hash: 3668fa81f90fca9e5e9f534bf7badde8
Hash: 7188f40e1d00b452805d78c9f260c8d4
HashAppended: 0
ClassTypes:
- Class: 1
@ -29,12 +29,8 @@ ClassTypes:
Script: {instanceID: 0}
- Class: 95
Script: {instanceID: 0}
- Class: 114
Script: {fileID: 11500000, guid: 066a41e004f415b4eb74d5e61a2aadbe, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: f589a35cd43c5a146b78729182754157, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: b0cca3244f403c24f819a870f31cdc29, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 90b8363d14ba26043977a371000195e9, type: 3}
- Class: 114