Dummy inputs

This commit is contained in:
Rapandrasmus 2023-10-04 16:51:50 +02:00
parent 48d866fcf2
commit 3047ea74f1
11 changed files with 297 additions and 8 deletions

View file

@ -499,6 +499,7 @@ GameObject:
- component: {fileID: 6285390310926959546} - component: {fileID: 6285390310926959546}
- component: {fileID: 6198430257364661693} - component: {fileID: 6198430257364661693}
- component: {fileID: -5564384145903586768} - component: {fileID: -5564384145903586768}
- component: {fileID: -4645702950898394595}
m_Layer: 0 m_Layer: 0
m_Name: Elephant m_Name: Elephant
m_TagString: Untagged m_TagString: Untagged
@ -558,13 +559,41 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2f9ee457016acdc4eb5dbfdc03be0d6f, type: 3} m_Script: {fileID: 11500000, guid: 2f9ee457016acdc4eb5dbfdc03be0d6f, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_onInit:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: -4645702950898394595}
m_TargetAssemblyTypeName: HeavenStudio.Games.Scripts_AnimalAcrobat.ObstacleInput,
Assembly-CSharp
m_MethodName: Init
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
_fullRotRange: 120 _fullRotRange: 120
_spawnDistance: 10.408
_spawnOffset: 0 _spawnOffset: 0
_holdLength: 2 _holdLength: 2
_ease: 4 _ease: 4
_rotateRoot: {fileID: 2616646720197201304} _rotateRoot: {fileID: 2616646720197201304}
_gripPoint: {fileID: 2131794628642567477} _gripPoint: {fileID: 2131794628642567477}
--- !u!114 &-4645702950898394595
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7540716611123628191}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a934a7ab91ef694e94df3dce43f43ca, type: 3}
m_Name:
m_EditorClassIdentifier:
_holdLength: 2
--- !u!1 &7805847212563886084 --- !u!1 &7805847212563886084
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -263,6 +263,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 1701002327333926128} - component: {fileID: 1701002327333926128}
- component: {fileID: 5248028064811562821} - component: {fileID: 5248028064811562821}
- component: {fileID: 3253363150451868373}
m_Layer: 0 m_Layer: 0
m_Name: Giraffe m_Name: Giraffe
m_TagString: Untagged m_TagString: Untagged
@ -301,12 +302,23 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_fullRotRange: 160 _fullRotRange: 160
_spawnDistance: 20.816
_spawnOffset: 10.408 _spawnOffset: 10.408
_holdLength: 4 _holdLength: 4
_ease: 4 _ease: 4
_rotateRoot: {fileID: 4208995891253938729} _rotateRoot: {fileID: 4208995891253938729}
_gripPoint: {fileID: 8714220451416272075} _gripPoint: {fileID: 8714220451416272075}
--- !u!114 &3253363150451868373
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2939598505969617365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f87e00a2ffbd0af4baae18b3c11268db, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &3911272779464478738 --- !u!1 &3911272779464478738
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -125,6 +125,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 532140475066366254} - component: {fileID: 532140475066366254}
- component: {fileID: 7370747047491091311} - component: {fileID: 7370747047491091311}
- component: {fileID: 3772265357728581139}
m_Layer: 0 m_Layer: 0
m_Name: WhiteMonkey m_Name: WhiteMonkey
m_TagString: Untagged m_TagString: Untagged
@ -162,13 +163,39 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_onInit: _onInit:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 3772265357728581139}
m_TargetAssemblyTypeName: HeavenStudio.Games.Scripts_AnimalAcrobat.ObstacleInput,
Assembly-CSharp
m_MethodName: Init
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
_fullRotRange: 160 _fullRotRange: 160
_spawnOffset: 5.204 _spawnOffset: 5.204
_holdLength: 1 _holdLength: 1
_ease: 4 _ease: 4
_rotateRoot: {fileID: 2068126119450832752} _rotateRoot: {fileID: 2068126119450832752}
_gripPoint: {fileID: 8286548847234487440} _gripPoint: {fileID: 8286548847234487440}
--- !u!114 &3772265357728581139
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1656536018348746482}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a934a7ab91ef694e94df3dce43f43ca, type: 3}
m_Name:
m_EditorClassIdentifier:
_holdLength: 1
--- !u!1 &3823740494665398411 --- !u!1 &3823740494665398411
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -1892,6 +1892,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 3439047595127619699} - component: {fileID: 3439047595127619699}
- component: {fileID: -3114631264593203074} - component: {fileID: -3114631264593203074}
- component: {fileID: 3068772248330600904}
m_Layer: 0 m_Layer: 0
m_Name: WhiteMonkeys m_Name: WhiteMonkeys
m_TagString: Untagged m_TagString: Untagged
@ -1931,13 +1932,39 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_onInit: _onInit:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls:
- m_Target: {fileID: 3068772248330600904}
m_TargetAssemblyTypeName: HeavenStudio.Games.Scripts_AnimalAcrobat.ObstacleInput,
Assembly-CSharp
m_MethodName: Init
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
_fullRotRange: 160 _fullRotRange: 160
_spawnOffset: 9.244 _spawnOffset: 9.244
_holdLength: 3 _holdLength: 3
_ease: 4 _ease: 4
_rotateRoot: {fileID: 3903953954711634507} _rotateRoot: {fileID: 3903953954711634507}
_gripPoint: {fileID: 3800820123473635694} _gripPoint: {fileID: 3800820123473635694}
--- !u!114 &3068772248330600904
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7969179947406382610}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9a934a7ab91ef694e94df3dce43f43ca, type: 3}
m_Name:
m_EditorClassIdentifier:
_holdLength: 3
--- !u!1 &8302616130811808557 --- !u!1 &8302616130811808557
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View file

