public void Init(int _idx, DBCraftingTable _runtimeTable) { idx = _idx; runtimeTable = _runtimeTable; state = new CLStateUpdator <State>(); state.Init(OnCheckState, OnSetState, OnUpdateState); selected.Subscribe(isOn => { if (isOn == true) { gameObject.CLGetComponent <RectTransform>("Image").DOScale(Vector3.one * 2.0f, 0.2f); } else { gameObject.CLGetComponent <RectTransform>("Image").DOScale(Vector3.one, 0.2f); } }); currentItem.Subscribe(item => { if (item == null) { gameObject.CLGetComponent <Image>("Image").sprite = null; } else { var staticItem = staticData.GetByID <GDCraftRecipeData>(item.recipeID).rewardArr[0].item; gameObject.CLGetComponent <Image>("Image").sprite = sprite.GetItem(staticItem.imageName); } }); }
void OnUpdate() { int lastUnlockableIdx = -1; for (int i = 0; i < recipeList.Count; i++) { var unlockedData = runtimeData.GetList <DBCraftingRecipeUnlock>().Where(x => x.recipeID == recipeList[i].id).FirstOrDefault(); if (unlockedData == null) { lastUnlockableIdx = i; break; } } //Its unlocked all.. if (lastUnlockableIdx == -1) { lastUnlockableIdx = 1000; } var curCnt = easy.GetItemCnt(resultItem.id); gameObject.CLGetComponent <Image>("ItemImage").sprite = sprite.GetItem(resultItem.imageName); if (idx < lastUnlockableIdx) { currState = State.Normal; gameObject.CLSetFormattedText("Text", string.Format("재고:{0}", curCnt)); gameObject.CLGetGameObject("Disabled").SetActive(false); } else if (idx == lastUnlockableIdx) { if (easy.UserInfo.userLv < currRecipe.unlockLv) { currState = State.Locked; gameObject.CLSetFormattedText("Text", string.Format("잠김\n레벨{0}", currRecipe.unlockLv + 1)); gameObject.CLGetGameObject("Disabled").SetActive(true); } else { currState = State.Unlockable; gameObject.CLSetFormattedText("Text", string.Format("해제가능\n레벨{0}", currRecipe.unlockLv + 1)); gameObject.CLGetGameObject("Disabled").SetActive(true); } } else { //This is hidden.. currState = State.Hide; gameObject.CLGetComponent <Image>("ItemImage").sprite = null; gameObject.CLGetGameObject("Disabled").SetActive(true); gameObject.CLSetFormattedText("Text", ""); } }
void UpdateInfo(GameObject go, int idx) { var customerStaticData = easy.StaticData.GetByID <GDCustomerData>(customerList[idx].customerID); var itemData = easy.StaticData.GetByID <GDItemData>(customerList[idx].itemID); var curItemCnt = easy.GetItemCnt(customerList[idx].itemID); go.CLGetComponent <Image>("Mover/Item/Image").sprite = sprite.GetItem(itemData.imageName); go.CLGetComponent <Image>("Mover/Image").sprite = sprite.GetThumbPeople(customerStaticData.image); if (curItemCnt < customerList[idx].itemCnt) { go.CLGetGameObject("Mover/Item/Check").SetActive(false); } else { go.CLGetGameObject("Mover/Item/Check").SetActive(true); } }
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"); }
void OnUpdateState(State currState) { switch (currState) { case State.Waiting: var item = staticData.GetByID <GDCraftRecipeData>(currentItem.recipeID); gameObject.CLGetComponent <Image>(string.Format("State/{0}/Image", currState)).sprite = sprite.GetItem(item.rewardArr[0].item.imageName); break; case State.Expand: gameObject.CLSetFormattedText("State/Expand/Text", staticTable.slotExpandReqGold); break; } }
void OnUpdateState(State currState) { switch (currState) { case State.Unhold: { var item = staticData.GetByID <GDCraftRecipeData>(currentMaking.recipeID); gameObject.CLGetComponent <Image>(string.Format("State/{0}/Image", currState)).sprite = sprite.GetItem(item.rewardArr[0].item.imageName); } break; case State.Making: { var item = staticData.GetByID <GDCraftRecipeData>(currentMaking.recipeID); gameObject.CLGetComponent <Image>(string.Format("State/{0}/Image", currState)).sprite = sprite.GetItem(item.rewardArr[0].item.imageName); gameObject.FISetSlider("State/Making/Slider", passedTime, currentMaking.reqTime); } break; } }