コード例 #1
0
ファイル: FoodItemBase.cs プロジェクト: unitycoder/zara
        public void RemoveAllNormal(DateTime currentTime)
        {
            var copy = FoodItemsGatheringInfo.ToList();

            foreach (var x in copy)
            {
                if (x.Item1 > currentTime.AddMinutes(-MinutesUntilSpoiled))
                {
                    FoodItemsGatheringInfo.Remove(x);
                }
            }
        }
コード例 #2
0
ファイル: FoodItemBase.cs プロジェクト: unitycoder/zara
        public int TakeOneFromNormalGroup(DateTime currentTime)
        {
            var normalItem = FoodItemsGatheringInfo.FirstOrDefault(x => x.Item1 > currentTime.AddMinutes(-MinutesUntilSpoiled));

            if (normalItem != null)
            {
                normalItem.Item2--;

                if (normalItem.Item2 <= 0)
                {
                    FoodItemsGatheringInfo.Remove(normalItem);
                }

                return(GetCountNormal(currentTime));
            }

            return(-1);
        }
コード例 #3
0
ファイル: FoodItemBase.cs プロジェクト: unitycoder/zara
        public int TakeOneFromSpoiledGroup(DateTime currentTime)
        {
            var spoiledItem = FoodItemsGatheringInfo.FirstOrDefault(x => x.Item1 <= currentTime.AddMinutes(-MinutesUntilSpoiled));

            if (spoiledItem != null)
            {
                spoiledItem.Item2--;

                if (spoiledItem.Item2 <= 0)
                {
                    FoodItemsGatheringInfo.Remove(spoiledItem);
                }

                return(GetCountSpoiled(currentTime));
            }

            return(-1);
        }
コード例 #4
0
ファイル: FoodItemBase.cs プロジェクト: unitycoder/zara
 public void AddGatheringInfo(DateTime time, int count)
 {
     FoodItemsGatheringInfo.Add(new Tuple <DateTime, int>(time, count));
 }
コード例 #5
0
ファイル: FoodItemBase.cs プロジェクト: unitycoder/zara
 public int GetCountNormal(DateTime currentTime)
 {
     return(FoodItemsGatheringInfo.Where(x => x.Item1 > currentTime.AddMinutes(-MinutesUntilSpoiled)).Sum(x => x.Item2));
 }