I am doing a CHAOS check in. showing support for one another. I need SIX jacks to post, not share, this message to show you are always there to kill chaos if someone needs it. let's go gentlemen...

This commit is contained in:
2023-09-04 16:11:05 -07:00
parent 4d0b0196e6
commit b315a90720
8 changed files with 71 additions and 29 deletions

View File

@@ -1,6 +1,35 @@
using Godot;
using Godot.Collections;
using System.Linq;
public partial class Level : Node3D
{
[Export]
private Array<PackedScene> _enemyScenes;
[Export]
private Array<Node3D> _spawnPoints;
private Array<Node3D> _enemies = new Array<Node3D>();
private GameManager _gameManager;
public override void _Ready()
{
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
for (var i = 0; i < _enemyScenes.Count; i++)
{
var enemy = _enemyScenes[i].Instantiate();
var convertedNode = (Node3D)enemy;
GetTree().Root.AddChild(convertedNode);
_enemies.Add(convertedNode);
//convertedNode.Transform = _spawnPoints[i].Transform;
}
}
public void OnEnemyDefeated(Node3D enemyDefeated)
{
_enemies.Remove(enemyDefeated);
if (!_enemies.Any())
_gameManager.OnAllEnemiesDefeated();
}
}