コード例 #1
0
 public void GainCake(int cakeCount, DateTime lastTakeCakeTime)
 {
     if (FoodInfos.Count > 0)
     {
         int index = FoodInfos.FindIndex(x => x.food is Cake);
         if (index != -1)
         {
             properties.foodInfos[index] = new FoodInfo
             {
                 food  = new Cake(),
                 count = FoodInfos[index].count + cakeCount
             };
         }
         LastTakeCakeTime = lastTakeCakeTime;
         OnCakeCountChange?.Invoke(CakeCount);
     }
 }
コード例 #2
0
 public bool UseCake(int number)
 {
     if (CakeCount >= number && FoodInfos.Count > 0)
     {
         int index = FoodInfos.FindIndex(x => x.food is Cake);
         if (index != -1)
         {
             properties.foodInfos[index] = new FoodInfo
             {
                 food  = new Cake(),
                 count = FoodInfos[index].count - number
             };
         }
         OnCakeCountChange?.Invoke(CakeCount);
         return(true);
     }
     else
     {
         return(false);
     }
 }