Rework enemy behavior (still in progress but shouldn't crash)
This commit is contained in:
@@ -76,15 +76,6 @@ libraries = {
|
||||
[node name="MapOrder" type="Node" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="Overworld (Add SpecialFloorLayout node for special floors and pick the FloorName from the list)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("2_00xd7")
|
||||
metadata/_custom_type_script = "uid://cabvj6s31iucg"
|
||||
|
||||
[node name="Altar (Arrange order of nodes to change default load order)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("2_00xd7")
|
||||
FloorName = 1
|
||||
metadata/_custom_type_script = "uid://cabvj6s31iucg"
|
||||
|
||||
[node name="Floor01 (Press Populate Map Data Button to load floor from SetAFloors folder)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("3_v14r0")
|
||||
LayoutWithSpawnRate = Dictionary[String, float]({
|
||||
@@ -95,6 +86,15 @@ EnemySpawnRates = {
|
||||
}
|
||||
metadata/_custom_type_script = "uid://ci7o3nn4mdo8o"
|
||||
|
||||
[node name="Overworld (Add SpecialFloorLayout node for special floors and pick the FloorName from the list)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("2_00xd7")
|
||||
metadata/_custom_type_script = "uid://cabvj6s31iucg"
|
||||
|
||||
[node name="Altar (Arrange order of nodes to change default load order)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("2_00xd7")
|
||||
FloorName = 1
|
||||
metadata/_custom_type_script = "uid://cabvj6s31iucg"
|
||||
|
||||
[node name="Floor02 (Add DungeonFloorLayout node for regular dungeon floors)" type="Node" parent="MapOrder"]
|
||||
script = ExtResource("3_v14r0")
|
||||
LayoutWithSpawnRate = Dictionary[String, float]({})
|
||||
|
||||
@@ -33,44 +33,36 @@ public partial class BossRoomA : Node3D, IBossRoom, IDungeonFloor
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
ActivateTrap.BodyEntered += ActivateTrap_BodyEntered;
|
||||
OxFace.CurrentHP.Sync += BossStatusUpdate;
|
||||
HorseFace.CurrentHP.Sync += BossStatusUpdate;
|
||||
_exit.AreaEntered += Exit_AreaEntered;
|
||||
ActivateTrap.BodyEntered += ActivateTrap_BodyEntered;
|
||||
_exit.AreaEntered += Exit_AreaEntered;
|
||||
}
|
||||
|
||||
private void ActivateTrap_BodyEntered(Node3D body)
|
||||
{
|
||||
ActivateTrap.BodyEntered -= ActivateTrap_BodyEntered;
|
||||
StartBossFight();
|
||||
ActivateTrap.BodyEntered -= ActivateTrap_BodyEntered;
|
||||
StartBossFight();
|
||||
}
|
||||
|
||||
public void StartBossFight()
|
||||
{
|
||||
OxFaceStatue.Hide();
|
||||
HorseHeadStatue.Hide();
|
||||
OxFace.StartFight();
|
||||
HorseFace.StartFight();
|
||||
OxFaceStatue.Hide();
|
||||
HorseHeadStatue.Hide();
|
||||
OxFace.StartFight();
|
||||
HorseFace.StartFight();
|
||||
}
|
||||
|
||||
public void OnBossFightEnded()
|
||||
{
|
||||
GateCollision.CallDeferred(MethodName.QueueFree);
|
||||
}
|
||||
|
||||
private void BossStatusUpdate(double hp)
|
||||
{
|
||||
if (OxFace.CurrentHP.Value <= 0 && HorseFace.CurrentHP.Value <= 0)
|
||||
OnBossFightEnded();
|
||||
GateCollision.CallDeferred(MethodName.QueueFree);
|
||||
}
|
||||
|
||||
public void ExitReached()
|
||||
=> Game.FloorExitReached();
|
||||
=> Game.FloorExitReached();
|
||||
|
||||
private void Exit_AreaEntered(Area3D area)
|
||||
{
|
||||
if (area.GetOwner() is IPlayer)
|
||||
ExitReached();
|
||||
if (area.GetOwner() is IPlayer)
|
||||
ExitReached();
|
||||
}
|
||||
|
||||
public void InitializeDungeon()
|
||||
|
||||
@@ -3,6 +3,7 @@ using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Collections.Immutable;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Godot;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
public interface IDungeonFloor : INode3D
|
||||
{
|
||||
void InitializeDungeon();
|
||||
|
||||
public Transform3D GetPlayerSpawnPoint();
|
||||
|
||||
public ImmutableList<IDungeonRoom> Rooms { get; }
|
||||
|
||||
public bool FloorIsLoaded { get; set; }
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Godot;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
public interface IDungeonRoom : INode3D
|
||||
{
|
||||
bool IsPlayerInRoom { get; }
|
||||
|
||||
bool PlayerDiscoveredRoom { get; }
|
||||
|
||||
ImmutableList<IEnemy> EnemiesInRoom { get; }
|
||||
}
|
||||
@@ -21,51 +21,51 @@ public partial class MonsterRoom : DungeonRoom
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
SpawnItems();
|
||||
SpawnItems();
|
||||
}
|
||||
|
||||
public void SpawnEnemies(Godot.Collections.Dictionary<EnemyType, float> enemyInfo)
|
||||
{
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var enemySpawnPoints = EnemySpawnPoints.GetChildren();
|
||||
var numberOfEnemiesToSpawn = rng.RandiRange(1, enemySpawnPoints.Count);
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var enemySpawnPoints = EnemySpawnPoints.GetChildren();
|
||||
var numberOfEnemiesToSpawn = rng.RandiRange(1, enemySpawnPoints.Count);
|
||||
|
||||
foreach (var spawnPoint in enemySpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfEnemiesToSpawn <= 0)
|
||||
break;
|
||||
numberOfEnemiesToSpawn--;
|
||||
foreach (var spawnPoint in enemySpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfEnemiesToSpawn <= 0)
|
||||
break;
|
||||
numberOfEnemiesToSpawn--;
|
||||
|
||||
var index = rng.RandWeighted([.. enemyInfo.Values]);
|
||||
var selectedEnemy = enemyInfo.ElementAt((int)index);
|
||||
var instantiatedEnemy = EnemyTypeToEnemyConverter.Convert(selectedEnemy.Key);
|
||||
instantiatedEnemy.Position = new Vector3(spawnPoint.Position.X, 1.75f, spawnPoint.Position.Z);
|
||||
AddChild(instantiatedEnemy);
|
||||
}
|
||||
var index = rng.RandWeighted([.. enemyInfo.Values]);
|
||||
var selectedEnemy = enemyInfo.ElementAt((int)index);
|
||||
var instantiatedEnemy = EnemyTypeToEnemyConverter.Convert(selectedEnemy.Key);
|
||||
instantiatedEnemy.Position = new Vector3(spawnPoint.Position.X, 1.75f, spawnPoint.Position.Z);
|
||||
AddChild(instantiatedEnemy);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnItems()
|
||||
{
|
||||
if (ItemSpawnPoints == null)
|
||||
return;
|
||||
if (ItemSpawnPoints == null)
|
||||
return;
|
||||
|
||||
var itemSpawnPoints = ItemSpawnPoints.GetChildren();
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var numberOfItemsToSpawn = rng.RandiRange(1, itemSpawnPoints.Count);
|
||||
itemSpawnPoints.Shuffle();
|
||||
var database = new ItemDatabase();
|
||||
foreach (var spawnPoint in itemSpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfItemsToSpawn <= 0)
|
||||
break;
|
||||
numberOfItemsToSpawn--;
|
||||
var itemSpawnPoints = ItemSpawnPoints.GetChildren();
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var numberOfItemsToSpawn = rng.RandiRange(1, itemSpawnPoints.Count);
|
||||
itemSpawnPoints.Shuffle();
|
||||
var database = new ItemDatabase();
|
||||
foreach (var spawnPoint in itemSpawnPoints.Cast<Marker3D>())
|
||||
{
|
||||
if (numberOfItemsToSpawn <= 0)
|
||||
break;
|
||||
numberOfItemsToSpawn--;
|
||||
|
||||
var selectedItem = database.PickItem<InventoryItem>();
|
||||
var duplicated = selectedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
duplicated.Position = new Vector3(spawnPoint.Position.X, -1.5f, spawnPoint.Position.Z);
|
||||
AddChild(duplicated);
|
||||
}
|
||||
var selectedItem = database.PickItem<InventoryItem>();
|
||||
var duplicated = selectedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
|
||||
duplicated.Position = new Vector3(spawnPoint.Position.X, -1.5f, spawnPoint.Position.Z);
|
||||
AddChild(duplicated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://dh8ji8g36mmx5"
|
||||
path="res://.godot/imported/a2-puer.glb-20bdcd533f2a6024a2fa1d9a726cae55.scn"
|
||||
path="res://.godot/imported/A2-Puer.glb-3b11ccd8f9ba6f91fbb05537c52490b0.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://src/map/dungeon/models/Area 2/Puer/a2-puer.glb"
|
||||
dest_files=["res://.godot/imported/a2-puer.glb-20bdcd533f2a6024a2fa1d9a726cae55.scn"]
|
||||
source_file="res://src/map/dungeon/models/Area 2/Puer/A2-Puer.glb"
|
||||
dest_files=["res://.godot/imported/A2-Puer.glb-3b11ccd8f9ba6f91fbb05537c52490b0.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user