Exemplo n.º 1
0
//	int totalGold;
//	int totalExp;
    void BindInstance()
    {
        view = viewManager.CreateView("Popup/Customer", "Popup");
        requestScrollView = new CLScrollView();
        rewardScrollView  = new CLScrollView();
        reqList           = new List <Tuple <int, int> >();
        rewardList        = new List <Tuple <int, int> >();
    }
Exemplo n.º 2
0
    void BindInstances()
    {
        view = viewManager.CreateView("Popup/Order", "Popup");

        orderScrollView       = new CLScrollView();
        requestItemScrollView = new CLScrollView();
        rewardItemScrollView  = new CLScrollView();

        orderConfirmBtn = view.CLGetComponent <Button>("Window/Bottom/Button_OK");
        orderCancelBtn  = view.CLGetComponent <Button>("Window/Bottom/Button_Cancel");

        state = new CLStateUpdator <State>();
    }
Exemplo n.º 3
0
    void Start()
    {
        scrollView = new CLScrollView();
        scrollView.Init(gameObject,
                        (idx, go) => {
            go.CLOnPointerClickAsObservable().Subscribe(x => {
                popupManager.PushPopup <FIPopupCustomer>(customerList[idx]);
            });

            UpdateInfo(go, idx);
            runtimeData.GetObserver(typeof(DBItem))
            .Merge(runtimeData.GetObserver(typeof(DBCustomer)))
            .Subscribe(x => {
                UpdateInfo(go, idx);
            }).AddTo(go);
            ReactiveProperty <bool> isAvailable = new ReactiveProperty <bool>(false);
            isAvailable.Subscribe(x => {
                if (x == true)
                {
//						UpdateInfo(go,idx);
                    go.CLGetComponent <RectTransform>("Mover").DOAnchorPosX(0, 0.1f);
                }
                else
                {
                    go.CLGetComponent <RectTransform>("Mover").DOAnchorPosX(400, 0.1f);
                }
            });
            this.gameObject.CLUpdateAsObservable().Subscribe(x => {
//					Debug.Log(string.Format("Cur={0} Cus={1}",easy.ServerTime,customerList[idx].waitStartedTime + easy.GlobalInfo.customerRegenTime));
                if (customerList[idx].waitStartedTime + easy.GlobalInfo.customerRegenTime < easy.ServerTime)
                {
                    isAvailable.Value = true;
                }
                else
                {
                    isAvailable.Value = false;
                }
            });
        }, () => {
            return(customerList.Count);
        }
                        );
        customerList = runtimeData.GetList <DBCustomer>();
        scrollView.OnRefresh();
    }
Exemplo n.º 4
0
 void BindInstance()
 {
     scrollView = new CLScrollView();
 }
 void BindCompleteSlotInstance()
 {
     completeScrollView = new CLScrollView();
 }
Exemplo n.º 6
0
 void BindCategoryInstance()
 {
     categoryScrollView = new CLScrollView();
     recipeScrollView   = new CLScrollView();
 }
Exemplo n.º 7
0
 //Inner bindings..
 void BindInstances()
 {
     view       = viewManager.CreateView("Popup/Achievement", "Popup");
     scrollView = new CLScrollView();
 }
Exemplo n.º 8
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");
    }
Exemplo n.º 9
0
//	Subject<GDCraftRecipeData> recipeInfoObserv = new Subject<GDCraftRecipeData>();
    void BindRecipeInstance()
    {
        recipeInfoScrollView = new CLScrollView();
    }
Exemplo n.º 10
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");
    }
Exemplo n.º 11
0
 void BindCraftingAreaInstance()
 {
     remainingAreaScrollView = new CLScrollView();
 }