diff --git a/Assets/Resources/1/VFX/_Game/Death/DeathBlue.prefab b/Assets/Resources/1/VFX/_Game/Death/DeathBlue.prefab index 2734d4f9..3e204ee1 100644 --- a/Assets/Resources/1/VFX/_Game/Death/DeathBlue.prefab +++ b/Assets/Resources/1/VFX/_Game/Death/DeathBlue.prefab @@ -4822,7 +4822,6 @@ GameObject: - component: {fileID: 4578021055421579414} - component: {fileID: 4578021055435659058} - component: {fileID: 4578021055437630178} - - component: {fileID: 4578021055424340148} m_Layer: 0 m_Name: DeathBlue m_TagString: Untagged @@ -4860,7 +4859,7 @@ ParticleSystem: lengthInSec: 3 simulationSpeed: 1 stopAction: 2 - cullingMode: 3 + cullingMode: 1 ringBufferMode: 0 ringBufferLoopRange: {x: 0, y: 1} looping: 0 @@ -9601,102 +9600,6 @@ ParticleSystemRenderer: m_Mesh2: {fileID: 0} m_Mesh3: {fileID: 0} m_MaskInteraction: 0 ---- !u!82 &4578021055424340148 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4578021055421768374} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 8300000, guid: b1acecdf352627048b995eca86c0f8ec, type: 3} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 --- !u!1 &4578021055421788354 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/1/VFX/_Game/Death/DeathGreen.prefab b/Assets/Resources/1/VFX/_Game/Death/DeathGreen.prefab index 9f1bae7f..19db0f95 100644 --- a/Assets/Resources/1/VFX/_Game/Death/DeathGreen.prefab +++ b/Assets/Resources/1/VFX/_Game/Death/DeathGreen.prefab @@ -24142,7 +24142,6 @@ GameObject: - component: {fileID: 8483527721606191231} - component: {fileID: 8483527721625702363} - component: {fileID: 8483527721626104331} - - component: {fileID: 8483527721614194781} m_Layer: 0 m_Name: DeathGreen m_TagString: Untagged @@ -24180,7 +24179,7 @@ ParticleSystem: lengthInSec: 3 simulationSpeed: 1 stopAction: 2 - cullingMode: 3 + cullingMode: 1 ringBufferMode: 0 ringBufferLoopRange: {x: 0, y: 1} looping: 0 @@ -28921,99 +28920,3 @@ ParticleSystemRenderer: m_Mesh2: {fileID: 0} m_Mesh3: {fileID: 0} m_MaskInteraction: 0 ---- !u!82 &8483527721614194781 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8483527721606052447} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 8300000, guid: b1acecdf352627048b995eca86c0f8ec, type: 3} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 diff --git a/Assets/Resources/1/VFX/_Game/Death/DeathRed.prefab b/Assets/Resources/1/VFX/_Game/Death/DeathRed.prefab index 89064c07..d21b856a 100644 --- a/Assets/Resources/1/VFX/_Game/Death/DeathRed.prefab +++ b/Assets/Resources/1/VFX/_Game/Death/DeathRed.prefab @@ -24142,7 +24142,6 @@ GameObject: - component: {fileID: 730781534365034970} - component: {fileID: 730781534379310718} - component: {fileID: 730781534378378158} - - component: {fileID: 730781534365420024} m_Layer: 0 m_Name: DeathRed m_TagString: Untagged @@ -24180,7 +24179,7 @@ ParticleSystem: lengthInSec: 3 simulationSpeed: 1 stopAction: 2 - cullingMode: 3 + cullingMode: 1 ringBufferMode: 0 ringBufferLoopRange: {x: 0, y: 1} looping: 0 @@ -28921,99 +28920,3 @@ ParticleSystemRenderer: m_Mesh2: {fileID: 0} m_Mesh3: {fileID: 0} m_MaskInteraction: 0 ---- !u!82 &730781534365420024 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 730781534364879866} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 8300000, guid: b1acecdf352627048b995eca86c0f8ec, type: 3} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 diff --git a/Assets/Resources/1/VFX/_Game/Death/DeathYellow.prefab b/Assets/Resources/1/VFX/_Game/Death/DeathYellow.prefab index e148bafb..7e55d28b 100644 --- a/Assets/Resources/1/VFX/_Game/Death/DeathYellow.prefab +++ b/Assets/Resources/1/VFX/_Game/Death/DeathYellow.prefab @@ -24142,7 +24142,6 @@ GameObject: - component: {fileID: 7140011676602217546} - component: {fileID: 7140011676621711426} - component: {fileID: 7140011676621667256} - - component: {fileID: 7140011676610264564} m_Layer: 0 m_Name: DeathYellow m_TagString: Untagged @@ -24180,7 +24179,7 @@ ParticleSystem: lengthInSec: 3 simulationSpeed: 1 stopAction: 2 - cullingMode: 3 + cullingMode: 1 ringBufferMode: 0 ringBufferLoopRange: {x: 0, y: 1} looping: 0 @@ -28921,99 +28920,3 @@ ParticleSystemRenderer: m_Mesh2: {fileID: 0} m_Mesh3: {fileID: 0} m_MaskInteraction: 0 ---- !u!82 &7140011676610264564 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7140011676602114744} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 8300000, guid: b1acecdf352627048b995eca86c0f8ec, type: 3} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 0 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 0 diff --git a/Assets/Resources/Data/FieldData.asset b/Assets/Resources/Data/FieldData.asset index b766cf47..426edf87 100644 --- a/Assets/Resources/Data/FieldData.asset +++ b/Assets/Resources/Data/FieldData.asset @@ -26,25 +26,29 @@ MonoBehaviour: colors: - _unitColor: 2 _texture: {fileID: 2800000, guid: 983242f4b4db7a841af48234cf0021b8, type: 3} - _vfxPrefab: {fileID: 0} - _buildinMaterial: {fileID: 0} + _vfxCellCapturePrefab: {fileID: 0} + _vfxDeathPrefab: {fileID: 0} - _unitColor: 0 _texture: {fileID: 2800000, guid: 0298dfcb0756f534a9a125d510461c7a, type: 3} - _vfxPrefab: {fileID: 8021195855904498788, guid: 2f6d0540c8fd7bb46b356ff86962379c, + _vfxCellCapturePrefab: {fileID: 8021195855904498788, guid: 2f6d0540c8fd7bb46b356ff86962379c, + type: 3} + _vfxDeathPrefab: {fileID: 8483527721606052447, guid: fd7fc481b936cf84a90d2d01d83e9b06, type: 3} - _buildinMaterial: {fileID: 2100000, guid: 948554a1d458a2f42afa262d79d6b7b8, type: 2} - _unitColor: 1 _texture: {fileID: 2800000, guid: 3b75368df991b164583e8cede390e24e, type: 3} - _vfxPrefab: {fileID: 442387583353148024, guid: 53959bc898e9a644daad0282881d596a, + _vfxCellCapturePrefab: {fileID: 442387583353148024, guid: 53959bc898e9a644daad0282881d596a, + type: 3} + _vfxDeathPrefab: {fileID: 730781534364879866, guid: 15620662117187f419d41032a4267445, type: 3} - _buildinMaterial: {fileID: 2100000, guid: 9eb3fa679bb990142a02982fb51700c9, type: 2} - _unitColor: 3 _texture: {fileID: 2800000, guid: 1a76a79d5a83143479c76f4f37c4b896, type: 3} - _vfxPrefab: {fileID: 5732852186060375560, guid: 54d847a18c62f57479c53469d4398ceb, + _vfxCellCapturePrefab: {fileID: 5732852186060375560, guid: 54d847a18c62f57479c53469d4398ceb, + type: 3} + _vfxDeathPrefab: {fileID: 7140011676602114744, guid: 6d9f179a27798c248b3c35df9139eb85, type: 3} - _buildinMaterial: {fileID: 2100000, guid: 8720b7cac4364f14f961a3b6968c9beb, type: 2} - _unitColor: 4 _texture: {fileID: 2800000, guid: 779719648deedb4478ddebb3b81751ef, type: 3} - _vfxPrefab: {fileID: 1651852338557341938, guid: fa6c1fc3da7c8d24c85a88b00cf598d4, + _vfxCellCapturePrefab: {fileID: 1651852338557341938, guid: fa6c1fc3da7c8d24c85a88b00cf598d4, + type: 3} + _vfxDeathPrefab: {fileID: 4578021055421768374, guid: b2b879dd7ca552a408d4349691d2c8df, type: 3} - _buildinMaterial: {fileID: 2100000, guid: 38aadeb2461f2b249bebec6bc7e539d9, type: 2} diff --git a/Assets/Resources/Data/UnitsData.asset b/Assets/Resources/Data/UnitsData.asset index 9afcd91d..fe80cecd 100644 --- a/Assets/Resources/Data/UnitsData.asset +++ b/Assets/Resources/Data/UnitsData.asset @@ -21,7 +21,7 @@ MonoBehaviour: type: 3} color: 3 manaRegen: 10 - maxMana: 100 + maxMana: 10000000 maxHP: 100 inventoryCapacity: 4 - isPlayer: 0 diff --git a/Assets/Scripts/Controller/GameInit.cs b/Assets/Scripts/Controller/GameInit.cs index b5c8cc18..e2d7712a 100644 --- a/Assets/Scripts/Controller/GameInit.cs +++ b/Assets/Scripts/Controller/GameInit.cs @@ -81,12 +81,12 @@ namespace Controller hexGrid.OnHexPainted += paintedController.SetHexColors; hexGrid.OnHexPainted += itemFabric.UpdateCellToOpenList; - hexGrid.OnHexPainted += paintedController.CheckDeath; + hexGrid.OnHexPainted += paintedController.CheckDeathOrDestroy; } private List SetUpItems() { - return new List() { typeof(Tower), typeof(AttackBonus), typeof(DefenceBonus) }; + return new List() { typeof(Building), typeof(AttackBonus), typeof(DefenceBonus) }; } } } \ No newline at end of file diff --git a/Assets/Scripts/HexFiled/CellColor.cs b/Assets/Scripts/HexFiled/CellColor.cs index 7874c525..c84800a0 100644 --- a/Assets/Scripts/HexFiled/CellColor.cs +++ b/Assets/Scripts/HexFiled/CellColor.cs @@ -8,13 +8,14 @@ namespace HexFiled { [SerializeField] private UnitColor _unitColor; [SerializeField] private Texture _texture; - [SerializeField] private GameObject _vfxPrefab; - [SerializeField] private Material _buildinMaterial; + [SerializeField] private GameObject _vfxCellCapturePrefab; + [SerializeField] private GameObject _vfxDeathPrefab; + public UnitColor UnitColor => _unitColor; public Texture Texture => _texture; - public Material BuildingMaterial => _buildinMaterial; - public GameObject VFXPrefab => _vfxPrefab; + public GameObject VFXDeathPrefab => _vfxDeathPrefab; + public GameObject VFXCellCapturePrefab => _vfxCellCapturePrefab; diff --git a/Assets/Scripts/HexFiled/HexCell.cs b/Assets/Scripts/HexFiled/HexCell.cs index 9618af79..a17ad714 100644 --- a/Assets/Scripts/HexFiled/HexCell.cs +++ b/Assets/Scripts/HexFiled/HexCell.cs @@ -4,6 +4,7 @@ using System.Linq; using DefaultNamespace; using Items; using UnityEngine; +using UnityEngine.UI; using Random = UnityEngine.Random; namespace HexFiled @@ -27,6 +28,19 @@ namespace HexFiled public UnitColor Color => _color; public Item Item => _item; + private TowerView _towerView; + + public TowerView Building + { + get => _towerView; + set + { + if (_towerView != null) + { + _towerView = value; + } + } + } private void Awake() { @@ -76,7 +90,7 @@ namespace HexFiled } _renderer.material.mainTexture = HexGrid.Colors[color].Texture; - + var previousColor = _color; _color = color; if (!HexManager.CellByColor.ContainsKey(_color)) @@ -85,12 +99,14 @@ namespace HexFiled } else { + if(previousColor != UnitColor.GREY && HexManager.CellByColor[previousColor].Remove(this)) + { + Debug.Log("Repainted"); + } HexManager.CellByColor[_color].Add(this); } - - - var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[color].VFXPrefab, transform.position + new Vector3(0,0.1f,0)); + var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[color].VFXCellCapturePrefab, transform.position + new Vector3(0,0.1f,0)); MusicController.Instance.AddAudioSource(vfx); MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures, vfx); diff --git a/Assets/Scripts/HexFiled/HexGrid.cs b/Assets/Scripts/HexFiled/HexGrid.cs index 97bac212..d56886e6 100644 --- a/Assets/Scripts/HexFiled/HexGrid.cs +++ b/Assets/Scripts/HexFiled/HexGrid.cs @@ -26,6 +26,7 @@ namespace HexFiled public int HexHardCaptureCost => _fieldData.hexHardCaptureManaCost; public float HardCaptureTime => _fieldData.hexHardCaptureTime; + public static Dictionary Colors => _colors; diff --git a/Assets/Scripts/HexFiled/HexManager.cs b/Assets/Scripts/HexFiled/HexManager.cs index 606f5f9e..83ad8c4e 100644 --- a/Assets/Scripts/HexFiled/HexManager.cs +++ b/Assets/Scripts/HexFiled/HexManager.cs @@ -56,7 +56,7 @@ namespace HexFiled field.ForEach(x => actions.Add(x.PaintHex)); - TimerHelper.Instance.StartTimer(actions, 0.05f, color); + TimerHelper.Instance.StartTimer(actions, 0.01f, color); } diff --git a/Assets/Scripts/HexFiled/PaintedController.cs b/Assets/Scripts/HexFiled/PaintedController.cs index d9c02889..8b002283 100644 --- a/Assets/Scripts/HexFiled/PaintedController.cs +++ b/Assets/Scripts/HexFiled/PaintedController.cs @@ -1,6 +1,8 @@ +using System; using System.Collections.Generic; using System.Linq; using Units; +using UnityEngine; using Random = UnityEngine.Random; namespace HexFiled @@ -15,12 +17,19 @@ namespace HexFiled HexManager.UnitCurrentCell = new Dictionary(); } - public void CheckDeath(HexCell cell) + public void CheckDeathOrDestroy(HexCell cell) { - foreach (var cells in HexManager.UnitCurrentCell.Where(cells => HexManager.CellByColor[cells.Key].Count < 2 || (cells.Value.cell == cell && cells.Value.unit.Color != cell.Color))) + foreach (var cells in HexManager.UnitCurrentCell + .Where(cells => HexManager.CellByColor[cells.Key].Count < 2 || (cells.Value.cell == cell && cells.Value.unit.Color != cell.Color))) { cells.Value.unit.Death(); } + + if (cell.Building != null && cell.Building.Color != cell.Color) + { + + + } } public void SetHexColors(HexCell cell) { diff --git a/Assets/Scripts/Items/Tower.cs b/Assets/Scripts/Items/Building.cs similarity index 83% rename from Assets/Scripts/Items/Tower.cs rename to Assets/Scripts/Items/Building.cs index b562b727..e764b1c6 100644 --- a/Assets/Scripts/Items/Tower.cs +++ b/Assets/Scripts/Items/Building.cs @@ -7,10 +7,11 @@ using Object = UnityEngine.Object; namespace Items { - public class Tower : Item + + public class Building : Item { - public Tower(ItemInfo data) : base(data) + public Building(ItemInfo data) : base(data) { } @@ -30,6 +31,7 @@ namespace Items Unit.UseItem(this); var obj = Object.Instantiate(Data.SpawnablePrefab, cell.transform.position + Data.SpawnablePrefab.transform.position, Quaternion.identity); obj.GetComponent().SetUp(Unit.Color); + cell.Building = obj.GetComponent(); OnItemUsed?.Invoke(this); } } diff --git a/Assets/Scripts/Items/Tower.cs.meta b/Assets/Scripts/Items/Building.cs.meta similarity index 100% rename from Assets/Scripts/Items/Tower.cs.meta rename to Assets/Scripts/Items/Building.cs.meta diff --git a/Assets/Scripts/Items/Item.cs b/Assets/Scripts/Items/Item.cs index db5f7953..6d91117c 100644 --- a/Assets/Scripts/Items/Item.cs +++ b/Assets/Scripts/Items/Item.cs @@ -8,14 +8,17 @@ using Object = UnityEngine.Object; namespace Items { - public abstract class Item + public abstract class Item : IDisposable { + private GameObject _instance; + protected ItemInfo Data; protected Unit Unit; protected Action OnItemUsed; public bool IsInstantUse => Data.IsInstanceUse; public Sprite Icon => Data.Icon; + public UnitColor Color => Unit.Color; protected Item(ItemInfo data) { Data = data; @@ -28,13 +31,19 @@ namespace Items public GameObject Spawn(HexCell cell) { - var item = Object.Instantiate(Data.Prefab, cell.transform.position + new Vector3(0, 1, 0), + _instance = Object.Instantiate(Data.Prefab, cell.transform.position + new Vector3(0, 1, 0), Quaternion.identity); - return item; + return _instance; } + public abstract void Invoke(Action item); public abstract void InstanceInvoke(); public abstract void PlaceItem(HexCell cell); + + public void Dispose() + { + Object.Destroy(_instance); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Items/ItemFabric.cs b/Assets/Scripts/Items/ItemFabric.cs index 91f3810b..0e828a3d 100644 --- a/Assets/Scripts/Items/ItemFabric.cs +++ b/Assets/Scripts/Items/ItemFabric.cs @@ -50,13 +50,13 @@ namespace Items time = Time.time; var cell = _openList[Random.Range(0, _openList.Count - 1)]; - while (closedList.Contains(cell) || cell.Item != null) + if (closedList.Contains(cell) || cell.Item != null) { return; } var type = GetWeightedType(); - while (type == null) + if (type == null) { return; } diff --git a/Assets/Scripts/Items/TowerView.cs b/Assets/Scripts/Items/TowerView.cs index 6331bc1b..97bb962f 100644 --- a/Assets/Scripts/Items/TowerView.cs +++ b/Assets/Scripts/Items/TowerView.cs @@ -23,15 +23,14 @@ public class TowerView : MonoBehaviour private UnitColor _color; private GameObject _target; [SerializeField] private Weapon weapon; - [SerializeField] private SkinnedMeshRenderer _meshRenderer; [SerializeField] private List crystals; - + public UnitColor Color => _color; public void SetUp(UnitColor unitColor) { _color = unitColor; - _meshRenderer.material = HexGrid.Colors[unitColor].BuildingMaterial; + crystals.First(x => x.UnitColor == unitColor).GameObject.SetActive(true); var capsule = gameObject.AddComponent(); capsule.radius = weapon.disnatce * HexGrid.HexDistance; diff --git a/Assets/Scripts/Units/Unit.cs b/Assets/Scripts/Units/Unit.cs index 81ee3c26..9ebe541a 100644 --- a/Assets/Scripts/Units/Unit.cs +++ b/Assets/Scripts/Units/Unit.cs @@ -295,9 +295,12 @@ namespace Units _isAlive = false; HexManager.UnitCurrentCell.Remove(Color); _animator.SetTrigger("Death"); - TimerHelper.Instance.StartTimer(() => { Object.Destroy(_instance); }, _animLength.Death); + var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[Color].VFXDeathPrefab, + _instance.transform.position); + vfx.GetComponent().OnPlayEnd += () => Object.Destroy(_instance); OnDeath?.Invoke(this); - MusicController.Instance.PlayAudioClip(MusicController.Instance.MusicData.SfxMusic.Death, _instance); + MusicController.Instance.AddAudioSource(vfx); + MusicController.Instance.PlayAudioClip(MusicController.Instance.MusicData.SfxMusic.Death, vfx); MusicController.Instance.RemoveAudioSource(_instance); HexManager.PaintHexList(HexManager.CellByColor[Color], UnitColor.GREY); } diff --git a/Assets/Scripts/VFXView.cs b/Assets/Scripts/VFXView.cs index 411966ef..9e423abb 100644 --- a/Assets/Scripts/VFXView.cs +++ b/Assets/Scripts/VFXView.cs @@ -6,17 +6,20 @@ namespace DefaultNamespace public class VFXView : MonoBehaviour { private ParticleSystem _system; + public Action OnPlayEnd; private void Start() { _system = GetComponent(); + } private void Update() { - if (_system != null && _system.isStopped) + if (_system != null && !_system.IsAlive()) { MusicController.Instance.RemoveAudioSource(gameObject); + OnPlayEnd?.Invoke(); Destroy(gameObject); } }