public void Init(List <GDCraftRecipeData> _recipeList, int _idx, ReactiveProperty <GDCraftRecipeData> _selectedRecipeObserv)
        {
            recipeList           = _recipeList;
            idx                  = _idx;
            selectedRecipeObserv = _selectedRecipeObserv;
            currRecipe           = recipeList[idx];
            resultItem           = currRecipe.rewardArr[0].item;

            gameObject.CLOnClickAsObservable().Subscribe(_ => {
                switch (currState)
                {
                case State.Normal:
                    if (selectedRecipeObserv.Value == currRecipe)
                    {
                        selectedRecipeObserv.Value = null;
                    }
                    else
                    {
                        selectedRecipeObserv.Value = currRecipe;
                    }
                    break;

                case State.Locked:

                    break;

                case State.Unlockable:
                    easy.CanIPerformProcessWithCostItem(
                        "레시피 언락",
                        "다음 재료가 듭니다",
                        Tuple.Create <int, int>(GDInstKey.ItemData_goldPoint, currRecipe.unlockReqGold),
                        () => {
                        server.GetWithErrHandling("enc/sess/craft/unlockrecipe", JObject.FromObject(new{ id = currRecipe.id }))
                        .Subscribe(x => {
                            //Success!
                            popupManager.PushPopup <FIPopupDialog>().SetNoticePopup("언락하였습니다!");
                        });
                    });
                    break;
                }
            });

            selectedRecipeObserv.Subscribe(item => {
                if (item == currRecipe)
                {
                    gameObject.CLGetGameObject("Selected").SetActive(true);
                }
                else
                {
                    gameObject.CLGetGameObject("Selected").SetActive(false);
                }
            }).AddTo(gameObject);

            runtimeData.GetAfterTotalUpdateObserver().Subscribe(_ => {
                OnUpdate();
            }).AddTo(gameObject);
            OnUpdate();
        }
示例#2
0
    void BindInstance()
    {
//		scrollView = new CLScrollView();
        var backObserv = view.CLOnPointerClickAsObservable("Back").Select(x => Unit.Default);

        view.CLOnClickAsObservable("Window/CraftingArea/Button_Exit").Merge(backObserv)
        .Subscribe(_ => {
            popupManager.DestroyPopup(this);
        });
        view.CLOnClickAsObservable("Window/CraftingArea/Button_Sell").Subscribe(_ => {
            if (runtimeData.GetList <DBCraftingTable>().Count <= 1)
            {
                popupManager.PushPopup <FIPopupDialog>().SetErrorPopup("하나남은 작업댄 팔수없습니다");
                return;
            }
            var currMakingList = runtimeData.GetList <DBCraftingItem>().Where(x => x.tableUID == runtimeTable.uid).ToList();
            if (currMakingList.Count > 0)
            {
                popupManager.PushPopup <FIPopupDialog>().SetErrorPopup("만들고 있는 아이템이 있습니다");
                return;
            }

            //Do Selling..
            var sellPopup = popupManager.PushPopup <FIPopupDialog>();
            sellPopup.SetChoosePopup(
                "알림",
                string.Format("item_goldPoint{0}에 작업대를 파시겠습니까?", staticTable.sellPrice),
                "확인",
                "취소",
                currPopup => {
                server.GetWithErrHandling("enc/sess/craft/selltable", JObject.FromObject(new{ uid = runtimeTable.uid }))
                .Subscribe(x => {
                    sellPopup.DestroyPopup();
                });
            });
        });
        BindCategoryInstance();
        BindCraftingAreaInstance();
        BindCompleteSlotInstance();
        BindRecipeInstance();
    }
        public void OnEndDrag(PointerEventData eventData)
        {
            if (collectDic == null)
            {
                return;
            }
            var toData  = collectDic.Select(x => x.Key).ToArray();
            var dataObj = JObject.FromObject(new{ uidArr = toData });

            server.GetWithErrHandling("enc/sess/craft/collect", dataObj)
            .Subscribe(_ => {
                foreach (var item in collectDic)
                {
                    item.Value.ResetSelected();
                }
                collectDic = null;
            });

//			foreach(var item in collectDic){
//				item.Value.ResetSelected();
//			}
//			collectDic = null;
        }
