Ejemplo n.º 1
0
        private void ResponseUnrenderItemEnhancement(ActionBase.ActionEvaluation <ItemEnhancement5> eval)
        {
            var agentAddress  = eval.Signer;
            var avatarAddress = eval.Action.avatarAddress;
            var slot          = eval.OutputStates.GetCombinationSlotState(avatarAddress, eval.Action.slotIndex);
            var result        = (ItemEnhancement.ResultModel)slot.Result;
            var itemUsable    = result.itemUsable;
            var avatarState   = eval.OutputStates.GetAvatarState(avatarAddress);

            // NOTE: 사용한 자원에 대한 레이어 다시 추가하기.
            LocalLayerModifier.ModifyAgentGold(agentAddress, -result.gold);
            LocalLayerModifier.RemoveItem(avatarAddress, itemUsable.ItemId);
            foreach (var itemId in result.materialItemIdList)
            {
                // NOTE: 최종적으로 UpdateCurrentAvatarState()를 호출한다면, 그곳에서 상태를 새로 설정할 것이다.
                LocalLayerModifier.RemoveItem(avatarAddress, itemId);
            }

            // NOTE: 메일 레이어 다시 없애기.
            LocalLayerModifier.AddItem(avatarAddress, itemUsable.ItemId, false);
            LocalLayerModifier.RemoveNewAttachmentMail(avatarAddress, result.id);

            // NOTE: 워크샵 슬롯의 모든 휘발성 상태 변경자를 다시 추가하기.
            var otherItemId = result.materialItemIdList.First();

            LocalLayerModifier.ModifyCombinationSlotItemEnhancement(
                itemUsable.ItemId,
                otherItemId,
                eval.Action.slotIndex);

            UpdateAgentState(eval);
            UpdateCurrentAvatarState(eval);
            UpdateCombinationSlotState(slot);
            UnrenderQuest(avatarAddress, avatarState.questList.completedQuestIds);
        }
Ejemplo n.º 2
0
        private void ResponseItemEnhancement(ActionBase.ActionEvaluation <ItemEnhancement> eval)
        {
            if (eval.Exception is null)
            {
                var agentAddress  = eval.Signer;
                var avatarAddress = eval.Action.avatarAddress;
                var slot          = eval.OutputStates.GetCombinationSlotState(avatarAddress, eval.Action.slotIndex);
                var result        = (ItemEnhancement.ResultModel)slot.Result;
                var itemUsable    = result.itemUsable;
                var avatarState   = eval.OutputStates.GetAvatarState(avatarAddress);

                // NOTE: 사용한 자원에 대한 레이어 벗기기.
                LocalLayerModifier.ModifyAgentGold(agentAddress, result.gold);
                LocalLayerModifier.AddItem(avatarAddress, itemUsable.ItemId, false);
                foreach (var itemId in result.materialItemIdList)
                {
                    // NOTE: 최종적으로 UpdateCurrentAvatarState()를 호출한다면, 그곳에서 상태를 새로 설정할 것이다.
                    LocalLayerModifier.AddItem(avatarAddress, itemId, false);
                }

                // NOTE: 메일 레이어 씌우기.
                LocalLayerModifier.RemoveItem(avatarAddress, itemUsable.ItemId);
                LocalLayerModifier.AddNewAttachmentMail(avatarAddress, result.id);

                // NOTE: 워크샵 슬롯의 모든 휘발성 상태 변경자를 제거하기.
                LocalLayerModifier.ResetCombinationSlot(slot);

                // NOTE: 노티 예약 걸기.
                var format = L10nManager.Localize("NOTIFICATION_ITEM_ENHANCEMENT_COMPLETE");
                UI.Notification.Reserve(
                    MailType.Workshop,
                    string.Format(format, result.itemUsable.GetLocalizedName()),
                    slot.UnlockBlockIndex,
                    result.itemUsable.ItemId);

                //[TentuPlay] 장비강화, 골드사용
                //Local에서 변경하는 States.Instance 보다는 블락에서 꺼내온 eval.OutputStates를 사용
                if (eval.OutputStates.TryGetGoldBalance(agentAddress, GoldCurrency, out var outAgentBalance))
                {
                    var total = outAgentBalance -
                                new FungibleAssetValue(outAgentBalance.Currency, result.gold, 0);
                    new TPStashEvent().CharacterCurrencyUse(
                        player_uuid: agentAddress.ToHex(),
                        character_uuid: States.Instance.CurrentAvatarState.address.ToHex().Substring(0, 4),
                        currency_slug: "gold",
                        currency_quantity: (float)result.gold,
                        currency_total_quantity: float.Parse(total.GetQuantityString()),
                        reference_entity: entity.Items, //강화가 가능하므로 장비
                        reference_category_slug: "item_enhancement",
                        reference_slug: itemUsable.Id.ToString());
                }

                UpdateAgentState(eval);
                UpdateCurrentAvatarState(eval);
                UpdateCombinationSlotState(slot);
                RenderQuest(avatarAddress, avatarState.questList.completedQuestIds);
            }
        }
