HeavenStudio/Assets/Scripts/Games/ClappyTrio/ClappyTrioPlayer.cs
Rapandrasmus 28a621b90d
Clappy Trio and Fork Lifter finished + small additions/fixes (#400)
* The funny

* Yar har har har

* 1 two tree

* Hilarious!

* procedurally spawning in stuff

* bored meeting

* A lot!

* Assistant stop added

* Added Bops

* Added Sounds

* Added miss stuff!! Only need the miss anim for the pigs!!!

* Tweaks

* Bugfixes!

* anim fix anim fix

* STRAIGHT!

* Sound offsets fixed

* added the new anims to implement

* new sheet

* loopSpin implemented

* woah

* mis stuff

* doen done done

* Various fixes

* Fixed clappy trio bop bug

* Epic tings

* Added color and screen shake

* Small things

* redid sheets a little

* Fixed burger preview

* Almost done with forklifter

* Bg color and fixed 4 peas for fork lifter

* icon

* bg stuff for tambourine and forklfiter

---------

Co-authored-by: ev <85412919+evdial@users.noreply.github.com>
2023-04-23 20:17:21 +00:00

92 lines
2.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_ClappyTrio
{
public class ClappyTrioPlayer : PlayerActionObject
{
ClappyTrio game;
private float lastClapBeat;
private float lastClapLength;
public bool clapStarted = false;
public bool canHit;
private GameObject clapEffect;
private void Awake()
{
game = ClappyTrio.instance;
clapEffect = transform.GetChild(4).GetChild(3).gameObject;
}
private void Update()
{
if (PlayerInput.Pressed() && !game.IsExpectingInputNow(InputType.STANDARD_DOWN))
{
Clap(false);
game.ScoreMiss();
}
}
public void QueueClap(float startBeat, float length)
{
lastClapBeat = startBeat;
lastClapLength = length;
game.ScheduleInput(startBeat, length, InputType.STANDARD_DOWN, Just, Miss, Out);
}
private void Just(PlayerActionEvent caller, float state)
{
if (!canHit) {
Clap(false);
return;
}
if (state >= 1f || state <= -1f) { //todo: proper near miss feedback
Clap(false);
return;
}
Clap(true);
}
private void Miss(PlayerActionEvent caller) {
game.playerHitLast = false;
game.missed = true;
if (clapStarted)
this.canHit = false;
}
private void Out(PlayerActionEvent caller) {}
private void Clap(bool just)
{
if (just)
{
clapEffect.SetActive(true);
Jukebox.PlayOneShotGame("clappyTrio/rightClap");
if (this.canHit)
game.playerHitLast = true;
}
else
{
clapEffect.SetActive(false);
Jukebox.PlayOneShot("miss");
game.playerHitLast = false;
game.missed = true;
if (clapStarted)
this.canHit = false;
}
clapStarted = false;
game.SetFace(game.Lion.Count - 1, 4);
this.GetComponent<Animator>().Play("Clap", 0, 0);
}
}
}