示例#4
0
    void BindLogic()
    {
        view.CLOnClickAsObservable("Window/Button_Wait").Subscribe(_ => {
//			popupManager.PopPopup();
            popupManager.DestroyPopup(this);
        });
        view.CLOnThrottleClickAsObservable("Window/Button_GoAway").Subscribe(_ => {
            server.GetWithErrHandling("enc/sess/customer/dispose", JObject.FromObject(new{ uid = customerData.uid }))
            .Subscribe(x => {
//					this.Dispose();
                popupManager.DestroyPopup(this);
            });
        });
        view.CLOnThrottleClickAsObservable("Window/Bottom/Button_Sell").Subscribe(_ => {
            if (easy.CanDisposeItems(reqList.ToArray()) == false)
            {
                var notice = popupManager.PushPopup <FIPopupDialog>();
                notice.SetNoticePopup("재료가 부족합니다");
                return;
            }
            server.GetWithErrHandling("enc/sess/customer/accept", JObject.FromObject(new{ uid = customerData.uid }))
            .Subscribe(x => {
                popupManager.DestroyPopup(this);
            });
        });
        view.CLOnClickAsObservable("Window/Bottom/Button_Content").Subscribe(_ => {
        });

        var customerStaticData = staticData.GetByID <GDCustomerData>(customerData.customerID);

        view.CLSetFormattedText("Window/Name", customerStaticData.name);
        view.CLSetFormattedText("Window/MessageBox/Text", customerStaticData.speechArr[0]);
        view.CLGetComponent <Image>("Window/People").sprite = sprite.GetPeople(customerStaticData.image);


        reqList.Add(Tuple.Create <int, int>(customerData.itemID, customerData.itemCnt));

        int totalGold = 0;
        int totalExp  = 3;

        foreach (var item in reqList)
        {
            var itemData = staticData.GetByID <GDItemData>(item.Item1);
//			int curItemCnt = easy.GetItemCnt( item.Item1 );
            totalGold += itemData.GetCustomerPrice(customerData.itemCnt);
        }
        rewardList.Add(Tuple.Create <int, int>(GDInstKey.ItemData_goldPoint, totalGold));
        rewardList.Add(Tuple.Create <int, int>(GDInstKey.ItemData_userExp, totalExp));

        requestScrollView.Init(view.CLGetGameObject("Window/ItemInfo/RequestGrid"),
                               (idx, go) => {
            var itemData = staticData.GetByID <GDItemData>(reqList[idx].Item1);
            int curCnt   = easy.GetItemCnt(reqList[idx].Item1);
            go.CLGetComponent <Image>("Item/Image").sprite = sprite.GetItem(itemData.imageName);
            go.CLSetFormattedText("Cnt", curCnt, reqList[idx].Item2);
        }, () => reqList.Count
                               );
        rewardScrollView.Init(view.CLGetGameObject("Window/ItemInfo/RewardGrid"),
                              (idx, go) => {
            var itemData = staticData.GetByID <GDItemData>(rewardList[idx].Item1);
            go.CLGetComponent <Image>("Item/Image").sprite = sprite.GetItem(itemData.imageName);
            go.CLSetFormattedText("Cnt", rewardList[idx].Item2);
        }, () => rewardList.Count
                              );

        requestScrollView.OnRefresh();
        rewardScrollView.OnRefresh();

        if (easy.CanDisposeItems(reqList.ToArray()) == false)
        {
            view.CLGetComponent <Button>("Window/Bottom/Button_Sell").interactable = false;
            //				throw new System.NotImplementedException("Need lack item popup!");
//			popupManager.PushPopup<FIPopupDialog>("Not enough item!");
            return;
        }
    }