Made school of fish more efficient. Not ready for pull yet
This commit is contained in:
parent
04c69cf7fd
commit
818eed711d
|
@ -78,6 +78,7 @@ Transform:
|
|||
m_Children:
|
||||
- {fileID: 4634833702056322427}
|
||||
- {fileID: 7723273551500933620}
|
||||
- {fileID: 2818073722642125740}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -973,6 +974,37 @@ SpriteRenderer:
|
|||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &4390065670873110041
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2818073722642125740}
|
||||
m_Layer: 0
|
||||
m_Name: GameObject
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2818073722642125740
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4390065670873110041}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 8.883, y: -0.02, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8426454068735829380}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &4834162464390078830
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -3049,6 +3081,10 @@ PrefabInstance:
|
|||
propertyPath: m_Layer
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2884346302206887626, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2884730572189615003, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 0
|
||||
|
@ -4389,6 +4425,10 @@ PrefabInstance:
|
|||
propertyPath: m_Layer
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5550615216608200862, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5554715371012578784, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 0
|
||||
|
@ -4953,6 +4993,14 @@ PrefabInstance:
|
|||
propertyPath: IsDummy
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6727980822855321933, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: XXXXXXXXXXXX
|
||||
value:
|
||||
objectReference: {fileID: 5603933457609349627}
|
||||
- target: {fileID: 6727980822855321933, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: FishSchoolHolder
|
||||
value:
|
||||
objectReference: {fileID: 7497580079990425751}
|
||||
- target: {fileID: 6731707513831972095, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 0
|
||||
|
@ -5113,6 +5161,10 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: LakeScene
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7031810916068253247, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7033415981174504355, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 0
|
||||
|
@ -5129,6 +5181,10 @@ PrefabInstance:
|
|||
propertyPath: m_Layer
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7075225906441527770, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_SortingOrder
|
||||
value: -32768
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7075225906441527770, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
propertyPath: m_SpriteSortPoint
|
||||
value: 0
|
||||
|
@ -6087,8 +6143,18 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
--- !u!1 &5603933457609349627 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2884346302206887626, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
m_PrefabInstance: {fileID: 7332540138187890481}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &6845776578194601929 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 4234368678986115320, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
m_PrefabInstance: {fileID: 7332540138187890481}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &7497580079990425751 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 994920842471430054, guid: 85290dc3ea9c9e241b6da3b302a5da7c, type: 3}
|
||||
m_PrefabInstance: {fileID: 7332540138187890481}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
|
77283
Assets/Resources/Prefabs/Games/CatchOfTheDay/FishSchool.prefab
Normal file
77283
Assets/Resources/Prefabs/Games/CatchOfTheDay/FishSchool.prefab
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 312cb925466f01449a182b3802d57f0a
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 107 KiB |
|
@ -609,64 +609,43 @@ TextureImporter:
|
|||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: manta_eye02
|
||||
name: blindfixh_frame1
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 81
|
||||
y: 33
|
||||
width: 78
|
||||
height: 78
|
||||
y: 17
|
||||
width: 270
|
||||
height: 94
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 23b6cf0f3cfa9354c96c9ad440c8b0f0
|
||||
internalID: 921391121
|
||||
spriteID: 7f94b77af5941894a94a126ec141537a
|
||||
internalID: 1795055450
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: manta_eye03
|
||||
name: blindfish_frame2
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 161
|
||||
y: 33
|
||||
width: 78
|
||||
height: 78
|
||||
x: 353
|
||||
y: 17
|
||||
width: 270
|
||||
height: 94
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
pivot: {x: 0, y: 0}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: 5bfdfa3d354496f4e8e1ac4943a06b5d
|
||||
internalID: 1163347792
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
- serializedVersion: 2
|
||||
name: manta_eye04
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 241
|
||||
y: 33
|
||||
width: 78
|
||||
height: 78
|
||||
alignment: 0
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
tessellationDetail: 0
|
||||
bones: []
|
||||
spriteID: b6141affe6ff96647980f28f8fef72b4
|
||||
internalID: -62231254
|
||||
spriteID: 2d49220105270654c8d5de54d38ca205
|
||||
internalID: -1438975205
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
|
@ -686,6 +665,8 @@ TextureImporter:
|
|||
blindfish: -604475310
|
||||
blindfish_eye: 1628223578
|
||||
blindfish_fin: -783979999
|
||||
blindfish_frame2: -1438975205
|
||||
blindfixh_frame1: 1795055450
|
||||
manta_bg01: -803293434
|
||||
manta_bg02: -294726697
|
||||
manta_bg03: 924937168
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace HeavenStudio.Games.Loaders
|
|||
}
|
||||
}
|
||||
},
|
||||
new List<string>() {"rvl", "normal"},
|
||||
new List<string>() { "rvl", "normal" },
|
||||
"rvlfishing", "en"
|
||||
, chronologicalSortKey: 21
|
||||
);
|
||||
|
@ -153,7 +153,12 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
/*
|
||||
BIG LIST OF TODOS
|
||||
- fix the distractions
|
||||
- optimise fish school
|
||||
- make rendertex not blurry
|
||||
- final sfx
|
||||
- wait for upscale
|
||||
- remove unused
|
||||
*/
|
||||
protected const int MAX_LAKES = 50;
|
||||
|
||||
|
|
105
Assets/Scripts/Games/CatchOfTheDay/DynamicTextureRenderer.cs
Normal file
105
Assets/Scripts/Games/CatchOfTheDay/DynamicTextureRenderer.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks.Triggers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
||||
{
|
||||
public class DynamicTextureRenderer : MonoBehaviour
|
||||
{
|
||||
protected static List<DynamicTextureRenderer> Instances = new();
|
||||
private RenderTexture _GameTexture;
|
||||
|
||||
[SerializeField] Camera RenderCamera;
|
||||
[SerializeField] SpriteRenderer DisplaySprite;
|
||||
[SerializeField] GameObject TargetObject;
|
||||
[SerializeField] Vector2Int Size = new Vector2Int(1024, 1024);
|
||||
[SerializeField] int Depth = 32;
|
||||
|
||||
private RenderTexture _RenderTexture;
|
||||
private Texture2D _DisplayTexture;
|
||||
|
||||
void Start()
|
||||
{
|
||||
AddInstance(this);
|
||||
GetGameTexture();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
Render();
|
||||
}
|
||||
|
||||
private void Render()
|
||||
{
|
||||
if (!DisplaySprite.enabled)
|
||||
return;
|
||||
|
||||
if (_GameTexture == null && GetGameTexture() == null)
|
||||
return;
|
||||
|
||||
if (_RenderTexture == null || _RenderTexture.width != _GameTexture.width * 2 || _RenderTexture.height != _GameTexture.height * 2)
|
||||
{
|
||||
GenerateRenderTexture();
|
||||
}
|
||||
|
||||
//CullInstances(this);
|
||||
RenderCamera.Render();
|
||||
//RestoreCulledInstances();
|
||||
|
||||
RenderTexture currentRenderTexture = RenderTexture.active;
|
||||
RenderTexture.active = _RenderTexture;
|
||||
_DisplayTexture.ReadPixels(new Rect(0, 0, _RenderTexture.width, _RenderTexture.height), 0, 0);
|
||||
_DisplayTexture.Apply();
|
||||
|
||||
RenderTexture.active = currentRenderTexture;
|
||||
}
|
||||
protected static void CullInstances(DynamicTextureRenderer currentInstance)
|
||||
{
|
||||
foreach (DynamicTextureRenderer instance in Instances)
|
||||
{
|
||||
if (instance != null && instance.isActiveAndEnabled)
|
||||
instance.TargetObject.SetActive(instance == currentInstance);
|
||||
}
|
||||
}
|
||||
protected static void RestoreCulledInstances()
|
||||
{
|
||||
foreach (DynamicTextureRenderer instance in Instances)
|
||||
{
|
||||
if (instance != null && instance.isActiveAndEnabled)
|
||||
instance.TargetObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void AddInstance(DynamicTextureRenderer instance)
|
||||
{
|
||||
TrimInstances();
|
||||
if (!Instances.Contains(instance))
|
||||
Instances.Add(instance);
|
||||
}
|
||||
private static void TrimInstances()
|
||||
{
|
||||
Instances.RemoveAll(instance => instance == null);
|
||||
}
|
||||
|
||||
private RenderTexture GetGameTexture()
|
||||
{
|
||||
return _GameTexture ??= GameCamera.instance.GetComponent<Camera>().targetTexture;
|
||||
}
|
||||
private void GenerateRenderTexture()
|
||||
{
|
||||
if (_RenderTexture != null) Destroy(_RenderTexture);
|
||||
if (_DisplayTexture != null) Destroy(_DisplayTexture);
|
||||
if (DisplaySprite.sprite != null) Destroy(DisplaySprite.sprite);
|
||||
|
||||
int width = _GameTexture.width;
|
||||
int height = _GameTexture.height;
|
||||
Debug.Log($"{width} x {height}");
|
||||
|
||||
_RenderTexture = new RenderTexture(width * 2, height * 2, Depth);
|
||||
RenderCamera.targetTexture = _RenderTexture;
|
||||
_DisplayTexture = new Texture2D(width * 2, height * 2, TextureFormat.RGBA32, false);
|
||||
Sprite sprite = Sprite.Create(_DisplayTexture, new Rect(0, 0, width * 2, height * 2), new Vector2(0.5f, 0.5f));
|
||||
DisplaySprite.sprite = sprite;
|
||||
DisplaySprite.transform.localScale = new Vector3(17.77695f / (width / 50), 10 / (height / 50), 1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1589b04d766700c47a3824ad5b9caeb4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Assets/Scripts/Games/CatchOfTheDay/FishParticleSystem.cs
Normal file
16
Assets/Scripts/Games/CatchOfTheDay/FishParticleSystem.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
||||
{
|
||||
public class FishParticleSystem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] ParticleSystem _ParticleSystem;
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 884c0430b0fce9141aec48d5a263abec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -20,9 +20,11 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
|||
[SerializeField] public SortingGroup _SortingGroup;
|
||||
[SerializeField] public GameObject BigManta;
|
||||
[SerializeField] public GameObject SmallManta;
|
||||
[SerializeField] public Transform FishSchoolHolder;
|
||||
[SerializeField] public GameObject FishSchool;
|
||||
[SerializeField] public GameObject[] SchoolFishes;
|
||||
[SerializeField] public ParticleSystem[] Bubbles;
|
||||
[SerializeField] DynamicTextureRenderer _DynamicTextureRenderer;
|
||||
|
||||
[SerializeField] Color[] TopColors;
|
||||
[SerializeField] Color[] BottomColors;
|
||||
|
@ -39,14 +41,13 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
|||
|
||||
private double? _CrossfadeStartBeat;
|
||||
[SerializeField] GameObject Renderer;
|
||||
private bool _FirstUpdate = false;
|
||||
|
||||
[SerializeField] Animator CrossfadeAnimator;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (FishSchool.activeSelf)
|
||||
FishSchool.transform.localEulerAngles = new Vector3(0, 0, Conductor.instance.songPositionInBeats * 45);
|
||||
if (FishSchoolHolder != null)
|
||||
FishSchoolHolder.transform.localEulerAngles = new Vector3(0, 0, Conductor.instance.songPositionInBeats * 45);
|
||||
if (BigManta.activeSelf)
|
||||
BigManta.transform.localPosition = new Vector3((float)Entity.beat - Conductor.instance.songPositionInBeats + 4.5f, BigManta.transform.localPosition.y, BigManta.transform.localPosition.z);
|
||||
if (SmallManta.activeSelf)
|
||||
|
@ -171,7 +172,6 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
|||
|
||||
if ((bool)e["schoolFish"])
|
||||
{
|
||||
FishSchool.SetActive(true);
|
||||
SetFishDensity(e["fishDensity"]);
|
||||
}
|
||||
else
|
||||
|
@ -188,6 +188,8 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
|||
Renderer.transform.localPosition -= new Vector3(0, 0, sortingIndex);
|
||||
RenderCamera.transform.localPosition -= new Vector3(0, 0, sortingIndex);
|
||||
|
||||
_DynamicTextureRenderer.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)
|
||||
|
@ -203,15 +205,17 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
|||
public void SetFishDensity(float density)
|
||||
{
|
||||
if (density <= 0.0f)
|
||||
{
|
||||
FishSchool.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
float fishCount = density * SchoolFishes.Length;
|
||||
for (int i = 0; i < SchoolFishes.Length; i++)
|
||||
Transform fishSchool = Instantiate(FishSchool, FishSchoolHolder).transform;
|
||||
|
||||
if (density >= 1)
|
||||
{
|
||||
SchoolFishes[i].SetActive(i < fishCount);
|
||||
float fishCount = density * fishSchool.childCount;
|
||||
for (int i = 0; i < fishSchool.childCount; i++)
|
||||
{
|
||||
fishSchool.GetChild(i).gameObject.SetActive(i < fishCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,7 +393,7 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
|||
[SerializeField] SpriteRenderer DisplaySprite;
|
||||
public void RenderScene()
|
||||
{
|
||||
if (!DisplaySprite.enabled)
|
||||
/*if (!DisplaySprite.enabled)
|
||||
return;
|
||||
|
||||
Rect rect = new Rect(0, 0, 1024, 1024);
|
||||
|
@ -410,7 +414,7 @@ namespace HeavenStudio.Games.Scripts_CatchOfTheDay
|
|||
_DisplayTexture.ReadPixels(rect, 0, 0);
|
||||
_DisplayTexture.Apply();
|
||||
|
||||
RenderTexture.active = currentRenderTexture;
|
||||
RenderTexture.active = currentRenderTexture;*/
|
||||
}
|
||||
|
||||
public void Crossfade(double beat)
|
||||
|
|
Loading…
Reference in a new issue