mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-26 03:25:22 +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>
146 lines
5.1 KiB
C#
146 lines
5.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using HeavenStudio.Util;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace HeavenStudio.Games.Scripts_AgbNightWalk
|
|
{
|
|
public class AgbStarHandler : MonoBehaviour
|
|
{
|
|
[SerializeField] private AgbStar starRef;
|
|
|
|
public float boundaryX = 10;
|
|
public float boundaryY = 10;
|
|
|
|
[SerializeField] private int starCount = 45;
|
|
[SerializeField] private double blinkFrequency = 0.125;
|
|
[SerializeField] private int blinkAmount = 5;
|
|
|
|
[NonSerialized] public float normalizedX;
|
|
[NonSerialized] public float normalizedY;
|
|
|
|
private AgbStar[] currentStars;
|
|
private int collectiveEvoStage = 1;
|
|
private GameEvent blinkEvent = new GameEvent();
|
|
private float halfScreenBoundaryX = 17.77695f / 2;
|
|
|
|
private void Awake()
|
|
{
|
|
currentStars = new AgbStar[starCount];
|
|
for (int i = 0; i < starCount; i++)
|
|
{
|
|
AgbStar spawnedStar = Instantiate(starRef, transform);
|
|
float xPos = UnityEngine.Random.Range(-boundaryX, boundaryX);
|
|
float yPos = UnityEngine.Random.Range(-boundaryY, boundaryY);
|
|
spawnedStar.Init(xPos, yPos, this);
|
|
currentStars[i] = spawnedStar;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
var cond = Conductor.instance;
|
|
|
|
if (cond.isPlaying && !cond.isPaused)
|
|
{
|
|
if (ReportBlinkBeat(ref blinkEvent.lastReportedBeat))
|
|
{
|
|
Blink();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Blink()
|
|
{
|
|
List<AgbStar> alreadyBlinked = new List<AgbStar>();
|
|
for (int i = 0; i < blinkAmount; i++)
|
|
{
|
|
AgbStar blinkedStar = currentStars[UnityEngine.Random.Range(0, currentStars.Length)];
|
|
if (alreadyBlinked.Count > 0 && alreadyBlinked.Contains(blinkedStar)) continue;
|
|
blinkedStar.Blink();
|
|
alreadyBlinked.Add(blinkedStar);
|
|
}
|
|
}
|
|
|
|
public void Evolve(int amount)
|
|
{
|
|
for (int i = 0; i < amount; i++)
|
|
{
|
|
List<AgbStar> nonEvolvedStars = currentStars.ToList().FindAll(x => x.evoStage == collectiveEvoStage);
|
|
List<AgbStar> onScreenStars = nonEvolvedStars.FindAll(x => x.transform.localPosition.x <= halfScreenBoundaryX && x.transform.localPosition.x >= -halfScreenBoundaryX && x.transform.localPosition.y <= 5 && x.transform.localPosition.y >= -5);
|
|
//Debug.Log("OnScreen: " + onScreenStars.Count + " nonEvolved: " + nonEvolvedStars.Count);
|
|
if (onScreenStars.Count > 0)
|
|
{
|
|
AgbStar randomStar = onScreenStars[UnityEngine.Random.Range(0, onScreenStars.Count)];
|
|
randomStar.Evolve();
|
|
}
|
|
else if (nonEvolvedStars.Count > 0)
|
|
{
|
|
AgbStar randomStar = nonEvolvedStars[UnityEngine.Random.Range(0, nonEvolvedStars.Count)];
|
|
randomStar.Evolve();
|
|
}
|
|
else
|
|
{
|
|
collectiveEvoStage++;
|
|
if (collectiveEvoStage > 5) collectiveEvoStage = 5;
|
|
currentStars[UnityEngine.Random.Range(0, currentStars.Length)].Evolve();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Devolve()
|
|
{
|
|
foreach (var star in currentStars)
|
|
{
|
|
star.Devolve();
|
|
}
|
|
}
|
|
|
|
public Vector3 GetRelativePosition(ref float ogX, ref float ogY)
|
|
{
|
|
float x = Mathf.LerpUnclamped(0, boundaryX, normalizedX) + ogX;
|
|
if (x > boundaryX)
|
|
{
|
|
ogX -= boundaryX * 2;
|
|
x = Mathf.LerpUnclamped(0, boundaryX, normalizedX) + ogX;
|
|
}
|
|
else if (x < -boundaryX)
|
|
{
|
|
ogX += boundaryX * 2;
|
|
x = Mathf.LerpUnclamped(0, boundaryX, normalizedX) + ogX;
|
|
}
|
|
float y = Mathf.LerpUnclamped(0, boundaryY, normalizedY) + ogY;
|
|
if (y > boundaryY)
|
|
{
|
|
ogY -= boundaryY * 2;
|
|
y = Mathf.LerpUnclamped(0, boundaryY, normalizedY) + ogY;
|
|
}
|
|
else if (y < -boundaryY)
|
|
{
|
|
ogY += boundaryY * 2;
|
|
y = Mathf.LerpUnclamped(0, boundaryY, normalizedY) + ogY;
|
|
}
|
|
return new Vector3(x, y);
|
|
}
|
|
|
|
private void OnDrawGizmos()
|
|
{
|
|
Gizmos.color = Color.blue;
|
|
Gizmos.DrawWireCube(Vector3.zero, new Vector3(boundaryX * 2, boundaryY * 2, 0));
|
|
}
|
|
|
|
private bool ReportBlinkBeat(ref double lastReportedBeat)
|
|
{
|
|
var cond = Conductor.instance;
|
|
bool result = cond.songPositionInBeats >= (lastReportedBeat) + blinkFrequency;
|
|
if (result)
|
|
{
|
|
lastReportedBeat += blinkFrequency;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|