clock arrow now moves
This commit is contained in:
parent
466199643c
commit
cd1b02b9a4
|
|
@ -20239,6 +20239,8 @@ MonoBehaviour:
|
||||||
cameraAnchor: {fileID: 6302321823436949001}
|
cameraAnchor: {fileID: 6302321823436949001}
|
||||||
cameraTransform: {fileID: 16600283237656001}
|
cameraTransform: {fileID: 16600283237656001}
|
||||||
cameraMoveable: {fileID: 7676047881968251921}
|
cameraMoveable: {fileID: 7676047881968251921}
|
||||||
|
monkeyClockArrow: {fileID: 8220690735241008560}
|
||||||
|
maxMonkeys: 30
|
||||||
--- !u!1 &6181011653585253546
|
--- !u!1 &6181011653585253546
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -22820,6 +22822,7 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 6857749598573628903}
|
- component: {fileID: 6857749598573628903}
|
||||||
- component: {fileID: 910339928251400446}
|
- component: {fileID: 910339928251400446}
|
||||||
|
- component: {fileID: 8220690735241008560}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: WatchHand
|
m_Name: WatchHand
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -22864,6 +22867,20 @@ Animator:
|
||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorStateOnDisable: 0
|
m_KeepAnimatorStateOnDisable: 0
|
||||||
m_WriteDefaultValuesOnDisable: 0
|
m_WriteDefaultValuesOnDisable: 0
|
||||||
|
--- !u!114 &8220690735241008560
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7415731391529710915}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: bb4fe7e944029da4b950e4ed4957b63b, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
anim: {fileID: 910339928251400446}
|
||||||
|
anchorRotateTransform: {fileID: 609139906039373078}
|
||||||
--- !u!1 &7446072329631304920
|
--- !u!1 &7446072329631304920
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
27
Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs
Normal file
27
Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using HeavenStudio.Util;
|
||||||
|
|
||||||
|
namespace HeavenStudio.Games.Scripts_MonkeyWatch
|
||||||
|
{
|
||||||
|
public class MonkeyClockArrow : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Header("Components")]
|
||||||
|
[SerializeField] private Animator anim;
|
||||||
|
[SerializeField] private Transform anchorRotateTransform;
|
||||||
|
|
||||||
|
public void Move()
|
||||||
|
{
|
||||||
|
anchorRotateTransform.localEulerAngles = new Vector3(0, 0, anchorRotateTransform.localEulerAngles.z - 6);
|
||||||
|
anim.DoScaledAnimationAsync("Click", 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveToAngle(float angle)
|
||||||
|
{
|
||||||
|
anchorRotateTransform.localEulerAngles = new Vector3(0, 0, -angle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
11
Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs.meta
Normal file
11
Assets/Scripts/Games/MonkeyWatch/MonkeyClockArrow.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bb4fe7e944029da4b950e4ed4957b63b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -3,7 +3,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Jukebox;
|
using Jukebox;
|
||||||
using DG.Tweening;
|
|
||||||
|
|
||||||
namespace HeavenStudio.Games.Loaders
|
namespace HeavenStudio.Games.Loaders
|
||||||
{
|
{
|
||||||
|
|
@ -16,6 +15,11 @@ namespace HeavenStudio.Games.Loaders
|
||||||
{
|
{
|
||||||
new GameAction("clap", "Clapping")
|
new GameAction("clap", "Clapping")
|
||||||
{
|
{
|
||||||
|
preFunction = delegate
|
||||||
|
{
|
||||||
|
MonkeyWatch.PreStartClapping(eventCaller.currentEntity.beat);
|
||||||
|
},
|
||||||
|
preFunctionLength = 1f,
|
||||||
defaultLength = 2f,
|
defaultLength = 2f,
|
||||||
parameters = new List<Param>()
|
parameters = new List<Param>()
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +81,7 @@ namespace HeavenStudio.Games.Loaders
|
||||||
|
|
||||||
namespace HeavenStudio.Games
|
namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
//using Scripts_MonkeyWatch;
|
using Scripts_MonkeyWatch;
|
||||||
public class MonkeyWatch : Minigame
|
public class MonkeyWatch : Minigame
|
||||||
{
|
{
|
||||||
private const float degreePerMonkey = 6f;
|
private const float degreePerMonkey = 6f;
|
||||||
|
|
@ -92,6 +96,10 @@ namespace HeavenStudio.Games
|
||||||
[SerializeField] private Transform cameraAnchor;
|
[SerializeField] private Transform cameraAnchor;
|
||||||
[SerializeField] private Transform cameraTransform;
|
[SerializeField] private Transform cameraTransform;
|
||||||
[SerializeField] private Transform cameraMoveable;
|
[SerializeField] private Transform cameraMoveable;
|
||||||
|
[SerializeField] private MonkeyClockArrow monkeyClockArrow;
|
||||||
|
|
||||||
|
[Header("Properties")]
|
||||||
|
[SerializeField] private int maxMonkeys = 30;
|
||||||
|
|
||||||
private float lastAngle = 0f;
|
private float lastAngle = 0f;
|
||||||
private int cameraIndex = 0;
|
private int cameraIndex = 0;
|
||||||
|
|
@ -106,6 +114,8 @@ namespace HeavenStudio.Games
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
|
pinkMonkeys = EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "off", "offStretch" });
|
||||||
|
pinkMonkeysCustom = EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "offInterval" });
|
||||||
CameraUpdate();
|
CameraUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,47 +124,145 @@ namespace HeavenStudio.Games
|
||||||
CameraUpdate();
|
CameraUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CameraUpdate()
|
|
||||||
{
|
|
||||||
var cond = Conductor.instance;
|
|
||||||
if (cond.isPlaying && !cond.isPaused && cameraMovements.Count > 0)
|
|
||||||
{
|
|
||||||
if (cameraIndex + 1 < cameraMovements.Count && cond.songPositionInBeats >= cameraMovements[cameraIndex].beat + cameraMovements[cameraIndex].length)
|
|
||||||
{
|
|
||||||
lastAngle = cameraMovements[cameraIndex].degreeTo;
|
|
||||||
cameraIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
float normalizedBeat = cond.GetPositionFromBeat(cameraMovements[cameraIndex].beat, cameraMovements[cameraIndex].length);
|
|
||||||
|
|
||||||
float newAngle;
|
|
||||||
|
|
||||||
if (normalizedBeat < 0)
|
|
||||||
{
|
|
||||||
newAngle = lastAngle;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newAngle = Mathf.LerpUnclamped(lastAngle, cameraMovements[cameraIndex].degreeTo, normalizedBeat);
|
|
||||||
}
|
|
||||||
|
|
||||||
cameraAnchor.localEulerAngles = new Vector3(0, 0, newAngle);
|
|
||||||
}
|
|
||||||
cameraMoveable.position = new Vector3(cameraTransform.position.x, cameraTransform.position.y * -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Persist
|
|
||||||
|
|
||||||
public override void OnGameSwitch(double beat)
|
public override void OnGameSwitch(double beat)
|
||||||
{
|
{
|
||||||
GetCameraMovements(beat, false);
|
GetCameraMovements(beat, false);
|
||||||
|
monkeyClockArrow.MoveToAngle(lastAngle);
|
||||||
|
if (wantClap >= beat && IsClapBeat(wantClap))
|
||||||
|
{
|
||||||
|
StartClapping(wantClap);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsClapBeat(double clapBeat)
|
||||||
|
{
|
||||||
|
return EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "clap" }).Find(x => x.beat == clapBeat) != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPlay(double beat)
|
public override void OnPlay(double beat)
|
||||||
{
|
{
|
||||||
GetCameraMovements(beat, true);
|
GetCameraMovements(beat, true);
|
||||||
|
monkeyClockArrow.MoveToAngle(lastAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region clapping
|
||||||
|
|
||||||
|
private bool clapRecursing = false;
|
||||||
|
private List<RiqEntity> pinkMonkeys = new();
|
||||||
|
private List<RiqEntity> pinkMonkeysCustom = new();
|
||||||
|
|
||||||
|
private bool IsPinkMonkeyAtBeat(double beat, out float length)
|
||||||
|
{
|
||||||
|
length = 2;
|
||||||
|
var e = pinkMonkeys.Find(x => x.beat == beat);
|
||||||
|
bool isNotNull = e != null;
|
||||||
|
if (isNotNull) length = e.length;
|
||||||
|
return isNotNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsCustomPinkMonkeyAtBeat(double beat, out float length)
|
||||||
|
{
|
||||||
|
length = 2;
|
||||||
|
var e = pinkMonkeysCustom.Find(x => x.beat == beat);
|
||||||
|
bool isNotNull = e != null;
|
||||||
|
if (isNotNull) length = e.length;
|
||||||
|
return isNotNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double wantClap = double.MinValue;
|
||||||
|
|
||||||
|
public static void PreStartClapping(double beat)
|
||||||
|
{
|
||||||
|
if (GameManager.instance.currentGame == "monkeyWatch")
|
||||||
|
{
|
||||||
|
instance.StartClapping(beat);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wantClap = beat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartClapping(double beat)
|
||||||
|
{
|
||||||
|
if (clapRecursing) return;
|
||||||
|
clapRecursing = true;
|
||||||
|
|
||||||
|
ClapRecursing(beat);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClapRecursing(double beat)
|
||||||
|
{
|
||||||
|
if (IsPinkMonkeyAtBeat(beat, out float length1))
|
||||||
|
{
|
||||||
|
PinkClap(length1);
|
||||||
|
}
|
||||||
|
else if (IsCustomPinkMonkeyAtBeat(beat, out float length2))
|
||||||
|
{
|
||||||
|
PinkClapCustom(length2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NormalClap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NormalClap()
|
||||||
|
{
|
||||||
|
BeatAction.New(instance.gameObject, new List<BeatAction.Action>()
|
||||||
|
{
|
||||||
|
new BeatAction.Action(beat + 1, delegate
|
||||||
|
{
|
||||||
|
ClapRecursing(beat + 2);
|
||||||
|
monkeyClockArrow.Move();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void PinkClap(float length)
|
||||||
|
{
|
||||||
|
List<BeatAction.Action> actions = new List<BeatAction.Action>()
|
||||||
|
{
|
||||||
|
new BeatAction.Action(beat, delegate
|
||||||
|
{
|
||||||
|
ClapRecursing(beat + length);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
actions.Add(new BeatAction.Action(beat + i + 0.5, delegate
|
||||||
|
{
|
||||||
|
monkeyClockArrow.Move();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
BeatAction.New(instance.gameObject, actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PinkClapCustom(float length)
|
||||||
|
{
|
||||||
|
List<BeatAction.Action> actions = new List<BeatAction.Action>()
|
||||||
|
{
|
||||||
|
new BeatAction.Action(beat, delegate
|
||||||
|
{
|
||||||
|
ClapRecursing(beat + length);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
var relevantEvents = FindCustomOffbeatMonkeysBetweenBeat(beat, beat + length);
|
||||||
|
|
||||||
|
foreach (var e in relevantEvents)
|
||||||
|
{
|
||||||
|
actions.Add(new BeatAction.Action(e.beat, delegate
|
||||||
|
{
|
||||||
|
monkeyClockArrow.Move();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
BeatAction.New(instance.gameObject, actions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Camera
|
||||||
private void GetCameraMovements(double beat, bool onPlay)
|
private void GetCameraMovements(double beat, bool onPlay)
|
||||||
{
|
{
|
||||||
double lastGameSwitchBeat = beat;
|
double lastGameSwitchBeat = beat;
|
||||||
|
|
@ -190,7 +298,7 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
clappingEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
clappingEvents.Sort((x, y) => x.beat.CompareTo(y.beat));
|
||||||
startClappingBeat = clappingEvents[0].beat;
|
startClappingBeat = clappingEvents[0].beat;
|
||||||
startAngle = clappingEvents[0]["min"];
|
startAngle = clappingEvents[0]["min"] * degreePerMonkey;
|
||||||
overrideStartBeat = false;
|
overrideStartBeat = false;
|
||||||
}
|
}
|
||||||
lastAngle = startAngle;
|
lastAngle = startAngle;
|
||||||
|
|
@ -210,6 +318,7 @@ namespace HeavenStudio.Games
|
||||||
for (int i = 0; i < relevantPinkClappingEvents.Count; i++)
|
for (int i = 0; i < relevantPinkClappingEvents.Count; i++)
|
||||||
{
|
{
|
||||||
var e = relevantPinkClappingEvents[i];
|
var e = relevantPinkClappingEvents[i];
|
||||||
|
if (e.beat < lastClappingBeat) continue;
|
||||||
if (e.beat - lastClappingBeat > 0)
|
if (e.beat - lastClappingBeat > 0)
|
||||||
{
|
{
|
||||||
cameraMovements.Add(new MonkeyCamera()
|
cameraMovements.Add(new MonkeyCamera()
|
||||||
|
|
@ -260,7 +369,34 @@ namespace HeavenStudio.Games
|
||||||
Debug.Log("Beat: " + cameraMovement.beat + ", Length: " + cameraMovement.length + " , DegreeTo: " + cameraMovement.degreeTo);
|
Debug.Log("Beat: " + cameraMovement.beat + ", Length: " + cameraMovement.length + " , DegreeTo: " + cameraMovement.degreeTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void CameraUpdate()
|
||||||
|
{
|
||||||
|
var cond = Conductor.instance;
|
||||||
|
if (cond.isPlaying && !cond.isPaused && cameraMovements.Count > 0)
|
||||||
|
{
|
||||||
|
if (cameraIndex + 1 < cameraMovements.Count && cond.songPositionInBeats >= cameraMovements[cameraIndex].beat + cameraMovements[cameraIndex].length)
|
||||||
|
{
|
||||||
|
lastAngle = cameraMovements[cameraIndex].degreeTo;
|
||||||
|
cameraIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
float normalizedBeat = cond.GetPositionFromBeat(cameraMovements[cameraIndex].beat, cameraMovements[cameraIndex].length);
|
||||||
|
|
||||||
|
float newAngle;
|
||||||
|
|
||||||
|
if (normalizedBeat < 0)
|
||||||
|
{
|
||||||
|
newAngle = lastAngle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newAngle = Mathf.LerpUnclamped(lastAngle, cameraMovements[cameraIndex].degreeTo, normalizedBeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
cameraAnchor.localEulerAngles = new Vector3(0, 0, newAngle);
|
||||||
|
}
|
||||||
|
cameraMoveable.position = new Vector3(cameraTransform.position.x, cameraTransform.position.y * -1);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static List<RiqEntity> FindCustomOffbeatMonkeysBetweenBeat(double beat, double endBeat)
|
private static List<RiqEntity> FindCustomOffbeatMonkeysBetweenBeat(double beat, double endBeat)
|
||||||
|
|
@ -268,6 +404,8 @@ namespace HeavenStudio.Games
|
||||||
return EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "offCustom" }).FindAll(x => x.beat >= beat && x.beat < endBeat);
|
return EventCaller.GetAllInGameManagerList("monkeyWatch", new string[] { "offCustom" }).FindAll(x => x.beat >= beat && x.beat < endBeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region pink monkey sounds
|
||||||
|
|
||||||
public static void PinkMonkeySound(double beat, float length, bool muteOoki, bool muteEek)
|
public static void PinkMonkeySound(double beat, float length, bool muteOoki, bool muteEek)
|
||||||
{
|
{
|
||||||
List<MultiSound.Sound> soundsToPlay = new();
|
List<MultiSound.Sound> soundsToPlay = new();
|
||||||
|
|
@ -338,5 +476,7 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
if (soundsToPlay.Count > 0) MultiSound.Play(soundsToPlay.ToArray(), forcePlay: true);
|
if (soundsToPlay.Count > 0) MultiSound.Play(soundsToPlay.ToArray(), forcePlay: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue