diff --git a/Assets/Animations/Misc/Pulverise.anim b/Assets/Animations/Misc/Pulverise.anim deleted file mode 100644 index e2bedcb..0000000 --- a/Assets/Animations/Misc/Pulverise.anim +++ /dev/null @@ -1,77 +0,0 @@ -%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: Pulverise - serializedVersion: 6 - m_Legacy: 0 - m_Compressed: 0 - m_UseHighQualityCurve: 1 - m_RotationCurves: [] - m_CompressedRotationCurves: [] - m_EulerCurves: [] - m_PositionCurves: [] - m_ScaleCurves: [] - m_FloatCurves: [] - m_PPtrCurves: - - curve: - - time: 0 - value: {fileID: 21300052, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - - time: 0.06666667 - value: {fileID: 21300054, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - - time: 0.13333334 - value: {fileID: 21300056, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - - time: 0.2 - value: {fileID: 21300058, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - attribute: m_Sprite - path: - classID: 212 - script: {fileID: 0} - m_SampleRate: 15 - 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: 0 - script: {fileID: 0} - typeID: 212 - customType: 23 - isPPtrCurve: 1 - pptrCurveMapping: - - {fileID: 21300052, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - - {fileID: 21300054, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - - {fileID: 21300056, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - - {fileID: 21300058, guid: 1611b607563ac5b4d919348f10e92487, type: 3} - m_AnimationClipSettings: - serializedVersion: 2 - m_AdditiveReferencePoseClip: {fileID: 0} - m_AdditiveReferencePoseTime: 0 - m_StartTime: 0 - m_StopTime: 0.26666668 - m_OrientationOffsetY: 0 - m_Level: 0 - m_CycleOffset: 0 - m_HasAdditiveReferencePose: 0 - m_LoopTime: 1 - 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: [] - m_EulerEditorCurves: [] - m_HasGenericRootTransform: 0 - m_HasMotionFloatCurves: 0 - m_Events: [] diff --git a/Assets/Animations/Misc/Pulverise.anim.meta b/Assets/Animations/Misc/Pulverise.anim.meta deleted file mode 100644 index 0cbf6f5..0000000 --- a/Assets/Animations/Misc/Pulverise.anim.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 536dece361312c14bac0cf30829bee84 -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 7400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Animations/Misc/Pulverised.controller b/Assets/Animations/Misc/Pulverised.controller deleted file mode 100644 index 043de82..0000000 --- a/Assets/Animations/Misc/Pulverised.controller +++ /dev/null @@ -1,93 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!91 &9100000 -AnimatorController: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Pulverised - serializedVersion: 5 - m_AnimatorParameters: - - m_Name: Blend - m_Type: 1 - m_DefaultFloat: 0 - m_DefaultInt: 0 - m_DefaultBool: 0 - m_Controller: {fileID: 0} - m_AnimatorLayers: - - serializedVersion: 5 - m_Name: Base Layer - m_StateMachine: {fileID: 1107354719584562404} - 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!206 &206365093828297014 -BlendTree: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Blend Tree - m_Childs: [] - m_BlendParameter: Blend - m_BlendParameterY: Blend - m_MinThreshold: 0 - m_MaxThreshold: 1 - m_UseAutomaticThresholds: 1 - m_NormalizedBlendValues: 0 - m_BlendType: 0 ---- !u!1102 &1102215421647958874 -AnimatorState: - serializedVersion: 5 - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Pulverise - 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: 206365093828297014} - m_Tag: - m_SpeedParameter: - m_MirrorParameter: - m_CycleOffsetParameter: - m_TimeParameter: ---- !u!1107 &1107354719584562404 -AnimatorStateMachine: - serializedVersion: 5 - 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: 1102215421647958874} - m_Position: {x: 264, y: 72, z: 0} - m_ChildStateMachines: [] - m_AnyStateTransitions: [] - m_EntryTransitions: [] - m_StateMachineTransitions: {} - m_StateMachineBehaviours: [] - m_AnyStatePosition: {x: 48, y: 24, z: 0} - m_EntryPosition: {x: 48, y: 120, z: 0} - m_ExitPosition: {x: 800, y: 120, z: 0} - m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} - m_DefaultState: {fileID: 1102215421647958874} diff --git a/Assets/Animations/Misc/Pulverised.controller.meta b/Assets/Animations/Misc/Pulverised.controller.meta deleted file mode 100644 index d427a88..0000000 --- a/Assets/Animations/Misc/Pulverised.controller.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f99f14e77d0442846ba579190dffc1c2 -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 9100000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Animations/Misc/RespawnPosition.controller b/Assets/Animations/Misc/RespawnPosition.controller deleted file mode 100644 index b474d0a..0000000 --- a/Assets/Animations/Misc/RespawnPosition.controller +++ /dev/null @@ -1,72 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!91 &9100000 -AnimatorController: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: RespawnPosition - serializedVersion: 5 - m_AnimatorParameters: [] - m_AnimatorLayers: - - serializedVersion: 5 - m_Name: Base Layer - m_StateMachine: {fileID: 1107214311928363052} - 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 &1102082738737299528 -AnimatorState: - serializedVersion: 5 - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: Pulverise - 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: 536dece361312c14bac0cf30829bee84, type: 2} - m_Tag: - m_SpeedParameter: - m_MirrorParameter: - m_CycleOffsetParameter: - m_TimeParameter: ---- !u!1107 &1107214311928363052 -AnimatorStateMachine: - serializedVersion: 5 - 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: 1102082738737299528} - m_Position: {x: 200, y: 0, 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: 1102082738737299528} diff --git a/Assets/Animations/Misc/RespawnPosition.controller.meta b/Assets/Animations/Misc/RespawnPosition.controller.meta deleted file mode 100644 index ecf84c9..0000000 --- a/Assets/Animations/Misc/RespawnPosition.controller.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 621169a4828cad04ba17bb6ddfae4979 -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 9100000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Resources/Managers/GameManager.prefab b/Assets/Resources/Managers/GameManager.prefab index 5223a31..321064a 100644 --- a/Assets/Resources/Managers/GameManager.prefab +++ b/Assets/Resources/Managers/GameManager.prefab @@ -10,8 +10,6 @@ GameObject: m_Component: - component: {fileID: 158905820630581587} - component: {fileID: 158905820630581586} - - component: {fileID: 158905820630581596} - - component: {fileID: 6316647355651322741} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -47,31 +45,3 @@ MonoBehaviour: m_EditorClassIdentifier: preStageUiPrefab: {fileID: 4994633962466276707, guid: 1f5ebc13237e070449ea8bc9e8b07ac8, type: 3} ---- !u!114 &158905820630581596 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158905820630581597} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 308dfc6b26c3b422faf1717231fc888b, type: 3} - m_Name: - m_EditorClassIdentifier: - boardHolder: {fileID: 0} - startPosition: {fileID: 0} - indestructibleWallPrefab: {fileID: 5996206011854593075, guid: 84b92ac1e96d940bda97d1b1125887d7, - type: 3} ---- !u!114 &6316647355651322741 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158905820630581597} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e64481d2e18e4b6ca4f22926a5061450, type: 3} - m_Name: - m_EditorClassIdentifier: diff --git a/Assets/Resources/Walls/destructible_high_snow.prefab b/Assets/Resources/Walls/destructible_high_snow.prefab index 38ca5e3..e5f45ea 100644 --- a/Assets/Resources/Walls/destructible_high_snow.prefab +++ b/Assets/Resources/Walls/destructible_high_snow.prefab @@ -10,7 +10,6 @@ GameObject: m_Component: - component: {fileID: 5407421983573782568} - component: {fileID: 8221087269156402184} - - component: {fileID: 9007082834052858790} m_Layer: 0 m_Name: Sprite m_TagString: Untagged @@ -80,25 +79,6 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!95 &9007082834052858790 -Animator: - serializedVersion: 3 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2151260512302392238} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: f99f14e77d0442846ba579190dffc1c2, type: 2} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorControllerStateOnDisable: 0 --- !u!1 &8729402555587492036 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Walls/destructible_snow.prefab b/Assets/Resources/Walls/destructible_snow.prefab index 6547ed6..80cece4 100644 --- a/Assets/Resources/Walls/destructible_snow.prefab +++ b/Assets/Resources/Walls/destructible_snow.prefab @@ -121,7 +121,6 @@ GameObject: m_Component: - component: {fileID: 8553251917334281199} - component: {fileID: 2562328647522734305} - - component: {fileID: 1235137903643130781} m_Layer: 8 m_Name: Sprite m_TagString: Untagged @@ -191,22 +190,3 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 ---- !u!95 &1235137903643130781 -Animator: - serializedVersion: 3 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5688352134163068791} - m_Enabled: 1 - m_Avatar: {fileID: 0} - m_Controller: {fileID: 9100000, guid: f99f14e77d0442846ba579190dffc1c2, type: 2} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorControllerStateOnDisable: 0 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index bae3c0f..ad67fe2 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -272,13 +272,11 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} - - target: {fileID: 158905820630581596, guid: fdaa7451ab31b477b930076bbc888bab, - type: 3} + - target: {fileID: 0} propertyPath: boardHolder value: objectReference: {fileID: 585332173} - - target: {fileID: 158905820630581596, guid: fdaa7451ab31b477b930076bbc888bab, - type: 3} + - target: {fileID: 0} propertyPath: startPosition value: objectReference: {fileID: 185746015} diff --git a/Assets/Scripts/src/Ammo/BombCameraShake.cs b/Assets/Scripts/src/Ammo/BombCameraShake.cs index f8066a2..49430fc 100644 --- a/Assets/Scripts/src/Ammo/BombCameraShake.cs +++ b/Assets/Scripts/src/Ammo/BombCameraShake.cs @@ -8,7 +8,7 @@ namespace src.Ammo { public class BombCameraShake : GameplayComponent { - private readonly BombsUtilManager _bombsUtilManager = BombsUtilManager.Instance; + private BombsUtilManager _bombsUtilManager; public float amplitudeGain = 3f; public float frequencyGain = 3f; @@ -18,6 +18,7 @@ namespace src.Ammo // Start is called before the first frame update private void Start() { + _bombsUtilManager = BombsUtilManager.instance; _virtualCamera = GetComponent(); _noiseMachine = _virtualCamera.GetCinemachineComponent(); } diff --git a/Assets/Scripts/src/Ammo/BombController.cs b/Assets/Scripts/src/Ammo/BombController.cs index 566044f..c527978 100644 --- a/Assets/Scripts/src/Ammo/BombController.cs +++ b/Assets/Scripts/src/Ammo/BombController.cs @@ -11,7 +11,7 @@ namespace src.Ammo public GameObject explosionPrefab; private BombCameraShake _cameraShake; - private readonly BombsUtilManager _bombsUtil = BombsUtilManager.Instance; + private readonly BombsUtilManager _bombsUtil = BombsUtilManager.instance; private bool _exploded; // Start is called before the first frame update diff --git a/Assets/Scripts/src/Ammo/BombsSpawner.cs b/Assets/Scripts/src/Ammo/BombsSpawner.cs index a0a4c72..64e62c0 100644 --- a/Assets/Scripts/src/Ammo/BombsSpawner.cs +++ b/Assets/Scripts/src/Ammo/BombsSpawner.cs @@ -1,4 +1,5 @@ -using src.Base; +using System; +using src.Base; using src.Managers; using UnityEngine; @@ -8,12 +9,18 @@ namespace src.Ammo { public GameObject bombPrefab; - private readonly BombsUtilManager _bombsUtil = BombsUtilManager.Instance; + private BombsUtilManager _bombsUtil; - public void PlaceBomb(Transform transform) + public void Start() { - var absX = Mathf.RoundToInt(transform.position.x); - var absY = Mathf.RoundToInt(transform.position.y); + _bombsUtil = BombsUtilManager.instance; + } + + public void PlaceBomb(Transform location) + { + var position1 = location.position; + var absX = Mathf.RoundToInt(position1.x); + var absY = Mathf.RoundToInt(position1.y); var position = new Vector2(absX, absY); if (_bombsUtil.CanPlaceBomb(position)) { diff --git a/Assets/Scripts/src/Ammo/Explosion.cs b/Assets/Scripts/src/Ammo/Explosion.cs index ec30d55..3d379a8 100644 --- a/Assets/Scripts/src/Ammo/Explosion.cs +++ b/Assets/Scripts/src/Ammo/Explosion.cs @@ -5,7 +5,7 @@ namespace src.Ammo { public class Explosion : GameplayComponent { - private readonly BombsUtilManager _bombUtil = BombsUtilManager.Instance; + private readonly BombsUtilManager _bombUtil = BombsUtilManager.instance; public void Start() { diff --git a/Assets/Scripts/src/Base/EnemyBase.cs b/Assets/Scripts/src/Base/EnemyBase.cs index ecd3469..4db57b5 100644 --- a/Assets/Scripts/src/Base/EnemyBase.cs +++ b/Assets/Scripts/src/Base/EnemyBase.cs @@ -6,10 +6,10 @@ using UnityEngine; namespace src.Base { - public abstract class EnemyBase : MonoBehaviour, IExplosable + public abstract class EnemyBase : GameplayComponent, IExplosable { private readonly Vector2[] _directions = {Vector3.up, Vector3.down, Vector3.left, Vector3.right}; - private readonly GameStateManager _gameStateManager = GameStateManager.Instance; + private readonly GameStateManager _gameStateManager = GameStateManager.instance; protected Rigidbody2D Rigidbody2d { get; set; } private Collider2D Collider2D { get; set; } diff --git a/Assets/Scripts/src/Base/UpgradeBase.cs b/Assets/Scripts/src/Base/UpgradeBase.cs index 5aa312e..75f74c2 100644 --- a/Assets/Scripts/src/Base/UpgradeBase.cs +++ b/Assets/Scripts/src/Base/UpgradeBase.cs @@ -6,13 +6,13 @@ namespace src.Base { public class UpgradeBase : GameplayComponent, IUpgrade { - protected GameManager GameManager; + protected GameManager gameManager; private UpgradeManager _upgradeManager; public void Start() { - GameManager = GameManager.Instance; - _upgradeManager = UpgradeManager.Instance; + gameManager = GameManager.instance; + _upgradeManager = UpgradeManager.instance; } public virtual void PerformUpgrade() diff --git a/Assets/Scripts/src/Enemy/Dummy.meta b/Assets/Scripts/src/Enemy/Dummy.meta deleted file mode 100644 index 4c03f67..0000000 --- a/Assets/Scripts/src/Enemy/Dummy.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 738f4be39c8d33d4dbfe91e24b6b1b63 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/src/Enemy/Dummy/OneDirectionEnemy.cs b/Assets/Scripts/src/Enemy/OneDirectionEnemy.cs similarity index 100% rename from Assets/Scripts/src/Enemy/Dummy/OneDirectionEnemy.cs rename to Assets/Scripts/src/Enemy/OneDirectionEnemy.cs diff --git a/Assets/Scripts/src/Enemy/Dummy/OneDirectionEnemy.cs.meta b/Assets/Scripts/src/Enemy/OneDirectionEnemy.cs.meta similarity index 100% rename from Assets/Scripts/src/Enemy/Dummy/OneDirectionEnemy.cs.meta rename to Assets/Scripts/src/Enemy/OneDirectionEnemy.cs.meta diff --git a/Assets/Scripts/src/Helpers/ApplicationActions.cs b/Assets/Scripts/src/Helpers/ApplicationActions.cs index 39da0f5..0ed6dee 100644 --- a/Assets/Scripts/src/Helpers/ApplicationActions.cs +++ b/Assets/Scripts/src/Helpers/ApplicationActions.cs @@ -5,7 +5,7 @@ namespace src.Helpers { public static class ApplicationActions { - private static GameStateManager _gameStateManager = GameStateManager.Instance; + private static GameStateManager _gameStateManager = GameStateManager.instance; public static void QuitGame() { diff --git a/Assets/Scripts/src/Helpers/PrefabAtlas.cs b/Assets/Scripts/src/Helpers/PrefabAtlas.cs index 3ca7ae2..e77e429 100644 --- a/Assets/Scripts/src/Helpers/PrefabAtlas.cs +++ b/Assets/Scripts/src/Helpers/PrefabAtlas.cs @@ -4,6 +4,10 @@ namespace src.Helpers { public static class PrefabAtlas { + /* UI */ + public static readonly GameObject PreStageUi = + Resources.Load("UI/PreStageUI"); + /* Snow Walls */ public static readonly GameObject DestructibleHighSnow = Resources.Load("Walls/destructible_high_snow"); diff --git a/Assets/Scripts/src/Level/LevelManager.cs b/Assets/Scripts/src/Level/LevelManager.cs index 3ee9cbf..eb2742f 100644 --- a/Assets/Scripts/src/Level/LevelManager.cs +++ b/Assets/Scripts/src/Level/LevelManager.cs @@ -15,29 +15,10 @@ namespace src.Level private const int XMaxEnemyPosition = 5; private const int YMinEnemyPosition = -5; - public Count DestructibleWallCount - { - get => _destructibleWallCount; - set => _destructibleWallCount = value; - } - - public Count UpgradesCount - { - get => _upgradesCount; - set => _upgradesCount = value; - } - - public Count EnemyCount - { - get => _enemyCount; - set => _enemyCount = value; - } - /* Used to group spawned objects */ - public Transform boardHolder; - + private Transform _boardHolder; /* Holds the starting position of the player */ - public Transform startPosition; + private Transform _startPosition; /* Holds references to prefabs for the specified level. */ private GameObject _indestructibleWallPrefab; @@ -57,11 +38,20 @@ namespace src.Level /* Holds the available positions */ private readonly List _freeGridPositionsBoard = new List(); private List _freeGridPositions; + + /* Holds initialized game objects */ private List _destructibleWalls; private List _enemies; /* Singletons */ - private GameStateManager _gameStateManager = GameStateManager.Instance; + private GameStateManager _gameStateManager; + + public void Awake() + { + _startPosition = GameObject.Find("RespawnPosition").GetComponent(); + _boardHolder = GameObject.Find("Grid").GetComponent(); + _gameStateManager = GameStateManager.instance; + } public void SetLevelData(LevelData levelData) { @@ -115,9 +105,9 @@ namespace src.Level } /* We want to iterate over the X axis taking into consideration the startPosition's offset */ - for (var x = startPosition.position.x; x < Columns; x++) + for (var x = _startPosition.position.x; x < Columns; x++) { - for (var y = startPosition.position.y; y > Rows * -1; y--) + for (var y = _startPosition.position.y; y > Rows * -1; y--) { /* We want the following positions to be a safe zone. */ /* Don't place anything on starting position */ @@ -156,7 +146,7 @@ namespace src.Level private void SetupLevelDestructibleWalls() { var numberOfWallsRemaining = _destructibleWallCount.RandomIntRange(); - List usedPositions = new List(); + var usedPositions = new List(); _freeGridPositions.ShuffleList(); foreach (var nextPosition in _freeGridPositions) { @@ -182,7 +172,7 @@ namespace src.Level var randomWall = _destructibleWallPrefabs.ChoseRandom(); var instance = Instantiate(randomWall, position, Quaternion.identity); _destructibleWalls.Add(instance); - instance.transform.SetParent(boardHolder); + instance.transform.SetParent(_boardHolder); } private bool PlaceIndestructibleTile(float x, float y) @@ -198,7 +188,7 @@ namespace src.Level var instance = Instantiate(_indestructibleWallPrefab, new Vector3(x, y, 0f), Quaternion.identity); - instance.transform.SetParent(boardHolder); + instance.transform.SetParent(_boardHolder); return true; } @@ -223,7 +213,7 @@ namespace src.Level DebugHelper.LogVerbose($"PlaceEnemy: x:{position.x} y:{position.y}"); var randomEnemy = _enemiesPrefab.ChoseRandom(); var instance = Instantiate(randomEnemy, position, Quaternion.identity); - instance.transform.SetParent(boardHolder); + instance.transform.SetParent(_boardHolder); _enemies.Add(instance); } diff --git a/Assets/Scripts/src/Managers/BombsUtilManager.cs b/Assets/Scripts/src/Managers/BombsUtilManager.cs index 3935c5d..2820176 100644 --- a/Assets/Scripts/src/Managers/BombsUtilManager.cs +++ b/Assets/Scripts/src/Managers/BombsUtilManager.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; +using src.Base; using UnityEngine; namespace src.Managers { - public sealed class BombsUtilManager + public sealed class BombsUtilManager : GameplayComponent { private readonly HashSet _usedPosition = new HashSet(); @@ -20,12 +21,20 @@ namespace src.Managers public float ExplosionDuration { get; } = 0.55f; - private BombsUtilManager() + public static BombsUtilManager instance; + + public void Awake() { + if (instance == null) + { + instance = this; + } + else if (instance != null) + { + Destroy(gameObject); + } } - public static BombsUtilManager Instance { get; } = new BombsUtilManager(); - public void IncreasePower() { if (Power <= MaxPower) diff --git a/Assets/Scripts/src/Managers/GameManager.cs b/Assets/Scripts/src/Managers/GameManager.cs index cd68580..a925a9b 100644 --- a/Assets/Scripts/src/Managers/GameManager.cs +++ b/Assets/Scripts/src/Managers/GameManager.cs @@ -1,5 +1,4 @@ using System.Collections; -using src.Ammo; using src.Helpers; using src.Level; using src.Level.src.Level; @@ -10,23 +9,22 @@ namespace src.Managers { public class GameManager : MonoBehaviour { - public static GameManager Instance; + public static GameManager instance; + + // Inner Components + private PlayerController _playerController; + private GameStateManager _gameStateManager; private LevelManager _levelManager; private UpgradeManager _upgradeManager; private BombsUtilManager _bombsUtilManager; - // External Components - public GameObject preStageUiPrefab; - private PlayerController _playerController; - private readonly GameStateManager _gameStateManager = GameStateManager.Instance; - public void Awake() { - if (Instance == null) + if (instance == null) { - Instance = this; + instance = this; } - else if (Instance != null) + else if (instance != null) { Destroy(gameObject); } @@ -34,10 +32,12 @@ namespace src.Managers /* Don't destroy when reloading the scene */ DontDestroyOnLoad(gameObject); - // Load inner components - _levelManager = GetComponent(); - _upgradeManager = GetComponent(); - _bombsUtilManager = BombsUtilManager.Instance; + // Load singletons + _bombsUtilManager = gameObject.AddComponent(); + _gameStateManager = gameObject.AddComponent(); + _levelManager = gameObject.AddComponent(); + _upgradeManager = gameObject.AddComponent(); + gameObject.AddComponent(); // Load external components _playerController = GameObject.Find("Player").GetComponent(); @@ -72,7 +72,7 @@ namespace src.Managers private IEnumerator PreInitGame() { - var preStageUi = Instantiate(preStageUiPrefab); // Will destroy itself. + var preStageUi = Instantiate(PrefabAtlas.PreStageUi); // Will destroy itself. preStageUi.SetActive(true); yield return new WaitForSeconds(1f); Destroy(preStageUi); diff --git a/Assets/Scripts/src/Managers/GameStateManager.cs b/Assets/Scripts/src/Managers/GameStateManager.cs index 3533686..f45110d 100644 --- a/Assets/Scripts/src/Managers/GameStateManager.cs +++ b/Assets/Scripts/src/Managers/GameStateManager.cs @@ -1,12 +1,26 @@ +using src.Base; +using UnityEngine; + namespace src.Managers { - public class GameStateManager + public class GameStateManager : GameplayComponent { - public static GameStateManager Instance { get; } = new GameStateManager(); + public static GameStateManager instance; public bool IsGamePaused { get; internal set; } public bool IsPlayerMovementForbidden { get; internal set; } public int Level { get; private set; } = 1; - + + public void Awake() + { + if (instance == null) + { + instance = this; + } + else if (instance != null) + { + Destroy(gameObject); + } + } public void IncreaseLevel() { diff --git a/Assets/Scripts/src/Managers/UpgradeManager.cs b/Assets/Scripts/src/Managers/UpgradeManager.cs index 9469e1f..eb972a7 100644 --- a/Assets/Scripts/src/Managers/UpgradeManager.cs +++ b/Assets/Scripts/src/Managers/UpgradeManager.cs @@ -10,17 +10,17 @@ namespace src.Managers { public class UpgradeManager : GameplayComponent, IDynamicLevelData { - public static UpgradeManager Instance; + public static UpgradeManager instance; private List _unclaimedUpgrades = new List(); private GameObject[] _upgradePrefabs; private void Awake() { - if (Instance == null) + if (instance == null) { - Instance = this; + instance = this; } - else if (Instance != null) + else if (instance != null) { Destroy(gameObject); } diff --git a/Assets/Scripts/src/Player/PlayerController.cs b/Assets/Scripts/src/Player/PlayerController.cs index 45e3d27..e3e4bbb 100644 --- a/Assets/Scripts/src/Player/PlayerController.cs +++ b/Assets/Scripts/src/Player/PlayerController.cs @@ -8,7 +8,7 @@ namespace src.Player { public class PlayerController : GameplayComponent, IExplosable { - private readonly GameStateManager _gameStateManager = GameStateManager.Instance; + private GameStateManager _gameStateManager; private Rigidbody2D _rigidbody2d; private Collider2D _collider2D; private Transform _respawnPosition; @@ -25,14 +25,16 @@ namespace src.Player private bool _isDead; protected void Start() - { + { + _gameStateManager = GameStateManager.instance; + _playerUpgrade = PlayerUpgrade.instance; + _rigidbody2d = GetComponent(); _collider2D = GetComponent(); _animator = GetComponentInChildren(); _respawnPosition = GameObject.Find("RespawnPosition").transform; _bombsSpawner = GameObject.Find("BombSpawner").GetComponent(); - - _playerUpgrade = PlayerUpgrade.Instance; + movementSpeed = _playerUpgrade.GetMovementSpeed(); _playerUpgrade.PlayerSpeed += OnSpeedUpgrade; diff --git a/Assets/Scripts/src/Player/PlayerUpgrade.cs b/Assets/Scripts/src/Player/PlayerUpgrade.cs index 8a3d369..a98ae1e 100644 --- a/Assets/Scripts/src/Player/PlayerUpgrade.cs +++ b/Assets/Scripts/src/Player/PlayerUpgrade.cs @@ -1,16 +1,25 @@ +using src.Base; + namespace src.Player { - public class PlayerUpgrade + public class PlayerUpgrade : GameplayComponent { public delegate void IncreaseSpeedDelegate(float speed); - public static PlayerUpgrade Instance = new PlayerUpgrade(); + public static PlayerUpgrade instance; public event IncreaseSpeedDelegate PlayerSpeed; public const float MaxPlayerSpeed = 8f; private float _movementSpeed = 4f; - private PlayerUpgrade() + public void Awake() { - + if (instance == null) + { + instance = this; + } + else if (instance != null) + { + Destroy(gameObject); + } } public float GetMovementSpeed() @@ -25,7 +34,7 @@ namespace src.Player return; } _movementSpeed += speed; - PlayerSpeed.Invoke(speed); + PlayerSpeed?.Invoke(speed); } } } \ No newline at end of file diff --git a/Assets/Scripts/src/UI/PreStageUiScript.cs b/Assets/Scripts/src/UI/PreStageUiScript.cs index d05826e..b8061f1 100644 --- a/Assets/Scripts/src/UI/PreStageUiScript.cs +++ b/Assets/Scripts/src/UI/PreStageUiScript.cs @@ -7,7 +7,7 @@ namespace src.UI { public class PreStageUiScript : GameplayComponent { - private readonly GameStateManager _gameStateManager = GameStateManager.Instance; + private readonly GameStateManager _gameStateManager = GameStateManager.instance; private Text _stageText; public void Start() diff --git a/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs b/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs index 9402172..b46e361 100644 --- a/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs +++ b/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs @@ -6,7 +6,7 @@ namespace src.Upgrade { public override void PerformUpgrade() { - var bombManager = GameManager.GetBombsUtilManager(); + var bombManager = gameManager.GetBombsUtilManager(); bombManager.IncreasePower(); } } diff --git a/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs b/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs index 89497ab..39b16ad 100644 --- a/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs +++ b/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs @@ -6,7 +6,7 @@ namespace src.Upgrade { public override void PerformUpgrade() { - var bombManager = GameManager.GetBombsUtilManager(); + var bombManager = gameManager.GetBombsUtilManager(); bombManager.IncreaseAllowedBombs(); } } diff --git a/Assets/Scripts/src/Upgrade/GoldenBombUpgrade.cs b/Assets/Scripts/src/Upgrade/GoldenBombUpgrade.cs index afb993e..acf0bff 100644 --- a/Assets/Scripts/src/Upgrade/GoldenBombUpgrade.cs +++ b/Assets/Scripts/src/Upgrade/GoldenBombUpgrade.cs @@ -7,7 +7,7 @@ namespace src.Upgrade { public override void PerformUpgrade() { - var bombManager = GameManager.GetBombsUtilManager(); + var bombManager = gameManager.GetBombsUtilManager(); bombManager.IncreaseAllowedBombs(); bombManager.IncreasePower(); } diff --git a/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs b/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs index 013a47b..94558e0 100644 --- a/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs +++ b/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs @@ -7,7 +7,7 @@ namespace src.Upgrade { public override void PerformUpgrade() { - var player = PlayerUpgrade.Instance; + var player = PlayerUpgrade.instance; player.IncreaseSpeed(.5f); } } diff --git a/Assets/Scripts/src/Wall/DestructibleWall.cs b/Assets/Scripts/src/Wall/DestructibleWall.cs index d27663e..7580ebc 100644 --- a/Assets/Scripts/src/Wall/DestructibleWall.cs +++ b/Assets/Scripts/src/Wall/DestructibleWall.cs @@ -1,4 +1,3 @@ -using System; using UnityEngine; using src.Base; @@ -14,13 +13,10 @@ namespace src.Wall private UpgradeManager _upgradeManager; public GameObject explosionPrefab; public GameObject exitDoorPrefab; - private Animator _animator; private void Start() { - _upgradeManager = GameManager.Instance.GetUpgradeManager(); - _animator = GetComponentInChildren(); - // _animator.speed = 0; + _upgradeManager = GameManager.instance.GetUpgradeManager(); } public void SpawnsExit() @@ -55,15 +51,9 @@ namespace src.Wall } } - private void PlayDestroyAnimation() - { - // _animator.speed = 10; - } - public void OnExplosion() { DebugHelper.LogInfo($"Destructible wall hit by explosion {transform.position}"); - PlayDestroyAnimation(); SpawnSomething(); Destroy(gameObject); } diff --git a/Assets/Scripts/src/Wall/ExitDoor.cs b/Assets/Scripts/src/Wall/ExitDoor.cs index 07709d4..b0d0444 100644 --- a/Assets/Scripts/src/Wall/ExitDoor.cs +++ b/Assets/Scripts/src/Wall/ExitDoor.cs @@ -12,7 +12,7 @@ namespace src.Wall private void Start() { - _gameManager = GameManager.Instance; + _gameManager = GameManager.instance; _collider2D = GetComponent(); }