Rework enemy behavior (still in progress but shouldn't crash)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -40,7 +41,7 @@ public class EffectService
|
||||
var spawnPoints = currentMonsterRoom.EnemySpawnPoints.GetChildren().OfType<Marker3D>().ToList();
|
||||
var spawnPointsGodotCollection = new Godot.Collections.Array<Marker3D>(spawnPoints);
|
||||
var randomSpawnPoint = spawnPointsGodotCollection.PickRandom();
|
||||
enemy.SetEnemyGlobalPosition(randomSpawnPoint.GlobalPosition);
|
||||
enemy.SetEnemyPosition(randomSpawnPoint.GlobalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +54,8 @@ public class EffectService
|
||||
var currentMonsterRoom = (MonsterRoom)currentRoom;
|
||||
var enemyList = currentMonsterRoom.GetEnemiesInCurrentRoom().ToList();
|
||||
var enemiesToKill = enemyList.Count / 2;
|
||||
for (var i = 0; i < enemiesToKill; i++)
|
||||
enemyList[i].Die();
|
||||
//for (var i = 0; i < enemiesToKill; i++)
|
||||
// enemyList[i].Die();
|
||||
}
|
||||
|
||||
public void TurnAllEnemiesInRoomIntoHealingItem()
|
||||
@@ -67,8 +68,8 @@ public class EffectService
|
||||
var currentEnemies = currentRoom.EnemiesInRoom;
|
||||
foreach (var enemy in currentEnemies)
|
||||
{
|
||||
enemy.Die();
|
||||
DropHealingItem(enemy.GetEnemyGlobalPosition());
|
||||
//enemy.Die();
|
||||
//DropHealingItem(enemy.GetEnemyGlobalPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +96,8 @@ public class EffectService
|
||||
return;
|
||||
|
||||
var currentEnemies = currentRoom.EnemiesInRoom;
|
||||
foreach (var enemy in currentEnemies)
|
||||
enemy.SetCurrentHP(enemy.GetMaximumHP());
|
||||
//foreach (var enemy in currentEnemies)
|
||||
// enemy.SetCurrentHP(enemy.GetMaximumHP());
|
||||
_player.Stats.SetCurrentHP(_player.Stats.MaximumHP.Value);
|
||||
}
|
||||
|
||||
@@ -109,8 +110,8 @@ public class EffectService
|
||||
|
||||
var currentEnemies = currentRoom.EnemiesInRoom;
|
||||
var hpToAbsorb = 0.0;
|
||||
foreach (var enemy in currentEnemies)
|
||||
hpToAbsorb += enemy.CurrentHP.Value * 0.05;
|
||||
//foreach (var enemy in currentEnemies)
|
||||
// hpToAbsorb += enemy.CurrentHP.Value * 0.05;
|
||||
_player.Stats.SetCurrentHP(_player.Stats.CurrentHP.Value + (int)hpToAbsorb);
|
||||
GD.Print("HP to absorb: " + hpToAbsorb);
|
||||
}
|
||||
@@ -124,7 +125,10 @@ public class EffectService
|
||||
|
||||
var currentEnemies = currentRoom.EnemiesInRoom;
|
||||
foreach (var enemy in currentEnemies)
|
||||
enemy.TakeDamage(20, elementType);
|
||||
{
|
||||
var damageDealt = DamageCalculator.CalculateDamage(new Damage(20, elementType, false, false, false), 10, new ElementalResistanceSet(0, 0, 0, 0, 0));
|
||||
enemy.TakeDamage(damageDealt);
|
||||
}
|
||||
}
|
||||
|
||||
public void SwapHPandVT()
|
||||
@@ -175,7 +179,7 @@ public class EffectService
|
||||
{
|
||||
var currentFloor = _game.CurrentFloor;
|
||||
var rooms = currentFloor.Rooms;
|
||||
var currentRoom = enemy.GetCurrentRoom();
|
||||
var currentRoom = enemy.GetCurrentRoom(rooms);
|
||||
var validRooms = rooms.OfType<MonsterRoom>().ToList();
|
||||
if (currentRoom is MonsterRoom currentMonsterRoom)
|
||||
validRooms.Remove(currentMonsterRoom);
|
||||
@@ -189,7 +193,7 @@ public class EffectService
|
||||
var spawnPointsGodotCollection = new Godot.Collections.Array<Marker3D>(spawnPoints);
|
||||
var randomSpawnPoint = spawnPointsGodotCollection.PickRandom();
|
||||
|
||||
enemy.SetEnemyGlobalPosition(randomSpawnPoint.GlobalPosition);
|
||||
enemy.SetEnemyPosition(randomSpawnPoint.GlobalPosition);
|
||||
}
|
||||
|
||||
public void TeleportToRandomRoom(IPlayer player)
|
||||
@@ -232,10 +236,4 @@ public class EffectService
|
||||
if (exitRoom.PlayerDiscoveredRoom)
|
||||
player.TeleportPlayer(exitRoom.PlayerSpawn.Transform);
|
||||
}
|
||||
|
||||
public void WarpToExit(IEnemy enemy)
|
||||
{
|
||||
var exitRoom = _game.CurrentFloor.Rooms.OfType<ExitRoom>().Single();
|
||||
enemy.SetEnemyGlobalPosition(exitRoom.PlayerSpawn.GlobalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public partial class Accessory : EquipableItem
|
||||
|
||||
public override float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public override double ThrowDamage => Stats.ThrowDamage;
|
||||
public override int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public override float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public partial class Armor : EquipableItem
|
||||
|
||||
public override float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public override double ThrowDamage => Stats.ThrowDamage;
|
||||
public override int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public override float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public partial class ConsumableItem : InventoryItem
|
||||
|
||||
public override float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public override double ThrowDamage => Stats.ThrowDamage;
|
||||
public override int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public override float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public partial class EffectItem : InventoryItem
|
||||
|
||||
public override float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public override double ThrowDamage => Stats.ThrowDamage;
|
||||
public override int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public override float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public partial class ThrowableItem : InventoryItem, IStackable
|
||||
|
||||
public override float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public override double ThrowDamage => Stats.ThrowDamage;
|
||||
public override int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public override float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -107,21 +108,22 @@ public partial class ThrownItem : RigidBody3D
|
||||
{
|
||||
switch (throwableItem.ThrowableItemTag)
|
||||
{
|
||||
case ThrowableItemTag.LowerTargetTo1HP:
|
||||
enemy.TakeDamage(enemy.CurrentHP.Value - 1, ignoreDefense: true, ignoreElementalResistance: true);
|
||||
break;
|
||||
//case ThrowableItemTag.LowerTargetTo1HP:
|
||||
// enemy.TakeDamage(enemy.CurrentHP.Value - 1, ignoreDefense: true, ignoreElementalResistance: true);
|
||||
// break;
|
||||
case ThrowableItemTag.TeleportToRandomLocation:
|
||||
_effectService.TeleportToRandomRoom(enemy);
|
||||
break;
|
||||
case ThrowableItemTag.WarpToExitIfFound:
|
||||
_effectService.WarpToExit(enemy);
|
||||
break;
|
||||
default:
|
||||
enemy.TakeDamage(throwableItem.ThrowDamage, throwableItem.ElementType);
|
||||
var damageDealt = DamageCalculator.CalculateDamage(new Damage(throwableItem.ThrowDamage, throwableItem.ElementType, false, false, false), 10, new ElementalResistanceSet(0, 0, 0, 0, 0));
|
||||
enemy.TakeDamage(damageDealt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
enemy.TakeDamage(ItemThatIsThrown.ThrowDamage);
|
||||
{
|
||||
var damageDealt = DamageCalculator.CalculateDamage(new Damage(ItemThatIsThrown.ThrowDamage, ElementType.None, false, false, false), 10, new ElementalResistanceSet(0, 0, 0, 0, 0));
|
||||
enemy.TakeDamage(damageDealt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public partial class Weapon : EquipableItem
|
||||
|
||||
public override float SpawnRate => Stats.SpawnRate;
|
||||
|
||||
public override double ThrowDamage => Stats.ThrowDamage;
|
||||
public override int ThrowDamage => Stats.ThrowDamage;
|
||||
|
||||
public override float ThrowSpeed => Stats.ThrowSpeed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user