void FixedUpdate() { float repairs = repairPerSecond * Time.fixedDeltaTime; if (repairPressed) { if (plane.ShouldRepair()) { if (plane.TrySpendMatter(repairs / 10f)) { if (plane.TrySpendEnergy(repairs)) { plane.Repair(repairs); } } } } }
void FixedUpdate() { float light = resourceCalculator.GetLight(); float density = resourceCalculator.GetDensity(); if (light < 0f || density < 0f) { // TODO display error to client Debug.LogWarning("Resource controller cannot calculate resources"); return; } float depth = Mathf.Clamp01(-plane.transform.position.y / 1400f + 0.5f); plane.RefuelEnergy(energyMultiplier * energyVsLight.Evaluate(light) * Time.fixedDeltaTime); plane.RefuelMatter(matterMultiplier * matterVsDensity.Evaluate(density) * matterVsDepth.Evaluate(depth) * Time.fixedDeltaTime); if (plane.TrySpendEnergy(baseEnergyPerSecond * Time.fixedDeltaTime) == false) { deathController.KillPlane(); } }