This commit is contained in:
ntr committed 2023-08-09 17:23:19 +10:00
1 parent 760d3fccb9
commit a5b25de90a
5 files changed
+97 -36

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
using System;
using UnityEngine;
public class PowerUnit {
static float baseOutput = 25.0f;
float acceleration = 2f * baseOutput;
float deceleration = 4f * baseOutput;
float strafing = 1f * baseOutput;
float stablisation = 75f;
float shieldsCurrent = 5000f;
float shieldsMax = 5000f;
float shieldsRegen = 10f; // * 100 ticks per second = 5s fully recharge
public float Acceleration => acceleration;
public float Deceleration => deceleration;
public float Strafing => strafing;
public float Shields => shieldsCurrent;
public float ShieldsMax => shieldsMax;
public float Stabilisation => stablisation;
public string ShieldsPct => $"{((shieldsCurrent / shieldsMax) * 100f):0}";
public void Init() {
shieldsCurrent = shieldsMax;
shieldsRegen = (shieldsMax / 5f) * Time.fixedDeltaTime;
}
public void Reassign(float accel, float decel, float strafe, float shields) {
acceleration = baseOutput * accel;
deceleration = baseOutput * decel;
strafing = baseOutput * strafe;
shieldsRegen = shields;
}
// returns whether shields depleted
public bool ShieldsReduce(float amt) {
shieldsCurrent = shieldsCurrent - amt;
return shieldsCurrent < 0f;
}
public void ShieldsRegenerate() {
shieldsCurrent = Math.Min(shieldsCurrent + shieldsRegen, shieldsMax);
}
}