public void ChargeAlchemy(BonusData bonus) { RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>(); PlayerService playerService = engine.GetService <IPlayerService>().Cast <PlayerService>(); foreach (var pair in bonus.ingredients) { IngredientData ingredientData = resourceService.GetIngredient(pair.Key); playerService.RemoveItem(ingredientData.type, ingredientData.id, pair.Value); } playerService.AddItem(new InventoryItem(bonus, 1)); //engine.Cast<RavenhillEngine>().DropItems(new List<DropItem> { new DropItem(DropType.item, 1, bonus )}); RavenhillEvents.OnAlchemyCharged(bonus); }
public bool IsAlchemyReadyToCharge(BonusData bonus) { bool alchemyReady = true; RavenhillResourceService resourceService = engine.GetService <IResourceService>().Cast <RavenhillResourceService>(); PlayerService playerService = engine.GetService <IPlayerService>().Cast <PlayerService>(); foreach (var pair in bonus.ingredients) { int playerCount = playerService.GetItemCount(resourceService.GetIngredient(pair.Key)); if (playerCount < pair.Value) { alchemyReady = false; break; } } return(alchemyReady); }