HeavenStudioPlus/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs
Rapandrasmus 19973638a2 Monkey watch (#555)
* basic setup+inputs

this is gonna be so annoying to optimize
i am SO overwhelmed with the options that i have
object pooling, disabling the monkeys, literally just placing them manually... idk.

* custom monkeys + more setup stuff

it's all coming together .

* a few tweaks

committing to update the spritesheet

* hi ev

* player stuff

* player anims

* particles

* more of prefab

* upscale for this sheet

* prefab more

* oops

* anims n stuff

* assign the stuff, a little bit of rotation

* better sheet

* balloon sheet

* particles

* Revert "particles"

This reverts commit fe4d589731a3ceacc7d80b7fde520f87b1c6e745.

* Revert "Revert "particles""

This reverts commit ce117b280d4bd7400bd40260f4d858f2d5fba9e3.

* fixed the watch outline + pink monkey prefab variant

the bccad really is a life saver

* anims for monkeys

* convert to dictionary

yippee for dictionaries
* better camera
* click animations are all done
* custom monkeys are actually good now :)
* prefab adjustments

* oopps2

* tweaked particles

* inactive monkeys/custom monkeys + prefab fixes

they should work perfectly now, and the prefab should also need no further adjustment
hopefully...

* many animations

* click fixes

* the prefab needed One more adjustment

* oops again

hopefully the shadow is good now

* sheet adjustment

* all yellow anims done

* progress.

starting on the monkeys appear block rn, and then i'll work on the monkey spawning logic. honestly should be pretty easy (and i DON'T think this will be something i look back on as if i was crazy 😄 )

* open / close hole

* monkey spawning working better

* pink monkey anims

* clean slate

* gonna test something

* proper camera

* Camera movements done

* pink monkey sounds and a small bug fix

* clock arrow now moves

* gettin ready to spawn el monkeys

* monkeys should spawn now ig

* bug fixes

* oops

* monkeys appear added

* more fixes yahoo

* shadow tweak

* bug fixes

* zoom out beginnings

* hour more smooth

* smooth minute too

* it now zooms out lol

* middle monkey

* oopsie doopsie

* hot air balloon

* oops

* anim

* disappear fix

* ticks on input now

* prepare earlier

* tiny tweak

* oops again

* fixed the input bug

* holes

* middle monkey anims

* fixed layering

* zoom out tweaks and shadow movement

* camera tweak

* tweaks

* quad

* camera tweak

* quart

* inspcetor

* shadow correct

* Okay

* zoom out seperation

* instant

* balloon movement

* balloon fixed

* fixed particle

* icon

* fixed beataction parameters

* monkey watch camera refactor

run sourcegen

---------

Co-authored-by: AstrlJelly <bdlawson115@gmail.com>
Co-authored-by: ev <85412919+evdial@users.noreply.github.com>
Co-authored-by: minenice55 <star.elementa@gmail.com>
2024-01-29 03:04:19 +00:00

90 lines
2.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using UnityEngine.Rendering;
namespace HeavenStudio.Games.Scripts_MonkeyWatch
{
public class WatchMonkeyHandler : MonoBehaviour
{
[Header("Components")]
[SerializeField] private WatchMonkey yellowMonkeyRef;
[SerializeField] private WatchMonkey pinkMonkeyRef;
[Header("Properties")]
[SerializeField] private int maxMonkeys = 30;
private MonkeyWatch game;
private int startMinute = 0;
private int watchHoleIndex = 0;
private List<Transform> watchHoles = new();
private List<WatchMonkey> currentMonkeys = new();
private void Awake()
{
game = MonkeyWatch.instance;
for (int i = 0; i < 60; i++)
{
watchHoles.Add(transform.GetChild(i));
}
}
public void Init(int minute)
{
startMinute = minute;
watchHoleIndex = startMinute;
}
private Transform GetNextAvailableWatchHole()
{
int currentIndex = watchHoleIndex;
watchHoleIndex++;
if (watchHoleIndex >= watchHoles.Count)
{
watchHoleIndex = 0;
}
return watchHoles[currentIndex];
}
public void SpawnMonkey(double beat, bool isPink, bool instant)
{
if (GetMonkeyAtBeat(beat) != null) return;
int index = watchHoleIndex;
var hole = GetNextAvailableWatchHole();
WatchMonkey spawnedMonkey = Instantiate(isPink ? pinkMonkeyRef : yellowMonkeyRef, hole);
spawnedMonkey.Appear(beat, instant, hole.GetComponent<Animator>(), GetMonkeyAngle(index));
spawnedMonkey.transform.eulerAngles = Vector3.zero;
var sortingGroup = spawnedMonkey.GetComponent<SortingGroup>();
if (index <= 30) sortingGroup.sortingOrder = 50 + watchHoleIndex;
else sortingGroup.sortingOrder = 50 + watchHoleIndex - (watchHoleIndex - 29);
currentMonkeys.Add(spawnedMonkey);
if (currentMonkeys.Count > maxMonkeys)
{
currentMonkeys[0].Disappear(Conductor.instance.songPositionInBeats);
currentMonkeys.Remove(currentMonkeys[0]);
}
}
public WatchMonkey GetMonkeyAtBeat(double beat)
{
return currentMonkeys.Find(x => x.monkeyBeat == beat);
}
private int GetMonkeyAngle(int monkey)
{
return monkey switch
{
>= 4 and <= 12 => 2,
>= 12 and <= 19 => 3,
>= 19 and <= 27 => 4,
>= 27 and <= 34 => 5,
>= 34 and <= 42 => 6,
>= 42 and <= 49 => 7,
>= 49 and <= 56 => 8,
_ => 1,
};
}
}
}