Ejemplo n.º 3
0
        public void Read(SellerMail sellerMail)
        {
            var agentAddress  = States.Instance.AgentState.address;
            var avatarAddress = States.Instance.CurrentAvatarState.address;
            var attachment    = (Buy.SellerResult)sellerMail.attachment;

            //TODO 관련 기획이 끝나면 별도 UI를 생성
            LocalLayerModifier.ModifyAgentGold(agentAddress, attachment.gold);
            LocalLayerModifier.RemoveNewAttachmentMail(avatarAddress, sellerMail.id);
        }
Ejemplo n.º 4
0
        private void ResponseCombinationConsumable(ActionBase.ActionEvaluation <CombinationConsumable> eval)
        {
            if (eval.Exception is null)
            {
                var agentAddress  = eval.Signer;
                var avatarAddress = eval.Action.AvatarAddress;
                var slot          = eval.OutputStates.GetCombinationSlotState(avatarAddress, eval.Action.slotIndex);
                var result        = (CombinationConsumable.ResultModel)slot.Result;
                var itemUsable    = result.itemUsable;
                var avatarState   = eval.OutputStates.GetAvatarState(avatarAddress);

                LocalLayerModifier.ModifyAgentGold(agentAddress, result.gold);
                LocalLayerModifier.ModifyAvatarActionPoint(avatarAddress, result.actionPoint);
                foreach (var pair in result.materials)
                {
                    // NOTE: 최종적으로 UpdateCurrentAvatarState()를 호출한다면, 그곳에서 상태를 새로 설정할 것이다.
                    LocalLayerModifier.AddItem(avatarAddress, pair.Key.ItemId, pair.Value, false);
                }

                LocalLayerModifier.RemoveItem(avatarAddress, itemUsable.ItemId);
                LocalLayerModifier.AddNewAttachmentMail(avatarAddress, result.id);
                LocalLayerModifier.ResetCombinationSlot(slot);

                var format = L10nManager.Localize("NOTIFICATION_COMBINATION_COMPLETE");
                UI.Notification.Reserve(
                    MailType.Workshop,
                    string.Format(format, result.itemUsable.GetLocalizedName()),
                    slot.UnlockBlockIndex,
                    result.itemUsable.ItemId
                    );
                AnalyticsManager.Instance.OnEvent(AnalyticsManager.EventName.ActionCombinationSuccess);

                //[TentuPlay] Consumable 합성에 사용한 골드 기록
                //Local에서 변경하는 States.Instance 보다는 블락에서 꺼내온 eval.OutputStates를 사용
                if (eval.OutputStates.TryGetGoldBalance(agentAddress, GoldCurrency, out var balance))
                {
                    var total = balance - new FungibleAssetValue(balance.Currency, result.gold, 0);
                    new TPStashEvent().CharacterCurrencyUse(
                        player_uuid: agentAddress.ToHex(),
                        character_uuid: States.Instance.CurrentAvatarState.address.ToHex().Substring(0, 4),
                        currency_slug: "gold",
                        currency_quantity: (float)result.gold,
                        currency_total_quantity: float.Parse(total.GetQuantityString()),
                        reference_entity: entity.Items,
                        reference_category_slug: "consumables_combination",
                        reference_slug: result.itemUsable.Id.ToString());
                }

                UpdateAgentState(eval);
                UpdateCurrentAvatarState(eval);
                UpdateCombinationSlotState(slot);
                RenderQuest(avatarAddress, avatarState.questList.completedQuestIds);
            }
        }
