// ReactiveProperty<DBCraftingItem> currentMaking = new ReactiveProperty<DBCraftingItem>(); public void Init(DBCraftingTable _table) { runtimeTable = _table; staticTable = staticData.GetByID <GDCraftingTable>(runtimeTable.craftingTableID); state = new CLStateUpdator <State>(); state.Init(OnCheckState, OnSetState, OnUpdateState); }
public void Init(DBCraftingTable _table, int _idx) { runtimeTable = _table; idx = _idx; staticTable = staticData.GetByID <GDCraftingTable>(runtimeTable.craftingTableID); state = new CLStateUpdator <State>(); state.Init(OnCheckState, OnSetState, OnUpdateState); gameObject.CLOnClickAsObservable("State/Expand").Subscribe(_ => { //Popup.. }); }
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); } }); }
public override void OnInitialize(params object[] args) { base.OnInitialize(args); runtimeTable = args[0] as DBCraftingTable; staticTable = staticData.GetByID <GDCraftingTable>(runtimeTable.craftingTableID); view = viewManager.CreateView("Popup/Craft", "Popup"); BindInstance(); BindLogic(); }
//Ref public static T GetRefFromAttrib <T>(this XElement xml, GDManager manager, string name) where T : GDDataBase { var value = xml.TryGetAttrib(name); if (value == null) { throw new Exception("There is no attrib value!"); } int instID = System.Convert.ToInt32(value.Value); if (instID == 0) { return(null); } return(manager.GetByID <T>(instID)); }
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(); }
public static List <T> GetRefFromAttribArr <T>(this XElement xml, GDManager manager, string name) where T : GDDataBase { List <T> tempList = new List <T>(); var value = xml.TryGetAttrib(name); if (value == null) { return(tempList); } foreach (var item in value.Elements()) { int instID = System.Convert.ToInt32(item.Value); tempList.Add(manager.GetByID <T>(instID)); } return(tempList); }
public void SetLackResourcePopup(GDManager staticData, Tuple <int, int>[] lackList, System.Action <FIPopupDialog, int> onConfirm) { Title = "재료부족"; System.Text.StringBuilder builder = new System.Text.StringBuilder(); builder.AppendLine("재료를 구매할까요?\n"); int totalDia = 0; foreach (var item in lackList) { var itemData = staticData.GetByID <GDItemData>(item.Item1); totalDia += itemData.diaPrice * item.Item2; builder.AppendLine(string.Format("item_{0}{1}", itemData.imageName, item.Item2)); } Desc = builder.ToString(); SetBtnCnt(2); BtnOneText = "item_diaPoint" + totalDia.ToString(); BtnTwoText = "취소"; BtnOneObservable.Subscribe(_ => { onConfirm(this, totalDia); }); BtnTwoObservable.Subscribe(_ => { DestroyPopup(); }); }
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; } }
public GDItemData GetItem(GDManager staticData) { return(staticData.GetByID <GDItemData>(itemID)); }
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 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"); }