185 lines
7.1 KiB
C#
185 lines
7.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
using HeavenStudio.InputSystem;
|
|
|
|
using Jukebox;
|
|
|
|
namespace HeavenStudio.Games.Loaders
|
|
{
|
|
using static Minigames;
|
|
public static class RvlChameleonLoader
|
|
{
|
|
public static Minigame AddGame(EventCaller eventCaller)
|
|
{
|
|
return new Minigame("chameleon", "Chameleon", "ffffff", false, false, new List<GameAction>()
|
|
{
|
|
new GameAction("far", "Far Fly")
|
|
{
|
|
function = delegate {var e = eventCaller.currentEntity; Chameleon.instance.SpawnFly(e.beat, 7, (int)Scripts_Chameleon.FlyType.Far, e["countIn"]); },
|
|
defaultLength = 8f,
|
|
parameters = new List<Param>()
|
|
{
|
|
new Param("countIn", false, "Count-In"),
|
|
}
|
|
},
|
|
new GameAction("close", "Close Fly")
|
|
{
|
|
function = delegate {var e = eventCaller.currentEntity; Chameleon.instance.SpawnFly(e.beat, 7, (int)Scripts_Chameleon.FlyType.Close, e["countIn"]); },
|
|
defaultLength = 8f,
|
|
parameters = new List<Param>()
|
|
{
|
|
new Param("countIn", false, "Count-In"),
|
|
}
|
|
},
|
|
// new GameAction("background appearance", "Background Appearance")
|
|
// {
|
|
// function = delegate {
|
|
// var e = eventCaller.currentEntity;
|
|
// Chameleon.instance.BackgroundColorSet(e.beat, e.length, e["colorBG1Start"], e["colorBG1End"], e["colorBG2Start"], e["colorBG2End"], e["ease"]);
|
|
// },
|
|
// defaultLength = 0.5f,
|
|
// resizable = true,
|
|
// parameters = new List<Param>()
|
|
// {
|
|
// new Param("colorBG1Start", new Color(1f, 0.937f, 0.224f), "Start BG Color", "Set top-most color of the background gradient at the start of the event."),
|
|
// new Param("colorBG1End", new Color(1f, 0.937f, 0.224f), "End BG Color", "Set top-most color of the background gradient at the end of the event."),
|
|
// new Param("colorBG2Start", new Color(1f, 0.937f, 0.224f), "Start BG Color", "Set bottom-most color of the background gradient at the start of the event."),
|
|
// new Param("colorBG2End", new Color(1f, 0.937f, 0.224f), "End BG Color", "Set bottom-most color of the background gradient at the end of the event."),
|
|
// new Param("ease", Util.EasingFunction.Ease.Instant, "Ease", "Set the easing of the action."),
|
|
// }
|
|
// },
|
|
},
|
|
new List<string>() { "rvl", "normal" },
|
|
"rvlchameleon", "en",
|
|
new List<string>() {},
|
|
chronologicalSortKey: 107
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace HeavenStudio.Games
|
|
{
|
|
using Scripts_Chameleon;
|
|
public class Chameleon : Minigame
|
|
{
|
|
public Transform baseFly;
|
|
public Animator chameleonAnim;
|
|
|
|
[SerializeField] SpriteRenderer gradient;
|
|
[SerializeField] SpriteRenderer bgHigh;
|
|
[SerializeField] SpriteRenderer bgLow;
|
|
|
|
private ColorEase[] colorEases = new ColorEase[2];
|
|
|
|
public static Chameleon instance;
|
|
|
|
const int IAAltDownCat = IAMAXCAT;
|
|
|
|
protected static bool IA_TouchLeft(out double dt)
|
|
{
|
|
bool want = PlayerInput.GetTouchDown(InputController.ActionsTouch.Left, out dt);
|
|
bool simul = false;
|
|
return want || simul;
|
|
}
|
|
|
|
protected static bool IA_PadAltPress(out double dt)
|
|
{
|
|
return PlayerInput.GetPadDown(InputController.ActionsPad.South, out dt);
|
|
}
|
|
protected static bool IA_BatonAltPress(out double dt)
|
|
{
|
|
return PlayerInput.GetSqueezeDown(out dt);
|
|
}
|
|
protected static bool IA_TouchRight(out double dt)
|
|
{
|
|
bool want = PlayerInput.GetTouchDown(InputController.ActionsTouch.Right, out dt);
|
|
bool simul = false;
|
|
return want || simul;
|
|
}
|
|
|
|
public static PlayerInput.InputAction InputAction_Close =
|
|
new("RvlChameleonClose", new int[] { IAPressCat, IAPressCat, IAPressCat },
|
|
IA_PadBasicPress, IA_TouchLeft, IA_BatonBasicPress);
|
|
|
|
public static PlayerInput.InputAction InputAction_Far =
|
|
new("RvlChameleonFar", new int[] { IAAltDownCat, IAAltDownCat, IAAltDownCat },
|
|
IA_PadAltPress, IA_TouchRight, IA_BatonAltPress);
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
|
|
colorEases = new ColorEase[] {
|
|
new(Color.white),
|
|
new(Color.white),
|
|
};
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
var cond = Conductor.instance;
|
|
if (cond.isPlaying && !cond.isPaused)
|
|
{
|
|
if (PlayerInput.GetIsAction(InputAction_Close) && !IsExpectingInputNow(InputAction_Close))
|
|
{
|
|
chameleonAnim.DoScaledAnimationAsync("tongueClose", 0.5f);
|
|
SoundByte.PlayOneShotGame("chameleon/blankClose");
|
|
}
|
|
if (PlayerInput.GetIsAction(InputAction_Far) && !IsExpectingInputNow(InputAction_Far))
|
|
{
|
|
chameleonAnim.DoScaledAnimationAsync("tongueFar", 0.5f);
|
|
SoundByte.PlayOneShotGame("chameleon/blankFar");
|
|
}
|
|
|
|
// UpdateBackgroundColor();
|
|
}
|
|
}
|
|
|
|
public void SpawnFly(double beat, double length, int type, bool countIn)
|
|
{
|
|
var newFly = Instantiate(baseFly, transform).GetComponent<Fly>();
|
|
newFly.startBeat = beat;
|
|
newFly.flyType = (FlyType)type;
|
|
|
|
if (countIn)
|
|
{
|
|
MultiSound.Play(new MultiSound.Sound[]{
|
|
new MultiSound.Sound("count-ins/and", beat + 2),
|
|
new MultiSound.Sound(UnityEngine.Random.Range(0.0f, 1.0f) > 0.5 ? "count-ins/go1" : "count-ins/go2", beat + 3),
|
|
}, forcePlay: true, game: false);
|
|
}
|
|
|
|
BeatAction.New(instance, new List<BeatAction.Action>()
|
|
{
|
|
new BeatAction.Action(beat, delegate {
|
|
newFly.gameObject.SetActive(true);
|
|
newFly.Init();
|
|
}),
|
|
});
|
|
}
|
|
|
|
|
|
public void BackgroundColorSet(double beat, float length, Color BG1Start, Color BG1End, Color BG2Start, Color BG2End, int colorEaseSet)
|
|
{
|
|
colorEases = new ColorEase[] {
|
|
new(beat, length, BG1Start, BG1End, colorEaseSet),
|
|
new(beat, length, BG2Start, BG2End, colorEaseSet),
|
|
};
|
|
|
|
UpdateBackgroundColor();
|
|
}
|
|
private void UpdateBackgroundColor()
|
|
{
|
|
gradient.color = colorEases[0].GetColor();
|
|
bgHigh.color = colorEases[0].GetColor();
|
|
bgLow.color = colorEases[1].GetColor();
|
|
}
|
|
}
|
|
} |