Ejemplo n.º 5
0
        private void ResponseBuy(ActionBase.ActionEvaluation <Buy4> eval)
        {
            if (!(eval.Exception is null))
            {
                return;
            }

            var        buyerAvatarAddress = eval.Action.buyerAvatarAddress;
            var        price = eval.Action.sellerResult.shopItem.Price;
            Address    renderQuestAvatarAddress;
            List <int> renderQuestCompletedQuestIds;

            if (buyerAvatarAddress == States.Instance.CurrentAvatarState.address)
            {
                var buyerAgentAddress = States.Instance.AgentState.address;
                var result            = eval.Action.buyerResult;

                var itemId      = result.itemUsable?.ItemId ?? result.costume.ItemId;
                var buyerAvatar = eval.OutputStates.GetAvatarState(buyerAvatarAddress);

                LocalLayerModifier.ModifyAgentGold(buyerAgentAddress, -price);
                LocalLayerModifier.AddItem(buyerAvatarAddress, itemId);
                LocalLayerModifier.RemoveNewAttachmentMail(buyerAvatarAddress, result.id);

                renderQuestAvatarAddress     = buyerAvatarAddress;
                renderQuestCompletedQuestIds = buyerAvatar.questList.completedQuestIds;
            }
            else
            {
                var sellerAvatarAddress = eval.Action.sellerAvatarAddress;
                var sellerAgentAddress  = eval.Action.sellerAgentAddress;
                var result       = eval.Action.sellerResult;
                var gold         = result.gold;
                var sellerAvatar = eval.OutputStates.GetAvatarState(sellerAvatarAddress);

                LocalLayerModifier.ModifyAgentGold(sellerAgentAddress, gold);
                LocalLayerModifier.RemoveNewAttachmentMail(sellerAvatarAddress, result.id);

                renderQuestAvatarAddress     = sellerAvatarAddress;
                renderQuestCompletedQuestIds = sellerAvatar.questList.completedQuestIds;
            }

            UpdateAgentState(eval);
            UpdateCurrentAvatarState(eval);
            UnrenderQuest(renderQuestAvatarAddress, renderQuestCompletedQuestIds);
        }
Ejemplo n.º 6
0
        private void ResponseBuy(ShopItem shopItem)
        {
            SharedModel.ItemCountAndPricePopup.Value.Item.Value = null;

            var buyerAgentAddress = States.Instance.AgentState.address;
            var productId         = shopItem.ProductId.Value;

            LocalLayerModifier.ModifyAgentGold(buyerAgentAddress, -shopItem.Price.Value);
            try
            {
                States.Instance.ShopState.Unregister(productId);
            }
            catch (FailedToUnregisterInShopStateException e)
            {
                Debug.LogError(e.Message);
            }
            shopItems.SharedModel.RemoveItemSubTypeProduct(productId);

            AudioController.instance.PlaySfx(AudioController.SfxCode.BuyItem);
            var format = L10nManager.Localize("NOTIFICATION_BUY_START");

            Notification.Push(MailType.Auction,
                              string.Format(format, shopItem.ItemBase.Value.GetLocalizedName()));
        }
