mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 23:45:55 +00:00
P power scaling
This commit is contained in:
parent
d5851bca00
commit
ee84bafdad
23 changed files with 158 additions and 44 deletions
|
|
@ -16,6 +16,7 @@ public partial class BulletResource : Resource
|
|||
[Export] public float BulletSpeed = 100f;
|
||||
[Export] public Vector2 Direction = Vector2.Right;
|
||||
[Export] public float BulletDamage = 1;
|
||||
[Export] public float MaxDamage = 1;
|
||||
[Export] public float Knockback = 1;
|
||||
[Export] public float LifeTime = 10f;
|
||||
[Export] public bool DestroyOnCollision = true;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ public partial class Weapon : Node2D
|
|||
|
||||
[Export]
|
||||
public Sprite2D Sprite { get; private set; }
|
||||
|
||||
[Export] public StringName PowerKey { get; set; } = "POWER";
|
||||
|
||||
[Signal]
|
||||
public delegate void ShootingEventHandler();
|
||||
|
|
@ -175,6 +177,13 @@ public partial class Weapon : Node2D
|
|||
{
|
||||
bulletData.Owner = ownerOverride.Value;
|
||||
}
|
||||
|
||||
if (bulletData.Owner is BulletOwner.Player || ownerOverride is BulletOwner.Player)
|
||||
{
|
||||
// Apply the P multiplier
|
||||
bulletData.Damage *=
|
||||
GetBulletStrengthMultiplier(bulletData.Damage, bulletData.OriginalBulletResource.MaxDamage, 20);
|
||||
}
|
||||
|
||||
bullet.Initialize(bulletData, _gameManager);
|
||||
|
||||
|
|
@ -198,6 +207,17 @@ public partial class Weapon : Node2D
|
|||
_cooldownTimer.Start(WeaponData?.RateOfFire ?? 0);
|
||||
}
|
||||
|
||||
private float GetBulletStrengthMultiplier(float baseDamage, float maxDamage, float maxPower)
|
||||
{
|
||||
var p = InventoryManager.Instance.GetItemCount(PowerKey);
|
||||
|
||||
float minMultiplier = 1.0f;
|
||||
float maxMultiplier = maxDamage / baseDamage;
|
||||
|
||||
float normalizedPower = Mathf.Clamp((float)p / maxPower, 0f, 1f);
|
||||
return Mathf.Lerp(minMultiplier, maxMultiplier, normalizedPower);
|
||||
}
|
||||
|
||||
public void RotateWeapon(Vector2 facingDirection, Vector2 leftPosition, Vector2 rightPosition)
|
||||
{
|
||||
bool facingLeft = facingDirection.X < 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue