This commit is contained in:
Rapandrasmus 2023-01-21 20:31:40 +01:00
parent 72d5c2c040
commit 58c48ee591
2 changed files with 60 additions and 2 deletions

View file

@ -6349,8 +6349,8 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: -100
m_Sprite: {fileID: 4182150794981042216, guid: 8471d5c767f1ecd4ab31873833b0c408, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Sprite: {fileID: 7482667652216324306, guid: ef2fa2a75dc283e40b9d4fe1f20dc6fb, type: 3}
m_Color: {r: 0.21960784, g: 0.54901963, b: 0.8156863, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
@ -6827,6 +6827,7 @@ MonoBehaviour:
scheduledInputs: []
firstEnable: 0
handsAnimator: {fileID: 1599401704102748781}
bg: {fileID: 7196257604761375275}
monkeyAnimator: {fileID: 241274462882064872}
flowerParticles: {fileID: 5490304671109547141}
happyFace: {fileID: 7823810765356384206}

View file

@ -2,6 +2,7 @@ using HeavenStudio.Util;
using System;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
namespace HeavenStudio.Games.Loaders
{
@ -53,6 +54,26 @@ namespace HeavenStudio.Games.Loaders
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.SuccessFace(e.beat); },
defaultLength = 1f,
priority = 4,
},
new GameAction("set background color", "Background Color")
{
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.ChangeBackgroundColor(e["colorA"], 0f); },
defaultLength = 0.5f,
parameters = new List<Param>()
{
new Param("colorA", Tambourine.defaultBGColor, "Background Color", "The background color to change to.")
}
},
new GameAction("fade background", "Fade Background Color")
{
function = delegate {var e = eventCaller.currentEntity; Tambourine.instance.FadeBackgroundColor(e["colorA"], e["colorB"], e.length); },
defaultLength = 4f,
resizable = true,
parameters = new List<Param>()
{
new Param("colorA", Color.white, "Start Color", "The starting color of the fade."),
new Param("colorB", Tambourine.defaultBGColor, "End Color", "The ending color of the fade.")
}
}
});
}
@ -63,8 +84,19 @@ namespace HeavenStudio.Games
{
public class Tambourine : Minigame
{
private static Color _defaultBGColor;
public static Color defaultBGColor
{
get
{
ColorUtility.TryParseHtmlString("#388cd0", out _defaultBGColor);
return _defaultBGColor;
}
}
[Header("Components")]
[SerializeField] Animator handsAnimator;
[SerializeField] SpriteRenderer bg;
[SerializeField] Animator monkeyAnimator;
[SerializeField] ParticleSystem flowerParticles;
[SerializeField] GameObject happyFace;
@ -79,6 +111,8 @@ namespace HeavenStudio.Games
float misses;
bool frogPresent;
Tween bgColorTween;
public enum WhoBops
{
Monkey,
@ -299,6 +333,29 @@ namespace HeavenStudio.Games
}
}
public void ChangeBackgroundColor(Color color, float beats)
{
var seconds = Conductor.instance.secPerBeat * beats;
if (bgColorTween != null)
bgColorTween.Kill(true);
if (seconds == 0)
{
bg.color = color;
}
else
{
bgColorTween = bg.DOColor(color, seconds);
}
}
public void FadeBackgroundColor(Color start, Color end, float beats)
{
ChangeBackgroundColor(start, 0f);
ChangeBackgroundColor(end, beats);
}
public void SummonFrog()
{
if (frogPresent) return;