// 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(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 void Init(DBOrder _order) { order = _order; state = new CLStateUpdator <State>(); state.Init( OnCheckState, OnChangeState, 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.. }); }
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>(); }
void SetShopByType(TabType type, int id, GameObject go) { var single = staticData.GetByID <GDShopItem>(id); go.CLSetFormattedText("Name", single.name); go.CLSetFormattedText("Desc/Text", single.desc); switch (type) { case TabType.Gold: case TabType.Dia: { go.CLGetComponent <Text>("Button/Text").text = string.Format("구매\n{0}", single.price); go.CLOnClickAsObservable("Button").Subscribe(_ => { }); } break; case TabType.Free: case TabType.Package: { //Check cooltime! DBShopItemCoolTime serverCoolTime = null; CLStateUpdator <CoolState> state = new CLStateUpdator <CoolState>(); go.CLOnClickAsObservable("Button").Subscribe(_ => { //Buy code.. switch (type) { case TabType.Package: Debug.Log("Buy Package"); break; case TabType.Free: Debug.Log("Buy Free"); break; } }); state.Init(() => { serverCoolTime = runtimeData.GetList <DBShopItemCoolTime>() .Where(x => x.shopItemID == id) .FirstOrDefault(); if (serverCoolTime != null) { if (serverCoolTime.endTime > easy.ServerTime) { //Its cooltime!.. var remain = serverCoolTime.endTime - easy.ServerTime; if (remain > System.TimeSpan.FromDays(365)) { return(CoolState.CannotBuy); } return(CoolState.CoolTime); } } return(CoolState.CanBuy); }, (before, after) => { switch (after) { case CoolState.CanBuy: go.CLGetComponent <Button>("Button").interactable = true; if (type == TabType.Package) { go.CLGetComponent <Text>("Button/Text").text = string.Format("구매\n{0}", single.price); } else { go.CLGetComponent <Text>("Button/Text").text = single.price; } break; case CoolState.CoolTime: go.CLGetComponent <Button>("Button").interactable = false; break; case CoolState.CannotBuy: go.CLGetComponent <Button>("Button").interactable = false; go.CLGetComponent <Text>("Button/Text").text = "구매함"; break; } }, (cur) => { switch (cur) { case CoolState.CoolTime: var timeSpan = serverCoolTime.endTime - easy.ServerTime; go.CLGetComponent <Text>("Button/Text").text = string.Format("쿨타임\n{0}", timeSpan); break; } }); go.CLUpdateAsObservable().Subscribe(x => { state.Update(); }); } break; } }
void BindLogic() { //Quit var quitStream = view.CLOnPointerClickAsObservable("Back").Select(x => Unit.Default); quitStream.Merge(view.CLOnClickAsObservable("Window/Button_Exit")).Subscribe(x => { popupManager.DestroyPopup(this); }); orderScrollView.Init(view.CLGetGameObject("Window/OrderWindow/Content"), (idx, go) => { go.name = idx.ToString(); var process = go.AddComponent <OrderProcess>(); container.Inject(process); process.Init(orderList[idx]); go.CLOnClickAsObservable().Subscribe(x => { if (selectedIdx.Value == idx) { selectedIdx.Value = -1; } else { selectedIdx.Value = idx; } }); }, () => { return(orderList.Count); }); requestItemScrollView.Init(view.CLGetGameObject("Window/InfoWindow/State/Selected/RequireContent"), (idx, go) => { int curCnt = easy.GetItemCnt(orderReqItemList[idx].itemID); int needCnt = orderReqItemList[idx].itemCnt; string color = "green"; if (curCnt < needCnt) { color = "red"; } go.CLSetFormattedText("Value", curCnt, needCnt, color, "white"); go.CLGetComponent <Image>("Image").sprite = sprite.GetItem(orderReqItemList[idx].GetItem(staticData).imageName); }, () => { return(orderReqItemList.Count); }); rewardItemScrollView.Init(view.CLGetGameObject("Window/InfoWindow/State/Selected/RewardContent"), (idx, go) => { go.CLSetFormattedText("Value", orderRewardItemList[idx].Item2); go.CLGetComponent <Image>("Image").sprite = sprite.GetItem(orderRewardItemList[idx].Item1.imageName); }, () => { return(orderRewardItemList.Count); }); state = new CLStateUpdator <State>(); state.Init(() => { if (selectedIdx.Value == -1) { return(State.Nothing); } if (orderList[selectedIdx.Value].waitStartedTime + easy.GlobalInfo.orderRegenTime < easy.ServerTime) { return(State.Selected); } return(State.Selected_ButWaiting); }, (before, after) => { if (before != State.Invalid) { view.CLGetGameObject("Window/InfoWindow/State/" + before.ToString()).SetActive(false); } view.CLGetGameObject("Window/InfoWindow/State/" + after.ToString()).SetActive(true); // switch (after) { case State.Selected: SetDataReqReward(selectedIdx.Value); orderConfirmBtn.interactable = true; orderCancelBtn.interactable = true; break; case State.Selected_ButWaiting: break; default: orderConfirmBtn.interactable = false; orderCancelBtn.interactable = false; break; } }, (current) => { switch (current) { case State.Selected: case State.Selected_ButWaiting: break; case State.Nothing: break; } }); Observable.EveryGameObjectUpdate().Subscribe(x => { state.Update(); }).AddTo(go); int beforeSelected = -1; selectedIdx.Subscribe(x => { if (beforeSelected != -1) { view.CLGetGameObject($"Window/OrderWindow/Content/{beforeSelected}/Selected").SetActive(false); } if (x != -1) { view.CLGetGameObject($"Window/OrderWindow/Content/{x}/Selected").SetActive(true); SetDataReqReward(x); } beforeSelected = x; }); orderConfirmBtn.onClick.AsObservable().Subscribe(unit => { if (selectedIdx.Value == -1) { throw new System.NotImplementedException("Need popup"); } if (orderList[selectedIdx.Value].waitStartedTime + easy.GlobalInfo.orderRegenTime > easy.ServerTime) { throw new System.NotImplementedException("Need popup"); } //Check can dispose item.. var listOfReqItem = runtimeData.GetList <DBOrderItem>() .Where(x => x.orderUID == orderList[selectedIdx.Value].uid) .Select(x => Tuple.Create <int, int>(x.itemID, x.itemCnt)) .ToArray(); if (easy.CanDisposeItems(listOfReqItem) == false) { throw new System.NotImplementedException("Need popup"); } server.Get("enc/sess/order/accept", JObject.FromObject(new{ uid = orderList[selectedIdx.Value].uid }) ).Subscribe(x => { selectedIdx.Value = -1; }); }); orderCancelBtn.onClick.AsObservable().Subscribe(unit => { if (selectedIdx.Value == -1) { throw new System.NotImplementedException("Need popup"); } if (orderList[selectedIdx.Value].waitStartedTime + easy.GlobalInfo.orderRegenTime > easy.ServerTime) { throw new System.NotImplementedException("Need popup"); } server.Get("enc/sess/order/dispose", JObject.FromObject(new{ uid = orderList[selectedIdx.Value].uid }) ).Subscribe(x => { selectedIdx.Value = -1; }); }); OnRefresh(); }