Merge pull request #80 from dnutiu/singletons-refactor
Singletons refactor
This commit is contained in:
commit
38daff83ef
35 changed files with 122 additions and 442 deletions
|
@ -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: []
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 536dece361312c14bac0cf30829bee84
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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}
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f99f14e77d0442846ba579190dffc1c2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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}
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 621169a4828cad04ba17bb6ddfae4979
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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<CinemachineVirtualCamera>();
|
||||
_noiseMachine = _virtualCamera.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 738f4be39c8d33d4dbfe91e24b6b1b63
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -4,6 +4,10 @@ namespace src.Helpers
|
|||
{
|
||||
public static class PrefabAtlas
|
||||
{
|
||||
/* UI */
|
||||
public static readonly GameObject PreStageUi =
|
||||
Resources.Load<GameObject>("UI/PreStageUI");
|
||||
|
||||
/* Snow Walls */
|
||||
public static readonly GameObject DestructibleHighSnow =
|
||||
Resources.Load<GameObject>("Walls/destructible_high_snow");
|
||||
|
|
|
@ -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<Vector3> _freeGridPositionsBoard = new List<Vector3>();
|
||||
private List<Vector3> _freeGridPositions;
|
||||
|
||||
/* Holds initialized game objects */
|
||||
private List<GameObject> _destructibleWalls;
|
||||
private List<GameObject> _enemies;
|
||||
|
||||
/* Singletons */
|
||||
private GameStateManager _gameStateManager = GameStateManager.Instance;
|
||||
private GameStateManager _gameStateManager;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_startPosition = GameObject.Find("RespawnPosition").GetComponent<Transform>();
|
||||
_boardHolder = GameObject.Find("Grid").GetComponent<Transform>();
|
||||
_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<Vector3> usedPositions = new List<Vector3>();
|
||||
var usedPositions = new List<Vector3>();
|
||||
_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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Vector3> _usedPosition = new HashSet<Vector3>();
|
||||
|
||||
|
@ -20,11 +21,19 @@ namespace src.Managers
|
|||
|
||||
public float ExplosionDuration { get; } = 0.55f;
|
||||
|
||||
private BombsUtilManager()
|
||||
{
|
||||
}
|
||||
public static BombsUtilManager instance;
|
||||
|
||||
public static BombsUtilManager Instance { get; } = new BombsUtilManager();
|
||||
public void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
else if (instance != null)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void IncreasePower()
|
||||
{
|
||||
|
|
|
@ -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<LevelManager>();
|
||||
_upgradeManager = GetComponent<UpgradeManager>();
|
||||
_bombsUtilManager = BombsUtilManager.Instance;
|
||||
// Load singletons
|
||||
_bombsUtilManager = gameObject.AddComponent<BombsUtilManager>();
|
||||
_gameStateManager = gameObject.AddComponent<GameStateManager>();
|
||||
_levelManager = gameObject.AddComponent<LevelManager>();
|
||||
_upgradeManager = gameObject.AddComponent<UpgradeManager>();
|
||||
gameObject.AddComponent<PlayerUpgrade>();
|
||||
|
||||
// Load external components
|
||||
_playerController = GameObject.Find("Player").GetComponent<PlayerController>();
|
||||
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -10,17 +10,17 @@ namespace src.Managers
|
|||
{
|
||||
public class UpgradeManager : GameplayComponent, IDynamicLevelData
|
||||
{
|
||||
public static UpgradeManager Instance;
|
||||
public static UpgradeManager instance;
|
||||
private List<GameObject> _unclaimedUpgrades = new List<GameObject>();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -26,13 +26,15 @@ namespace src.Player
|
|||
|
||||
protected void Start()
|
||||
{
|
||||
_gameStateManager = GameStateManager.instance;
|
||||
_playerUpgrade = PlayerUpgrade.instance;
|
||||
|
||||
_rigidbody2d = GetComponent<Rigidbody2D>();
|
||||
_collider2D = GetComponent<Collider2D>();
|
||||
_animator = GetComponentInChildren<Animator>();
|
||||
_respawnPosition = GameObject.Find("RespawnPosition").transform;
|
||||
_bombsSpawner = GameObject.Find("BombSpawner").GetComponent<BombsSpawner>();
|
||||
|
||||
_playerUpgrade = PlayerUpgrade.Instance;
|
||||
movementSpeed = _playerUpgrade.GetMovementSpeed();
|
||||
_playerUpgrade.PlayerSpeed += OnSpeedUpgrade;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace src.Upgrade
|
|||
{
|
||||
public override void PerformUpgrade()
|
||||
{
|
||||
var bombManager = GameManager.GetBombsUtilManager();
|
||||
var bombManager = gameManager.GetBombsUtilManager();
|
||||
bombManager.IncreasePower();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace src.Upgrade
|
|||
{
|
||||
public override void PerformUpgrade()
|
||||
{
|
||||
var bombManager = GameManager.GetBombsUtilManager();
|
||||
var bombManager = gameManager.GetBombsUtilManager();
|
||||
bombManager.IncreaseAllowedBombs();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace src.Upgrade
|
|||
{
|
||||
public override void PerformUpgrade()
|
||||
{
|
||||
var bombManager = GameManager.GetBombsUtilManager();
|
||||
var bombManager = gameManager.GetBombsUtilManager();
|
||||
bombManager.IncreaseAllowedBombs();
|
||||
bombManager.IncreasePower();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace src.Upgrade
|
|||
{
|
||||
public override void PerformUpgrade()
|
||||
{
|
||||
var player = PlayerUpgrade.Instance;
|
||||
var player = PlayerUpgrade.instance;
|
||||
player.IncreaseSpeed(.5f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>();
|
||||
// _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);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace src.Wall
|
|||
|
||||
private void Start()
|
||||
{
|
||||
_gameManager = GameManager.Instance;
|
||||
_gameManager = GameManager.instance;
|
||||
_collider2D = GetComponent<Collider2D>();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue