HeavenStudioPlus/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.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

113 lines
3.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_MonkeyWatch
{
public class WatchMonkey : MonoBehaviour
{
private Animator anim;
private Animator holeAnim;
[Header("Properties")]
[SerializeField] private bool isPink;
private MonkeyWatch game;
private int direction = 0;
public double monkeyBeat;
private double disappearBeat = 0;
private bool disappear = false;
private PlayerActionEvent inputEvent;
private void Awake()
{
game = MonkeyWatch.instance;
anim = GetComponent<Animator>();
}
private void Update()
{
if (disappear)
{
float normalizedBeat = Conductor.instance.GetPositionFromBeat(disappearBeat, 0.5f);
anim.DoNormalizedAnimation(isPink ? "PinkAppear" : "Appear", 1 - normalizedBeat);
float normalizedBeatClose = Conductor.instance.GetPositionFromBeat(disappearBeat + 0.25f, 0.25f);
holeAnim.DoNormalizedAnimation("HoleClose", Mathf.Clamp01(normalizedBeatClose));
if (normalizedBeat > 1f)
{
Destroy(gameObject);
}
}
}
public void Appear(double beat, bool instant, Animator hole, int dir)
{
monkeyBeat = beat;
direction = dir;
holeAnim = hole;
holeAnim.DoScaledAnimationAsync("HoleOpen", 0.4f, instant ? 1 : 0);
anim.DoScaledAnimationAsync(isPink ? "PinkAppear" : "Appear", 0.4f, instant ? 1 : 0);
}
public void Disappear(double beat)
{
disappear = true;
disappearBeat = beat;
Update();
}
public void Prepare(double prepareBeat, double inputBeat)
{
anim.DoScaledAnimationAsync(isPink ? "PinkPrepare" + direction : "Prepare" + direction, 0);
inputEvent = game.ScheduleInput(prepareBeat, inputBeat - prepareBeat, MonkeyWatch.InputAction_BasicPress, Just, Miss, Empty);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(prepareBeat - 0.25, delegate
{
if (inputEvent != null && inputEvent.enabled) anim.DoScaledAnimationAsync(isPink ? "PinkPrepare" + direction : "Prepare" + direction, 0.4f);
})
});
}
private void Just(PlayerActionEvent caller, float state)
{
bool barely = state >= 1f || state <= -1f;
if (barely)
{
SoundByte.PlayOneShot("nearMiss");
}
else
{
SoundByte.PlayOneShotGame(isPink ? "monkeyWatch/clapOffbeat" : $"monkeyWatch/clapOnbeat{UnityEngine.Random.Range(1, 6)}");
}
game.monkeyClockArrow.Move();
game.PlayerMonkeyClap(isPink, barely);
anim.DoScaledAnimationAsync(isPink ? "PinkClap" + direction : "Clap" + direction, 0.4f);
BeatAction.New(this, new List<BeatAction.Action>()
{
new BeatAction.Action(caller.timer + caller.startBeat + 1, delegate
{
string whichAnim = barely ? "Barely" : "Just";
anim.DoScaledAnimationAsync(isPink ? "Pink" + whichAnim : whichAnim, 0.4f);
})
});
}
private void Miss(PlayerActionEvent caller)
{
anim.DoScaledAnimationAsync(isPink ? "PinkMiss" : "Miss", 0.4f);
game.monkeyClockArrow.Move();
}
private void Empty(PlayerActionEvent caller)
{
}
}
}