Add projectiles
This commit is contained in:
@@ -92,6 +92,10 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
|
||||
[Node] private ShakeCamera _camera3D { get; set; } = default!;
|
||||
|
||||
[Node] private Projectile FireReactor { get; set; } = default!;
|
||||
[Node] private Projectile AirReactor { get; set; } = default!;
|
||||
[Node] private Projectile WaterReactor { get; set; } = default!;
|
||||
|
||||
#endregion
|
||||
|
||||
public bool CanEquipState { get; set; } = true;
|
||||
@@ -319,6 +323,13 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
|
||||
private void Attack()
|
||||
{
|
||||
var weapon = EquipmentComponent.EquippedWeapon.Value as Weapon;
|
||||
if (weapon.WeaponTag == WeaponTag.ElementalProjectile)
|
||||
{
|
||||
HandleProjectile(weapon);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerIsHittingGeometry())
|
||||
WeaponAnimations.Play("hit_wall");
|
||||
else if (!WeaponAnimations.IsPlaying())
|
||||
@@ -326,13 +337,40 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
else
|
||||
return;
|
||||
|
||||
var weapon = EquipmentComponent.EquippedWeapon.Value as Weapon;
|
||||
if (weapon.WeaponTag == WeaponTag.DegradeOnSwing)
|
||||
_playerEffectService.Degrade();
|
||||
else if (weapon.WeaponTag == WeaponTag.SelfDamage)
|
||||
_playerEffectService.TakeSelfDamage(5);
|
||||
}
|
||||
|
||||
private void HandleProjectile(Weapon weapon)
|
||||
{
|
||||
var ammo = EquipmentComponent.EquippedAmmo.Value as Ammo;
|
||||
if (ammo == null || ammo.Count <= 0)
|
||||
return;
|
||||
|
||||
if (weapon.WeaponTag != WeaponTag.ElementalProjectile)
|
||||
return;
|
||||
|
||||
var fired = false;
|
||||
if (ammo.AmmoElement == ElementType.Igneous)
|
||||
fired = FireReactor.Fire();
|
||||
if (ammo.AmmoElement == ElementType.Aeolic)
|
||||
fired = AirReactor.Fire();
|
||||
if (ammo.AmmoElement == ElementType.Hydric)
|
||||
fired = WaterReactor.Fire();
|
||||
|
||||
if (!fired)
|
||||
return;
|
||||
|
||||
ammo.SetCount(ammo.Count - 1);
|
||||
if (ammo.Count <= 0)
|
||||
{
|
||||
EquipmentComponent.Unequip(ammo);
|
||||
Inventory.Remove(ammo);
|
||||
}
|
||||
}
|
||||
|
||||
private void ThrowItem()
|
||||
{
|
||||
var itemScene = GD.Load<PackedScene>("res://src/items/throwable/ThrowableItem.tscn");
|
||||
|
||||
Reference in New Issue
Block a user