Пример #1
0
    void BindLogic()
    {
        view.CLOnClickAsObservable("Window/BottomBar/Button_Exit").Subscribe(_ => {
            popupManager.DestroyPopup(this);
        });
        scrollView.Init(view.CLGetGameObject("Window/ScrollView/Viewport/Content"),
                        (idx, sample) => {
            var item = dataList[idx];
            switch (item.Item1)
            {
            case TabType.Ingredient:
                SetIngredient(item.Item2, sample);
                break;

            case TabType.CraftingTable:
                SetCraftingTable(item.Item2, sample);
                break;

            case TabType.Interior:
                SetInterior(item.Item2, sample);
                break;

            case TabType.Gold:
                SetShopByType(item.Item1, item.Item2, sample);
                break;

            case TabType.Dia:
                SetShopByType(item.Item1, item.Item2, sample);
                break;

            case TabType.Package:
                SetShopByType(item.Item1, item.Item2, sample);
                break;

            case TabType.Free:
                SetShopByType(item.Item1, item.Item2, sample);
                break;
            }
        }, () => {
            return(dataList.Count);
        });
        toggle = view.CLAddToggleGroup("Window/ToggleGroup", selectedToggle => {
            OnRefresh((TabType)System.Enum.Parse(typeof(TabType), selectedToggle));
        }, "Ingredient");
    }
Пример #2
0
    void BindLogic()
    {
        //Quit
        var quitStream = view.CLOnPointerClickAsObservable("Back").Select(x => Unit.Default);

        quitStream.Merge(view.CLOnClickAsObservable("Window/Button_Exit")).Subscribe(x => {
            popupManager.DestroyPopup(this);
        });

        //ItemScrollView..
        scrollView = new CLScrollView();
        scrollView.Init(view.CLGetGameObject("Window/ScrollView/Viewport/Content"),
                        (idx, go) => {
            go.CLGetComponent <Image>("Item/Image").sprite = sprite.GetItem(itemList[idx].imageName);
            go.CLSetFormattedText("Item/Text", easy.GetItemCnt(itemList[idx].id));
            selectedItem.Subscribe(x => {
                if (x == itemList[idx])
                {
                    go.CLGetGameObject("Check").SetActive(true);
                }
                else
                {
                    go.CLGetGameObject("Check").SetActive(false);
                }
            }).AddTo(go);
            go.CLOnClickAsObservable().Subscribe(x => {
                if (selectedItem.Value == itemList[idx])
                {
                    selectedItem.Value = null;
                }
                else
                {
                    selectedItem.Value = itemList[idx];
                }
            });
        },
                        () => {
            return(itemList.Count);
        });

        //selected item..
        selectedItem.Subscribe(x => {
            if (x == null)
            {
                view.CLGetComponent <Button>("Window/BottomBar/Button_Confirm").interactable = false;
                view.CLGetGameObject("Window/BottomBar/Item/Inner").SetActive(false);
                view.CLGetGameObject("Window/BottomBar/Item/Empty").SetActive(true);
                view.CLGetComponent <Button>("Window/BottomBar/Item").interactable = false;
            }
            else
            {
                view.CLGetComponent <Button>("Window/BottomBar/Button_Confirm").interactable = true;
                view.CLGetGameObject("Window/BottomBar/Item/Inner").SetActive(true);
                view.CLGetGameObject("Window/BottomBar/Item/Empty").SetActive(false);
                view.CLGetComponent <Button>("Window/BottomBar/Item").interactable      = true;
                view.CLGetComponent <Image>("Window/BottomBar/Item/Inner/Image").sprite = sprite.GetItem(x.imageName);
            }
        });

        //Confirm..
        view.CLOnClickAsObservable("Window/BottomBar/Button_Confirm").Subscribe(x => {
            if (easy.GetItemCnt(GDInstKey.ItemData_searchTicket) <= 0)
            {
//				throw new System.NotImplementedException("Need popup!");
                popupManager.PushPopup <FIPopupDialog>("Need Ticket!");
            }
            else
            {
                popupManager.DestroyPopup(this);
            }
        });

        //Update ticket count..
        view.CLSetFormattedText("Window/TopBar/Empty", easy.GetItemCnt(GDInstKey.ItemData_searchTicket));
        runtimeData.OnChangeObserver
        .Where(x => x.Item2.GetType() == typeof(DBItem))
        .Select(x => x.Item2 as DBItem)
        .Where(x => x.itemID == GDInstKey.ItemData_searchTicket)
        .Subscribe(x => {
//				x.count
            view.CLSetFormattedText("Window/TopBar/Empty", x.count);
        }).AddTo(go);


        //Filter toggle..
        toggle = view.CLAddToggleGroup("Window/ToggleGroup", selectedToggle => {
            OnRefresh((Filter)System.Enum.Parse(typeof(Filter), selectedToggle));
        }, "All");
    }
