2022-03-12 03:15:15 +00:00
|
|
|
using DG.Tweening;
|
|
|
|
using NaughtyBezierCurves;
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Util;
|
2023-10-29 19:44:47 +00:00
|
|
|
using HeavenStudio.InputSystem;
|
2022-03-12 03:15:15 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2022-04-12 16:14:46 +00:00
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
|
|
{
|
|
|
|
using static Minigames;
|
|
|
|
public static class CtrBearLoader
|
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
public static Minigame AddGame(EventCaller eventCaller)
|
|
|
|
{
|
|
|
|
return new Minigame("blueBear", "Blue Bear", "b4e6f6", "e7e7e7", "bf9d34", false, false, new List<GameAction>()
|
2022-04-12 16:14:46 +00:00
|
|
|
{
|
2022-08-21 03:13:52 +00:00
|
|
|
new GameAction("donut", "Donut")
|
|
|
|
{
|
2023-11-21 18:29:02 +00:00
|
|
|
preFunction = delegate { BlueBear.TreatSound(eventCaller.currentEntity.beat, false); },
|
|
|
|
function = delegate { BlueBear.instance.SpawnTreat(eventCaller.currentEntity.beat, false, eventCaller.currentEntity.beat); },
|
2022-08-21 03:13:52 +00:00
|
|
|
defaultLength = 3,
|
|
|
|
},
|
|
|
|
new GameAction("cake", "Cake")
|
|
|
|
{
|
2023-11-21 18:29:02 +00:00
|
|
|
preFunction = delegate { BlueBear.TreatSound(eventCaller.currentEntity.beat, true); },
|
|
|
|
function = delegate { BlueBear.instance.SpawnTreat(eventCaller.currentEntity.beat, true, eventCaller.currentEntity.beat); },
|
2022-08-21 03:13:52 +00:00
|
|
|
defaultLength = 4,
|
|
|
|
},
|
2023-11-22 01:07:35 +00:00
|
|
|
new GameAction("setEmotion", "Emotion")
|
2023-03-27 03:10:38 +00:00
|
|
|
{
|
2023-12-05 22:38:52 +00:00
|
|
|
function = delegate { var e = eventCaller.currentEntity; BlueBear.instance.SetEmotion(e.beat, e["type"]); },
|
2023-11-22 01:07:35 +00:00
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
|
|
|
new Param("type", BlueBear.EmotionType.ClosedEyes, "Emotion", "Which emotion should the blue bear use?")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new GameAction("stretchEmotion", "Long Emotion")
|
|
|
|
{
|
|
|
|
defaultLength = 4,
|
|
|
|
resizable = true,
|
2023-03-27 03:10:38 +00:00
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
new Param("type", BlueBear.EmotionStretchType.LookUp, "Emotion", "Which emotion should the blue bear use?")
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
new GameAction("wind", "Wind")
|
|
|
|
{
|
|
|
|
function = delegate { BlueBear.instance.Wind(); },
|
|
|
|
defaultLength = 0.5f
|
|
|
|
},
|
2023-11-21 18:29:02 +00:00
|
|
|
new GameAction("story", "Story")
|
|
|
|
{
|
|
|
|
defaultLength = 4,
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
|
|
|
new Param("story", BlueBear.StoryType.Date, "Story"),
|
|
|
|
new Param("enter", true, "Enter")
|
|
|
|
},
|
|
|
|
resizable = true
|
|
|
|
},
|
2023-03-27 03:10:38 +00:00
|
|
|
new GameAction("crumb", "Set Crumb Threshold")
|
|
|
|
{
|
|
|
|
function = delegate { var e = eventCaller.currentEntity; BlueBear.instance.SetCrumbThreshold(e["right"], e["left"], e["reset"]); },
|
|
|
|
defaultLength = 0.5f,
|
|
|
|
parameters = new List<Param>()
|
|
|
|
{
|
|
|
|
new Param("right", new EntityTypes.Integer(0, 500, 15), "Right Crumb", "How many treats should the bear eat before the right crumb can appear on his face?"),
|
|
|
|
new Param("left", new EntityTypes.Integer(0, 500, 30), "Left Crumb", "How many treats should the bear eat before the left crumb can appear on his face?"),
|
|
|
|
new Param("reset", false, "Reset Treats Eaten", "Should the numbers of treats eaten be reset?")
|
|
|
|
}
|
|
|
|
}
|
2023-05-28 17:34:44 +00:00
|
|
|
},
|
2023-10-29 19:44:47 +00:00
|
|
|
new List<string>() { "ctr", "normal" },
|
2023-05-28 17:34:44 +00:00
|
|
|
"ctrbear", "en",
|
2023-10-29 19:44:47 +00:00
|
|
|
new List<string>() { }
|
2023-05-28 17:34:44 +00:00
|
|
|
);
|
2022-04-12 16:14:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Games
|
2022-03-12 03:15:15 +00:00
|
|
|
{
|
2023-11-21 18:29:02 +00:00
|
|
|
using Jukebox;
|
2022-03-12 14:14:41 +00:00
|
|
|
using Scripts_BlueBear;
|
2023-11-22 01:07:35 +00:00
|
|
|
|
2022-03-12 03:15:15 +00:00
|
|
|
public class BlueBear : Minigame
|
|
|
|
{
|
2023-03-27 03:10:38 +00:00
|
|
|
public enum EmotionType
|
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
Neutral = 0,
|
|
|
|
ClosedEyes = 1,
|
|
|
|
Cry = 2,
|
|
|
|
Sigh = 3
|
|
|
|
}
|
|
|
|
public enum EmotionStretchType
|
|
|
|
{
|
|
|
|
LookUp = 0,
|
|
|
|
Smile = 1,
|
|
|
|
StartCrying = 2,
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
2023-11-21 18:29:02 +00:00
|
|
|
public enum StoryType
|
|
|
|
{
|
|
|
|
Date,
|
|
|
|
Gift,
|
|
|
|
Girl,
|
|
|
|
Eat,
|
|
|
|
BreakUp
|
|
|
|
}
|
2022-03-12 14:14:41 +00:00
|
|
|
[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
|
2023-03-27 03:10:38 +00:00
|
|
|
[SerializeField] Animator windAnim;
|
2022-03-12 14:14:41 +00:00
|
|
|
|
|
|
|
[Header("References")]
|
2023-03-27 03:10:38 +00:00
|
|
|
[SerializeField] GameObject leftCrumb;
|
|
|
|
[SerializeField] GameObject rightCrumb;
|
2023-11-21 18:29:02 +00:00
|
|
|
[SerializeField] private Animator _storyAnim;
|
2022-03-12 14:14:41 +00:00
|
|
|
public GameObject donutBase;
|
|
|
|
public GameObject cakeBase;
|
2022-03-27 12:08:26 +00:00
|
|
|
public GameObject crumbsBase;
|
2022-03-12 14:14:41 +00:00
|
|
|
public Transform foodHolder;
|
2022-03-27 12:08:26 +00:00
|
|
|
public Transform crumbsHolder;
|
2022-03-12 14:14:41 +00:00
|
|
|
public GameObject individualBagHolder;
|
|
|
|
|
2023-03-27 03:10:38 +00:00
|
|
|
[Header("Variables")]
|
2023-11-23 16:19:39 +00:00
|
|
|
private int rightCrumbAppearThreshold = 15;
|
|
|
|
private int leftCrumbAppearThreshold = 30;
|
|
|
|
private int eatenTreats = 0;
|
2023-03-27 03:10:38 +00:00
|
|
|
bool crying;
|
2023-11-21 18:29:02 +00:00
|
|
|
private List<RiqEntity> _allStoryEvents = new();
|
2023-11-22 01:07:35 +00:00
|
|
|
[SerializeField] private SuperCurveObject.Path[] _treatCurves;
|
2022-03-12 14:14:41 +00:00
|
|
|
|
2022-03-27 12:08:26 +00:00
|
|
|
[Header("Gradients")]
|
|
|
|
public Gradient donutGradient;
|
|
|
|
public Gradient cakeGradient;
|
|
|
|
|
2022-03-12 14:14:41 +00:00
|
|
|
private bool squashing;
|
|
|
|
|
|
|
|
public static BlueBear instance;
|
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
const int IALeft = 0;
|
|
|
|
const int IARight = 1;
|
|
|
|
protected static bool IA_PadLeft(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetPadDown(InputController.ActionsPad.Up, out dt)
|
|
|
|
|| PlayerInput.GetPadDown(InputController.ActionsPad.Down, out dt)
|
|
|
|
|| PlayerInput.GetPadDown(InputController.ActionsPad.Left, out dt)
|
|
|
|
|| PlayerInput.GetPadDown(InputController.ActionsPad.Right, out dt);
|
|
|
|
}
|
|
|
|
protected static bool IA_BatonLeft(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetBatonDown(InputController.ActionsBaton.West, out dt);
|
|
|
|
}
|
|
|
|
protected static bool IA_TouchLeft(out double dt)
|
|
|
|
{
|
|
|
|
bool want = PlayerInput.GetTouchDown(InputController.ActionsTouch.Left, out dt);
|
|
|
|
bool simul = false;
|
|
|
|
// if (!want)
|
|
|
|
// {
|
|
|
|
// simul = PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt)
|
|
|
|
// && instance.IsExpectingInputNow(InputAction_Left.inputLockCategory)
|
|
|
|
// && instance.IsExpectingInputNow(InputAction_Right.inputLockCategory);
|
|
|
|
// }
|
|
|
|
return want || simul;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static bool IA_PadRight(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetPadDown(InputController.ActionsPad.East, out dt);
|
|
|
|
}
|
|
|
|
protected static bool IA_BatonRight(out double dt)
|
|
|
|
{
|
|
|
|
return PlayerInput.GetBatonDown(InputController.ActionsBaton.East, out dt);
|
|
|
|
}
|
|
|
|
protected static bool IA_TouchRight(out double dt)
|
|
|
|
{
|
|
|
|
bool want = PlayerInput.GetTouchDown(InputController.ActionsTouch.Right, out dt);
|
|
|
|
bool simul = false;
|
|
|
|
// if (!want)
|
|
|
|
// {
|
|
|
|
// simul = PlayerInput.GetTouchDown(InputController.ActionsTouch.Tap, out dt)
|
|
|
|
// && instance.IsExpectingInputNow(InputAction_Right.inputLockCategory)
|
|
|
|
// && instance.IsExpectingInputNow(InputAction_Left.inputLockCategory);
|
|
|
|
// }
|
|
|
|
return want || simul;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static PlayerInput.InputAction InputAction_Left =
|
|
|
|
new("CtrBearLeft", new int[] { IALeft, IALeft, IALeft },
|
|
|
|
IA_PadLeft, IA_TouchLeft, IA_BatonLeft);
|
|
|
|
|
|
|
|
public static PlayerInput.InputAction InputAction_Right =
|
|
|
|
new("CtrBearRight", new int[] { IARight, IARight, IARight },
|
|
|
|
IA_PadRight, IA_TouchRight, IA_BatonRight);
|
|
|
|
|
2023-11-22 01:07:35 +00:00
|
|
|
// Editor gizmo to draw trajectories
|
|
|
|
new void OnDrawGizmos()
|
|
|
|
{
|
|
|
|
base.OnDrawGizmos();
|
|
|
|
foreach (SuperCurveObject.Path path in _treatCurves)
|
|
|
|
{
|
|
|
|
if (path.preview)
|
|
|
|
{
|
|
|
|
donutBase.GetComponent<SuperCurveObject>().DrawEditorGizmo(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public SuperCurveObject.Path GetPath(string name)
|
|
|
|
{
|
|
|
|
foreach (SuperCurveObject.Path path in _treatCurves)
|
|
|
|
{
|
|
|
|
if (path.name == name)
|
|
|
|
{
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return default(SuperCurveObject.Path);
|
|
|
|
}
|
|
|
|
|
2022-03-12 14:14:41 +00:00
|
|
|
private void Awake()
|
2022-03-12 03:15:15 +00:00
|
|
|
{
|
2022-03-12 14:14:41 +00:00
|
|
|
instance = this;
|
2023-11-21 18:29:02 +00:00
|
|
|
_allStoryEvents = EventCaller.GetAllInGameManagerList("blueBear", new string[] { "story" });
|
|
|
|
UpdateStory();
|
|
|
|
}
|
|
|
|
|
|
|
|
private int _storyIndex = 0;
|
|
|
|
|
|
|
|
private void UpdateStory()
|
|
|
|
{
|
|
|
|
var cond = Conductor.instance;
|
|
|
|
|
|
|
|
if (_storyIndex >= _allStoryEvents.Count) return;
|
|
|
|
|
|
|
|
var currentStory = _allStoryEvents[_storyIndex];
|
|
|
|
|
|
|
|
if (cond.songPositionInBeatsAsDouble >= currentStory.beat + currentStory.length && _storyIndex + 1 != _allStoryEvents.Count)
|
|
|
|
{
|
|
|
|
_storyIndex++;
|
|
|
|
UpdateStory();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float normalizedBeat = Mathf.Clamp01(cond.GetPositionFromBeat(currentStory.beat, currentStory.length));
|
|
|
|
|
|
|
|
bool enter = currentStory["enter"];
|
|
|
|
|
|
|
|
switch (currentStory["story"])
|
|
|
|
{
|
|
|
|
case (int)StoryType.Date:
|
|
|
|
_storyAnim.DoNormalizedAnimation(enter ? "Flashback0" : "Flashback0Exit", normalizedBeat);
|
|
|
|
break;
|
|
|
|
case (int)StoryType.Gift:
|
|
|
|
_storyAnim.DoNormalizedAnimation(enter ? "Flashback1" : "Flashback1Exit", normalizedBeat);
|
|
|
|
break;
|
|
|
|
case (int)StoryType.Girl:
|
|
|
|
_storyAnim.DoNormalizedAnimation(enter ? "Flashback2" : "Flashback2Exit", normalizedBeat);
|
|
|
|
break;
|
|
|
|
case (int)StoryType.Eat:
|
|
|
|
_storyAnim.DoNormalizedAnimation(enter ? "Flashback3" : "Flashback3Exit", normalizedBeat);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_storyAnim.DoNormalizedAnimation(enter ? "Breakup" : "BreakupExit", normalizedBeat);
|
|
|
|
break;
|
|
|
|
}
|
2022-03-27 12:08:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-03-12 14:14:41 +00:00
|
|
|
headAndBodyAnim.SetBool("ShouldOpenMouth", foodHolder.childCount != 0);
|
2023-11-22 01:07:35 +00:00
|
|
|
if (headAndBodyAnim.GetBool("ShouldOpenMouth"))
|
|
|
|
{
|
2023-12-05 22:38:52 +00:00
|
|
|
_emotionCancelledBeat = Conductor.instance.songPositionInBeatsAsDouble;
|
2023-11-22 01:07:35 +00:00
|
|
|
}
|
2022-03-12 14:14:41 +00:00
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
if (PlayerInput.GetIsAction(InputAction_Left) && !IsExpectingInputNow(InputAction_Left.inputLockCategory))
|
2022-03-12 14:14:41 +00:00
|
|
|
{
|
2023-11-23 16:19:39 +00:00
|
|
|
SoundByte.PlayOneShotGame("blueBear/whiff", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-1, 2), false));
|
2023-12-05 22:38:52 +00:00
|
|
|
Bite(Conductor.instance.songPositionInBeatsAsDouble, true);
|
2022-03-12 14:14:41 +00:00
|
|
|
}
|
2023-10-29 19:44:47 +00:00
|
|
|
else if (PlayerInput.GetIsAction(InputAction_Right) && !IsExpectingInputNow(InputAction_Right.inputLockCategory))
|
2022-03-12 14:14:41 +00:00
|
|
|
{
|
2023-11-23 16:19:39 +00:00
|
|
|
SoundByte.PlayOneShotGame("blueBear/whiff", -1, SoundByte.GetPitchFromSemiTones(UnityEngine.Random.Range(-1, 2), false));
|
2023-12-05 22:38:52 +00:00
|
|
|
Bite(Conductor.instance.songPositionInBeatsAsDouble, false);
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
|
|
|
|
2023-11-22 01:07:35 +00:00
|
|
|
UpdateEmotions();
|
|
|
|
|
|
|
|
UpdateStory();
|
|
|
|
headAndBodyAnim.SetScaledAnimationSpeed();
|
|
|
|
bagsAnim.SetScaledAnimationSpeed();
|
|
|
|
cakeBagAnim.SetScaledAnimationSpeed();
|
|
|
|
donutBagAnim.SetScaledAnimationSpeed();
|
|
|
|
windAnim.SetScaledAnimationSpeed();
|
|
|
|
}
|
|
|
|
|
2023-12-05 22:38:52 +00:00
|
|
|
private double _emotionCancelledBeat = -1;
|
2023-11-22 01:07:35 +00:00
|
|
|
private int _emotionIndex = 0;
|
|
|
|
private List<RiqEntity> _allEmotionsStretch = new();
|
|
|
|
private EmotionStretchType _lastEmotion = EmotionStretchType.LookUp;
|
2023-03-27 03:10:38 +00:00
|
|
|
|
2023-11-22 01:07:35 +00:00
|
|
|
private void UpdateEmotions()
|
|
|
|
{
|
|
|
|
var cond = Conductor.instance;
|
|
|
|
if (_allEmotionsStretch.Count == 0 || _emotionIndex >= _allEmotionsStretch.Count) return;
|
|
|
|
|
|
|
|
var beat = cond.songPositionInBeatsAsDouble;
|
|
|
|
|
|
|
|
var e = _allEmotionsStretch[_emotionIndex];
|
|
|
|
|
|
|
|
if (beat > e.beat + e.length)
|
2023-03-27 03:10:38 +00:00
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
_emotionIndex++;
|
|
|
|
_lastEmotion = (EmotionStretchType)_allEmotionsStretch[_emotionIndex - 1]["type"];
|
|
|
|
crying = _lastEmotion == EmotionStretchType.StartCrying;
|
|
|
|
UpdateEmotions();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-12-05 22:38:52 +00:00
|
|
|
if (beat >= e.beat && beat < e.beat + e.length && !(_emotionCancelledBeat >= e.beat && _emotionCancelledBeat < e.beat + e.length))
|
2023-11-22 01:07:35 +00:00
|
|
|
{
|
|
|
|
_lastEmotion = (EmotionStretchType)e["type"];
|
|
|
|
crying = _lastEmotion == EmotionStretchType.StartCrying;
|
|
|
|
float normalizedBeat = cond.GetPositionFromBeat(e.beat, e.length);
|
|
|
|
|
|
|
|
string animName = (EmotionStretchType)e["type"] switch
|
2023-03-27 03:10:38 +00:00
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
EmotionStretchType.LookUp => "OpenEyes",
|
|
|
|
EmotionStretchType.Smile => "Smile",
|
|
|
|
EmotionStretchType.StartCrying => "Sad",
|
|
|
|
_ => throw new NotImplementedException(),
|
|
|
|
};
|
|
|
|
headAndBodyAnim.DoNormalizedAnimation(animName, normalizedBeat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleEmotions(double beat)
|
|
|
|
{
|
|
|
|
_allEmotionsStretch = EventCaller.GetAllInGameManagerList("blueBear", new string[] { "stretchEmotion" });
|
|
|
|
if (_allEmotionsStretch.Count == 0) return;
|
|
|
|
UpdateEmotions();
|
|
|
|
var allEmosBeforeBeat = EventCaller.GetAllInGameManagerList("blueBear", new string[] { "stretchEmotion" }).FindAll(x => x.beat < beat);
|
2023-11-25 16:05:20 +00:00
|
|
|
if (allEmosBeforeBeat.Count == 0) return;
|
2023-11-22 01:07:35 +00:00
|
|
|
if ((EmotionStretchType)allEmosBeforeBeat[^1]["type"] == EmotionStretchType.StartCrying)
|
|
|
|
{
|
|
|
|
headAndBodyAnim.DoScaledAnimationAsync("CryIdle", 0.5f);
|
|
|
|
}
|
|
|
|
else if ((EmotionStretchType)allEmosBeforeBeat[^1]["type"] == EmotionStretchType.Smile)
|
|
|
|
{
|
|
|
|
headAndBodyAnim.DoScaledAnimationAsync("SmileIdle", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
2023-11-21 18:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnPlay(double beat)
|
|
|
|
{
|
|
|
|
HandleTreatsOnStart(beat);
|
2023-11-22 01:07:35 +00:00
|
|
|
HandleEmotions(beat);
|
2023-11-23 16:19:39 +00:00
|
|
|
HandleCrumbs(beat);
|
2023-11-21 18:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnGameSwitch(double beat)
|
|
|
|
{
|
|
|
|
HandleTreatsOnStart(beat);
|
2023-11-22 01:07:35 +00:00
|
|
|
HandleEmotions(beat);
|
2023-11-23 16:19:39 +00:00
|
|
|
HandleCrumbs(beat);
|
2023-11-21 18:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleTreatsOnStart(double gameswitchBeat)
|
|
|
|
{
|
|
|
|
var allTreatEvents = EventCaller.GetAllInGameManagerList("blueBear", new string[] { "donut", "cake" });
|
|
|
|
|
|
|
|
foreach (var e in allTreatEvents)
|
|
|
|
{
|
|
|
|
if (e.beat + e.length - 1 > gameswitchBeat && e.beat < gameswitchBeat)
|
|
|
|
{
|
|
|
|
SpawnTreat(e.beat, e.datamodel == "blueBear/cake", gameswitchBeat);
|
|
|
|
}
|
|
|
|
}
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Wind()
|
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
windAnim.DoScaledAnimationAsync("Wind", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
|
|
|
|
2023-12-05 22:38:52 +00:00
|
|
|
public void Bite(double beat, bool left)
|
2023-03-27 03:10:38 +00:00
|
|
|
{
|
2023-12-05 22:38:52 +00:00
|
|
|
_emotionCancelledBeat = beat;
|
2023-03-27 03:10:38 +00:00
|
|
|
if (crying)
|
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
headAndBodyAnim.DoScaledAnimationAsync(left ? "CryBiteL" : "CryBiteR", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
headAndBodyAnim.DoScaledAnimationAsync(left ? "BiteL" : "BiteR", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-23 16:19:39 +00:00
|
|
|
private void HandleCrumbs(double beat)
|
|
|
|
{
|
|
|
|
var allEventsBeforeBeat = EventCaller.GetAllInGameManagerList("blueBear", new string[] { "crumb" }).FindAll(x => x.beat < beat);
|
|
|
|
if (allEventsBeforeBeat.Count == 0) return;
|
|
|
|
var lastCrumbEvent = allEventsBeforeBeat[^1];
|
|
|
|
SetCrumbThreshold(lastCrumbEvent["right"], lastCrumbEvent["left"], lastCrumbEvent["reset"]);
|
|
|
|
EatTreat(false);
|
|
|
|
}
|
|
|
|
|
2023-03-27 03:10:38 +00:00
|
|
|
public void SetCrumbThreshold(int rightThreshold, int leftThreshold, bool reset)
|
|
|
|
{
|
|
|
|
rightCrumbAppearThreshold = rightThreshold;
|
|
|
|
leftCrumbAppearThreshold = leftThreshold;
|
|
|
|
if (reset) eatenTreats = 0;
|
|
|
|
}
|
|
|
|
|
2023-11-23 16:19:39 +00:00
|
|
|
public void EatTreat(bool appendTreats = true)
|
2023-03-27 03:10:38 +00:00
|
|
|
{
|
2023-11-23 16:19:39 +00:00
|
|
|
if (appendTreats) eatenTreats++;
|
2023-03-27 03:10:38 +00:00
|
|
|
if (eatenTreats >= leftCrumbAppearThreshold)
|
|
|
|
{
|
|
|
|
leftCrumb.SetActive(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
leftCrumb.SetActive(false);
|
|
|
|
}
|
|
|
|
if (eatenTreats >= rightCrumbAppearThreshold)
|
|
|
|
{
|
|
|
|
rightCrumb.SetActive(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rightCrumb.SetActive(false);
|
2022-03-12 14:14:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2023-11-22 01:07:35 +00:00
|
|
|
bagsAnim.DoScaledAnimationAsync("Idle", 0.5f);
|
2022-03-12 14:14:41 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-12 03:15:15 +00:00
|
|
|
}
|
|
|
|
|
2023-12-05 22:38:52 +00:00
|
|
|
public void SetEmotion(double beat, int emotion)
|
2023-03-27 03:10:38 +00:00
|
|
|
{
|
2023-12-05 22:38:52 +00:00
|
|
|
_emotionCancelledBeat = beat;
|
2023-03-27 03:10:38 +00:00
|
|
|
switch (emotion)
|
|
|
|
{
|
|
|
|
case (int)EmotionType.Neutral:
|
2023-11-22 01:07:35 +00:00
|
|
|
headAndBodyAnim.DoScaledAnimationAsync("Idle", 0.5f);
|
2023-12-05 22:38:52 +00:00
|
|
|
if (_allEmotionsStretch.Count == 0 || _lastEmotion != EmotionStretchType.Smile) return;
|
|
|
|
headAndBodyAnim.DoScaledAnimationAsync("StopSmile", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
crying = false;
|
|
|
|
break;
|
|
|
|
case (int)EmotionType.ClosedEyes:
|
2023-11-22 01:07:35 +00:00
|
|
|
headAndBodyAnim.DoScaledAnimationAsync("EyesClosed", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
crying = false;
|
|
|
|
break;
|
2023-11-22 01:07:35 +00:00
|
|
|
case (int)EmotionType.Cry:
|
|
|
|
headAndBodyAnim.DoScaledAnimationAsync("CryIdle", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
crying = true;
|
|
|
|
break;
|
|
|
|
case (int)EmotionType.Sigh:
|
2023-11-22 01:07:35 +00:00
|
|
|
headAndBodyAnim.DoScaledAnimationAsync("Sigh", 0.5f);
|
2023-03-27 03:10:38 +00:00
|
|
|
crying = false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-21 18:29:02 +00:00
|
|
|
public void SpawnTreat(double beat, bool isCake, double gameSwitchBeat)
|
2022-03-12 03:15:15 +00:00
|
|
|
{
|
2022-03-12 14:14:41 +00:00
|
|
|
var objectToSpawn = isCake ? cakeBase : donutBase;
|
|
|
|
var newTreat = GameObject.Instantiate(objectToSpawn, foodHolder);
|
2023-10-29 19:44:47 +00:00
|
|
|
|
2022-03-12 14:14:41 +00:00
|
|
|
var treatComp = newTreat.GetComponent<Treat>();
|
|
|
|
treatComp.startBeat = beat;
|
|
|
|
|
|
|
|
newTreat.SetActive(true);
|
|
|
|
|
2023-11-21 18:29:02 +00:00
|
|
|
if (beat >= gameSwitchBeat) SquashBag(isCake);
|
|
|
|
}
|
2022-03-12 14:14:41 +00:00
|
|
|
|
2023-11-21 18:29:02 +00:00
|
|
|
public static void TreatSound(double beat, bool isCake)
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot(isCake ? "games/blueBear/cake" : "games/blueBear/donut", beat);
|
2022-03-12 14:14:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SquashBag(bool isCake)
|
|
|
|
{
|
|
|
|
squashing = true;
|
2023-11-22 01:07:35 +00:00
|
|
|
bagsAnim.DoScaledAnimationAsync("Squashing", 0.5f);
|
2022-03-12 14:14:41 +00:00
|
|
|
|
|
|
|
individualBagHolder.SetActive(true);
|
|
|
|
|
|
|
|
if (isCake)
|
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
cakeBagAnim.DoScaledAnimationAsync("CakeSquash", 0.5f);
|
2022-03-12 14:14:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-22 01:07:35 +00:00
|
|
|
donutBagAnim.DoScaledAnimationAsync("DonutSquash", 0.5f);
|
2022-03-12 14:14:41 +00:00
|
|
|
}
|
2022-03-12 03:15:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|