diff --git a/.idea/.idea.Infratest/.idea/workspace.xml b/.idea/.idea.Infratest/.idea/workspace.xml
index 9ab36de..c932928 100644
--- a/.idea/.idea.Infratest/.idea/workspace.xml
+++ b/.idea/.idea.Infratest/.idea/workspace.xml
@@ -5,32 +5,12 @@
-
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -200,15 +180,13 @@
-
+
-
+
diff --git a/Assets/Code/Example/Platformer/Entity/Entity.cs b/Assets/Code/Example/Platformer/Entity/Entity.cs
index b95a580..20f97c4 100644
--- a/Assets/Code/Example/Platformer/Entity/Entity.cs
+++ b/Assets/Code/Example/Platformer/Entity/Entity.cs
@@ -15,13 +15,11 @@ namespace Code.Example.Platformer.Entity
[SerializeField] protected SpriteRenderer spriteRenderer;
[SerializeField] private Vector2 groundPoint;
- private EntityHealth _health;
private PlatformerEntityData _data;
public void SetData(PlatformerEntityData data)
{
_data = data;
- _health = new(data.maxHealth);
}
protected bool onGround;
@@ -51,7 +49,5 @@ namespace Code.Example.Platformer.Entity
}
protected abstract void Move();
-
- public virtual void GetDamage(int damage) => _health.GiveDamage(damage);
}
}
\ No newline at end of file
diff --git a/Assets/Code/Example/Platformer/Entity/EntityHealth.cs b/Assets/Code/Example/Platformer/Entity/EntityHealth.cs
index 5f85861..7329874 100644
--- a/Assets/Code/Example/Platformer/Entity/EntityHealth.cs
+++ b/Assets/Code/Example/Platformer/Entity/EntityHealth.cs
@@ -1,15 +1,14 @@
+using UnityEngine;
+
namespace Code.Example.Platformer.Entity
{
- public class EntityHealth
+ public class EntityHealth : MonoBehaviour
{
- private int _health, _maxHealth;
+ private int _health;
+ private int _maxHealth;
+ public void SetMaxHealth(int maxHealth) => _maxHealth = maxHealth;
public bool IsDead { get; private set; }
- public EntityHealth(int initialHealth)
- {
- _health = initialHealth;
- }
-
public void GiveDamage(int damage)
{
_health -= damage;
diff --git a/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs b/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs
index 57b4cf8..75af65a 100644
--- a/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs
+++ b/Assets/Code/Example/Platformer/Entity/PlatformerEnemyFactory.cs
@@ -12,7 +12,7 @@ namespace Code.Example.Platformer.Entity
{
public interface IPlatformerEnemyFactory
{
- UniTaskVoid LoadEnemy(PlatformerEntityType enemyType);
+ UniTaskVoid WarmEnemy(PlatformerEntityType enemyType);
void ReleaseEnemy(PlatformerEntityType racerType);
UniTaskVoid SpawnEnemy(
@@ -45,12 +45,11 @@ namespace Code.Example.Platformer.Entity
await _enemyConfigsHandle.ToUniTask();
_enemyConfigs = _enemyConfigsHandle.Result.ToDictionary(x => x.EntityData.type);
- _enemyConfigs.Remove(PlatformerEntityType.Player);
_eventBus.RaiseEvent(x => x.PlatformerEnemyFactoryInitialized());
}
- public async UniTaskVoid LoadEnemy(PlatformerEntityType enemyType)
+ public async UniTaskVoid WarmEnemy(PlatformerEntityType enemyType)
{
if (enemyType == PlatformerEntityType.Player) return;
@@ -66,10 +65,14 @@ namespace Code.Example.Platformer.Entity
Addressables.LoadAssetAsync(_enemyConfigs[enemyType].prefabReference));
await _enemyPrefabsHandle[enemyType].ToUniTask();
- var racer = _enemyPrefabsHandle[enemyType].Result.GetComponent();
- racer.SetData(_enemyConfigs[enemyType].EntityData);
-
- _eventBus.RaiseEvent(x => x.PlatformerEnemyLoaded(enemyType, racer));
+
+ var entity = _enemyPrefabsHandle[enemyType].Result.GetComponent();
+ entity.SetData(_enemyConfigs[enemyType].EntityData);
+
+ var health = _enemyPrefabsHandle[enemyType].Result.GetComponent();
+ health.SetMaxHealth(_enemyConfigs[enemyType].EntityData.maxHealth);
+
+ _eventBus.RaiseEvent(x => x.PlatformerEnemyLoaded(enemyType, entity));
}
public void ReleaseEnemy(PlatformerEntityType racerType)
diff --git a/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs b/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs
index 074190c..c392327 100644
--- a/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs
+++ b/Assets/Code/Example/Platformer/Entity/PlayerEntity.cs
@@ -88,7 +88,7 @@ namespace Code.Example.Platformer.Entity
foreach (var damaged in damagedOnes)
{
- damaged.gameObject.GetComponent().GetDamage(1);
+ damaged.gameObject.GetComponent().GiveDamage(1);
_audioService.PlayOneShot(AudioNames.UISounds, 2);
}
}
diff --git a/Assets/Code/Example/Platformer/PlatformerState.cs b/Assets/Code/Example/Platformer/PlatformerState.cs
index f4b38d3..6b8f58f 100644
--- a/Assets/Code/Example/Platformer/PlatformerState.cs
+++ b/Assets/Code/Example/Platformer/PlatformerState.cs
@@ -74,9 +74,9 @@ namespace Code.Example.Platformer
_firstLevelData = container.Resolve();
_enemyFactory = container.Resolve();
- _enemyFactory.LoadEnemy(PlatformerEntityType.Bee);
- _enemyFactory.LoadEnemy(PlatformerEntityType.Boar);
- _enemyFactory.LoadEnemy(PlatformerEntityType.Snail);
+ _enemyFactory.WarmEnemy(PlatformerEntityType.Bee);
+ _enemyFactory.WarmEnemy(PlatformerEntityType.Boar);
+ _enemyFactory.WarmEnemy(PlatformerEntityType.Snail);
_loading.DoProgress();
}