public void CollectWaterTest() { var ps = new int[] { 1, 2, 3, 1, 1, 3, 2, 1 }; var w = WaterCollector.CollectWater(ps); Assert.IsTrue(w == 4); Console.WriteLine("water {0}", w); }
public float GetMultiSourceAvailableAmount(WaterCollector collector) { float sum = 0f; foreach (var source in sources) { sum += collector.GetAvailableAmount(source); } return(sum); }
public void CollectWatersTest() { var ps = new int[] { 1, 2, 3, 1, 1, 3, 2, 1 }; var ws = WaterCollector.CollectWaters(ps); Assert.IsNotNull(ws); Assert.IsTrue(ws.Count == 2); foreach (var w in ws) { Console.WriteLine("index {0} water {1}", w.Key, w.Value); } }
public float GetPullAmount(WaterCollector collector) { float totalAvailableAmount = GetMultiSourceAvailableAmount(collector); if (totalAvailableAmount <= 0f) { return(0f); } float pullOptimizationRatio = totalAvailableAmount / collector.optimalAmount; float pulledAmount = collector.maxLitresPerSecond * Time.deltaTime * pullOptimizationRatio; //TODO: Add every X frames return(pulledAmount); }