mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
98233e174d
* Nightwalks set up * Play yan with balloons * platformSetUp * Platform handler fundamentals * Count In Added * small thing * Got em inputs in nightwalk gba to work * Platforms now spawn when there's no count-in * He jumps now! * Decreased platform count * Height changes added * Randomness for height changes * Name changing * Fixed a bug with no count in blocks * Ok height changes should be flawless now * No jumping added * Umbrella and lollipop added * Umbrella drum pattern added * Fallyan :( * Implemented falling :( * Fixed drum patterns not working * Fish implemented * Fixed kick sound being weird * 4 beat count in added * Tweaked landing pos * Walking Count-In added * new sprites touched up anims * oops1 * barely anims * Implemented barelies into nightwalk gba * Balloons have random positioning now * New sounds and whiff/barely sounds * Fall smear added * Fixed issues with platform heights on gameswitches * 24 platforms * walk is normalized now * Star scrolling functionality done * Blink animations n stuff * STARS BLINK NOW * Force evolve added + tweaks * Fixed stars not stopping + upped amount of stars * End event setup * Finding end blocks logic added * end event functionality finished * end platform anim * fixed anim * only stars on screen evolve * 2 evolve by default * End event fixes * more blinking * star blinks now and has string * minor tweak * fix to interaction between fish and end block * tweaked dropdown values * removed fish sound * named some sprites in the spritesheet * high jump and roll anims * Roll sound should only play if valid * Small fix to roll cue sound logic * Another small fix to roll cue sound logic * ok actually fixed roll sound * roll platform added to jumpl platform prefab * Roll cue platform visuals done * Basic Roll Cue implemented * flower * umbrella * barely for roll release * OOPS * smol fixes * fixed visual stuff and added missing to rolls * redid sheet, new anims * slow walkin' * adjustments * oops * adjusted smear * improved interaction between roll and end block * improved interaction between roll cue and platform heights * 32 stars * made the star boundary way smaller * how was i this stupid * fixed more interactions * stack proof roll cue and also end block + roll cue fix * Fixed things related to stars * fixed no jumping not working with end block + roll * nearing the final stages * rolls counts for 2 jumps now * fixed a bug to do with roll platforms and made roll platform sounds not be able to be played on invalid beats * made stage 2 stars bigger * added destroy roll platform sprites * update to new systems --------- Co-authored-by: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Co-authored-by: minenice55 <star.elementa@gmail.com>
251 lines
10 KiB
C#
251 lines
10 KiB
C#
using HeavenStudio.Util;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace HeavenStudio.Games.Scripts_AgbNightWalk
|
|
{
|
|
public class AgbPlayYan : SuperCurveObject
|
|
{
|
|
private enum JumpingState
|
|
{
|
|
Flying,
|
|
Walking,
|
|
Jumping,
|
|
Shocked,
|
|
Falling,
|
|
Whiffing,
|
|
Floating,
|
|
Rolling,
|
|
HighJumping,
|
|
JumpingFall,
|
|
HighJumpingFall
|
|
}
|
|
private JumpingState jumpingState;
|
|
private AgbNightWalk game;
|
|
private double jumpBeat;
|
|
[SerializeField] private List<Animator> balloons = new List<Animator>();
|
|
[SerializeField] private Animator star;
|
|
private Path jumpPath;
|
|
private Path whiffPath;
|
|
private Path highJumpPath;
|
|
private Animator anim;
|
|
private float fallStartY;
|
|
private double playYanFallBeat;
|
|
private double walkBeat;
|
|
[SerializeField] private float randomMinBalloonX = -0.45f;
|
|
[SerializeField] private float randomMaxBalloonX = 0.45f;
|
|
[SerializeField] private Transform spriteTrans; //for rolling rotation
|
|
|
|
private void Awake()
|
|
{
|
|
game = AgbNightWalk.instance;
|
|
jumpPath = game.GetPath("Jump");
|
|
whiffPath = game.GetPath("Whiff");
|
|
highJumpPath = game.GetPath("highJump");
|
|
anim = GetComponent<Animator>();
|
|
foreach (var balloon in balloons)
|
|
{
|
|
balloon.Play("Idle", 0, UnityEngine.Random.Range(0f, 1f));
|
|
Transform balloonTrans = balloon.transform.parent;
|
|
balloonTrans.localPosition = new Vector3(balloonTrans.localPosition.x + UnityEngine.Random.Range(randomMinBalloonX, randomMaxBalloonX), balloonTrans.localPosition.y);
|
|
}
|
|
}
|
|
bool hasFallen;
|
|
private void Update()
|
|
{
|
|
var cond = Conductor.instance;
|
|
if (cond.isPlaying && !cond.isPaused)
|
|
{
|
|
switch (jumpingState)
|
|
{
|
|
case JumpingState.Jumping:
|
|
Vector3 pos = GetPathPositionFromBeat(jumpPath, Math.Min(jumpBeat + jumpPath.positions[0].duration, cond.songPositionInBeatsAsDouble), jumpBeat);
|
|
transform.localPosition = pos;
|
|
float normalizedBeat = cond.GetPositionFromBeat(jumpBeat, jumpPath.positions[0].duration);
|
|
if (normalizedBeat >= 1f)
|
|
{
|
|
Walk();
|
|
}
|
|
break;
|
|
case JumpingState.JumpingFall:
|
|
Vector3 posf = GetPathPositionFromBeat(jumpPath, cond.songPositionInBeatsAsDouble, jumpBeat);
|
|
transform.localPosition = posf;
|
|
float normalizedBeatf = cond.GetPositionFromBeat(jumpBeat, jumpPath.positions[0].duration);
|
|
if (normalizedBeatf >= 1f && !hasFallen)
|
|
{
|
|
hasFallen = true;
|
|
SoundByte.PlayOneShotGame("nightWalkAgb/fall");
|
|
}
|
|
break;
|
|
case JumpingState.Walking:
|
|
transform.localPosition = Vector3.zero;
|
|
anim.DoScaledAnimation("Walk", walkBeat, 0.5f, 0.35f);
|
|
if (PlayerInput.GetIsAction(Minigame.InputAction_BasicPress) && !game.IsExpectingInputNow(Minigame.InputAction_BasicPress))
|
|
{
|
|
Whiff(cond.songPositionInBeatsAsDouble);
|
|
}
|
|
break;
|
|
case JumpingState.Flying:
|
|
transform.localPosition = Vector3.zero;
|
|
break;
|
|
case JumpingState.Shocked:
|
|
break;
|
|
case JumpingState.Falling:
|
|
float normalizedFallBeat = cond.GetPositionFromBeat(playYanFallBeat, 2);
|
|
EasingFunction.Function func = EasingFunction.GetEasingFunction(EasingFunction.Ease.EaseInQuad);
|
|
float newPlayYanY = func(fallStartY, -12, normalizedFallBeat);
|
|
transform.localPosition = new Vector3(0, newPlayYanY);
|
|
break;
|
|
case JumpingState.Whiffing:
|
|
Vector3 pos2 = GetPathPositionFromBeat(whiffPath, Math.Min(jumpBeat + 0.5, cond.songPositionInBeatsAsDouble), jumpBeat);
|
|
transform.localPosition = pos2;
|
|
float normalizedBeat2 = cond.GetPositionFromBeat(jumpBeat, 0.5);
|
|
if (normalizedBeat2 >= 1f)
|
|
{
|
|
Walk();
|
|
}
|
|
break;
|
|
case JumpingState.Floating:
|
|
float normalizedFloatBeat = cond.GetPositionFromBeat(playYanFallBeat, 10);
|
|
EasingFunction.Function funcF = EasingFunction.GetEasingFunction(EasingFunction.Ease.Linear);
|
|
float newPlayYanYF = funcF(fallStartY, 12, normalizedFloatBeat);
|
|
transform.localPosition = new Vector3(0, newPlayYanYF);
|
|
break;
|
|
case JumpingState.Rolling:
|
|
float normalizedRoll = cond.GetPositionFromBeat(jumpBeat, 0.5f);
|
|
float newRot = Mathf.LerpUnclamped(0, -360, normalizedRoll);
|
|
spriteTrans.localEulerAngles = new Vector3(0, 0, newRot);
|
|
break;
|
|
case JumpingState.HighJumping:
|
|
Vector3 posH = GetPathPositionFromBeat(highJumpPath, Math.Min(jumpBeat + highJumpPath.positions[0].duration, cond.songPositionInBeatsAsDouble), jumpBeat);
|
|
transform.localPosition = posH;
|
|
float normalizedBeatH = cond.GetPositionFromBeat(jumpBeat, highJumpPath.positions[0].duration);
|
|
if (normalizedBeatH >= 1f)
|
|
{
|
|
Walk();
|
|
}
|
|
break;
|
|
case JumpingState.HighJumpingFall:
|
|
Vector3 posHf = GetPathPositionFromBeat(highJumpPath, cond.songPositionInBeatsAsDouble, jumpBeat);
|
|
transform.localPosition = posHf;
|
|
float normalizedBeatHf = cond.GetPositionFromBeat(jumpBeat, highJumpPath.positions[0].duration);
|
|
if (normalizedBeatHf >= 1f && !hasFallen)
|
|
{
|
|
hasFallen = true;
|
|
SoundByte.PlayOneShotGame("nightWalkAgb/fall");
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Shock(bool roll = false)
|
|
{
|
|
jumpingState = JumpingState.Shocked;
|
|
anim.DoScaledAnimationAsync(roll ? "RollShock" : "Shock", 0.5f);
|
|
SoundByte.PlayOneShotGame("nightWalkAgb/shock");
|
|
spriteTrans.localEulerAngles = Vector3.zero;
|
|
}
|
|
|
|
public void Fall(double beat)
|
|
{
|
|
jumpingState = JumpingState.Falling;
|
|
anim.Play("Jump", 0, 0);
|
|
playYanFallBeat = beat;
|
|
fallStartY = transform.localPosition.y;
|
|
SoundByte.PlayOneShotGame("nightWalkAgb/fall");
|
|
spriteTrans.localEulerAngles = Vector3.zero;
|
|
Update();
|
|
}
|
|
|
|
public void Float(double beat)
|
|
{
|
|
jumpingState = JumpingState.Floating;
|
|
anim.Play("Jump", 0, 0);
|
|
playYanFallBeat = beat;
|
|
fallStartY = transform.localPosition.y;
|
|
star.gameObject.SetActive(true);
|
|
StarBlink();
|
|
spriteTrans.localEulerAngles = Vector3.zero;
|
|
Update();
|
|
}
|
|
|
|
private void StarBlink()
|
|
{
|
|
if (UnityEngine.Random.Range(1, 3) == 1) star.DoScaledAnimationAsync("Blink", 0.5f);
|
|
Invoke("StarBlink", UnityEngine.Random.Range(0.1f, 0.3f));
|
|
}
|
|
public void Jump(double beat, bool fall = false)
|
|
{
|
|
jumpingState = fall ? JumpingState.JumpingFall : JumpingState.Jumping;
|
|
jumpBeat = beat;
|
|
anim.Play("Jump", 0, 0);
|
|
spriteTrans.localEulerAngles = Vector3.zero;
|
|
jumpPath.positions[0].duration = 1 - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(jumpBeat));
|
|
Update();
|
|
}
|
|
|
|
public void HighJump(double beat, bool fall = false, bool barely = false)
|
|
{
|
|
jumpingState = fall ? JumpingState.HighJumpingFall : JumpingState.HighJumping;
|
|
jumpBeat = beat;
|
|
anim.DoScaledAnimationAsync("HighJump", 0.5f);
|
|
spriteTrans.localEulerAngles = Vector3.zero;
|
|
highJumpPath.positions[0].duration = 1.5f - (float)Conductor.instance.SecsToBeats(Minigame.justEarlyTime, Conductor.instance.GetBpmAtBeat(jumpBeat));
|
|
highJumpPath.positions[0].height = barely ? 3.5f : 4.5f;
|
|
Update();
|
|
}
|
|
|
|
public void Roll(double beat)
|
|
{
|
|
jumpingState = JumpingState.Rolling;
|
|
jumpBeat = beat;
|
|
anim.DoScaledAnimationAsync("Roll", 0.5f);
|
|
Update();
|
|
}
|
|
|
|
public void Whiff(double beat)
|
|
{
|
|
jumpingState = JumpingState.Whiffing;
|
|
jumpBeat = beat;
|
|
anim.Play("Jump", 0, 0);
|
|
SoundByte.PlayOneShotGame("nightWalkAgb/whiff");
|
|
spriteTrans.localEulerAngles = Vector3.zero;
|
|
Update();
|
|
}
|
|
|
|
public void Walk()
|
|
{
|
|
if (jumpingState == JumpingState.Walking) return;
|
|
jumpingState = JumpingState.Walking;
|
|
walkBeat = Conductor.instance.songPositionInBeats;
|
|
spriteTrans.localEulerAngles = Vector3.zero;
|
|
}
|
|
public void PopBalloon(int index, bool instant)
|
|
{
|
|
if (instant)
|
|
{
|
|
balloons[index].DoNormalizedAnimation("Pop", 1);
|
|
return;
|
|
}
|
|
balloons[index].DoScaledAnimationAsync("Pop", 0.5f);
|
|
}
|
|
|
|
public void PopAll()
|
|
{
|
|
foreach (var balloon in balloons)
|
|
{
|
|
balloon.DoNormalizedAnimation("Pop", 1);
|
|
}
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
anim.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
|