Blue Bear: Basic gameplay setup

This commit is contained in:
Jenny Crowe
2022-03-12 07:14:41 -07:00
parent 147332cff2
commit caf2394c47
45 changed files with 5689 additions and 28 deletions

View File

@ -7,20 +7,97 @@ using UnityEngine;
namespace RhythmHeavenMania.Games
{
// using Scripts_BlueBear; -No scripts under this namespace yet.
using Scripts_BlueBear;
public class BlueBear : Minigame
{
// Start is called before the first frame update
void Start()
[Header("Animators")]
public Animator headAndBodyAnim; // Head and body
public Animator bagsAnim; // Both bags sprite
public Animator donutBagAnim; // Individual donut bag
public Animator cakeBagAnim; // Individual cake bag
[Header("References")]
public GameObject donutBase;
public GameObject cakeBase;
public Transform foodHolder;
public GameObject individualBagHolder;
[Header("Curves")]
public BezierCurve3D donutCurve;
public BezierCurve3D cakeCurve;
private bool squashing;
public static BlueBear instance;
private void Awake()
{
instance = this;
}
// Update is called once per frame
void Update()
private void Update()
{
headAndBodyAnim.SetBool("ShouldOpenMouth", foodHolder.childCount != 0);
if (PlayerInput.GetAnyDirectionDown())
{
headAndBodyAnim.Play("BiteL", 0, 0);
}
else if (PlayerInput.Pressed())
{
headAndBodyAnim.Play("BiteR", 0, 0);
}
}
private void LateUpdate()
{
if (squashing)
{
var dState = donutBagAnim.GetCurrentAnimatorStateInfo(0);
var cState = cakeBagAnim.GetCurrentAnimatorStateInfo(0);
bool noDonutSquash = dState.IsName("DonutIdle");
bool noCakeSquash = cState.IsName("CakeIdle");
if (noDonutSquash && noCakeSquash)
{
squashing = false;
bagsAnim.Play("Idle", 0, 0);
}
}
}
public void SpawnTreat(float beat, bool isCake)
{
var objectToSpawn = isCake ? cakeBase : donutBase;
var newTreat = GameObject.Instantiate(objectToSpawn, foodHolder);
var treatComp = newTreat.GetComponent<Treat>();
treatComp.startBeat = beat;
treatComp.curve = isCake ? cakeCurve : donutCurve;
newTreat.SetActive(true);
Jukebox.PlayOneShotGame(isCake ? "blueBear/cake" : "blueBear/donut");
SquashBag(isCake);
}
public void SquashBag(bool isCake)
{
squashing = true;
bagsAnim.Play("Squashing", 0, 0);
individualBagHolder.SetActive(true);
if (isCake)
{
cakeBagAnim.Play("CakeSquash", 0, 0);
}
else
{
donutBagAnim.Play("DonutSquash", 0, 0);
}
}
}
}

View File

@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using NaughtyBezierCurves;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.Scripts_BlueBear
{
public class Treat : PlayerActionObject
{
const float rotSpeed = 360f;
public bool isCake;
public float startBeat;
bool flying = true;
float flyBeats;
[NonSerialized] public BezierCurve3D curve;
private BlueBear game;
private void Awake()
{
game = BlueBear.instance;
flyBeats = isCake ? 3f : 2f;
}
private void Update()
{
if (flying)
{
var cond = Conductor.instance;
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
flyPos *= isCake ? 0.75f : 0.6f;
transform.position = curve.GetPoint(flyPos);
if (flyPos > 1f)
{
GameObject.Destroy(gameObject);
return;
}
float rot = isCake ? rotSpeed : -rotSpeed;
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (rot * Time.deltaTime));
float normalizedBeat = cond.GetPositionFromMargin(startBeat + flyBeats, 1f);
StateCheck(normalizedBeat);
if (PlayerInput.Pressed())
{
if (!isCake)
{
if (state.perfect)
{
flying = false;
Jukebox.PlayOneShotGame("blueBear/chompDonut");
// Placeholder! Show particles here!
GameObject.Destroy(gameObject);
}
}
}
else if (PlayerInput.GetAnyDirection())
{
if (isCake)
{
if (state.perfect)
{
flying = false;
Jukebox.PlayOneShotGame("blueBear/chompCake");
// Placeholder! Show particles here!
GameObject.Destroy(gameObject);
}
}
}
}
}
public override void OnAce()
{
flying = false;
if (isCake)
{
game.headAndBodyAnim.Play("BiteL", 0, 0);
Jukebox.PlayOneShotGame("blueBear/chompCake");
}
else
{
game.headAndBodyAnim.Play("BiteR", 0, 0);
Jukebox.PlayOneShotGame("blueBear/chompDonut");
}
// Placeholder! Show particles here!
GameObject.Destroy(gameObject);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f7dae340f4a85ba44ab2f8cfd4429430
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -411,6 +411,8 @@ namespace RhythmHeavenMania
}),
new Minigame("blueBear", "Blue Bear \n<color=#eb5454>[WIP don't use]</color>", "B4E6F6", false, false, new List<GameAction>()
{
new GameAction("donut", delegate { BlueBear.instance.SpawnTreat(eventCaller.currentEntity.beat, false); }, 3, false),
new GameAction("cake", delegate { BlueBear.instance.SpawnTreat(eventCaller.currentEntity.beat, true); }, 4, false),
}),
/*new Minigame("spaceDance", "Space Dance", "B888F8", new List<GameAction>()
{