@ -3,12 +3,13 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using HeavenStudio.Util; using HeavenStudio.Util;
using UnityEngine.Events; using UnityEngine.Events;
using System;
namespace HeavenStudio.Games.Scripts_AnimalAcrobat namespace HeavenStudio.Games.Scripts_AnimalAcrobat
{ {
public class AcrobatObstacle : MonoBehaviour public class AcrobatObstacle : MonoBehaviour
{ {
[SerializeField] private UnityEvent<double> _onInit; public Action<double, bool> OnInit;
[Header("Values")] [Header("Values")]
[SerializeField] private float _fullRotRange; [SerializeField] private float _fullRotRange;
@ -33,11 +34,11 @@ namespace HeavenStudio.Games.Scripts_AnimalAcrobat
_func = EasingFunction.GetEasingFunction(_ease); _func = EasingFunction.GetEasingFunction(_ease);
} }
public void Init(double beat, double expirationBeat) public void Init(double beat, double expirationBeat, bool behindGiraffe)
{ {
_startBeat = beat; _startBeat = beat;
_expirationBeat = expirationBeat; _expirationBeat = expirationBeat;
_onInit.Invoke(_startBeat); OnInit(beat, behindGiraffe);
Update(); Update();
} }

View file

@ -74,6 +74,14 @@ namespace HeavenStudio.Games
private List<QueuedAnimal> _queuedAnimals = new(); private List<QueuedAnimal> _queuedAnimals = new();
private int _animalPoolIndex = 0; private int _animalPoolIndex = 0;
private float _animalSummatedDistance = 0; private float _animalSummatedDistance = 0;
private bool _lastAnimalWasGiraffe = false;
public static AnimalAcrobat instance;
private void Awake()
{
instance = this;
}
private void Update() private void Update()
{ {
@ -124,10 +132,11 @@ namespace HeavenStudio.Games
expBeat += seekedAnimal.length; expBeat += seekedAnimal.length;
} }
animal.Init(currentAnimal.startBeat, expBeat); animal.Init(currentAnimal.startBeat, expBeat, _lastAnimalWasGiraffe);
animal.transform.localPosition = new Vector3(_animalSummatedDistance, 0, 0); animal.transform.localPosition = new Vector3(_animalSummatedDistance, 0, 0);
_animalSummatedDistance += animal.GetRotationDistance() + _jumpDistance; _animalSummatedDistance += animal.GetRotationDistance() + _jumpDistance;
_lastAnimalWasGiraffe = currentAnimal.type == AnimalType.Giraffe;
_animalPoolIndex++; _animalPoolIndex++;
} }

View file

