Skip to content

Commit

Permalink
Rebalance enemies and projectiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorbn committed Jun 6, 2023
1 parent 819d66f commit 03bc14d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
4 changes: 3 additions & 1 deletion Common/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Enemy
private Player? _targetPlayer;
private readonly Attacker? _attacker;
private readonly WeaponStats _weaponStats;
private readonly float _attackRange;

public Enemy(EnemyType enemyType, float x, float z, int id,
Attacker? attacker, int? health = null)
Expand All @@ -35,6 +36,7 @@ public Enemy(EnemyType enemyType, float x, float z, int id,
SpritePosition = _position;
Health = health ?? Stats.MaxHealth;
_attacker = attacker;
_attackRange = _weaponStats.AttackRange * ProjectileStats.EnemyRangeMultiplier;
}

public void CalculatePath(AStar aStar, Map map, Player? targetPlayer)
Expand Down Expand Up @@ -68,7 +70,7 @@ public bool UpdateServer(Map map, float deltaTime)

if (distanceToPlayer > ChaseDistance) return false;

if (distanceToPlayer <= _weaponStats.AttackRange)
if (distanceToPlayer <= _attackRange)
_attacker.Attack(_weaponStats, directionToPlayer, Position.X, Position.Z, map);

if (_targetPathNodeI >= _path.Count) return false;
Expand Down
18 changes: 9 additions & 9 deletions Common/EnemyStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ public class EnemyStats

private const float MediumSpeed = 1.2f;

private const int LowMaxHealth = 20;
private const int MediumMaxHealth = 40;
private const int HighMaxHealth = 60;
private const int LowMaxHealth = 40;
private const int MediumMaxHealth = 60;
private const int HighMaxHealth = 80;

private const int BossLowMaxHealth = 200;
private const int BossMediumMaxHealth = 300;
private const int BossHighMaxHealth = 400;
private const int BossLowMaxHealth = 600;
private const int BossMediumMaxHealth = 800;
private const int BossHighMaxHealth = 1000;

private const float BossLowSpeed = 1f;
private const float BossMediumSpeed = 1.1f;
private const float BossHighSpeed = 1.2f;
private const float BossLowSpeed = 1.1f;
private const float BossMediumSpeed = 1.2f;
private const float BossHighSpeed = 1.3f;

static EnemyStats()
{
Expand Down
19 changes: 16 additions & 3 deletions Common/Projectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public struct Projectile

private Vector3 _position;
private readonly Vector3 _startPosition;
private readonly float _range;
private readonly float _speed;

public Projectile(ProjectileType projectileType, WeaponType weaponType, Team team, Vector3 direction, float x,
float z)
Expand All @@ -24,6 +26,17 @@ public Projectile(ProjectileType projectileType, WeaponType weaponType, Team tea
Direction = direction;
_position = new Vector3(x, 0f, z);
_startPosition = _position;

if (Team == Team.Enemies)
{
_range = Stats.Range * ProjectileStats.EnemyRangeMultiplier;
_speed = Stats.Speed * ProjectileStats.EnemySpeedMultiplier;
}
else
{
_range = Stats.Range;
_speed = Stats.Speed;
}
}

// Returns true if the projectile collided with something.
Expand All @@ -36,7 +49,7 @@ private bool Move(Vector3 movement, Map map, float deltaTime)
movement.Normalize();

var newPosition = _position;
newPosition.X += movement.X * Stats.Speed * deltaTime;
newPosition.X += movement.X * _speed * deltaTime;

if (map.IsCollidingWithBox(newPosition, Size))
{
Expand All @@ -46,7 +59,7 @@ private bool Move(Vector3 movement, Map map, float deltaTime)

_position.X = newPosition.X;

newPosition.Z += movement.Z * Stats.Speed * deltaTime;
newPosition.Z += movement.Z * _speed * deltaTime;

if (map.IsCollidingWithBox(newPosition, Size))
{
Expand All @@ -57,7 +70,7 @@ private bool Move(Vector3 movement, Map map, float deltaTime)
_position.Z = newPosition.Z;

var distanceTravelled = (_position - _startPosition).Length();
if (distanceTravelled > Stats.Range) hasCollision = true;
if (distanceTravelled > _range) hasCollision = true;

switch (Team)
{
Expand Down
21 changes: 12 additions & 9 deletions Common/ProjectileStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ public class ProjectileStats
{
public static readonly Dictionary<ProjectileType, ProjectileStats> Registry = new();

private const int LowDamageTier1 = 5;
private const int MediumDamageTier1 = 10;
private const int HighDamageTier1 = 15;
private const int LowDamageTier2 = 10;
private const int MediumDamageTier2 = 15;
private const int HighDamageTier2 = 20;
private const int LowDamageTier3 = 15;
private const int MediumDamageTier3 = 20;
private const int HighDamageTier3 = 25;
public const float EnemyRangeMultiplier = 2f;
public const float EnemySpeedMultiplier = 0.9f;

private const int LowDamageTier1 = 6;
private const int MediumDamageTier1 = 8;
private const int HighDamageTier1 = 10;
private const int LowDamageTier2 = 8;
private const int MediumDamageTier2 = 10;
private const int HighDamageTier2 = 12;
private const int LowDamageTier3 = 10;
private const int MediumDamageTier3 = 12;
private const int HighDamageTier3 = 14;

private const float LowRange = 1.5f;
private const float MediumRange = 3f;
Expand Down

0 comments on commit 03bc14d

Please sign in to comment.