refactor: unify runtime sets, update naming of event channels #17
2
Assets/Prefabs/Hero.prefab
generated
2
Assets/Prefabs/Hero.prefab
generated
@ -50,7 +50,7 @@ MonoBehaviour:
|
|||||||
level: 0
|
level: 0
|
||||||
xp: 0
|
xp: 0
|
||||||
attrs: {fileID: 0}
|
attrs: {fileID: 0}
|
||||||
_party: {fileID: 11400000, guid: c9a46588e6ec04d4d91bb80fdffd7869, type: 2}
|
_party: {fileID: 11400000, guid: 2fdb3d0bb73994d4ba32eb41950b8f15, type: 2}
|
||||||
--- !u!1 &4632618406133265053
|
--- !u!1 &4632618406133265053
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
15
Assets/Runtime Sets/PlayerParty.asset
generated
Normal file
15
Assets/Runtime Sets/PlayerParty.asset
generated
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 0ec1a0df7a5949a2959596c722680f76, type: 3}
|
||||||
|
m_Name: PlayerParty
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
items: []
|
8
Assets/Runtime Sets/PlayerParty.asset.meta
generated
Normal file
8
Assets/Runtime Sets/PlayerParty.asset.meta
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2fdb3d0bb73994d4ba32eb41950b8f15
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
6
Assets/Scenes/test.unity
generated
6
Assets/Scenes/test.unity
generated
@ -527,9 +527,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: bb718e52728142e4a8db081fd6a36a70, type: 3}
|
m_Script: {fileID: 11500000, guid: bb718e52728142e4a8db081fd6a36a70, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
startNewSpawnWaveEventChannel: {fileID: 11400000, guid: 3f9039af54fd5d240b144e1ab3bbeb72, type: 2}
|
startNewSpawnWaveEvent: {fileID: 11400000, guid: 3f9039af54fd5d240b144e1ab3bbeb72, type: 2}
|
||||||
endSpawnWaveEventChannel: {fileID: 11400000, guid: b8a8049e92364834ebac76909a03324b, type: 2}
|
endSpawnWaveEventEvent: {fileID: 11400000, guid: b8a8049e92364834ebac76909a03324b, type: 2}
|
||||||
enemyRuntimeSet: {fileID: 11400000, guid: 7c32c32e039cdda409e8a56d2e320f2d, type: 2}
|
activeEnemies: {fileID: 11400000, guid: 7c32c32e039cdda409e8a56d2e320f2d, type: 2}
|
||||||
spawnCenter: {fileID: 19609788}
|
spawnCenter: {fileID: 19609788}
|
||||||
minimumSpawnRadius: 10
|
minimumSpawnRadius: 10
|
||||||
timeBetweenClearedWaves: 0
|
timeBetweenClearedWaves: 0
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace DefaultNamespace
|
|
||||||
{
|
|
||||||
[CreateAssetMenu(menuName = "Enemy Runtime Set", fileName =
|
|
||||||
"EnemyRuntimeSet")]
|
|
||||||
public class EnemyRuntimeSetSO : RuntimeSetSO<Enemy>
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
namespace Events
|
namespace Events
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(menuName = "Events/Spawn Wave SO Event Channel")]
|
[CreateAssetMenu(menuName = "Events/Spawn Wave Event")]
|
||||||
|
|||||||
public class SpawnWaveSOEventChannelSO : ScriptableObject
|
public class SpawnWaveEventSO : ScriptableObject
|
||||||
madxmike
commented
testtest testtest
madxmike
commented
test test
|
|||||||
{
|
{
|
||||||
public event UnityAction<SpawnWaveSO> OnEventRaised;
|
public event UnityAction<SpawnWaveSO> OnEventRaised;
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
[CreateAssetMenu(fileName = "HeroParty", menuName = "Hero Party")]
|
|
||||||
public class HeroPartySO : ScriptableObject
|
|
||||||
zephyr
commented
Just FYI, I made the hero party a separate class rather than a generic RuntimeSetSO because the hero party will have other constraints, e.g. on size. Just FYI, I made the hero party a separate class rather than a generic RuntimeSetSO because the hero party will have other constraints, e.g. on size.
zephyr
commented
srtinky srtinky
madxmike
commented
test test
|
|||||||
{
|
|
||||||
[SerializeField]
|
|
||||||
private List<HeroUnit> unitList = new List<HeroUnit>();
|
|
||||||
public ReadOnlyCollection<HeroUnit> UnitList => unitList.AsReadOnly();
|
|
||||||
|
|
||||||
public void Add(HeroUnit unit) { unitList.Add(unit); }
|
|
||||||
public void Remove(HeroUnit unit) { unitList.Remove(unit); }
|
|
||||||
public int Count => unitList.Count;
|
|
||||||
}
|
|
11
Assets/Scripts/HeroPartySO.cs.meta
generated
11
Assets/Scripts/HeroPartySO.cs.meta
generated
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f0603cf6e7f1d884e89c3eb6a478a96c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,9 +1,8 @@
|
|||||||
using System.Collections;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Collections.Generic;
|
using RuntimeSet;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Assertions;
|
using UnityEngine.Assertions;
|
||||||
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
[assembly: InternalsVisibleTo("TestsPlaymode")]
|
[assembly: InternalsVisibleTo("TestsPlaymode")]
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -17,8 +16,8 @@ public class HeroUnit : MonoBehaviour
|
|||||||
[SerializeField] private long level;
|
[SerializeField] private long level;
|
||||||
[SerializeField] private long xp;
|
[SerializeField] private long xp;
|
||||||
[SerializeField] private HeroAttributesSO attrs;
|
[SerializeField] private HeroAttributesSO attrs;
|
||||||
[SerializeField] private HeroPartySO _party;
|
[SerializeField] private HeroUnitRuntimeSetSO _party;
|
||||||
internal HeroPartySO party => _party;
|
internal HeroUnitRuntimeSetSO party => _party;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
|
3
Assets/Scripts/RuntimeSet.meta
generated
Normal file
3
Assets/Scripts/RuntimeSet.meta
generated
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9f6f30f3d8e4445a4a25d03245b2645
|
||||||
|
timeCreated: 1691632737
|
10
Assets/Scripts/RuntimeSet/EnemyRuntimeSetSO.cs
Normal file
10
Assets/Scripts/RuntimeSet/EnemyRuntimeSetSO.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using DefaultNamespace;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RuntimeSet
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(fileName = "EnemyRuntimeSet",menuName = "Runtime Set/Enemy")]
|
||||||
|
public class EnemyRuntimeSetSO : RuntimeSetSO<Enemy>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
9
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs
Normal file
9
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RuntimeSet
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(fileName = "EnemyRuntimeSet",menuName = "Runtime Set/Hero Unit")]
|
||||||
|
public class HeroUnitRuntimeSetSO : RuntimeSetSO<HeroUnit>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs.meta
generated
Normal file
3
Assets/Scripts/RuntimeSet/HeroUnitRuntimeSet.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ec1a0df7a5949a2959596c722680f76
|
||||||
|
timeCreated: 1691632762
|
41
Assets/Scripts/RuntimeSet/RuntimeSetSO.cs
Normal file
41
Assets/Scripts/RuntimeSet/RuntimeSetSO.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace RuntimeSet
|
||||||
|
{
|
||||||
|
public abstract class RuntimeSetSO<T> : ScriptableObject, IEnumerable<T>
|
||||||
|
{
|
||||||
|
[HideInInspector] [SerializeField] private List<T> items = new();
|
||||||
|
|
||||||
|
protected IReadOnlyCollection<T> Items => items;
|
||||||
|
public bool IsEmpty => items.Count == 0;
|
||||||
|
public int Count => items.Count;
|
||||||
|
|
||||||
|
public void Add(T item)
|
||||||
|
{
|
||||||
|
if (!items.Contains(item))
|
||||||
|
{
|
||||||
|
items.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(T item)
|
||||||
|
{
|
||||||
|
if (items.Contains(item))
|
||||||
|
{
|
||||||
|
items.Remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<T> GetEnumerator()
|
||||||
|
{
|
||||||
|
return items.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public abstract class RuntimeSetSO<T> : ScriptableObject
|
|
||||||
{
|
|
||||||
[HideInInspector] [SerializeField] private List<T> items = new();
|
|
||||||
|
|
||||||
public IReadOnlyCollection<T> Items => items;
|
|
||||||
public bool IsEmpty => items.Count == 0;
|
|
||||||
|
|
||||||
public void Add(T thing)
|
|
||||||
{
|
|
||||||
if (!items.Contains(thing))
|
|
||||||
{
|
|
||||||
items.Add(thing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Remove(T thing)
|
|
||||||
{
|
|
||||||
if (items.Contains(thing))
|
|
||||||
{
|
|
||||||
items.Remove(thing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace Wave
|
namespace Wave
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(fileName = "SpawnWave", menuName = "Spawn Wave", order = 0)]
|
[CreateAssetMenu(fileName = "SpawnWave", menuName = "Spawn/Wave", order = 0)]
|
||||||
public class SpawnWaveSO : ScriptableObject
|
public class SpawnWaveSO : ScriptableObject
|
||||||
{
|
{
|
||||||
[SerializeField] private List<SpawnPackSO> packs;
|
[SerializeField] private List<SpawnPackSO> packs;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DefaultNamespace;
|
using DefaultNamespace;
|
||||||
using Events;
|
using Events;
|
||||||
|
using RuntimeSet;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Assertions;
|
using UnityEngine.Assertions;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
@ -12,8 +13,8 @@ namespace Wave
|
|||||||
{
|
{
|
||||||
public class WaveSpawner : MonoBehaviour
|
public class WaveSpawner : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private SpawnWaveSOEventChannelSO startNewSpawnWaveEventChannel;
|
[SerializeField] private SpawnWaveEventSO startNewSpawnWaveEventChannel;
|
||||||
[SerializeField] private SpawnWaveSOEventChannelSO endSpawnWaveEventChannel;
|
[SerializeField] private SpawnWaveEventSO endSpawnWaveEventChannel;
|
||||||
|
|
||||||
[SerializeField] private EnemyRuntimeSetSO enemyRuntimeSet;
|
[SerializeField] private EnemyRuntimeSetSO enemyRuntimeSet;
|
||||||
[SerializeField] private Transform spawnCenter;
|
[SerializeField] private Transform spawnCenter;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -18,6 +17,6 @@ public IEnumerator HeroPartyGetsAllTheHeroes()
|
|||||||
Assert.AreEqual(1, hero.party.Count);
|
Assert.AreEqual(1, hero.party.Count);
|
||||||
Object.Destroy(instance);
|
Object.Destroy(instance);
|
||||||
yield return null;
|
yield return null;
|
||||||
Assert.IsEmpty(hero.party.UnitList);
|
Assert.IsEmpty(hero.party);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user
test