Commit 86dc2076 authored by Martin Mihálik's avatar Martin Mihálik 🔥
Browse files

Finished Refactoring

parent acc30f9b
......@@ -173,14 +173,23 @@ TrailRenderer:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0.0052223206
value: 0.75
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 0.12477445
value: 0.7550806
inSlope: -0.8896997
outSlope: -0.8896997
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
......
......@@ -604,6 +604,7 @@ GameObject:
- component: {fileID: 1654006370}
- component: {fileID: 1654006371}
- component: {fileID: 1654006373}
- component: {fileID: 1654006374}
m_Layer: 0
m_Name: Settings
m_TagString: Untagged
......@@ -664,11 +665,11 @@ MonoBehaviour:
m_Prefab: {fileID: 82881188109033727, guid: 9c8a7026b012f2a4aa0ec85ca243f8a4, type: 3}
m_Parent: {fileID: 2028534472}
m_BaseSpeed: 10
m_BaseSpeedLevelIncrease: 5
m_SpeedLevelIncrease: 5
m_BaseSpawnRate: 0.1
m_SpawnRateGrowthRate: 0.1
m_RotationsPerSecond: 1
m_Damage: 0
m_Damage: 1
--- !u!114 &1654006371
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -687,7 +688,7 @@ MonoBehaviour:
m_BaseMaxScale: 2
m_MaxScaleLevelIncrease: 0.5
m_Duration: 0.5
m_Damage: 0
m_Damage: 1
--- !u!114 &1654006372
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -703,6 +704,7 @@ MonoBehaviour:
m_MeteorSettings: {fileID: 1654006370}
m_ExplosionSettings: {fileID: 1654006371}
m_RubbleSettings: {fileID: 1654006373}
m_WallSettings: {fileID: 1654006374}
--- !u!114 &1654006373
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -719,6 +721,23 @@ MonoBehaviour:
m_Parent: {fileID: 574392414}
m_SpawnCount: 3
m_SpawnShootoutForce: 300
--- !u!114 &1654006374
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1654006367}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 486a1cf29d5bb9b40a314ecd1e2e2cee, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Prefab: {fileID: 2654140422281934948, guid: 116e75d1ce3069d41b738de55fcdf8cd, type: 3}
m_Parent: {fileID: 1695424173}
m_Grid: {fileID: 1364465087}
m_StartingHealth: 3
m_BuildingCost: 5
--- !u!1 &1695424172
GameObject:
m_ObjectHideFlags: 0
......@@ -765,8 +784,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: bea89f73c7d0f4f4eaa902784e4b227c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_WallPrefab: {fileID: 2654140422281934948, guid: 116e75d1ce3069d41b738de55fcdf8cd, type: 3}
m_WorldGrid: {fileID: 1364465087}
m_Settings: {fileID: 1654006372}
m_Player: {fileID: 512397504}
--- !u!66 &1695424175
CompositeCollider2D:
......
......@@ -6,22 +6,20 @@ public class DamageTaker : MonoBehaviour
{
[SerializeField] private uint m_StartingHealth;
public uint StartingHealth { get => m_StartingHealth; }
public uint StartingHealth { get => m_StartingHealth; set => m_StartingHealth = value; }
public uint Health { get; private set; }
public bool Dead
{
get => Health == 0;
}
public bool Dead { get => Health == 0; }
[SerializeField] private UnityEvent m_OnDamageTaken;
[SerializeField] private UnityEvent m_OnDeath;
private HashSet<long> m_DamageTaken;
private HashSet<long> m_DamageSources;
private void Start()
{
Health = m_StartingHealth;
m_DamageTaken = new HashSet<long>();
m_DamageSources = new HashSet<long>();
}
private void OnTriggerEnter2D(Collider2D collision)
......@@ -38,7 +36,7 @@ public class DamageTaker : MonoBehaviour
return;
}
if (m_DamageTaken.Contains(dealer.Id))
if (m_DamageSources.Contains(dealer.Id))
{
return;
}
......@@ -52,7 +50,7 @@ public class DamageTaker : MonoBehaviour
{
Health -= dealer.Damage;
m_OnDamageTaken.Invoke();
m_DamageTaken.Add(dealer.Id);
m_DamageSources.Add(dealer.Id);
}
}
}
......@@ -6,7 +6,7 @@ public class MeteorSettings : MonoBehaviour
[SerializeField] private Transform m_Parent;
[SerializeField] private float m_BaseSpeed;
[SerializeField] private float m_BaseSpeedLevelIncrease;
[SerializeField] private float m_SpeedLevelIncrease;
[SerializeField] private float m_BaseSpawnRate;
[SerializeField] private float m_SpawnRateGrowthRate;
[SerializeField] private float m_RotationsPerSecond;
......@@ -58,6 +58,6 @@ public class MeteorSettings : MonoBehaviour
private void IncreaseMeteorSpeed()
{
Speed += m_BaseSpeedLevelIncrease;
Speed += m_SpeedLevelIncrease;
}
}
......@@ -5,9 +5,10 @@ public class Settings : MonoBehaviour
[SerializeField] private MeteorSettings m_MeteorSettings;
[SerializeField] private ExplosionSettings m_ExplosionSettings;
[SerializeField] private RubbleSettings m_RubbleSettings;
// [SerializeField] private WallSettings m_WallSettings;
[SerializeField] private WallSettings m_WallSettings;
public MeteorSettings Meteors { get => m_MeteorSettings; }
public ExplosionSettings Explosions { get => m_ExplosionSettings; }
public RubbleSettings Rubbles { get => m_RubbleSettings; }
public WallSettings Walls { get => m_WallSettings; }
}
using UnityEngine;
public class WallSettings : MonoBehaviour
{
[SerializeField] private GameObject m_Prefab;
[SerializeField] private Transform m_Parent;
[SerializeField] private Grid m_Grid;
[SerializeField] private uint m_StartingHealth;
[SerializeField] private uint m_BuildingCost;
public GameObject Prefab { get => m_Prefab; }
public Transform Parent { get => m_Parent; }
public Grid Grid { get => m_Grid; }
public uint StartingHealth { get => m_StartingHealth; }
public uint BuildingCost { get => m_BuildingCost; }
}
fileFormatVersion: 2
guid: 486a1cf29d5bb9b40a314ecd1e2e2cee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -2,25 +2,30 @@ using UnityEngine;
public class WallSpawner : MonoBehaviour
{
[SerializeField] private GameObject m_WallPrefab;
[SerializeField] private Grid m_WorldGrid;
[SerializeField] private Settings m_Settings;
[SerializeField] private Transform m_Player;
private Settings Settings { get => m_Settings; }
private void Update()
{
if (Input.GetKeyDown(KeyCode.W))
{
SpawnWall(m_Player.position, gameObject.transform);
SpawnWall(m_Player.position);
}
}
private void SpawnWall(Vector2 position, Transform parent)
private void SpawnWall(Vector2 position)
{
var cell = m_WorldGrid.LocalToCell(position);
var cell = Settings.Walls.Grid.LocalToCell(position);
cell.y += 2;
position = Settings.Walls.Grid.GetCellCenterWorld(cell);
var wall = Instantiate(Settings.Walls.Prefab, position, Quaternion.identity, Settings.Walls.Parent);
position = m_WorldGrid.GetCellCenterWorld(cell);
var damageTaker = wall.GetComponent<DamageTaker>();
Instantiate(m_WallPrefab, position, Quaternion.identity, parent);
damageTaker.StartingHealth = Settings.Walls.StartingHealth;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment