Crossfade close to done

This commit is contained in:
playinful 2024-03-30 15:10:34 -04:00
parent 8e96219a46
commit 4d1be565d8
11 changed files with 1844 additions and 1075 deletions

View file

@ -1704,6 +1704,26 @@ PrefabInstance:
propertyPath: m_Name
value: LakeScene
objectReference: {fileID: 0}
- target: {fileID: 7075225906441527770, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
propertyPath: m_SpriteSortPoint
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7094553776486818153, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
propertyPath: m_SizeDelta.x
value: 8.08
objectReference: {fileID: 0}
- target: {fileID: 7094553776486818153, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
propertyPath: m_SizeDelta.y
value: 4.55
objectReference: {fileID: 0}
- target: {fileID: 7094553776486818153, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7094553776486818153, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8700198444596314370, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
propertyPath: m_SortingOrder
value: -100

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8d0ceacd2d6c5594f99b45496653b223
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,116 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Crossfade
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path:
classID: 212
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 304273561
script: {fileID: 0}
typeID: 212
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.5
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.5
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path:
classID: 212
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d979268770ea085488a1f5955194182e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,101 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1102 &-8650472206130311706
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: None
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 6bdd2cf6e49e72e43962bb1c5784c84a, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Display
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 3592794445225652459}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &3427675535650201557
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Crossfade
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: d979268770ea085488a1f5955194182e, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &3592794445225652459
AnimatorStateMachine:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: -8650472206130311706}
m_Position: {x: 30, y: 170, z: 0}
- serializedVersion: 1
m_State: {fileID: 3427675535650201557}
m_Position: {x: 30, y: 220, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -8650472206130311706}

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 90044c49795e92c429564fb22db54689
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,116 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: None
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 3.4833333
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path:
classID: 212
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 304273561
script: {fileID: 0}
typeID: 212
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 3.4833333
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 3.4833333
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
path:
classID: 212
script: {fileID: 0}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6bdd2cf6e49e72e43962bb1c5784c84a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -113,10 +113,10 @@ namespace HeavenStudio.Games
{
/*
BIG LIST OF TODOS
- ping @hexiedecimal
- scene transitions
- wait for upscale
- make ann movable
- remove pointless usings
*/
public static CatchOfTheDay Instance
{
@ -319,17 +319,17 @@ namespace HeavenStudio.Games
}
return false;
}
public void DisposeLake(LakeScene lake)
public void DisposeLake(LakeScene lake, double beat)
{
ActiveLakes.Remove(lake.Entity);
if (ActiveLakes.Count <= 0)
{
if (SpawnNextFish(conductor.songPositionInBeatsAsDouble))
Destroy(lake.gameObject);
lake.Crossfade(beat);
}
else
Destroy(lake.gameObject);
lake.Crossfade(beat);
}
public enum FishLayout : int

View file

@ -1,10 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using HeavenStudio;
using HeavenStudio.Games;
using HeavenStudio.Util;
using Jukebox;
using Newtonsoft.Json;
using TMPro;
using UnityEditor.Playables;
using UnityEngine;
using UnityEngine.Rendering;
@ -12,7 +16,7 @@ using UnityEngine.Rendering;
namespace HeavenStudio.Games.Scripts_CatchOfTheDay
{
public class LakeScene : MonoBehaviour
{
{
[SerializeField] public bool IsDummy = false;
[SerializeField] public Animator FishAnimator;
@ -38,6 +42,13 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
public MultiSound _MultiSound;
private RenderTexture _RenderTexture;
private Texture2D _DisplayTexture;
private double? _CrossfadeStartBeat;
[SerializeField] Animator CrossfadeAnimator;
void Update()
{
if (FishSchool.activeSelf)
@ -46,6 +57,20 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
BigManta.transform.localPosition = new Vector3((float)Entity.beat - Conductor.instance.songPositionInBeats + 4.5f, BigManta.transform.localPosition.y, BigManta.transform.localPosition.z);
if (SmallManta.activeSelf)
SmallManta.transform.localPosition = new Vector3(1.25f + ((Conductor.instance.songPositionInBeats - (float)Entity.beat) * 0.13f), SmallManta.transform.localPosition.y, SmallManta.transform.localPosition.y);
if (!IsDummy)
RenderScene();
if (_CrossfadeStartBeat is double startBeat)
{
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 1);
//Debug.Log(1 - normalizedBeat);
DisplaySprite.color = new Color(1, 1, 1, 1 - normalizedBeat);
Debug.Log(DisplaySprite.color);
if (normalizedBeat >= 1f) Destroy(gameObject);
}
}
public int Setup(RiqEntity e, CatchOfTheDay minigame, int? lastLayout = null, int sortingIndex = 0)
@ -65,7 +90,7 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
new BeatAction.Action(e.beat, delegate { DoPickAnim(e.beat); }),
new BeatAction.Action(e.beat + 1, delegate { DoPickAnim(e.beat + 1); }),
new BeatAction.Action(e.beat + 2 - 0.1f, delegate { DoBiteAnim(e.beat + 2 - 0.1f); }),
new BeatAction.Action(e.beat + 2 + (float)e["sceneDelay"], delegate { minigame.DisposeLake(this); }),
new BeatAction.Action(e.beat + 2 + (float)e["sceneDelay"], delegate { minigame.DisposeLake(this, e.beat + 2 + (float)e["sceneDelay"]); }),
});
break;
case "catchOfTheDay/fish2":
@ -79,7 +104,7 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
new BeatAction.Action(e.beat + 0.5f, delegate { DoPickAnim(e.beat + 0.5f); }),
new BeatAction.Action(e.beat + 1, delegate { DoPickAnim(e.beat + 1); }),
new BeatAction.Action(e.beat + 3 - 0.1f, delegate { DoBiteAnim(e.beat + 3 - 0.1f); }),
new BeatAction.Action(e.beat + 3 + (float)e["sceneDelay"], delegate { minigame.DisposeLake(this); }),
new BeatAction.Action(e.beat + 3 + (float)e["sceneDelay"], delegate { minigame.DisposeLake(this, e.beat + 3 + (float)e["sceneDelay"]); }),
});
break;
case "catchOfTheDay/fish3":
@ -100,7 +125,7 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
new BeatAction.Action(e.beat + 0.5f, delegate { DoPickAnim(e.beat + 0.5f); }),
new BeatAction.Action(e.beat + 1f, delegate { DoPickAnim(e.beat + 1f, down: true); }),
new BeatAction.Action(e.beat + 4.5f - 0.1f, delegate { DoBiteAnim(e.beat + 4.5f - 0.1f); }),
new BeatAction.Action(e.beat + 4.5f + (float)e["sceneDelay"], delegate { minigame.DisposeLake(this); }),
new BeatAction.Action(e.beat + 4.5f + (float)e["sceneDelay"], delegate { minigame.DisposeLake(this, e.beat + 4.5f + (float)e["sceneDelay"]); }),
});
BeatAction.New(this, beatActions);
break;
@ -164,6 +189,8 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
foreach (ParticleSystem particle in Bubbles.OrderBy(_ => UnityEngine.Random.Range(0.0f, 1.0f)).ToArray()[0..bubbleCount])
particle.PlayScaledAsync(0.5f);
DisplaySprite.enabled = true;
return layout; // returning this so we can catalogue the most recent layout so we don't double up
}
public void SetBGColors(Color topColor, Color bottomColor)
@ -361,6 +388,44 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
}
}
[SerializeField] Camera RenderCamera;
[SerializeField] SpriteRenderer DisplaySprite;
public void RenderScene()
{
if (!DisplaySprite.enabled)
return;
Rect rect = new Rect(0, 0, 1024, 1024);
if (_RenderTexture == null)
{
_RenderTexture = new RenderTexture(1024, 1024, 24);
RenderCamera.targetTexture = _RenderTexture;
_DisplayTexture = new Texture2D(1024, 1024, TextureFormat.RGBA32, true);
Sprite sprite = Sprite.Create(_DisplayTexture, new Rect(0, 0, 1024, 1024), new Vector2(0.5f, 0.5f));
DisplaySprite.sprite = sprite;
}
int originalSort = _SortingGroup.sortingOrder;
_SortingGroup.sortingOrder = short.MaxValue;
RenderCamera.Render();
_SortingGroup.sortingOrder = originalSort;
_DisplayTexture.alphaIsTransparency = true;
RenderTexture currentRenderTexture = RenderTexture.active;
RenderTexture.active = _RenderTexture;
_DisplayTexture.ReadPixels(rect, 0, 0);
_DisplayTexture.Apply();
RenderTexture.active = currentRenderTexture;
}
public void Crossfade(double beat)
{
_CrossfadeStartBeat = beat;
//CrossfadeAnimator.DoScaledAnimationAsync("Crossfade", 0.5f);
}
[SerializeField] GameObject SchoolFishPrefab;
[ContextMenu("Spawn a bunch of fish")]
void SpawnABunchOfFish()