Пример #3
0
    void PreloadFinished()
    {
        view = viewManager.CreateView("Popup/Storage", "Popup");
        view.CLOnPointerClickAsObservable("Back").Subscribe(x => {
            popupManager.DestroyPopup(this);
        });

        //Set Content items..
        itemScroll = new CLScrollView();
        itemScroll.Init(view.CLGetGameObject("Window/ScrollView/Viewport/Content"), (idx, go) => {
            var curItem  = itemList[idx];
            var baseItem = staticData.GetByID <GDItemData>(curItem.itemID);
            go.CLGetComponent <Image>("Image").sprite = sprite.GetItem(baseItem.imageName);
            go.CLSetFormattedText("NormalValue",
                                  baseItem.name,
                                  curItem.count
                                  );
            go.CLSetFormattedText("SellValue",
                                  baseItem.GetSellPrice()
                                  );

            var btn = go.CLGetComponent <Button>();
            btn.onClick.AsObservable().Subscribe(x => {
                if (itemToSell.ContainsKey(baseItem.id) == false)
                {
                    itemToSell.Add(baseItem.id, 0);
                }
                if (itemToSell[baseItem.id] < curItem.count)
                {
                    itemToSell[baseItem.id]++;
                    go.CLSetFormattedText("Sell/Value",
                                          itemToSell.ContainsKey(baseItem.id) == false ? 0 : itemToSell[baseItem.id],
                                          curItem.count
                                          );
                }
            });
            isSell.Subscribe(x => {
                if (x == true)
                {
                    go.CLGetGameObject("NormalValue").SetActive(false);
                    go.CLGetGameObject("SellValue").SetActive(true);
                    go.CLGetGameObject("NotSell").SetActive(false);
                    go.CLGetGameObject("Sell").SetActive(true);

                    go.CLSetFormattedText("Sell/Value",
                                          itemToSell.ContainsKey(baseItem.id) == false ? 0 : itemToSell[baseItem.id],
                                          curItem.count
                                          );
                    btn.interactable = true;
                }
                else
                {
                    go.CLGetGameObject("NormalValue").SetActive(true);
                    go.CLGetGameObject("SellValue").SetActive(false);
                    go.CLGetGameObject("NotSell").SetActive(true);
                    go.CLGetGameObject("Sell").SetActive(false);

                    go.CLSetFormattedText("NotSell/Value",
                                          curItem.count
                                          );

                    btn.interactable = false;
                }
            }).AddTo(go);
        }, () => {
            return(itemList.Count);
        });
        //		progressText = CLLabelFormatter.CreateFormatter(view.CLGetComponent<Text>("Window/TopBar/ProgressBar/Text"));



        upgradeBtn    = view.CLGetComponent <Button>("Window/TopBar/Button_Upgrade");
        sellModeBtn   = view.CLGetComponent <Button>("Window/BottomBar/NotSellMode/Button_Sell");
        sellCancelBtn = view.CLGetComponent <Button>("Window/BottomBar/SellMode/Button_Cancel");
        sellBtn       = view.CLGetComponent <Button>("Window/BottomBar/SellMode/Button_Sell");

        sellModeGameObject    = view.CLGetGameObject("Window/BottomBar/SellMode");
        notSellModeGameObject = view.CLGetGameObject("Window/BottomBar/NotSellMode");

        int totalMoney = 0;

        isSell.Subscribe(x => {
            if (x == false)
            {
                sellModeGameObject.SetActive(false);
                notSellModeGameObject.SetActive(true);
            }
            else
            {
                sellModeGameObject.SetActive(true);
                notSellModeGameObject.SetActive(false);
                itemToSell.Clear();
            }
        });

        Observable.EveryGameObjectUpdate().Subscribe(x => {
            totalMoney = 0;
            foreach (var item in itemToSell)
            {
                var baseItem = staticData.GetByID <GDItemData>(item.Key);
                totalMoney  += baseItem.GetSellPrice(item.Value);
            }
            view.CLGetComponent <Text>("Window/BottomBar/SellMode/Value").text = totalMoney.ToString();
            if (totalMoney <= 0)
            {
                sellBtn.interactable = false;
            }
            else
            {
                sellBtn.interactable = true;
            }
        }).AddTo(go);

        sellModeBtn.OnClickAsObservable().Subscribe(x => {
            isSell.Value = true;
        });
        sellCancelBtn.OnClickAsObservable().Subscribe(x => {
            isSell.Value = false;
        });
        sellBtn.OnClickAsObservable().Subscribe(x => {
            var arr    = new JArray();
            var prop   = new JProperty("listOfSellItems", arr);
            var reqObj = new JObject(prop);
            foreach (var item in itemToSell)
            {
                arr.Add(new JObject(
                            new JProperty("uid", item.Key),
                            new JProperty("cnt", item.Value)
                            )
                        );
            }
            server.Request("enc/sess/storage/sellitem", reqObj, null, (err, onRes) => {
                Debug.Log("Success!");
                isSell.Value = false;
                toggle.Refresh();
            });
        });



        toggle = view.CLAddToggleGroup("Window/ToggleGroup", selectedToggle => {
            OnRefresh((Filter)System.Enum.Parse(typeof(Filter), selectedToggle));
        }, "All");
    }