Beispiel #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;
 }
Beispiel #2
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);
     }
 }
Beispiel #3
0
        private async UniTask <UITextKeys> ClaimMailItems(string mailId, IPlayerCharacterData playerCharacter)
        {
#if UNITY_STANDALONE && !CLIENT_BUILD
            AsyncResponseData <GetMailResp> mailResp = await DbServiceClient.GetMailAsync(new GetMailReq()
            {
                MailId = mailId,
                UserId = playerCharacter.UserId,
            });

            if (!mailResp.IsSuccess)
            {
                return(UITextKeys.UI_ERROR_INTERNAL_SERVER_ERROR);
            }
            Mail mail = mailResp.Response.Mail;
            if (mail.IsClaim)
            {
                return(UITextKeys.UI_ERROR_MAIL_CLAIM_ALREADY_CLAIMED);
            }
            else if (mail.IsDelete)
            {
                return(UITextKeys.UI_ERROR_MAIL_CLAIM_NOT_ALLOWED);
            }
            else
            {
                if (mail.Items.Count > 0)
                {
                    if (playerCharacter.IncreasingItemsWillOverwhelming(mail.Items))
                    {
                        return(UITextKeys.UI_ERROR_WILL_OVERWHELMING);
                    }
                    else
                    {
                        playerCharacter.IncreaseItems(mail.Items);
                    }
                }
                if (mail.Currencies.Count > 0)
                {
                    playerCharacter.IncreaseCurrencies(mail.Currencies);
                }
                if (mail.Gold > 0)
                {
                    playerCharacter.Gold = playerCharacter.Gold.Increase(mail.Gold);
                }
                if (mail.Cash > 0)
                {
                    AsyncResponseData <CashResp> changeCashResp = await DbServiceClient.ChangeCashAsync(new ChangeCashReq()
                    {
                        UserId       = playerCharacter.UserId,
                        ChangeAmount = -mail.Cash
                    });

                    if (!changeCashResp.IsSuccess)
                    {
                        return(UITextKeys.UI_ERROR_INTERNAL_SERVER_ERROR);
                    }
                    playerCharacter.UserCash = changeCashResp.Response.Cash;
                }
            }
            AsyncResponseData <UpdateClaimMailItemsStateResp> resp = await DbServiceClient.UpdateClaimMailItemsStateAsync(new UpdateClaimMailItemsStateReq()
            {
                MailId = mailId,
                UserId = playerCharacter.UserId,
            });

            return(UITextKeys.NONE);
#else
            return(UITextKeys.UI_ERROR_SERVICE_NOT_AVAILABLE);
#endif
        }