@ -0,0 +1,102 @@
using HeavenStudio.Util;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HeavenStudio.Games.Scripts_AnimalAcrobat
{
public class GiraffeInput : MonoBehaviour
{
private AcrobatObstacle _mainScript;
private AnimalAcrobat _game;
private Sound _drumRollSound;
private void Awake()
{
_game = AnimalAcrobat.instance;
_mainScript = GetComponent<AcrobatObstacle>();
_mainScript.OnInit += Init;
}
private void OnDestroy()
{
if (_drumRollSound != null) _drumRollSound.Stop();
}
public void Init(double beat, bool beforeGiraffe)
{
_game.ScheduleInput(beat - 1, 1, InputType.STANDARD_DOWN, beforeGiraffe ? JustHoldGiraffe : JustHold, Empty, Empty);
_game.ScheduleInput(beat, 4, InputType.STANDARD_UP, JustRelease, Empty, Empty);
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("animalAcrobat/eek", beat + 2),
new MultiSound.Sound("animalAcrobat/eek", beat + 3)
});
}
private void JustHold(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("animalAcrobat/catch");
}
private void JustHoldGiraffe(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("animalAcrobat/giraffeCatch");
}
private void JustRelease(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("animalAcrobat/giraffeJump");
double beat = caller.startBeat + caller.timer;
_drumRollSound = SoundByte.PlayOneShotGame("animalAcrobat/giraffeDrumroll", beat, 1, 1, true);
StartCoroutine(GiraffeDrumRollLoop(beat));
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("animalAcrobat/giraffeCymbal", beat + 2),
new MultiSound.Sound("animalAcrobat/applause", beat + 2.25),
new MultiSound.Sound("animalAcrobat/turn", beat + 3)
});
}
private IEnumerator GiraffeDrumRollLoop(double beat)
{
float fadeOutNormalized = 0;
var cond = Conductor.instance;
while (fadeOutNormalized <= 1)
{
fadeOutNormalized = cond.GetPositionFromBeat(beat, 1);
_drumRollSound.SetVolume(Mathf.Lerp(1, 0.125f, fadeOutNormalized));
yield return null;
}
float fadeInNormalized = 0;
while (fadeInNormalized <= 1)
{
fadeInNormalized = cond.GetPositionFromBeat(beat + 1, 3);
_drumRollSound.SetVolume(Mathf.Lerp(0.125f, 1, fadeOutNormalized));
yield return null;
}
float fadeOutFinal = 0;
double fadeOutLength = cond.SecsToBeats(0.587, cond.GetBpmAtBeat(beat + 4));
while (fadeOutFinal <= 1)
{
fadeOutFinal = cond.GetPositionFromBeat(beat + 4, fadeOutLength);
_drumRollSound.SetVolume(Mathf.Lerp(1, 0, fadeOutNormalized));
yield return null;
}
_drumRollSound.Stop();
_drumRollSound = null;
}
private void Empty(PlayerActionEvent caller) { }
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f87e00a2ffbd0af4baae18b3c11268db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,55 @@
using HeavenStudio.Util;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HeavenStudio.Games.Scripts_AnimalAcrobat
{
public class ObstacleInput : MonoBehaviour
{
[SerializeField] private double _holdLength;
private AcrobatObstacle _mainScript;
private AnimalAcrobat _game;
private void Awake()
{
_game = AnimalAcrobat.instance;
_mainScript = GetComponent<AcrobatObstacle>();
_mainScript.OnInit += Init;
}
public void Init(double beat, bool beforeGiraffe)
{
_game.ScheduleInput(beat - 1, 1, InputType.STANDARD_DOWN, beforeGiraffe ? JustHoldGiraffe : JustHold, Empty, Empty);
_game.ScheduleInput(beat, _holdLength, InputType.STANDARD_UP, JustRelease, Empty, Empty);
MultiSound.Play(new MultiSound.Sound[]
{
new MultiSound.Sound("animalAcrobat/eek", beat + _holdLength - 2),
new MultiSound.Sound("animalAcrobat/eek", beat + _holdLength - 1)
});
}
private void JustHold(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("animalAcrobat/catch");
}
private void JustHoldGiraffe(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("animalAcrobat/giraffeCatch");
}
private void JustRelease(PlayerActionEvent caller, float state)
{
SoundByte.PlayOneShotGame("animalAcrobat/release");
SoundByte.PlayOneShotGame("animalAcrobat/turn", caller.startBeat + caller.timer + 1);
}
private void Empty(PlayerActionEvent caller) { }
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9a934a7ab91ef694e94df3dce43f43ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -43,6 +43,11 @@ namespace HeavenStudio.Util
{ {
} }
public void SetVolume(float volume)
{
audioSource.volume = volume;
}
public void Play() public void Play()
{ {
if (!available) if (!available)