Ejemplo n.º 1
0
        public void Read(CombinationMail mail)
        {
            var avatarAddress   = States.Instance.CurrentAvatarState.address;
            var attachment      = (CombinationConsumable.ResultModel)mail.attachment;
            var itemBase        = attachment.itemUsable ?? (ItemBase)attachment.costume;
            var nonFungibleItem = attachment.itemUsable ?? (INonFungibleItem)attachment.costume;
            var popup           = Find <CombinationResultPopup>();
            var materialItems   = attachment.materials
                                  .Select(pair => new { pair, item = pair.Key })
                                  .Select(t => new CombinationMaterial(
                                              t.item,
                                              t.pair.Value,
                                              t.pair.Value,
                                              t.pair.Value))
                                  .ToList();
            var model = new UI.Model.CombinationResultPopup(new CountableItem(itemBase, 1))
            {
                isSuccess     = true,
                materialItems = materialItems
            };

            model.OnClickSubmit.Subscribe(_ =>
            {
                LocalLayerModifier.AddItem(avatarAddress, nonFungibleItem.ItemId, false);
                LocalLayerModifier.RemoveNewAttachmentMail(avatarAddress, mail.id, false);
                LocalLayerModifier.RemoveAttachmentResult(avatarAddress, mail.id);
                LocalLayerModifier.ModifyAvatarItemRequiredIndex(
                    avatarAddress,
                    nonFungibleItem.ItemId,
                    Game.Game.instance.Agent.BlockIndex);
            });
            popup.Pop(model);
        }