コード例 #1
0
    private void Refill()
    {
        float refillAmount = MaxWaterLevel - WaterLevel;
        float inputWater   = shipResources.ChangeWater(-refillAmount);

        waterLevel -= inputWater;
        waterLevel  = Mathf.Clamp(WaterLevel, 0, MaxWaterLevel);
    }
コード例 #2
0
    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);
    }