HeavenStudioPlus/Assets/Scripts/Games/MonkeyWatch/WatchBackgroundHandler.cs
Rapandrasmus 1f03646118
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

89 lines
2.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
using Starpelly;
namespace HeavenStudio.Games.Scripts_MonkeyWatch
{
public class WatchBackgroundHandler : MonoBehaviour
{
[Header("Components")]
[SerializeField] private SpriteRenderer[] srsIn;
[SerializeField] private SpriteRenderer[] srsOut;
[SerializeField] private Transform anchorHour;
[SerializeField] private Transform anchorMinute;
private double fadeBeat = -1;
private float fadeLength = 0f;
private bool fadeOut = false;
private bool realTime = true;
private void Awake()
{
Update();
}
private void Update()
{
var cond = Conductor.instance;
float normalizedBeat = Mathf.Clamp01(cond.GetPositionFromBeat(fadeBeat, fadeLength));
if (fadeOut)
{
foreach (var s in srsIn)
{
s.color = new Color(s.color.r, s.color.g, s.color.b, 1 - normalizedBeat);
}
foreach (var s in srsOut)
{
s.color = new Color(s.color.r, s.color.g, s.color.b, normalizedBeat);
}
}
else
{
foreach (var s in srsIn)
{
s.color = new Color(s.color.r, s.color.g, s.color.b, normalizedBeat);
}
foreach (var s in srsOut)
{
s.color = new Color(s.color.r, s.color.g, s.color.b, 1 - normalizedBeat);
}
}
if (realTime)
{
var nowTime = System.DateTime.Now;
SetArrowsToTime(nowTime.Hour, nowTime.Minute, nowTime.Second);
}
}
public void SetFade(double beat, float length, bool outFade, MonkeyWatch.TimeMode timeMode, int hours, int minutes)
{
fadeBeat = beat;
fadeLength = length;
fadeOut = outFade;
realTime = timeMode == MonkeyWatch.TimeMode.RealTime;
if (!realTime)
{
SetArrowsToTime(hours, minutes, 0);
}
Update();
}
private void SetArrowsToTime(int hours, int minutes, int seconds)
{
float normalizedHour = Mathp.Normalize(hours + (minutes / 60f) + (seconds / 3600f), 0f, 12f);
anchorHour.localEulerAngles = new Vector3(0, 0, -Mathf.LerpUnclamped(0, 360, normalizedHour));
float normalizedMinute = Mathp.Normalize(minutes + (seconds / 60f), 0, 60);
anchorMinute.localEulerAngles = new Vector3(0, 0, -Mathf.LerpUnclamped(0, 360, normalizedMinute));
}
}
}