void BindRecipeLogic() { view.CLOnClickAsObservable("Window/RecipeInfo/State/Show/Button_Create").Subscribe(_ => { easy.IsResourceAvailable(selectedRecipeObserv.Value.reqItemArr, () => { server.GetWithErrHandling("enc/sess/craft/insertrecipe", JObject.FromObject( new{ tableUID = runtimeTable.uid, recipeID = selectedRecipeObserv.Value.id })) .Subscribe(x => { //DoNothing.. }); }); }); recipeInfoScrollView.Init(view.CLGetGameObject("Window/RecipeInfo/State/Show/IngredientInfo/Grid"), (idx, sample) => { var staticSingle = staticData.GetByID <GDItemData>(recipeInfoDataList[idx].Item1); var curCnt = easy.GetItemCnt(staticSingle.id); sample.CLSetFormattedText("Text" , recipeInfoDataList[idx].Item2 , curCnt); runtimeData.GetAfterUpdateObserver <DBItem>() .Where(x => x.itemID == staticSingle.id) .Subscribe(_ => { curCnt = easy.GetItemCnt(staticSingle.id); sample.CLSetFormattedText("Text" , curCnt , recipeInfoDataList[idx].Item2); }).AddTo(sample); sample.CLGetComponent <Image>("Image").sprite = sprite.GetItem(staticSingle.imageName); }, () => { return(recipeInfoDataList.Count); }); selectedRecipeObserv.Subscribe(data => { if (data == null) { view.CLGetGameObject("Window/RecipeInfo/State/Waiting").SetActive(true); view.CLGetGameObject("Window/RecipeInfo/State/Show").SetActive(false); // recipeInfoDataList = data.reqItemArr.Select(x=>Tuple.Create<int,int>( x.item.id, x.cnt )).ToList(); // recipeInfoScrollView.OnRefresh(); return; } view.CLGetGameObject("Window/RecipeInfo/State/Waiting").SetActive(false); view.CLGetGameObject("Window/RecipeInfo/State/Show").SetActive(true); view.CLGetComponent <Image>("Window/RecipeInfo/State/Show/Item").sprite = sprite.GetItem(data.rewardArr[0].item.imageName); view.CLSetFormattedText("Window/RecipeInfo/State/Show/ItemName", data.rewardArr[0].item.name); view.CLSetFormattedText("Window/RecipeInfo/State/Show/IngredientInfo/Time", data.reqTime); //Update... recipeInfoDataList = data.reqItemArr.Select(x => Tuple.Create <int, int>(x.item.id, x.cnt)).ToList(); recipeInfoScrollView.OnRefresh(); }).AddTo(this.go); // recipeInfoObserv.OnNext(null); }
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"); }
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(); }
void BindLogic() { scrollView.Init(gameObject, (idx, go) => { var staticTable = staticData.GetByID <GDCraftingTable>(tableList[idx].craftingTableID); go.CLOnClickAsObservable().Subscribe(_ => { popupManager.ChangePopup <FIPopupCraft>(tableList[idx]); }); go.CLSetFormattedText("Text", staticTable.name); }, () => { return(tableList.Count); }); runtimeData.GetAfterTotalUpdateObserver().Subscribe(x => { Debug.Log("TableUpdated!"); OnRefresh(); }).AddTo(this.gameObject); OnRefresh(); }
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; } }
void BindLogic() { //Quit view.CLOnPointerClickAsObservable("Back").Select(x => Unit.Default).Subscribe(_ => { popupManager.DestroyPopup(this); }); scrollView.Init(view.CLGetGameObject("Window/ScrollView/Viewport/Content"), (idx, go) => { var singleData = dataList[idx]; go.CLSetFormattedText("Name", singleData.name); if (singleData.reqAchiev == GDAchievementType.Invalid) { go.CLGetGameObject("Button_Reward").SetActive(false); go.CLGetGameObject("Slider").SetActive(false); go.CLSetFormattedText("Cond", "완료됨"); return; } var baseDesc = staticData.GetList <GDAchievementTypeDesc>().Where(x => x.type == singleData.reqAchiev).FirstOrDefault().desc; go.CLSetFormattedText("Cond", string.Format(baseDesc, singleData.reqAchievCnt)); int curCnt = 0; var curAchivCntData = runtimeData.GetList <DBAchievementTypeCount>().Where(x => x.type == singleData.reqAchiev).FirstOrDefault(); if (curAchivCntData != null) { curCnt = curAchivCntData.cnt; } go.CLSetFormattedText("Slider/Text", curCnt, singleData.reqAchievCnt); go.CLGetComponent <Slider>("Slider").value = (float)curCnt / (float)singleData.reqAchievCnt; if (curCnt >= singleData.reqAchievCnt) { go.CLGetComponent <Button>("Button_Reward").interactable = true; } else { go.CLGetComponent <Button>("Button_Reward").interactable = false; } var diaItem = staticData.GetByID <GDItemData>(GDInstKey.ItemData_diaPoint); go.CLGetComponent <Image>("Button_Reward/Item/Image").sprite = sprite.GetItem(diaItem.imageName); go.CLSetFormattedText("Button_Reward/Item/Text", singleData.rewardDiaCnt); go.CLOnThrottleClickAsObservable("Button_Reward").Subscribe(_ => { server.Get("enc/sess/achievement/collect", JObject.FromObject(new{ id = singleData.id })) .Subscribe(x => { // popupManager.PushPopup<FIPopupDialog>("업적 보상 받음"); var notice = popupManager.PushPopup <FIPopupDialog>(); notice.SetNoticePopup("업적 보상 받음"); OnRefresh(); }); }); // runtimeData.GetObserver<DBAchievementTypeCount>() // .Where(x=>x.Item2.type==singleData.reqAchiev) // .Select(x=>x.Item2) // .Subscribe(x=>{ // // }).AddTo(go); }, () => { return(dataList.Count); }); OnRefresh(); }
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"); }
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"); }