From ae09d98a3b572fe47ef950a14388577e2e0bfb67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nu=C8=9Biu?= Date: Sat, 22 Jun 2019 17:37:26 +0300 Subject: [PATCH 1/2] Implement UpgradeManager --- Assets/DevMocks/TestUpgrade.prefab | 121 ++++++++++++++++++ Assets/DevMocks/TestUpgrade.prefab.meta | 7 + Assets/Prefabs/Managers/GameManager.prefab | 13 ++ Assets/Scenes/SampleScene.unity | 23 +++- Assets/Scripts/src/Enemy/DumbEnemy.cs | 14 +- Assets/Scripts/src/Helpers/ArrayExtensions.cs | 6 +- Assets/Scripts/src/Interfaces/IUpgrade.cs | 10 ++ .../Scripts/src/Interfaces/IUpgrade.cs.meta | 3 + Assets/Scripts/src/Managers/GameManager.cs | 7 + Assets/Scripts/src/Managers/UpgradeManager.cs | 16 +++ .../src/Managers/UpgradeManager.cs.meta | 3 + Assets/Scripts/src/Player/PlayerController.cs | 1 + Assets/Scripts/src/Upgrade.meta | 3 + Assets/Scripts/src/Upgrade/TestUpgrade.cs | 23 ++++ .../Scripts/src/Upgrade/TestUpgrade.cs.meta | 3 + Assets/Scripts/src/Wall/DestructibleWall.cs | 11 +- 16 files changed, 247 insertions(+), 17 deletions(-) create mode 100644 Assets/DevMocks/TestUpgrade.prefab create mode 100644 Assets/DevMocks/TestUpgrade.prefab.meta create mode 100644 Assets/Scripts/src/Interfaces/IUpgrade.cs create mode 100644 Assets/Scripts/src/Interfaces/IUpgrade.cs.meta create mode 100644 Assets/Scripts/src/Managers/UpgradeManager.cs create mode 100644 Assets/Scripts/src/Managers/UpgradeManager.cs.meta create mode 100644 Assets/Scripts/src/Upgrade.meta create mode 100644 Assets/Scripts/src/Upgrade/TestUpgrade.cs create mode 100644 Assets/Scripts/src/Upgrade/TestUpgrade.cs.meta diff --git a/Assets/DevMocks/TestUpgrade.prefab b/Assets/DevMocks/TestUpgrade.prefab new file mode 100644 index 0000000..aefc338 --- /dev/null +++ b/Assets/DevMocks/TestUpgrade.prefab @@ -0,0 +1,121 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &4585348266300200282 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4585348266300200286} + - component: {fileID: 4585348266300200285} + - component: {fileID: 4585348266300200284} + - component: {fileID: 4585348266300200283} + m_Layer: 0 + m_Name: TestUpgrade + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4585348266300200286 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4585348266300200282} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!61 &4585348266300200285 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4585348266300200282} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!212 &4585348266300200284 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4585348266300200282} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 10 + m_Sprite: {fileID: 21300000, guid: 753e29d30d8044605aede9853c9308c7, type: 3} + m_Color: {r: 0.0509078, g: 0.36098272, b: 0.9811321, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &4585348266300200283 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4585348266300200282} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: daf1c278fd544eae9246c4abe6bf611e, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/DevMocks/TestUpgrade.prefab.meta b/Assets/DevMocks/TestUpgrade.prefab.meta new file mode 100644 index 0000000..e9f47c5 --- /dev/null +++ b/Assets/DevMocks/TestUpgrade.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2ea1eb2b6b05340a4a99948a6eb818b2 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Managers/GameManager.prefab b/Assets/Prefabs/Managers/GameManager.prefab index aab07ff..539f2dd 100644 --- a/Assets/Prefabs/Managers/GameManager.prefab +++ b/Assets/Prefabs/Managers/GameManager.prefab @@ -11,6 +11,7 @@ GameObject: - component: {fileID: 158905820630581587} - component: {fileID: 158905820630581586} - component: {fileID: 158905820630581596} + - component: {fileID: 6316647355651322741} m_Layer: 0 m_Name: GameManager m_TagString: Untagged @@ -66,3 +67,15 @@ MonoBehaviour: enemiesPrefab: - {fileID: 4346602752014574748, guid: e719de70e335f4e49ae40cc6731309d4, type: 3} - {fileID: 7795087027144463245, guid: fe8fb4e4a7e127648b306469b723d81e, 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/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index ecaf692..b1f0ec3 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -404,7 +404,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 519420028} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 10.72334, y: -4.0430503, z: -10} + m_LocalPosition: {x: 10.75168, y: -4.0430503, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -562,6 +562,17 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 6316647355651322741, guid: fdaa7451ab31b477b930076bbc888bab, + type: 3} + propertyPath: upgradePrefabs.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6316647355651322741, guid: fdaa7451ab31b477b930076bbc888bab, + type: 3} + propertyPath: upgradePrefabs.Array.data[0] + value: + objectReference: {fileID: 4585348266300200282, guid: 2ea1eb2b6b05340a4a99948a6eb818b2, + type: 3} - target: {fileID: 158905820630581597, guid: fdaa7451ab31b477b930076bbc888bab, type: 3} propertyPath: m_Name @@ -719,11 +730,6 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 7054975846833851214, guid: f064c0737a3e54f1fadc75fc09919760, - type: 3} - propertyPath: m_Name - value: Grid - objectReference: {fileID: 0} - target: {fileID: 7054975846833851208, guid: f064c0737a3e54f1fadc75fc09919760, type: 3} propertyPath: m_LocalPosition.x @@ -779,6 +785,11 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 7054975846833851214, guid: f064c0737a3e54f1fadc75fc09919760, + type: 3} + propertyPath: m_Name + value: Grid + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: f064c0737a3e54f1fadc75fc09919760, type: 3} --- !u!1001 &9082059503859367018 diff --git a/Assets/Scripts/src/Enemy/DumbEnemy.cs b/Assets/Scripts/src/Enemy/DumbEnemy.cs index 677ae44..5a41c97 100644 --- a/Assets/Scripts/src/Enemy/DumbEnemy.cs +++ b/Assets/Scripts/src/Enemy/DumbEnemy.cs @@ -11,7 +11,8 @@ public class DumbEnemy : EnemyBase protected new void FixedUpdate() { - if (transform.position.x == Mathf.Floor(transform.position.x) && transform.position.y == Mathf.Floor(transform.position.y)) + if (transform.position.x == Mathf.Floor(transform.position.x) && + transform.position.y == Mathf.Floor(transform.position.y)) { if (RandomChange()) { @@ -19,27 +20,26 @@ public class DumbEnemy : EnemyBase } else { - Rigidbody2d.MovePosition(Rigidbody2d.position + Direction * Speed * Time.deltaTime); + Rigidbody2d.MovePosition(Rigidbody2d.position + Speed * Time.deltaTime * Direction); } } else { - Rigidbody2d.MovePosition(Rigidbody2d.position + Direction * Speed * Time.deltaTime); + Rigidbody2d.MovePosition(Rigidbody2d.position + Speed * Time.deltaTime * Direction); } } private bool RandomChange() { - System.Random random = new System.Random(); - int randomNumber = random.Next(0, 100); + var random = new System.Random(); + var randomNumber = random.Next(0, 100); return randomNumber <= 25; } private void HandleChangeDirection() { - DebugHelper.LogInfo("Direction randomly changed"); Direction = ChooseRandomExceptCertainDirection(Direction); MoveToCenterOfTheCell(); - Rigidbody2d.MovePosition(Rigidbody2d.position + Direction * Speed * Time.deltaTime); + Rigidbody2d.MovePosition(Rigidbody2d.position + Speed * Time.deltaTime * Direction); } } diff --git a/Assets/Scripts/src/Helpers/ArrayExtensions.cs b/Assets/Scripts/src/Helpers/ArrayExtensions.cs index 4ee1c47..91cdeb9 100644 --- a/Assets/Scripts/src/Helpers/ArrayExtensions.cs +++ b/Assets/Scripts/src/Helpers/ArrayExtensions.cs @@ -8,7 +8,7 @@ namespace src.Helpers { public static T ChoseRandom(this T[] arr) { - var randomIndex = Mathf.FloorToInt(Random.Range(0, arr.Length)); + var randomIndex = Random.Range(0, arr.Length); return arr[randomIndex]; } @@ -17,7 +17,7 @@ namespace src.Helpers T value; do { - var randomIndex = Mathf.FloorToInt(Random.Range(0, arr.Length)); + var randomIndex = Random.Range(0, arr.Length); value = arr[randomIndex]; } while (exceptValue.Equals(value)); @@ -29,7 +29,7 @@ namespace src.Helpers T value; do { - var randomIndex = Mathf.FloorToInt(Random.Range(0, arr.Length)); + var randomIndex = Random.Range(0, arr.Length); value = arr[randomIndex]; } while (exceptValue.Contains(value)); diff --git a/Assets/Scripts/src/Interfaces/IUpgrade.cs b/Assets/Scripts/src/Interfaces/IUpgrade.cs new file mode 100644 index 0000000..f92f8f2 --- /dev/null +++ b/Assets/Scripts/src/Interfaces/IUpgrade.cs @@ -0,0 +1,10 @@ +using UnityEngine; + +namespace src.Interfaces +{ + public interface IUpgrade + { + void PerformUpgrade(); + void OnTriggerEnter2D(Collider2D other); + } +} \ No newline at end of file diff --git a/Assets/Scripts/src/Interfaces/IUpgrade.cs.meta b/Assets/Scripts/src/Interfaces/IUpgrade.cs.meta new file mode 100644 index 0000000..ae2ce95 --- /dev/null +++ b/Assets/Scripts/src/Interfaces/IUpgrade.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 527ddc9d1a334e739b995e82c8e96d10 +timeCreated: 1561210723 \ No newline at end of file diff --git a/Assets/Scripts/src/Managers/GameManager.cs b/Assets/Scripts/src/Managers/GameManager.cs index adc3f65..0ab7350 100644 --- a/Assets/Scripts/src/Managers/GameManager.cs +++ b/Assets/Scripts/src/Managers/GameManager.cs @@ -6,6 +6,7 @@ namespace src.Managers { public static GameManager Instance; private LevelManager _levelManager; + private UpgradeManager _upgradeManager; public void Awake() { @@ -22,10 +23,16 @@ namespace src.Managers DontDestroyOnLoad(gameObject); _levelManager = GetComponent(); + _upgradeManager = GetComponent(); InitGame(); } + public UpgradeManager GetUpgradeManager() + { + return _upgradeManager; + } + private void InitGame() { _levelManager.InitLevel(); diff --git a/Assets/Scripts/src/Managers/UpgradeManager.cs b/Assets/Scripts/src/Managers/UpgradeManager.cs new file mode 100644 index 0000000..9bbb09a --- /dev/null +++ b/Assets/Scripts/src/Managers/UpgradeManager.cs @@ -0,0 +1,16 @@ +using src.Base; +using src.Helpers; +using UnityEngine; + +namespace src.Managers +{ + public class UpgradeManager : GameplayComponent + { + public GameObject[] upgradePrefabs; + + public GameObject GetUpgradePrefab() + { + return upgradePrefabs.ChoseRandom(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/src/Managers/UpgradeManager.cs.meta b/Assets/Scripts/src/Managers/UpgradeManager.cs.meta new file mode 100644 index 0000000..f4e5c60 --- /dev/null +++ b/Assets/Scripts/src/Managers/UpgradeManager.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e64481d2e18e4b6ca4f22926a5061450 +timeCreated: 1561211937 \ No newline at end of file diff --git a/Assets/Scripts/src/Player/PlayerController.cs b/Assets/Scripts/src/Player/PlayerController.cs index 90a3a5a..f34270d 100644 --- a/Assets/Scripts/src/Player/PlayerController.cs +++ b/Assets/Scripts/src/Player/PlayerController.cs @@ -1,6 +1,7 @@ using src.Ammo; using src.Base; using src.Helpers; +using src.Interfaces; using UnityEngine; namespace src.Player diff --git a/Assets/Scripts/src/Upgrade.meta b/Assets/Scripts/src/Upgrade.meta new file mode 100644 index 0000000..f78cc06 --- /dev/null +++ b/Assets/Scripts/src/Upgrade.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ce5704d616e542aa9e6b98025b958d84 +timeCreated: 1561212967 \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/TestUpgrade.cs b/Assets/Scripts/src/Upgrade/TestUpgrade.cs new file mode 100644 index 0000000..55971cc --- /dev/null +++ b/Assets/Scripts/src/Upgrade/TestUpgrade.cs @@ -0,0 +1,23 @@ +using src.Base; +using src.Helpers; +using src.Interfaces; +using UnityEngine; + +namespace src.Upgrade +{ + public class TestUpgrade : GameplayComponent, IUpgrade + { + public void PerformUpgrade() + { + DebugHelper.LogError("Test upgrade works."); + } + + public void OnTriggerEnter2D(Collider2D other) + { + if (!other.CompareTag("Player")) return; + + DebugHelper.LogWarning("TestUpgrade WORKS!"); + Destroy(gameObject); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/TestUpgrade.cs.meta b/Assets/Scripts/src/Upgrade/TestUpgrade.cs.meta new file mode 100644 index 0000000..adeba4b --- /dev/null +++ b/Assets/Scripts/src/Upgrade/TestUpgrade.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: daf1c278fd544eae9246c4abe6bf611e +timeCreated: 1561212975 \ No newline at end of file diff --git a/Assets/Scripts/src/Wall/DestructibleWall.cs b/Assets/Scripts/src/Wall/DestructibleWall.cs index cbfd909..240985a 100644 --- a/Assets/Scripts/src/Wall/DestructibleWall.cs +++ b/Assets/Scripts/src/Wall/DestructibleWall.cs @@ -1,7 +1,9 @@ +using System; using UnityEngine; using src.Base; using src.Helpers; +using src.Managers; namespace src.Wall { @@ -9,9 +11,15 @@ namespace src.Wall { private bool _spawnExit; private bool _spawnUpgrade; + private UpgradeManager _upgradeManager; public GameObject explosionPrefab; public GameObject exitDoorPrefab; + private void Start() + { + _upgradeManager = GameManager.Instance.GetUpgradeManager(); + } + public void SpawnsExit() { _spawnExit = true; @@ -38,7 +46,8 @@ namespace src.Wall else if (_spawnUpgrade) { DebugHelper.LogInfo($"Destructible spawned upgrade {transform.position}"); - // TODO: Get and instantiate upgrade from manager + var upgrade = _upgradeManager.GetUpgradePrefab(); + Instantiate(upgrade, currentPosition, Quaternion.identity); } } From 70a977ac09a75ae8a15489c298119c08576ab1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nu=C8=9Biu?= Date: Sun, 23 Jun 2019 15:15:37 +0300 Subject: [PATCH 2/2] Implement Speed, Bombs and Flames upgrade --- Assets/DevMocks/BombsUpgrade.prefab | 121 ++++++++++++++++++ Assets/DevMocks/BombsUpgrade.prefab.meta | 7 + Assets/DevMocks/FlameUpgrade.prefab | 108 ++++++++++++++++ Assets/DevMocks/FlameUpgrade.prefab.meta | 7 + Assets/DevMocks/SpeedUpgrade.prefab | 108 ++++++++++++++++ Assets/DevMocks/SpeedUpgrade.prefab.meta | 7 + Assets/Scripts/src/Base/PlayerBase.cs | 5 + .../Scripts/src/Managers/BombsUtilManager.cs | 6 +- Assets/Scripts/src/Managers/GameManager.cs | 7 + .../Scripts/src/Upgrade/BombFlamesUpgrade.cs | 11 ++ .../src/Upgrade/BombFlamesUpgrade.cs.meta | 3 + .../src/Upgrade/BombPlacementUpgrade.cs | 11 ++ .../src/Upgrade/BombPlacementUpgrade.cs.meta | 3 + .../Scripts/src/Upgrade/PlayerSpeedUpgrade.cs | 15 +++ .../src/Upgrade/PlayerSpeedUpgrade.cs.meta | 3 + Assets/Scripts/src/Upgrade/TestUpgrade.cs | 12 +- Assets/Scripts/src/Upgrade/UpgradeBase.cs | 29 +++++ .../Scripts/src/Upgrade/UpgradeBase.cs.meta | 3 + 18 files changed, 453 insertions(+), 13 deletions(-) create mode 100644 Assets/DevMocks/BombsUpgrade.prefab create mode 100644 Assets/DevMocks/BombsUpgrade.prefab.meta create mode 100644 Assets/DevMocks/FlameUpgrade.prefab create mode 100644 Assets/DevMocks/FlameUpgrade.prefab.meta create mode 100644 Assets/DevMocks/SpeedUpgrade.prefab create mode 100644 Assets/DevMocks/SpeedUpgrade.prefab.meta create mode 100644 Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs create mode 100644 Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs.meta create mode 100644 Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs create mode 100644 Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs.meta create mode 100644 Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs create mode 100644 Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs.meta create mode 100644 Assets/Scripts/src/Upgrade/UpgradeBase.cs create mode 100644 Assets/Scripts/src/Upgrade/UpgradeBase.cs.meta diff --git a/Assets/DevMocks/BombsUpgrade.prefab b/Assets/DevMocks/BombsUpgrade.prefab new file mode 100644 index 0000000..8dc626b --- /dev/null +++ b/Assets/DevMocks/BombsUpgrade.prefab @@ -0,0 +1,121 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2377911311221568072 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7980903176349258245} + - component: {fileID: 6699440875015304414} + - component: {fileID: 7875732231624854186} + - component: {fileID: 7738746775589240714} + m_Layer: 0 + m_Name: BombsUpgrade + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7980903176349258245 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2377911311221568072} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &6699440875015304414 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2377911311221568072} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 753e29d30d8044605aede9853c9308c7, type: 3} + m_Color: {r: 0.9485793, g: 0, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &7875732231624854186 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2377911311221568072} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0.5, y: 0.5} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!114 &7738746775589240714 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2377911311221568072} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7fd512904859421b9f2b6420aa955d9a, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/DevMocks/BombsUpgrade.prefab.meta b/Assets/DevMocks/BombsUpgrade.prefab.meta new file mode 100644 index 0000000..c4e5efe --- /dev/null +++ b/Assets/DevMocks/BombsUpgrade.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6d6a8eb6810cd4483a761f7b02fff67f +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DevMocks/FlameUpgrade.prefab b/Assets/DevMocks/FlameUpgrade.prefab new file mode 100644 index 0000000..3f00305 --- /dev/null +++ b/Assets/DevMocks/FlameUpgrade.prefab @@ -0,0 +1,108 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7385886653159515755 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 685382037628668327} + - component: {fileID: 7037551310800415105} + - component: {fileID: 7958292204112110464} + m_Layer: 0 + m_Name: FlameUpgrade + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &685382037628668327 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7385886653159515755} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &7037551310800415105 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7385886653159515755} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 753e29d30d8044605aede9853c9308c7, type: 3} + m_Color: {r: 1, g: 0.1812256, b: 0, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &7958292204112110464 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7385886653159515755} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0.5, y: 0.5} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 diff --git a/Assets/DevMocks/FlameUpgrade.prefab.meta b/Assets/DevMocks/FlameUpgrade.prefab.meta new file mode 100644 index 0000000..75482cd --- /dev/null +++ b/Assets/DevMocks/FlameUpgrade.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ba0e1f9d79914426ba805d871bcad311 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/DevMocks/SpeedUpgrade.prefab b/Assets/DevMocks/SpeedUpgrade.prefab new file mode 100644 index 0000000..5c56ba5 --- /dev/null +++ b/Assets/DevMocks/SpeedUpgrade.prefab @@ -0,0 +1,108 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &4242909486338491383 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5958400204756161002} + - component: {fileID: 7382262205660184478} + - component: {fileID: 2747432428292150867} + m_Layer: 0 + m_Name: SpeedUpgrade + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5958400204756161002 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4242909486338491383} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &7382262205660184478 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4242909486338491383} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 753e29d30d8044605aede9853c9308c7, type: 3} + m_Color: {r: 0.97521883, g: 0.9811321, b: 0, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &2747432428292150867 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4242909486338491383} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0.5, y: 0.5} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 diff --git a/Assets/DevMocks/SpeedUpgrade.prefab.meta b/Assets/DevMocks/SpeedUpgrade.prefab.meta new file mode 100644 index 0000000..2d8acbc --- /dev/null +++ b/Assets/DevMocks/SpeedUpgrade.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c0bd5085d71f847b19df326a2fbcf069 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/src/Base/PlayerBase.cs b/Assets/Scripts/src/Base/PlayerBase.cs index 02823a1..2009d37 100644 --- a/Assets/Scripts/src/Base/PlayerBase.cs +++ b/Assets/Scripts/src/Base/PlayerBase.cs @@ -37,5 +37,10 @@ namespace src.Base { DebugHelper.LogInfo("Player hit by enemy"); } + + public void IncreaseSpeed(float speed) + { + movementSpeed += speed; + } } } \ No newline at end of file diff --git a/Assets/Scripts/src/Managers/BombsUtilManager.cs b/Assets/Scripts/src/Managers/BombsUtilManager.cs index 2091465..3935c5d 100644 --- a/Assets/Scripts/src/Managers/BombsUtilManager.cs +++ b/Assets/Scripts/src/Managers/BombsUtilManager.cs @@ -36,7 +36,7 @@ namespace src.Managers public void IncreaseAllowedBombs() { - if(AllowedBombs <= MaxAllowedBombs) + if (AllowedBombs <= MaxAllowedBombs) { AllowedBombs++; } @@ -44,7 +44,7 @@ namespace src.Managers public void PlaceBomb(Vector3 position) { - if(CanPlaceBomb(position)) + if (CanPlaceBomb(position)) { PlacedBombs++; _usedPosition.Add(position); @@ -53,7 +53,7 @@ namespace src.Managers public void RemoveBomb(Vector3 position) { - if(_usedPosition.Contains(position)) + if (_usedPosition.Contains(position)) { PlacedBombs--; _usedPosition.Remove(position); diff --git a/Assets/Scripts/src/Managers/GameManager.cs b/Assets/Scripts/src/Managers/GameManager.cs index 0ab7350..5f4ba61 100644 --- a/Assets/Scripts/src/Managers/GameManager.cs +++ b/Assets/Scripts/src/Managers/GameManager.cs @@ -7,6 +7,7 @@ namespace src.Managers public static GameManager Instance; private LevelManager _levelManager; private UpgradeManager _upgradeManager; + private BombsUtilManager _bombsUtilManager; public void Awake() { @@ -24,6 +25,7 @@ namespace src.Managers _levelManager = GetComponent(); _upgradeManager = GetComponent(); + _bombsUtilManager = BombsUtilManager.Instance; InitGame(); } @@ -33,6 +35,11 @@ namespace src.Managers return _upgradeManager; } + public BombsUtilManager GetBombsUtilManager() + { + return _bombsUtilManager; + } + private void InitGame() { _levelManager.InitLevel(); diff --git a/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs b/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs new file mode 100644 index 0000000..110f877 --- /dev/null +++ b/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs @@ -0,0 +1,11 @@ +namespace src.Upgrade +{ + public class BombFlamesUpgrade : UpgradeBase + { + public override void PerformUpgrade() + { + var bombManager = gameManager.GetBombsUtilManager(); + bombManager.IncreasePower(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs.meta b/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs.meta new file mode 100644 index 0000000..b457338 --- /dev/null +++ b/Assets/Scripts/src/Upgrade/BombFlamesUpgrade.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 94153367f2364ab38597c8f4a6521909 +timeCreated: 1561283550 \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs b/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs new file mode 100644 index 0000000..3e7b770 --- /dev/null +++ b/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs @@ -0,0 +1,11 @@ +namespace src.Upgrade +{ + public class BombPlacementUpgrade : UpgradeBase + { + public override void PerformUpgrade() + { + var bombManager = gameManager.GetBombsUtilManager(); + bombManager.IncreaseAllowedBombs(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs.meta b/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs.meta new file mode 100644 index 0000000..692bf64 --- /dev/null +++ b/Assets/Scripts/src/Upgrade/BombPlacementUpgrade.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7fd512904859421b9f2b6420aa955d9a +timeCreated: 1561283568 \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs b/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs new file mode 100644 index 0000000..7ec3ab4 --- /dev/null +++ b/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs @@ -0,0 +1,15 @@ +using src.Player; +using UnityEngine; + +namespace src.Upgrade +{ + public class PlayerSpeedUpgrade : UpgradeBase + { + public override void PerformUpgrade() + { + /* TODO: Refactor to use a player manager. */ + var player = GameObject.Find("Player").GetComponent(); + player.IncreaseSpeed(.5f); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs.meta b/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs.meta new file mode 100644 index 0000000..56eef9e --- /dev/null +++ b/Assets/Scripts/src/Upgrade/PlayerSpeedUpgrade.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0b8c723aa8c7476789cbee67fcadfbef +timeCreated: 1561283202 \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/TestUpgrade.cs b/Assets/Scripts/src/Upgrade/TestUpgrade.cs index 55971cc..07fb37e 100644 --- a/Assets/Scripts/src/Upgrade/TestUpgrade.cs +++ b/Assets/Scripts/src/Upgrade/TestUpgrade.cs @@ -5,19 +5,11 @@ using UnityEngine; namespace src.Upgrade { - public class TestUpgrade : GameplayComponent, IUpgrade + public class TestUpgrade : UpgradeBase { public void PerformUpgrade() { - DebugHelper.LogError("Test upgrade works."); - } - - public void OnTriggerEnter2D(Collider2D other) - { - if (!other.CompareTag("Player")) return; - - DebugHelper.LogWarning("TestUpgrade WORKS!"); - Destroy(gameObject); + DebugHelper.LogWarning("Test upgrade works!"); } } } \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/UpgradeBase.cs b/Assets/Scripts/src/Upgrade/UpgradeBase.cs new file mode 100644 index 0000000..2286e75 --- /dev/null +++ b/Assets/Scripts/src/Upgrade/UpgradeBase.cs @@ -0,0 +1,29 @@ +using src.Base; +using src.Interfaces; +using src.Managers; +using UnityEngine; + +namespace src.Upgrade +{ + public class UpgradeBase : GameplayComponent, IUpgrade + { + protected GameManager gameManager; + + public void Start() + { + gameManager = GameManager.Instance; + } + + public virtual void PerformUpgrade() + { + throw new System.NotImplementedException(); + } + + public void OnTriggerEnter2D(Collider2D other) + { + if (!other.CompareTag("Player")) return; + PerformUpgrade(); + Destroy(gameObject); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/src/Upgrade/UpgradeBase.cs.meta b/Assets/Scripts/src/Upgrade/UpgradeBase.cs.meta new file mode 100644 index 0000000..5506814 --- /dev/null +++ b/Assets/Scripts/src/Upgrade/UpgradeBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: be2063b5b2df4c0b884f11a7ee5e3380 +timeCreated: 1561283281 \ No newline at end of file