private static void RefineItem(IPlayerCharacterData character, CharacterItem refiningItem, System.Action <CharacterItem> onRefine, System.Action onDestroy, out GameMessage.Type gameMessageType) { gameMessageType = GameMessage.Type.CannotRefine; if (!refiningItem.NotEmptySlot()) { // Cannot refine because character item is empty return; } Item equipmentItem = refiningItem.GetEquipmentItem(); if (equipmentItem == null) { // Cannot refine because it's not equipment item return; } if (!equipmentItem.CanRefine(character, refiningItem.level, out gameMessageType)) { // Cannot refine because of some reasons return; } ItemRefineLevel refineLevel = equipmentItem.itemRefine.levels[refiningItem.level - 1]; if (Random.value <= refineLevel.SuccessRate) { // If success, increase item level gameMessageType = GameMessage.Type.RefineSuccess; ++refiningItem.level; onRefine.Invoke(refiningItem); } else { // Fail gameMessageType = GameMessage.Type.RefineFail; if (refineLevel.RefineFailDestroyItem) { // If condition when fail is it has to be destroyed onDestroy.Invoke(); } else { // If condition when fail is reduce its level refiningItem.level -= refineLevel.RefineFailDecreaseLevels; if (refiningItem.level < 1) { refiningItem.level = 1; } onRefine.Invoke(refiningItem); } } if (refineLevel.RequireItems != null) { // Decrease required items foreach (ItemAmount requireItem in refineLevel.RequireItems) { if (requireItem.item != null && requireItem.amount > 0) { character.DecreaseItems(requireItem.item.DataId, requireItem.amount); } } } // Decrease required gold GameInstance.Singleton.GameplayRule.DecreaseCurrenciesWhenRefineItem(character, refineLevel); }
public override void DecreaseCurrenciesWhenRefineItem(IPlayerCharacterData character, ItemRefineLevel refineLevel) { character.Gold -= refineLevel.RequireGold; }
public abstract void DecreaseCurrenciesWhenRefineItem(IPlayerCharacterData character, ItemRefineLevel refineLevel);
public override bool CurrenciesEnoughToRefineItem(IPlayerCharacterData character, ItemRefineLevel refineLevel) { return(character.Gold >= refineLevel.RequireGold); }
public abstract bool CurrenciesEnoughToRefineItem(IPlayerCharacterData character, ItemRefineLevel refineLevel);