Refactor stats
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using System;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
using Zennysoft.Game.Implementation;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -37,12 +38,7 @@ public class EffectService
|
||||
var enemyList = validRooms.SelectMany(x => x.GetEnemiesInCurrentRoom());
|
||||
|
||||
foreach (var enemy in enemyList)
|
||||
{
|
||||
var spawnPoints = currentMonsterRoom.EnemySpawnPoints.GetChildren().OfType<Marker3D>().ToList();
|
||||
var spawnPointsGodotCollection = new Godot.Collections.Array<Marker3D>(spawnPoints);
|
||||
var randomSpawnPoint = spawnPointsGodotCollection.PickRandom();
|
||||
enemy.SetEnemyPosition(randomSpawnPoint.GlobalPosition);
|
||||
}
|
||||
enemy.MoveEnemyToNewRoom(currentMonsterRoom);
|
||||
}
|
||||
|
||||
public void KillHalfEnemiesInRoom()
|
||||
@@ -54,8 +50,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()
|
||||
@@ -68,8 +64,8 @@ public class EffectService
|
||||
var currentEnemies = currentRoom.EnemiesInRoom;
|
||||
foreach (var enemy in currentEnemies)
|
||||
{
|
||||
//enemy.Die();
|
||||
//DropHealingItem(enemy.GetEnemyGlobalPosition());
|
||||
enemy.Die();
|
||||
DropHealingItem(enemy.GlobalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +91,7 @@ public class EffectService
|
||||
if (currentRoom is not MonsterRoom)
|
||||
return;
|
||||
|
||||
var currentEnemies = currentRoom.EnemiesInRoom;
|
||||
//foreach (var enemy in currentEnemies)
|
||||
// enemy.SetCurrentHP(enemy.GetMaximumHP());
|
||||
currentRoom.EnemiesInRoom.ForEach(e => e.HealthComponent.SetHealth(e.HealthComponent.MaximumHP.Value));
|
||||
_player.HealthComponent.SetHealth(_player.HealthComponent.MaximumHP.Value);
|
||||
}
|
||||
|
||||
@@ -110,8 +104,12 @@ 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)
|
||||
{
|
||||
var absorbAmount = enemy.HealthComponent.MaximumHP.Value * 0.05;
|
||||
enemy.HealthComponent.Damage((int)absorbAmount);
|
||||
hpToAbsorb += absorbAmount;
|
||||
}
|
||||
_player.HealthComponent.Heal((int)hpToAbsorb);
|
||||
GD.Print("HP to absorb: " + hpToAbsorb);
|
||||
}
|
||||
@@ -127,7 +125,7 @@ public class EffectService
|
||||
foreach (var enemy in currentEnemies)
|
||||
{
|
||||
var damageDealt = DamageCalculator.CalculateDamage(new Damage(20, elementType, false, false, false), 10, new ElementalResistanceSet(0, 0, 0, 0, 0));
|
||||
enemy.TakeDamage(damageDealt);
|
||||
enemy.HealthComponent.Damage(damageDealt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,28 +150,25 @@ public class EffectService
|
||||
|
||||
public void RaiseCurrentWeaponAttack()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_player.EquippedWeapon.Value.ItemName))
|
||||
if (string.IsNullOrEmpty(_player.EquipmentComponent.EquippedWeapon.Value.ItemName))
|
||||
return;
|
||||
|
||||
var currentWeapon = (Weapon)_player.EquippedWeapon.Value;
|
||||
var currentWeapon = (Weapon)_player.EquipmentComponent.EquippedWeapon.Value;
|
||||
currentWeapon.IncreaseWeaponAttack(1);
|
||||
//_player.ModifyBonusAttack(1);
|
||||
_player.AttackComponent.RaiseBonusAttack(1);
|
||||
}
|
||||
|
||||
public void RaiseCurrentArmorDefense()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_player.EquippedArmor.Value.ItemName))
|
||||
if (string.IsNullOrEmpty(_player.EquipmentComponent.EquippedArmor.Value.ItemName))
|
||||
return;
|
||||
|
||||
var currentArmor = (Armor)_player.EquippedArmor.Value;
|
||||
var currentArmor = (Armor)_player.EquipmentComponent.EquippedArmor.Value;
|
||||
currentArmor.IncreaseArmorDefense(1);
|
||||
_player.DefenseComponent.RaiseBonusDefense(1);
|
||||
}
|
||||
|
||||
public void RaiseLevel()
|
||||
{
|
||||
_player.LevelUp();
|
||||
}
|
||||
public void RaiseLevel() => _player.LevelUp();
|
||||
|
||||
public void TeleportToRandomRoom(IEnemy enemy)
|
||||
{
|
||||
@@ -189,11 +184,8 @@ public class EffectService
|
||||
|
||||
var roomsGodotCollection = new Godot.Collections.Array<MonsterRoom>(validRooms);
|
||||
var randomRoom = roomsGodotCollection.PickRandom();
|
||||
var spawnPoints = randomRoom.EnemySpawnPoints.GetChildren().OfType<Marker3D>().ToList();
|
||||
var spawnPointsGodotCollection = new Godot.Collections.Array<Marker3D>(spawnPoints);
|
||||
var randomSpawnPoint = spawnPointsGodotCollection.PickRandom();
|
||||
|
||||
enemy.SetEnemyPosition(randomSpawnPoint.GlobalPosition);
|
||||
enemy.MoveEnemyToNewRoom(randomRoom);
|
||||
}
|
||||
|
||||
public void TeleportToRandomRoom(IPlayer player)
|
||||
|
||||
@@ -5,6 +5,7 @@ using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -2,7 +2,6 @@ using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
@@ -108,22 +109,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.HealthComponent.SetHealth(1);
|
||||
break;
|
||||
case ThrowableItemTag.TeleportToRandomLocation:
|
||||
_effectService.TeleportToRandomRoom(enemy);
|
||||
break;
|
||||
default:
|
||||
var damageDealt = DamageCalculator.CalculateDamage(new Damage(throwableItem.ThrowDamage, throwableItem.ElementType, false, false, false), 10, new ElementalResistanceSet(0, 0, 0, 0, 0));
|
||||
enemy.TakeDamage(damageDealt);
|
||||
enemy.HealthComponent.Damage(damageDealt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var damageDealt = DamageCalculator.CalculateDamage(new Damage(ItemThatIsThrown.ThrowDamage, ElementType.None, false, false, false), 10, new ElementalResistanceSet(0, 0, 0, 0, 0));
|
||||
enemy.TakeDamage(damageDealt);
|
||||
enemy.HealthComponent.Damage(damageDealt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.Serialization;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
Reference in New Issue
Block a user