fan club face poser

This commit is contained in:
minenice55
2024-05-11 01:07:59 -04:00
parent 84a955f58d
commit fa425365b5
65 changed files with 9574 additions and 1373 deletions

View File

@ -61,6 +61,30 @@ namespace HeavenStudio.Games.Loaders
inactiveFunction = delegate { var e = eventCaller.currentEntity; FanClub.WarnBigReady(e.beat, e["toggle"]); },
preFunction = delegate { var e = eventCaller.currentEntity; FanClub.BigReadySound(e.beat, e["toggle"]); }
},
new GameAction("arisa faceposer", "Idol Face Poser")
{
function = delegate { var e = eventCaller.currentEntity; FanClub.instance.SetArisaFacePoser(e["poserOn"], e["mouth"], e["mouthEnd"], e["eyeL"], e["eyeR"], e["eyex"], e["eyey"], e["eyeEaseEnable"], e.beat, e.length, e["eyeEase"]); },
resizable = true,
defaultLength = 1,
parameters = new List<Param>()
{
new Param("poserOn", true, "Enable Face Poser", "Enables Face Poser on Arisa.", new List<Param.CollapseParam>()
{
new Param.CollapseParam((x, _) => (bool)x, new string[] { "mouth", "eyeL", "eyeR", "eyex", "eyey" }),
}),
new Param("mouth", FanClub.MouthShape.Normal, "Mouth Shape", "Sets mouth shape."),
new Param("mouthEnd", FanClub.MouthShape.Normal, "Last Mouth Shape", "Sets mouth shape at the end of the event."),
new Param("eyeL", FanClub.EyeShape.Normal, "Left Eye Shape", "Sets left eye shape."),
new Param("eyeR", FanClub.EyeShape.Normal, "Right Eye Shape", "Sets right eye shape."),
new Param("eyex", new EntityTypes.Float(-1f, 1f, 0f), "Horizontal Eye Movement", "Sets horizontal eye movement."),
new Param("eyey", new EntityTypes.Float(-1f, 1f, 0f), "Vertical Eye Movement", "Sets vertical eye movement."),
new Param("eyeEaseEnable", true, "Ease Eye Movement", "Enable easing for eye movement.", new List<Param.CollapseParam>()
{
new Param.CollapseParam((x, _) => (bool)x, new string[] { "eyeEase" }),
}),
new Param("eyeEase", Util.EasingFunction.Ease.Instant, "Easing Type", "Set the type of easing for eye movement."),
}
},
new GameAction("play idol animation", "Idol Choreography")
{
function = delegate { var e = eventCaller.currentEntity; FanClub.instance.PlayAnim(e.beat, e.length, e["type"], e["who"]); },
@ -169,6 +193,26 @@ namespace HeavenStudio.Games
LeftDancer,
RightDancer
}
public enum MouthShape
{
Normal,
A,
E,
I,
O,
U,
Frown
}
public enum EyeShape
{
Normal,
HalfClosed,
Closed,
Smug,
SmugFlipped,
Wink,
Shine
}
// userdata here
[Header("Animators")]
@ -199,6 +243,7 @@ namespace HeavenStudio.Games
//arisa's animation controller
private Animator idolAnimator;
private NtrIdolAri arisaController;
// blue's animation controller
private Animator backupRAnimator;
@ -303,6 +348,7 @@ namespace HeavenStudio.Games
{
Blue.Init();
Orange.Init();
arisaController = Arisa.GetComponent<NtrIdolAri>();
var amieWalkEvts = EventCaller.GetAllInGameManagerList("fanClub", new string[] { "friend walk" });
foreach (var e in amieWalkEvts)
@ -639,6 +685,31 @@ namespace HeavenStudio.Games
}
}
System.Threading.CancellationTokenSource mouthCancel = null;
public void SetArisaFacePoser(bool enable, int mouth, int mouthEnd, int eyeL, int eyeR, float eyeX, float eyeY, bool ease, double beat, float length, int easeType)
{
if (mouthCancel != null)
{
mouthCancel.Cancel();
mouthCancel = null;
}
arisaController.ToggleFacePoser(enable);
arisaController.SetMouthShape(mouth);
arisaController.SetEyeShape(eyeL, eyeR);
if (ease)
{
arisaController.SetEyeTargetEase(beat, length, eyeX, eyeY, (Util.EasingFunction.Ease)easeType);
}
else
{
arisaController.SetEyeTarget(eyeX, eyeY);
}
mouthCancel = BeatAction.New(instance, new List<BeatAction.Action>()
{
new BeatAction.Action(beat + length, delegate { arisaController.SetMouthShape(mouthEnd);}),
});
}
const float HAIS_LENGTH = 4.5f;
public void CallHai(double beat, bool noSound = false, bool noResponse = false, int type = 0)
{

View File

@ -2,19 +2,57 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_FanClub
{
public class NtrIdolAri : MonoBehaviour
{
[Header("Objects")]
public ParticleSystem idolClapEffect;
public ParticleSystem idolWinkEffect;
public ParticleSystem idolKissEffect;
public ParticleSystem idolWinkArrEffect;
[SerializeField] ParticleSystem idolClapEffect;
[SerializeField] ParticleSystem idolWinkEffect;
[SerializeField] ParticleSystem idolKissEffect;
[SerializeField] ParticleSystem idolWinkArrEffect;
[SerializeField] SpriteRenderer baseHead;
[SerializeField] GameObject facePoser;
[Header("References")]
public Material coreMat;
Animator animator;
float previousEyeX, previousEyeY;
float nextEyeX, nextEyeY;
double eyeEaseStartBeat;
float eyeEaseLength;
EasingFunction.Ease eyeEase = EasingFunction.Ease.Instant;
private void Start()
{
animator = GetComponent<Animator>();
ToggleFacePoser(false);
}
private void Update()
{
var cond = Conductor.instance;
if (cond is null)
return;
float prog = cond.GetPositionFromBeat(eyeEaseStartBeat, eyeEaseLength);
if (prog > 1)
{
SetEyeTarget(nextEyeX, nextEyeY);
}
else if (prog >= 0)
{
float x = EasingFunction.GetEasingFunction(eyeEase)(previousEyeX, nextEyeX, prog);
float y = EasingFunction.GetEasingFunction(eyeEase)(previousEyeY, nextEyeY, prog);
animator.SetFloat("EyeX", Mathf.Clamp(x, -1, 1));
animator.SetFloat("EyeY", Mathf.Clamp(y, -1, 1));
}
}
public void ClapParticle()
{
idolClapEffect.Play();
@ -42,5 +80,48 @@ namespace HeavenStudio.Games.Scripts_FanClub
else
coreMat.SetColor("_AddColor", new Color(0, 100 / 255f, 200 / 255f, 0));
}
public void ToggleFacePoser(bool toggle)
{
facePoser.SetActive(toggle);
baseHead.enabled = !toggle;
}
public void SetMouthShape(int type)
{
animator.SetInteger("Mouth Type", type);
}
public void SetEyeShape(int leftType, int rightType)
{
float interval = 1f / (float)FanClub.EyeShape.Shine;
animator.SetFloat("Left Eye Type", interval * leftType);
animator.SetFloat("Right Eye Type", interval * rightType);
}
public void SetEyeTarget(float x, float y)
{
previousEyeX = x;
previousEyeY = y;
nextEyeX = x;
nextEyeY = y;
eyeEase = EasingFunction.Ease.Instant;
eyeEaseStartBeat = double.MaxValue;
eyeEaseLength = 0;
animator.SetFloat("EyeX", Mathf.Clamp(x, -1, 1));
animator.SetFloat("EyeY", Mathf.Clamp(y, -1, 1));
}
public void SetEyeTargetEase(double startBeat, float length, float nextX, float nextY, EasingFunction.Ease ease)
{
previousEyeX = nextEyeX;
previousEyeY = nextEyeY;
eyeEaseStartBeat = startBeat;
eyeEaseLength = length;
nextEyeX = nextX;
nextEyeY = nextY;
eyeEase = ease;
}
}
}