mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Generic enemies
This commit is contained in:
parent
762666242e
commit
d99c773641
55 changed files with 968 additions and 204 deletions
|
|
@ -26,6 +26,8 @@ public partial class RogueliteEnemySpawner : Marker2D
|
|||
}
|
||||
}
|
||||
|
||||
[Export] public bool AutoSpawn { get; set; } = false;
|
||||
|
||||
[Export] public int Wave { get; private set; } = 0;
|
||||
|
||||
public bool Spawned { get; private set; } = false;
|
||||
|
|
@ -48,32 +50,51 @@ public partial class RogueliteEnemySpawner : Marker2D
|
|||
QueueRedraw();
|
||||
}
|
||||
|
||||
public EnemyFSMProxy Spawn(RogueliteMapTheme mapTheme)
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
if (!AutoSpawn) return;
|
||||
|
||||
Spawn();
|
||||
|
||||
}
|
||||
|
||||
public EnemyFSMProxy Spawn()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return null;
|
||||
if (Spawned) return _spawnedEnemy;
|
||||
|
||||
var enemyScene = GD.Load<PackedScene>(Enemy.PrefabPath);
|
||||
|
||||
_spawnedEnemy = this.CreateSibling<EnemyFSMProxy>(enemyScene);
|
||||
_spawnedEnemy.Init(Enemy);
|
||||
Spawned = true;
|
||||
|
||||
_spawnedEnemy.Death += SpawnedEnemyOnDeath;
|
||||
return _spawnedEnemy;
|
||||
}
|
||||
|
||||
_spawnedEnemy.OverrideLoot = true;
|
||||
_spawnedEnemy.ExtraLoot.Add(new LootDrop()
|
||||
public EnemyFSMProxy Spawn(RogueliteMapTheme mapTheme)
|
||||
{
|
||||
if (Engine.IsEditorHint()) return null;
|
||||
if (Spawned) return _spawnedEnemy;
|
||||
|
||||
var spawnedEnemy = Spawn();
|
||||
|
||||
spawnedEnemy.OverrideLoot = true;
|
||||
spawnedEnemy.ExtraLoot.Add(new LootDrop()
|
||||
{
|
||||
Item = mapTheme.EnemiesLootTable.Items.ToList().Shuffle().First(),
|
||||
Chance = mapTheme.EnemyDropChance
|
||||
});
|
||||
|
||||
_spawnedEnemy.ExtraLoot.Add(new LootDrop()
|
||||
spawnedEnemy.ExtraLoot.Add(new LootDrop()
|
||||
{
|
||||
Item = mapTheme.PointItemResource,
|
||||
Chance = 100
|
||||
});
|
||||
|
||||
Spawned = true;
|
||||
|
||||
_spawnedEnemy.Death += SpawnedEnemyOnDeath;
|
||||
|
||||
return _spawnedEnemy;
|
||||
return spawnedEnemy;
|
||||
}
|
||||
|
||||
private void SpawnedEnemyOnDeath(EnemyFSMProxy enemy)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue