From 000f72bc7ac37a61cd46357a9e37f1cda245bb49 Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Sun, 21 Apr 2024 06:56:15 +0200 Subject: [PATCH] Enemy drop money on dealth --- Assets/Prefabs/Enemies/Enemy.prefab | 40 +++++++++++++++++++ Assets/Prefabs/Enemies/GreenBoy1.prefab | 5 +++ Assets/Prefabs/Enemies/GreenBoy2.prefab | 5 +++ Assets/Prefabs/Enemies/GreenBoyBoss.prefab | 5 +++ Assets/Prefabs/Enemies/GreenBoyJetpack.prefab | 5 +++ Assets/Scripts/Money.meta | 8 ++++ Assets/Scripts/Money/MoneyOnEnemyDeath.cs | 26 ++++++++++++ .../Scripts/Money/MoneyOnEnemyDeath.cs.meta | 11 +++++ 8 files changed, 105 insertions(+) create mode 100644 Assets/Scripts/Money.meta create mode 100644 Assets/Scripts/Money/MoneyOnEnemyDeath.cs create mode 100644 Assets/Scripts/Money/MoneyOnEnemyDeath.cs.meta diff --git a/Assets/Prefabs/Enemies/Enemy.prefab b/Assets/Prefabs/Enemies/Enemy.prefab index 04ac963..6628bf6 100644 --- a/Assets/Prefabs/Enemies/Enemy.prefab +++ b/Assets/Prefabs/Enemies/Enemy.prefab @@ -9,6 +9,8 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 8711060493889635308} + - component: {fileID: 369596802107988542} + - component: {fileID: 8270377878650669399} m_Layer: 0 m_Name: Enemy m_TagString: Untagged @@ -31,3 +33,41 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &369596802107988542 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 95331384460172707} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 62293fbacde88045196dca1e291b5f23, type: 3} + m_Name: + m_EditorClassIdentifier: + startHealth: 100 + OnHealthZero: + m_PersistentCalls: + m_Calls: [] + OnHealthChange: + m_PersistentCalls: + m_Calls: [] + OnHealthChange2: + m_PersistentCalls: + m_Calls: [] + OnHealthChange3: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &8270377878650669399 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 95331384460172707} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d1d1daa1d5342744bb097706d0969cae, type: 3} + m_Name: + m_EditorClassIdentifier: + MoneyDropOnDeath: 0 diff --git a/Assets/Prefabs/Enemies/GreenBoy1.prefab b/Assets/Prefabs/Enemies/GreenBoy1.prefab index b2c04f7..367d050 100644 --- a/Assets/Prefabs/Enemies/GreenBoy1.prefab +++ b/Assets/Prefabs/Enemies/GreenBoy1.prefab @@ -13,6 +13,11 @@ PrefabInstance: propertyPath: m_Name value: GreenBoy1 objectReference: {fileID: 0} + - target: {fileID: 8270377878650669399, guid: eff762e00bcd52a438a5abf98a554a0b, + type: 3} + propertyPath: MoneyDropOnDeath + value: 25 + objectReference: {fileID: 0} - target: {fileID: 8711060493889635308, guid: eff762e00bcd52a438a5abf98a554a0b, type: 3} propertyPath: m_LocalPosition.x diff --git a/Assets/Prefabs/Enemies/GreenBoy2.prefab b/Assets/Prefabs/Enemies/GreenBoy2.prefab index bbb05bf..01bc255 100644 --- a/Assets/Prefabs/Enemies/GreenBoy2.prefab +++ b/Assets/Prefabs/Enemies/GreenBoy2.prefab @@ -13,6 +13,11 @@ PrefabInstance: propertyPath: m_Name value: GreenBoy2 objectReference: {fileID: 0} + - target: {fileID: 8270377878650669399, guid: eff762e00bcd52a438a5abf98a554a0b, + type: 3} + propertyPath: MoneyDropOnDeath + value: 50 + objectReference: {fileID: 0} - target: {fileID: 8711060493889635308, guid: eff762e00bcd52a438a5abf98a554a0b, type: 3} propertyPath: m_LocalPosition.x diff --git a/Assets/Prefabs/Enemies/GreenBoyBoss.prefab b/Assets/Prefabs/Enemies/GreenBoyBoss.prefab index 1a992a0..bffcd4b 100644 --- a/Assets/Prefabs/Enemies/GreenBoyBoss.prefab +++ b/Assets/Prefabs/Enemies/GreenBoyBoss.prefab @@ -87,6 +87,11 @@ PrefabInstance: propertyPath: m_Name value: GreenBoyBoss objectReference: {fileID: 0} + - target: {fileID: 8270377878650669399, guid: eff762e00bcd52a438a5abf98a554a0b, + type: 3} + propertyPath: MoneyDropOnDeath + value: 200 + objectReference: {fileID: 0} - target: {fileID: 8711060493889635308, guid: eff762e00bcd52a438a5abf98a554a0b, type: 3} propertyPath: m_LocalPosition.x diff --git a/Assets/Prefabs/Enemies/GreenBoyJetpack.prefab b/Assets/Prefabs/Enemies/GreenBoyJetpack.prefab index 317a8a1..785477f 100644 --- a/Assets/Prefabs/Enemies/GreenBoyJetpack.prefab +++ b/Assets/Prefabs/Enemies/GreenBoyJetpack.prefab @@ -87,6 +87,11 @@ PrefabInstance: propertyPath: m_Name value: GreenBoyJetpack objectReference: {fileID: 0} + - target: {fileID: 8270377878650669399, guid: eff762e00bcd52a438a5abf98a554a0b, + type: 3} + propertyPath: MoneyDropOnDeath + value: 150 + objectReference: {fileID: 0} - target: {fileID: 8711060493889635308, guid: eff762e00bcd52a438a5abf98a554a0b, type: 3} propertyPath: m_LocalPosition.x diff --git a/Assets/Scripts/Money.meta b/Assets/Scripts/Money.meta new file mode 100644 index 0000000..5921bb8 --- /dev/null +++ b/Assets/Scripts/Money.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aac742eb4131cb34a87890b1b678b4b9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Money/MoneyOnEnemyDeath.cs b/Assets/Scripts/Money/MoneyOnEnemyDeath.cs new file mode 100644 index 0000000..06bc902 --- /dev/null +++ b/Assets/Scripts/Money/MoneyOnEnemyDeath.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class MoneyOnEnemyDeath : MonoBehaviour +{ + private HealthComponent healthComp; + + [SerializeField] private float MoneyDropOnDeath; + + private void OnEnable() + { + healthComp = GetComponent(); + healthComp.OnHealthZero.AddListener(OnDeath); + } + + private void OnDisable() + { + healthComp.OnHealthZero.RemoveListener(OnDeath); + } + + void OnDeath() + { + GameManager.Instance.Balance.Value += MoneyDropOnDeath; + } +} diff --git a/Assets/Scripts/Money/MoneyOnEnemyDeath.cs.meta b/Assets/Scripts/Money/MoneyOnEnemyDeath.cs.meta new file mode 100644 index 0000000..8f27e65 --- /dev/null +++ b/Assets/Scripts/Money/MoneyOnEnemyDeath.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d1d1daa1d5342744bb097706d0969cae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: