enemy spawner
This commit is contained in:
66
Game/Scripts/Runtime/Spawning/Editor/EnemySpawnerGizmos.cs
Normal file
66
Game/Scripts/Runtime/Spawning/Editor/EnemySpawnerGizmos.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Scripts.Runtime.Spawning.Editor
|
||||
{
|
||||
[CustomEditor(typeof(EnemySpawner))]
|
||||
public class EnemySpawnerGizmos : UnityEditor.Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
using (new EditorGUI.DisabledScope(!Application.isPlaying))
|
||||
{
|
||||
if (GUILayout.Button("Force Spawn Test Enemy"))
|
||||
{
|
||||
var spawner = (EnemySpawner)target;
|
||||
var table = spawner.ActiveTable;
|
||||
if (table != null)
|
||||
{
|
||||
var def = table.Pick(spawner.CurrentWaveIndex, new System.Random());
|
||||
if (def != null)
|
||||
{
|
||||
spawner.TrySpawn(def);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneGUI()
|
||||
{
|
||||
var spawner = (EnemySpawner)target;
|
||||
var config = spawner.ActiveConfig;
|
||||
var player = spawner.PlayerTransform;
|
||||
if (config == null || player == null || !config.DrawGizmos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handles.color = new Color(1f, 0.8f, 0f, 0.7f);
|
||||
Handles.DrawWireDisc(player.position, Vector3.up, config.MinSpawnRadius);
|
||||
Handles.color = new Color(1f, 0f, 0f, 0.7f);
|
||||
Handles.DrawWireDisc(player.position, Vector3.up, config.MaxSpawnRadius);
|
||||
|
||||
var samples = spawner.RecentSamples;
|
||||
if (samples != null)
|
||||
{
|
||||
foreach (var sample in samples)
|
||||
{
|
||||
Handles.color = sample.Accepted ? Color.green : Color.magenta;
|
||||
Handles.SphereHandleCap(0, sample.Position, Quaternion.identity, 0.35f, EventType.Repaint);
|
||||
}
|
||||
}
|
||||
|
||||
Handles.BeginGUI();
|
||||
GUILayout.BeginArea(new Rect(12f, 12f, 200f, 70f), GUI.skin.box);
|
||||
GUILayout.Label("Spawner Debug", EditorStyles.boldLabel);
|
||||
GUILayout.Label($"Active: {spawner.ActiveEnemyCount}/{config.MaxConcurrent}");
|
||||
GUILayout.EndArea();
|
||||
Handles.EndGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9439d534025ac2a28a9250ffd9e349be
|
||||
Reference in New Issue
Block a user