diff --git a/MissileCommander/.idea/.idea.MissileCommander/.idea/contentModel.xml b/MissileCommander/.idea/.idea.MissileCommander/.idea/contentModel.xml
index ea2f463..45c5684 100644
--- a/MissileCommander/.idea/.idea.MissileCommander/.idea/contentModel.xml
+++ b/MissileCommander/.idea/.idea.MissileCommander/.idea/contentModel.xml
@@ -21,7 +21,6 @@
-
diff --git a/MissileCommander/Assets/Game/Core/DestroyEffect.prefab b/MissileCommander/Assets/Game/Core/DestroyEffect.prefab
new file mode 100644
index 0000000..0de6c03
--- /dev/null
+++ b/MissileCommander/Assets/Game/Core/DestroyEffect.prefab
@@ -0,0 +1,127 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &6752188890843315280
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 7176714262414095371}
+ - component: {fileID: 8081201054838013091}
+ m_Layer: 0
+ m_Name: DestroyEffect_0
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &7176714262414095371
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 6752188890843315280}
+ 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: 8440115618531013871}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &8081201054838013091
+SpriteRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 6752188890843315280}
+ 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_ReceiveGI: 1
+ m_PreserveUVs: 0
+ m_IgnoreNormalsForChartDetection: 0
+ m_ImportantGI: 0
+ m_StitchLightmapSeams: 1
+ 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: -1864373156434754777, guid: a288b627034cd4497ab612861d948f9a,
+ type: 3}
+ m_Color: {r: 1, g: 1, b: 1, a: 1}
+ m_FlipX: 0
+ m_FlipY: 0
+ m_DrawMode: 0
+ m_Size: {x: 1.2, y: 1.2}
+ m_AdaptiveModeThreshold: 0.5
+ m_SpriteTileMode: 0
+ m_WasSpriteAssigned: 1
+ m_MaskInteraction: 0
+ m_SpriteSortPoint: 0
+--- !u!1 &6951797282581088142
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 8440115618531013871}
+ - component: {fileID: 6117580419327657503}
+ m_Layer: 0
+ m_Name: DestroyEffect
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &8440115618531013871
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 6951797282581088142}
+ 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:
+ - {fileID: 7176714262414095371}
+ m_Father: {fileID: 0}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &6117580419327657503
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 6951797282581088142}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: cdbcc414a06341c5a9585ad907a01c32, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
diff --git a/MissileCommander/Assets/Game/Core/DestroyEffect.prefab.meta b/MissileCommander/Assets/Game/Core/DestroyEffect.prefab.meta
new file mode 100644
index 0000000..81728d3
--- /dev/null
+++ b/MissileCommander/Assets/Game/Core/DestroyEffect.prefab.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 460346ccc206af549931e9ccb77609ba
+PrefabImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/MissileCommander/Assets/_Scripts/BuildingManager.cs b/MissileCommander/Assets/_Scripts/BuildingManager.cs
index d785bab..33c4500 100644
--- a/MissileCommander/Assets/_Scripts/BuildingManager.cs
+++ b/MissileCommander/Assets/_Scripts/BuildingManager.cs
@@ -55,6 +55,7 @@ public Vector3 GetRandomBuildingPosition()
private void OnBuildingDestroyed(Building building)
{
Vector3 lastPos = building.transform.position;
+ lastPos.y += building.GetComponent().size.y * 0.5f;
building.onDestroyed -= this.OnBuildingDestroyed;
int index = _buildings.IndexOf(building);
@@ -63,6 +64,13 @@ private void OnBuildingDestroyed(Building building)
RecyclableObject effect = _effectFactory.Get();
effect.Activate(lastPos);
+ effect.onDestroyed += OnEffectDestroyed;
+ }
+
+ private void OnEffectDestroyed(RecyclableObject effect)
+ {
+ effect.onDestroyed -= this.OnEffectDestroyed;
+ _effectFactory.ReturnToPool(effect);
}
}
}
\ No newline at end of file
diff --git a/MissileCommander/Assets/_Scripts/DestroyEffect.cs b/MissileCommander/Assets/_Scripts/DestroyEffect.cs
index ccf87a8..f53cca3 100644
--- a/MissileCommander/Assets/_Scripts/DestroyEffect.cs
+++ b/MissileCommander/Assets/_Scripts/DestroyEffect.cs
@@ -1,9 +1,25 @@
-using UnityEngine;
+using System;
+using UnityEngine;
namespace MissileCommander
{
public class DestroyEffect : RecyclableObject
{
-
+ [SerializeField] private float effectTime = 0.5f;
+ private float _elapsedTime = 0f;
+
+ private void Update()
+ {
+ if (!isActivated) { return; }
+
+ _elapsedTime += Time.deltaTime;
+ if (_elapsedTime >= effectTime)
+ {
+ _elapsedTime = 0f;
+ isActivated = false;
+
+ onDestroyed?.Invoke(this);
+ }
+ }
}
}
\ No newline at end of file