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); } }
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); } }