sum fixes
This commit is contained in:
20
Scripts/BasicEnemy.cs
Normal file
20
Scripts/BasicEnemy.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Godot;
|
||||
|
||||
public partial class BasicEnemy : Node3D
|
||||
{
|
||||
protected GameManager _gameManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_gameManager = GetTree().Root.GetNode<GameManager>("Main/GameManager");
|
||||
}
|
||||
|
||||
public void OnEnemyHit(Node3D node)
|
||||
{
|
||||
QueueFree();
|
||||
if (_gameManager.CheckAllEnemiesDefeated())
|
||||
{
|
||||
_gameManager.OnAllEnemiesDefeated();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ public partial class GameManager : Node
|
||||
|
||||
public IEnumerable<Player> Players = new List<Player>();
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
foreach (var playerScene in PlayerScenes)
|
||||
@@ -31,6 +30,19 @@ public partial class GameManager : Node
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAllEnemiesDefeated()
|
||||
{
|
||||
GD.Print("All enemies defeated");
|
||||
P1CharactersOut.AddRange(Players.ElementAt(0).CharactersLeftOnStage);
|
||||
P2CharactersOut.AddRange(Players.ElementAt(1).CharactersLeftOnStage);
|
||||
OnLevelClear();
|
||||
}
|
||||
|
||||
public bool CheckAllEnemiesDefeated()
|
||||
{
|
||||
return !GetTree().GetNodesInGroup("Enemy").Any();
|
||||
}
|
||||
|
||||
public void OnHandleCharacterSelectUI(Player player)
|
||||
{
|
||||
EmitSignal(SignalName.ReselectCharacter, player);
|
||||
|
||||
6
Scripts/Level.cs
Normal file
6
Scripts/Level.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using Godot;
|
||||
|
||||
public partial class Level : Node3D
|
||||
{
|
||||
|
||||
}
|
||||
@@ -17,18 +17,4 @@ public partial class MeleeEnemy : BasicEnemy
|
||||
LookAt(-target.Position, Vector3.Up);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class BasicEnemy : Node3D
|
||||
{
|
||||
public void OnHit(Node3D node)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
private void DebugOnHit()
|
||||
{
|
||||
var node = new Node3D();
|
||||
OnHit(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,4 @@ public partial class RangedEnemy : BasicEnemy
|
||||
area.LookAt(target.Position, Vector3.Up);
|
||||
}
|
||||
}
|
||||
public void OnHit(Node node)
|
||||
{
|
||||
GD.Print("Hit detected");
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user