Fix Object Instantiating
This commit is contained in:
34
Assets/GameVariables.asset
Normal file
34
Assets/GameVariables.asset
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 9f37e854902a46cb8bd927cf84ab450c, type: 3}
|
||||||
|
m_Name: GameVariables
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
bgTilePrefabs: {fileID: 2914066502361773997, guid: 3f39182b81f944a4d93213431acb41c3,
|
||||||
|
type: 3}
|
||||||
|
bombPrefab: {fileID: 5652386976359944012, guid: aa0291e650b382941875040db9e8a232,
|
||||||
|
type: 3}
|
||||||
|
gemsPrefabs:
|
||||||
|
- {fileID: 3808538059049426536, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
||||||
|
- {fileID: 4490600519223577409, guid: 784323496d719684cb6201b200b95864, type: 3}
|
||||||
|
- {fileID: 745607475630438949, guid: 93bd623174244c047af9ce43cc254c32, type: 3}
|
||||||
|
- {fileID: 6213027626580313688, guid: 473855e3d0d3c8143836b678c9a1b8b5, type: 3}
|
||||||
|
- {fileID: 1845825807271331471, guid: 91ba2370328500d4db689dad894b1602, type: 3}
|
||||||
|
destroyEffectPrefabs: []
|
||||||
|
bonusAmount: 0.5
|
||||||
|
bombChance: 2
|
||||||
|
dropHeight: 0
|
||||||
|
gemSpeed: 7
|
||||||
|
scoreSpeed: 5
|
||||||
|
width: 7
|
||||||
|
height: 7
|
||||||
|
rowsSize: 7
|
||||||
|
colsSize: 7
|
||||||
8
Assets/GameVariables.asset.meta
Normal file
8
Assets/GameVariables.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: edd9a973e745f4f41bce834af2c68d05
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -5,6 +5,7 @@ PrefabInstance:
|
|||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Modification:
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 0}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
- target: {fileID: -7932498854989450506, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
- target: {fileID: -7932498854989450506, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
@@ -55,6 +56,11 @@ PrefabInstance:
|
|||||||
value:
|
value:
|
||||||
objectReference: {fileID: 8968486364681163996, guid: 05c754e3d4f9fd349ac1def58d17670f,
|
objectReference: {fileID: 8968486364681163996, guid: 05c754e3d4f9fd349ac1def58d17670f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_RootOrder
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
@@ -70,6 +76,11 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
@@ -85,16 +96,6 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
|
||||||
type: 3}
|
|
||||||
propertyPath: m_RootOrder
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
- target: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
@@ -110,5 +111,31 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents:
|
||||||
|
- {fileID: -7932498854989450506, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 7667143225876670874, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
|
type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 5350632371355805727}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
||||||
|
--- !u!1 &1210587634127288510 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 7667143225876670874, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 8839428272799928612}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &5350632371355805727
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1210587634127288510}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7645dd1d371740729311dd834ab649f3, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 7667143225876670887}
|
- component: {fileID: 7667143225876670887}
|
||||||
- component: {fileID: 7667143225876670884}
|
- component: {fileID: 7667143225876670884}
|
||||||
- component: {fileID: -7932498854989450506}
|
|
||||||
- component: {fileID: -4313073739878660840}
|
- component: {fileID: -4313073739878660840}
|
||||||
|
- component: {fileID: 3808538059049426536}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Gem - Blue
|
m_Name: Gem - Blue
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -26,12 +26,13 @@ Transform:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 7667143225876670874}
|
m_GameObject: {fileID: 7667143225876670874}
|
||||||
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!212 &7667143225876670884
|
--- !u!212 &7667143225876670884
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
@@ -44,10 +45,12 @@ SpriteRenderer:
|
|||||||
m_CastShadows: 0
|
m_CastShadows: 0
|
||||||
m_ReceiveShadows: 0
|
m_ReceiveShadows: 0
|
||||||
m_DynamicOccludee: 1
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
m_MotionVectors: 1
|
m_MotionVectors: 1
|
||||||
m_LightProbeUsage: 1
|
m_LightProbeUsage: 1
|
||||||
m_ReflectionProbeUsage: 1
|
m_ReflectionProbeUsage: 1
|
||||||
m_RayTracingMode: 0
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
@@ -83,25 +86,6 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!114 &-7932498854989450506
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 7667143225876670874}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: c5d1e13e319aa044e9776fbd351e9d03, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
posIndex: {x: 0, y: 0}
|
|
||||||
type: 0
|
|
||||||
isMatch: 0
|
|
||||||
destroyEffect: {fileID: 8904178830182364799, guid: d794be08823edd34da1790efd1739074,
|
|
||||||
type: 3}
|
|
||||||
scoreValue: 10
|
|
||||||
blastSize: 1
|
|
||||||
--- !u!61 &-4313073739878660840
|
--- !u!61 &-4313073739878660840
|
||||||
BoxCollider2D:
|
BoxCollider2D:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -112,6 +96,25 @@ BoxCollider2D:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_Density: 1
|
m_Density: 1
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_ForceSendLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ForceReceiveLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ContactCaptureLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_CallbackLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_UsedByEffector: 0
|
m_UsedByEffector: 0
|
||||||
m_UsedByComposite: 0
|
m_UsedByComposite: 0
|
||||||
@@ -128,3 +131,15 @@ BoxCollider2D:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 0.95, y: 0.95}
|
m_Size: {x: 0.95, y: 0.95}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
||||||
|
--- !u!114 &3808538059049426536
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7667143225876670874}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7645dd1d371740729311dd834ab649f3, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 5754733557323264208}
|
- component: {fileID: 5754733557323264208}
|
||||||
- component: {fileID: 7273189601935488900}
|
- component: {fileID: 7273189601935488900}
|
||||||
|
- component: {fileID: 5589707646945116404}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: RootLifetimeScope
|
m_Name: RootLifetimeScope
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -48,3 +49,15 @@ MonoBehaviour:
|
|||||||
TypeName:
|
TypeName:
|
||||||
autoRun: 1
|
autoRun: 1
|
||||||
autoInjectGameObjects: []
|
autoInjectGameObjects: []
|
||||||
|
--- !u!114 &5589707646945116404
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8304424163596944933}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 51137073af0548959f4e16ceffc344b5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ Transform:
|
|||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 376092240}
|
|
||||||
- {fileID: 1445334646}
|
|
||||||
- {fileID: 259844899}
|
- {fileID: 259844899}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
@@ -224,50 +222,6 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 3199143}
|
m_Father: {fileID: 3199143}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &376092239
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 376092240}
|
|
||||||
- component: {fileID: 376092241}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: SC_GameLogic
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &376092240
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 376092239}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 3199143}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &376092241
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 376092239}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: db185b18195d3814aab9ba4ac5f95047, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!1 &519420028
|
--- !u!1 &519420028
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -810,66 +764,6 @@ SpriteRenderer:
|
|||||||
m_WasSpriteAssigned: 1
|
m_WasSpriteAssigned: 1
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_SpriteSortPoint: 0
|
m_SpriteSortPoint: 0
|
||||||
--- !u!1 &1445334645
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1445334646}
|
|
||||||
- component: {fileID: 1445334647}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: SC_GameVariables
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &1445334646
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1445334645}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 3199143}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &1445334647
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1445334645}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 3b3b891bcdf21df4ab82ea34c3afc99e, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
bgTilePrefabs: {fileID: 2914066502361773997, guid: 3f39182b81f944a4d93213431acb41c3,
|
|
||||||
type: 3}
|
|
||||||
bomb: {fileID: 7728721766547317714, guid: aa0291e650b382941875040db9e8a232, type: 3}
|
|
||||||
gems:
|
|
||||||
- {fileID: -7932498854989450506, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
|
||||||
- {fileID: 1972979191936378847, guid: 784323496d719684cb6201b200b95864, type: 3}
|
|
||||||
- {fileID: 3416069867743778491, guid: 93bd623174244c047af9ce43cc254c32, type: 3}
|
|
||||||
- {fileID: 8289337781777951430, guid: 473855e3d0d3c8143836b678c9a1b8b5, type: 3}
|
|
||||||
- {fileID: 4372168081761593873, guid: 91ba2370328500d4db689dad894b1602, type: 3}
|
|
||||||
bonusAmount: 0.5
|
|
||||||
bombChance: 3
|
|
||||||
dropHeight: 1
|
|
||||||
gemSpeed: 7
|
|
||||||
scoreSpeed: 5
|
|
||||||
rowsSize: 7
|
|
||||||
colsSize: 7
|
|
||||||
--- !u!1 &1450061018
|
--- !u!1 &1450061018
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1037,6 +931,56 @@ Transform:
|
|||||||
- {fileID: 1136728301}
|
- {fileID: 1136728301}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &2056718315
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2056718317}
|
||||||
|
- component: {fileID: 2056718316}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: LevelScope
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &2056718316
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2056718315}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a1e22ac45ff5446daf1aaa01329759a9, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
parentReference:
|
||||||
|
TypeName: Scopes.RootLifetimeScope
|
||||||
|
autoRun: 1
|
||||||
|
autoInjectGameObjects: []
|
||||||
|
gameVariables: {fileID: 11400000, guid: edd9a973e745f4f41bce834af2c68d05, type: 2}
|
||||||
|
gemsHolder: {fileID: 1740955909}
|
||||||
|
--- !u!4 &2056718317
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2056718315}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1660057539 &9223372036854775807
|
--- !u!1660057539 &9223372036854775807
|
||||||
SceneRoots:
|
SceneRoots:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1046,3 +990,4 @@ SceneRoots:
|
|||||||
- {fileID: 1740955909}
|
- {fileID: 1740955909}
|
||||||
- {fileID: 1450061022}
|
- {fileID: 1450061022}
|
||||||
- {fileID: 3199143}
|
- {fileID: 3199143}
|
||||||
|
- {fileID: 2056718317}
|
||||||
|
|||||||
39
Assets/Scripts/Scopes/LevelLifetimeScope.cs
Normal file
39
Assets/Scripts/Scopes/LevelLifetimeScope.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using Models;
|
||||||
|
using Models.Interfaces;
|
||||||
|
using ScriptableObjects;
|
||||||
|
using Services;
|
||||||
|
using Services.Interfaces;
|
||||||
|
using UnityEngine;
|
||||||
|
using VContainer;
|
||||||
|
using VContainer.Unity;
|
||||||
|
using Views;
|
||||||
|
|
||||||
|
namespace Scopes
|
||||||
|
{
|
||||||
|
public class LevelLifetimeScope : LifetimeScope
|
||||||
|
{
|
||||||
|
[SerializeField] private GameVariables gameVariables;
|
||||||
|
[SerializeField] private Transform gemsHolder;
|
||||||
|
|
||||||
|
protected override void Configure(IContainerBuilder builder)
|
||||||
|
{
|
||||||
|
builder.RegisterInstance(this.gameVariables);
|
||||||
|
builder.RegisterInstance(this.gemsHolder);
|
||||||
|
|
||||||
|
builder.Register<IGameBoard>(c =>
|
||||||
|
new GameBoard(this.gameVariables.width, this.gameVariables.height),
|
||||||
|
Lifetime.Scoped);
|
||||||
|
|
||||||
|
builder.Register<IMatchService, MatchService>(Lifetime.Scoped);
|
||||||
|
builder.Register<IScoreService, ScoreService>(Lifetime.Scoped);
|
||||||
|
|
||||||
|
builder.Register<IObjectPool<GemView>>(c =>
|
||||||
|
new ObjectPoolService(this.gameVariables.gemsPrefabs, this.gemsHolder, this.gameVariables.width * this.gameVariables.height),
|
||||||
|
Lifetime.Scoped);
|
||||||
|
|
||||||
|
builder.Register<IGameBoardService, GameBoardService>(Lifetime.Scoped);
|
||||||
|
|
||||||
|
builder.RegisterEntryPoint<LevelEntryPoint>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Scopes/LevelLifetimeScope.cs.meta
Normal file
3
Assets/Scripts/Scopes/LevelLifetimeScope.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a1e22ac45ff5446daf1aaa01329759a9
|
||||||
|
timeCreated: 1765676452
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
|
using Services;
|
||||||
|
using Services.Interfaces;
|
||||||
using VContainer;
|
using VContainer;
|
||||||
using VContainer.Unity;
|
using VContainer.Unity;
|
||||||
|
|
||||||
namespace Scopes {
|
namespace Scopes {
|
||||||
public class RootLifetimeScope : LifetimeScope {
|
public class RootLifetimeScope : LifetimeScope {
|
||||||
protected override void Configure(IContainerBuilder builder) {
|
protected override void Configure(IContainerBuilder builder)
|
||||||
|
{
|
||||||
|
builder.RegisterComponentInHierarchy<InputService>()
|
||||||
|
.As<IInputService>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Enums;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Views;
|
using Views;
|
||||||
|
|
||||||
@@ -14,6 +16,8 @@ namespace ScriptableObjects {
|
|||||||
public int dropHeight = 1;
|
public int dropHeight = 1;
|
||||||
public float gemSpeed = 7;
|
public float gemSpeed = 7;
|
||||||
public float scoreSpeed = 5;
|
public float scoreSpeed = 5;
|
||||||
|
public int width;
|
||||||
|
public int height;
|
||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public int rowsSize = 7;
|
public int rowsSize = 7;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
@@ -7,6 +6,7 @@ using Models.Interfaces;
|
|||||||
using ScriptableObjects;
|
using ScriptableObjects;
|
||||||
using Services.Interfaces;
|
using Services.Interfaces;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Utils;
|
||||||
using Views;
|
using Views;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
@@ -17,26 +17,20 @@ namespace Services {
|
|||||||
private GameVariables gameVariables;
|
private GameVariables gameVariables;
|
||||||
private IMatchService matchService;
|
private IMatchService matchService;
|
||||||
private IScoreService scoreService;
|
private IScoreService scoreService;
|
||||||
|
private IObjectPool<GemView> objectPool;
|
||||||
private Transform gemsHolder;
|
private Transform gemsHolder;
|
||||||
|
|
||||||
public GameBoardService(IGameBoard gameBoard, GameVariables gameVariables, IMatchService matchService, IScoreService scoreSerivce, Transform gemsHolder) {
|
public GameBoardService(IGameBoard gameBoard, GameVariables gameVariables, IMatchService matchService, IScoreService scoreSerivce, IObjectPool<GemView> objectPool, Transform gemsHolder) {
|
||||||
this.gameBoard = gameBoard;
|
this.gameBoard = gameBoard;
|
||||||
this.gameVariables = gameVariables;
|
this.gameVariables = gameVariables;
|
||||||
this.matchService = matchService;
|
this.matchService = matchService;
|
||||||
this.scoreService = scoreSerivce;
|
this.scoreService = scoreSerivce;
|
||||||
|
this.objectPool = objectPool;
|
||||||
this.gemsHolder = gemsHolder;
|
this.gemsHolder = gemsHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int RandomGemTypeAsInt() {
|
|
||||||
GemType[] spawnableGems = Enum.GetValues(typeof(GemType))
|
|
||||||
.Cast<GemType>()
|
|
||||||
.Where(gType => gType != GemType.Bomb)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
return Random.Range(0, spawnableGems.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Setup() {
|
public void Setup() {
|
||||||
|
Debug.Log("Setting up the board");
|
||||||
for (int x = 0; x < this.gameBoard.Width; x++)
|
for (int x = 0; x < this.gameBoard.Width; x++)
|
||||||
for (int y = 0; y < this.gameBoard.Height; y++)
|
for (int y = 0; y < this.gameBoard.Height; y++)
|
||||||
{
|
{
|
||||||
@@ -45,28 +39,25 @@ namespace Services {
|
|||||||
backgroundTile.transform.SetParent(this.gemsHolder);
|
backgroundTile.transform.SetParent(this.gemsHolder);
|
||||||
backgroundTile.name = "BG Tile - " + x + ", " + y;
|
backgroundTile.name = "BG Tile - " + x + ", " + y;
|
||||||
|
|
||||||
|
int gemToUse = RandomUtils.RandomGemTypeAsInt();
|
||||||
|
|
||||||
int gemToUse = RandomGemTypeAsInt();
|
|
||||||
|
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
while (this.matchService.MatchesAt(new Vector2Int(x, y), (GemType)gemToUse) && iterations < 100)
|
while (this.matchService.MatchesAt(new Vector2Int(x, y), (GemType)gemToUse) && iterations < 100)
|
||||||
{
|
{
|
||||||
gemToUse = RandomGemTypeAsInt();
|
gemToUse = RandomUtils.RandomGemTypeAsInt();
|
||||||
iterations++;
|
iterations++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ToDo: change gameVariables.gemsPrefabs[gemToUse] since gemToUse is index, if the order changes it wont work
|
|
||||||
SpawnGem(new Vector2Int(x, y), this.gameVariables.gemsPrefabs[gemToUse], (GemType)gemToUse);
|
SpawnGem(new Vector2Int(x, y), this.gameVariables.gemsPrefabs[gemToUse], (GemType)gemToUse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SpawnGem(Vector2Int position, GemView gemPrefab, GemType gemType) {
|
public void SpawnGem(Vector2Int position, GemView gemPrefab, GemType gemType) {
|
||||||
|
Debug.Log("Spawning gem at " + position + " with type " + gemType + "");
|
||||||
if (Random.Range(0, 100f) < this.gameVariables.bombChance)
|
if (Random.Range(0, 100f) < this.gameVariables.bombChance)
|
||||||
gemPrefab = this.gameVariables.bombPrefab;
|
gemPrefab = this.gameVariables.bombPrefab;
|
||||||
|
|
||||||
GemView gemView = Object.Instantiate(gemPrefab, new Vector3(position.x, position.y + this.gameVariables.dropHeight, 0f), Quaternion.identity);
|
GemView gemView = this.objectPool.Get(gemType, position, this.gameVariables.dropHeight);
|
||||||
gemView.transform.SetParent(this.gemsHolder);
|
|
||||||
gemView.name = "Gem - " + position.x + ", " + position.y;
|
gemView.name = "Gem - " + position.x + ", " + position.y;
|
||||||
SetGem(new Vector2Int(position.x,position.y), new Gem(gemType, position));
|
SetGem(new Vector2Int(position.x,position.y), new Gem(gemType, position));
|
||||||
}
|
}
|
||||||
@@ -140,7 +131,7 @@ namespace Services {
|
|||||||
{
|
{
|
||||||
Gem currentGem = this.gameBoard.GetGemAt(new Vector2Int(x,y));
|
Gem currentGem = this.gameBoard.GetGemAt(new Vector2Int(x,y));
|
||||||
if (currentGem == null) {
|
if (currentGem == null) {
|
||||||
int gemToUse = RandomGemTypeAsInt();
|
int gemToUse = RandomUtils.RandomGemTypeAsInt();
|
||||||
SpawnGem(new Vector2Int(x, y), this.gameVariables.gemsPrefabs[gemToUse], (GemType)gemToUse);
|
SpawnGem(new Vector2Int(x, y), this.gameVariables.gemsPrefabs[gemToUse], (GemType)gemToUse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,6 +165,7 @@ namespace Services {
|
|||||||
if (currentGem != null)
|
if (currentGem != null)
|
||||||
{
|
{
|
||||||
GemView gemView = gemsViews.FirstOrDefault(gv => gv.Gem == currentGem);
|
GemView gemView = gemsViews.FirstOrDefault(gv => gv.Gem == currentGem);
|
||||||
|
if(this.gameVariables.destroyEffectPrefabs.Length > 0)
|
||||||
Object.Instantiate(this.gameVariables.destroyEffectPrefabs[(int)currentGem.Type], new Vector2(position.x, position.y), Quaternion.identity);
|
Object.Instantiate(this.gameVariables.destroyEffectPrefabs[(int)currentGem.Type], new Vector2(position.x, position.y), Quaternion.identity);
|
||||||
|
|
||||||
Object.Destroy(gemView!.gameObject);
|
Object.Destroy(gemView!.gameObject);
|
||||||
|
|||||||
35
Assets/Scripts/Services/InputService.cs
Normal file
35
Assets/Scripts/Services/InputService.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using Services.Interfaces;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Services {
|
||||||
|
public class InputService : MonoBehaviour, IInputService
|
||||||
|
{
|
||||||
|
public event Action<Vector2> OnPointerDown;
|
||||||
|
public event Action<Vector2> OnPointerUp;
|
||||||
|
|
||||||
|
private bool wasDown;
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
// Mouse
|
||||||
|
var isDown = Input.GetMouseButton(0);
|
||||||
|
if (!wasDown && isDown)
|
||||||
|
OnPointerDown?.Invoke(Input.mousePosition);
|
||||||
|
|
||||||
|
if (wasDown && !isDown)
|
||||||
|
OnPointerUp?.Invoke(Input.mousePosition);
|
||||||
|
|
||||||
|
wasDown = isDown;
|
||||||
|
|
||||||
|
// Optional: Touch (if you want both, you can merge logic more carefully)
|
||||||
|
if (Input.touchCount <= 0) return;
|
||||||
|
|
||||||
|
var t = Input.GetTouch(0);
|
||||||
|
if (t.phase == TouchPhase.Began)
|
||||||
|
OnPointerDown?.Invoke(t.position);
|
||||||
|
else if (t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled)
|
||||||
|
OnPointerUp?.Invoke(t.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Services/InputService.cs.meta
Normal file
3
Assets/Scripts/Services/InputService.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 51137073af0548959f4e16ceffc344b5
|
||||||
|
timeCreated: 1765676415
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
using Enums;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Services.Interfaces {
|
namespace Services.Interfaces {
|
||||||
public interface IObjectPool<T> where T : class {
|
public interface IObjectPool<T> where T : class {
|
||||||
T Get();
|
T Get(GemType type, Vector2Int position, float offsetY);
|
||||||
void Fill();
|
void Release(T gemView);
|
||||||
void Release(T gameObject);
|
|
||||||
void Clear();
|
void Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
26
Assets/Scripts/Services/LevelEntryPoint.cs
Normal file
26
Assets/Scripts/Services/LevelEntryPoint.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Services.Interfaces;
|
||||||
|
using UnityEngine;
|
||||||
|
using VContainer.Unity;
|
||||||
|
using Views;
|
||||||
|
|
||||||
|
namespace Services
|
||||||
|
{
|
||||||
|
public class LevelEntryPoint : IStartable
|
||||||
|
{
|
||||||
|
private readonly IObjectPool<GemView> gemViewPool;
|
||||||
|
private readonly IGameBoardService gameBoardService;
|
||||||
|
|
||||||
|
public LevelEntryPoint(IObjectPool<GemView> gemViewPool, IGameBoardService gameBoardService)
|
||||||
|
{
|
||||||
|
this.gemViewPool = gemViewPool;
|
||||||
|
this.gameBoardService = gameBoardService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
Debug.Log("Level Entry Point");
|
||||||
|
this.gameBoardService.Setup();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Services/LevelEntryPoint.cs.meta
Normal file
3
Assets/Scripts/Services/LevelEntryPoint.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e888313cbfdb43e2b11c0e7d1d030fdb
|
||||||
|
timeCreated: 1765676578
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Enums;
|
using Enums;
|
||||||
|
using Models.Interfaces;
|
||||||
using Services.Interfaces;
|
using Services.Interfaces;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -9,9 +10,9 @@ namespace Services {
|
|||||||
private List<Gem> currentMatches = new List<Gem>();
|
private List<Gem> currentMatches = new List<Gem>();
|
||||||
public List<Gem> CurrentMatches => this.currentMatches;
|
public List<Gem> CurrentMatches => this.currentMatches;
|
||||||
|
|
||||||
private GameBoard gameBoard;
|
private IGameBoard gameBoard;
|
||||||
|
|
||||||
public MatchService(GameBoard gameBoard) {
|
public MatchService(IGameBoard gameBoard) {
|
||||||
this.gameBoard = gameBoard;
|
this.gameBoard = gameBoard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,49 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Enums;
|
||||||
using Services.Interfaces;
|
using Services.Interfaces;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Utils;
|
||||||
using Views;
|
using Views;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace Services {
|
namespace Services {
|
||||||
public class ObjectPoolService:IObjectPool<GemView> {
|
public class ObjectPoolService:IObjectPool<GemView> {
|
||||||
private readonly GemView prefab;
|
private readonly GemView[] prefabs;
|
||||||
private readonly Transform parent;
|
private readonly Transform parent;
|
||||||
private readonly int size;
|
private readonly int size;
|
||||||
|
|
||||||
private readonly Stack<GemView> pool = new Stack<GemView>();
|
private readonly Stack<GemView> pool = new Stack<GemView>();
|
||||||
|
|
||||||
public ObjectPoolService(GemView prefab, Transform parent, int size = 5) {
|
public ObjectPoolService(GemView[] prefabs, Transform parent, int size = 5) {
|
||||||
this.prefab = prefab;
|
this.prefabs = prefabs;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GemView Get() {
|
public GemView Get(GemType type, Vector2Int position, float dropHeight) {
|
||||||
return this.pool.Count == 0 ? Object.Instantiate(this.prefab, this.parent) : this.pool.Pop();
|
int typeAsInt = (int) type;
|
||||||
|
|
||||||
|
GemView gemView;
|
||||||
|
if (this.pool.Count > 0) {
|
||||||
|
gemView = this.pool.Pop();
|
||||||
|
gemView.transform.localPosition = new Vector2(position.x, position.y + dropHeight);
|
||||||
|
return gemView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Fill() {
|
gemView = Object.Instantiate(this.prefabs[typeAsInt], new Vector2(position.x, position.y + dropHeight), Quaternion.identity, this.parent);
|
||||||
for (int i = 0; i < this.size; i++) {
|
return gemView;
|
||||||
Object.Instantiate(this.prefab, this.parent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Release(GemView gameObject) {
|
public void Release(GemView gemView) {
|
||||||
this.pool.Push(gameObject);
|
if (gemView == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gemView.gameObject.SetActive(false);
|
||||||
|
this.pool.Push(gemView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear() {
|
public void Clear() {
|
||||||
|
|||||||
3
Assets/Scripts/Utils.meta
Normal file
3
Assets/Scripts/Utils.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bb63cba0ae32411c8c20c6228c68c922
|
||||||
|
timeCreated: 1765680476
|
||||||
17
Assets/Scripts/Utils/RandomUtils.cs
Normal file
17
Assets/Scripts/Utils/RandomUtils.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using Enums;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
public static class RandomUtils {
|
||||||
|
public static int RandomGemTypeAsInt() {
|
||||||
|
GemType[] spawnableGems = Enum.GetValues(typeof(GemType))
|
||||||
|
.Cast<GemType>()
|
||||||
|
.Where(gType => gType != GemType.Bomb)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
return Random.Range(0, spawnableGems.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Assets/Scripts/Utils/RandomUtils.cs.meta
Normal file
3
Assets/Scripts/Utils/RandomUtils.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ba833efb34fd4c16a0a2ef2ad6979951
|
||||||
|
timeCreated: 1765680493
|
||||||
Reference in New Issue
Block a user