Ejemplo n.º 7
0
        private void ResponseBuy(ActionBase.ActionEvaluation <Buy> eval)
        {
            if (eval.Exception is null)
            {
                var        buyerAvatarAddress = eval.Action.buyerAvatarAddress;
                var        price = eval.Action.sellerResult.shopItem.Price;
                Address    renderQuestAvatarAddress;
                List <int> renderQuestCompletedQuestIds = null;

                if (buyerAvatarAddress == States.Instance.CurrentAvatarState.address)
                {
                    var buyerAgentAddress = States.Instance.AgentState.address;
                    var result            = eval.Action.buyerResult;
                    var nonFungibleItem   = result.itemUsable ?? (INonFungibleItem)result.costume;
                    var itemBase          = result.itemUsable ?? (ItemBase)result.costume;
                    var buyerAvatar       = eval.OutputStates.GetAvatarState(buyerAvatarAddress);

                    // 골드 처리.
                    LocalLayerModifier.ModifyAgentGold(buyerAgentAddress, price);

                    // 메일 처리.
                    LocalLayerModifier.RemoveItem(buyerAvatarAddress, nonFungibleItem.ItemId);
                    LocalLayerModifier.AddNewAttachmentMail(buyerAvatarAddress, result.id);

                    var format = L10nManager.Localize("NOTIFICATION_BUY_BUYER_COMPLETE");
                    UI.Notification.Push(MailType.Auction, string.Format(format, itemBase.GetLocalizedName()));

                    //[TentuPlay] 아이템 구입, 골드 사용
                    //Local에서 변경하는 States.Instance 보다는 블락에서 꺼내온 eval.OutputStates를 사용
                    if (eval.OutputStates.TryGetGoldBalance(buyerAgentAddress, GoldCurrency, out var buyerAgentBalance))
                    {
                        var total = buyerAgentBalance - price;
                        new TPStashEvent().CharacterCurrencyUse(
                            player_uuid: States.Instance.AgentState.address.ToHex(),
                            character_uuid: States.Instance.CurrentAvatarState.address.ToHex().Substring(0, 4),
                            currency_slug: "gold",
                            currency_quantity: float.Parse(price.GetQuantityString()),
                            currency_total_quantity: float.Parse(total.GetQuantityString()),
                            reference_entity: entity.Trades,
                            reference_category_slug: "buy",
                            reference_slug: itemBase.Id.ToString() //아이템 품번
                            );
                    }

                    renderQuestAvatarAddress     = buyerAvatarAddress;
                    renderQuestCompletedQuestIds = buyerAvatar.questList.completedQuestIds;
                }
                else
                {
                    var sellerAvatarAddress = eval.Action.sellerAvatarAddress;
                    var sellerAgentAddress  = eval.Action.sellerAgentAddress;
                    var result       = eval.Action.sellerResult;
                    var itemBase     = result.itemUsable ?? (ItemBase)result.costume;
                    var gold         = result.gold;
                    var sellerAvatar = eval.OutputStates.GetAvatarState(sellerAvatarAddress);

                    LocalLayerModifier.ModifyAgentGold(sellerAgentAddress, -gold);
                    LocalLayerModifier.AddNewAttachmentMail(sellerAvatarAddress, result.id);

                    var format    = L10nManager.Localize("NOTIFICATION_BUY_SELLER_COMPLETE");
                    var buyerName =
                        new AvatarState(
                            (Bencodex.Types.Dictionary)eval.OutputStates.GetState(eval.Action.buyerAvatarAddress))
                        .NameWithHash;
                    UI.Notification.Push(MailType.Auction, string.Format(format, buyerName, itemBase.GetLocalizedName()));

                    //[TentuPlay] 아이템 판매완료, 골드 증가
                    //Local에서 변경하는 States.Instance 보다는 블락에서 꺼내온 eval.OutputStates를 사용
                    var sellerAgentBalance = eval.OutputStates.GetBalance(sellerAgentAddress, GoldCurrency);
                    var total = sellerAgentBalance + gold;
                    new TPStashEvent().CharacterCurrencyGet(
                        player_uuid: sellerAgentAddress.ToHex(), // seller == 본인인지 확인필요
                        character_uuid: States.Instance.CurrentAvatarState.address.ToHex().Substring(0, 4),
                        currency_slug: "gold",
                        currency_quantity: float.Parse(gold.GetQuantityString()),
                        currency_total_quantity: float.Parse(total.GetQuantityString()),
                        reference_entity: entity.Trades,
                        reference_category_slug: "sell",
                        reference_slug: itemBase.Id.ToString() //아이템 품번
                        );

                    renderQuestAvatarAddress     = sellerAvatarAddress;
                    renderQuestCompletedQuestIds = sellerAvatar.questList.completedQuestIds;
                }

                UpdateAgentState(eval);
                UpdateCurrentAvatarState(eval);
                RenderQuest(renderQuestAvatarAddress, renderQuestCompletedQuestIds);
            }
        }
