private void Refill() { float refillAmount = MaxWaterLevel - WaterLevel; float inputWater = shipResources.ChangeWater(-refillAmount); waterLevel -= inputWater; waterLevel = Mathf.Clamp(WaterLevel, 0, MaxWaterLevel); }
protected override void Update() { base.Update(); if (Active) { if (shipResources.StoredWater < shipResources.MaxWater) { currentWaterProductionRate = Mathf.Min((shipResources.MaxWater - shipResources.StoredWater) * TimeManager.Instance.GameDeltaTime, MaxWaterProductionRate); if (currentWaterProductionRate == MaxWaterProductionRate) { shipResources.ChangeWater(currentWaterProductionRate * TimeManager.Instance.GameDeltaTime); } else { shipResources.ChangeWater(currentWaterProductionRate); } } } Water.localScale = new Vector3(Water.localScale.x, shipResources.StoredWater / shipResources.MaxWater, Water.localScale.z); Water.localPosition = new Vector3(Water.localPosition.x, (-0.95f + Water.localScale.y) / 2, Water.localPosition.z); }