Exemplo n.º 1
0
 public void CraftItem(IPlayerCharacterData character)
 {
     character.IncreaseItems(craftingItem.DataId, 1, 1);
     foreach (var craftRequirement in craftRequirements)
     {
         if (craftRequirement.item != null && craftRequirement.amount > 0)
         {
             character.DecreaseItems(craftRequirement.item.DataId, craftRequirement.amount);
         }
     }
     character.Gold -= requireGold;
 }
Exemplo n.º 2
0
 public void ReduceCreateGuildResource(IPlayerCharacterData character)
 {
     if (createGuildRequireItems != null)
     {
         foreach (var requireItem in createGuildRequireItems)
         {
             if (requireItem.item != null && requireItem.amount > 0)
             {
                 character.DecreaseItems(requireItem.item.DataId, requireItem.amount);
             }
         }
     }
     character.Gold -= createGuildRequiredGold;
 }
 public void DecreaseCreateGuildResource(IPlayerCharacterData character)
 {
     if (createGuildRequireItems != null)
     {
         foreach (ItemAmount requireItem in createGuildRequireItems)
         {
             if (requireItem.item != null && requireItem.amount > 0)
             {
                 character.DecreaseItems(requireItem.item.DataId, requireItem.amount);
             }
         }
     }
     // Decrease required gold
     GameInstance.Singleton.GameplayRule.DecreaseCurrenciesWhenCreateGuild(character, this);
 }
Exemplo n.º 4
0
 public void CraftItem(IPlayerCharacterData character)
 {
     if (character.IncreaseItems(CharacterItem.Create(craftingItem)))
     {
         // Reduce item when able to increase craft item
         foreach (ItemAmount craftRequirement in craftRequirements)
         {
             if (craftRequirement.item != null && craftRequirement.amount > 0)
             {
                 character.DecreaseItems(craftRequirement.item.DataId, craftRequirement.amount);
             }
         }
         // Decrease required gold
         GameInstance.Singleton.GameplayRule.DecreaseCurrenciesWhenCraftItem(character, this);
     }
 }
        private static void EnhanceSocketItem(IPlayerCharacterData character, CharacterItem enhancingItem, int enhancerId, System.Action <CharacterItem> onEnhanceSocket, out GameMessage.Type gameMessageType)
        {
            gameMessageType = GameMessage.Type.CannotEnhanceSocket;
            if (!enhancingItem.NotEmptySlot())
            {
                // Cannot enhance socket because character item is empty
                return;
            }
            Item equipmentItem = enhancingItem.GetEquipmentItem();

            if (equipmentItem == null)
            {
                // Cannot enhance socket because it's not equipment item
                return;
            }
            if (equipmentItem.maxSocket <= 0)
            {
                // Cannot enhance socket because equipment has no socket(s)
                return;
            }
            if (enhancingItem.Sockets.Count >= equipmentItem.maxSocket)
            {
                // Cannot enhance socket because socket is full
                return;
            }
            Item enhancerItem;

            if (!GameInstance.Items.TryGetValue(enhancerId, out enhancerItem) || !enhancerItem.IsSocketEnhancer())
            {
                // Cannot enhance socket because enhancer id is invalid
                return;
            }
            if (!character.DecreaseItems(enhancerItem.DataId, 1))
            {
                // Cannot enhance socket because there is no item
                gameMessageType = GameMessage.Type.NotEnoughSocketEnchaner;
                return;
            }
            enhancingItem.Sockets.Add(enhancerId);
            onEnhanceSocket.Invoke(enhancingItem);
        }
Exemplo n.º 6
0
        public bool RefineItem(IPlayerCharacterData character, int nonEquipIndex)
        {
            var isSuccess    = false;
            var refiningItem = character.NonEquipItems[nonEquipIndex];

            if (Random.value <= successRate)
            {
                ++refiningItem.level;
                character.NonEquipItems[nonEquipIndex] = refiningItem;
                isSuccess = true;
            }
            else
            {
                if (refineFailDestroyItem)
                {
                    character.NonEquipItems.RemoveAt(nonEquipIndex);
                }
                else
                {
                    refiningItem.level -= refineFailDecreaseLevels;
                    if (refiningItem.level < 1)
                    {
                        refiningItem.level = 1;
                    }
                    character.NonEquipItems[nonEquipIndex] = refiningItem;
                }
            }
            if (requireItems != null)
            {
                foreach (var requireItem in requireItems)
                {
                    if (requireItem.item != null && requireItem.amount > 0)
                    {
                        character.DecreaseItems(requireItem.item.DataId, requireItem.amount);
                    }
                }
            }
            character.Gold -= requireGold;
            return(isSuccess);
        }
Exemplo n.º 7
0
        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);
        }