Ejemplo n.º 8
0
        private void ResponseCombinationEquipment(ActionBase.ActionEvaluation <CombinationEquipment> eval)
        {
            if (eval.Exception is null)
            {
                var agentAddress  = eval.Signer;
                var avatarAddress = eval.Action.AvatarAddress;
                var slot          = eval.OutputStates.GetCombinationSlotState(avatarAddress, eval.Action.SlotIndex);
                var result        = (CombinationConsumable.ResultModel)slot.Result;
                var avatarState   = eval.OutputStates.GetAvatarState(avatarAddress);

                // NOTE: 사용한 자원에 대한 레이어 벗기기.
                LocalLayerModifier.ModifyAgentGold(agentAddress, result.gold);
                LocalLayerModifier.ModifyAvatarActionPoint(avatarAddress, result.actionPoint);
                foreach (var pair in result.materials)
                {
                    // NOTE: 최종적으로 UpdateCurrentAvatarState()를 호출한다면, 그곳에서 상태를 새로 설정할 것이다.
                    LocalLayerModifier.AddItem(avatarAddress, pair.Key.ItemId, pair.Value, false);
                }

                // NOTE: 메일 레이어 씌우기.
                LocalLayerModifier.RemoveItem(avatarAddress, result.itemUsable.ItemId);
                LocalLayerModifier.AddNewAttachmentMail(avatarAddress, result.id);
                LocalLayerModifier.ResetCombinationSlot(slot);

                // NOTE: 노티 예약 걸기.
                var format = L10nManager.Localize("NOTIFICATION_COMBINATION_COMPLETE");
                UI.Notification.Reserve(
                    MailType.Workshop,
                    string.Format(format, result.itemUsable.GetLocalizedName()),
                    slot.UnlockBlockIndex,
                    result.itemUsable.ItemId);

                AnalyticsManager.Instance.OnEvent(AnalyticsManager.EventName.ActionCombinationSuccess);

                //[TentuPlay] Equipment 합성에 사용한 골드 기록
                //Local에서 변경하는 States.Instance 보다는 블락에서 꺼내온 eval.OutputStates를 사용
                if (eval.OutputStates.TryGetGoldBalance(agentAddress, GoldCurrency, out var balance))
                {
                    var total = balance - new FungibleAssetValue(balance.Currency, result.gold, 0);
                    new TPStashEvent().CharacterCurrencyUse(
                        player_uuid: agentAddress.ToHex(),
                        character_uuid: States.Instance.CurrentAvatarState.address.ToHex().Substring(0, 4),
                        currency_slug: "gold",
                        currency_quantity: (float)result.gold,
                        currency_total_quantity: float.Parse(total.GetQuantityString()),
                        reference_entity: entity.Items,
                        reference_category_slug: "equipments_combination",
                        reference_slug: result.itemUsable.Id.ToString());
                }

                var gameInstance = Game.Game.instance;

                var nextQuest = gameInstance.States.CurrentAvatarState.questList?
                                .OfType <CombinationEquipmentQuest>()
                                .Where(x => !x.Complete)
                                .OrderBy(x => x.StageId)
                                .FirstOrDefault(x =>
                                                gameInstance.TableSheets.EquipmentItemRecipeSheet.TryGetValue(x.RecipeId, out _));

                UpdateAgentState(eval);
                UpdateCurrentAvatarState(eval);
                RenderQuest(avatarAddress, avatarState.questList.completedQuestIds);
                UpdateCombinationSlotState(slot);

                if (!(nextQuest is null))
                {
                    var isRecipeMatch = nextQuest.RecipeId == eval.Action.RecipeId;

                    if (isRecipeMatch)
                    {
                        var celebratesPopup = Widget.Find <CelebratesPopup>();
                        celebratesPopup.Show(nextQuest);
                        celebratesPopup.OnDisableObservable
                        .First()
                        .Subscribe(_ =>
                        {
                            var menu = Widget.Find <Menu>();
                            if (menu.isActiveAndEnabled)
                            {
                                menu.UpdateGuideQuest(avatarState);
                            }

                            var combination = Widget.Find <Combination>();
                            if (combination.isActiveAndEnabled)
                            {
                                combination.UpdateRecipe();
                            }
                        });
                    }
                }
            }
        }