Exemple #1
0
 public void DoFakeLogin(System.Action onRes)
 {
     server.Get("enc/auth/logindid", JObject.FromObject(new{ deviceID = "hello" }))
     .SelectMany(x => server.Get("enc/sess/auth/userLogin", new JObject()))
     .SelectMany(x => server.Get("enc/sess/get/itemlist", new JObject()))
     .Subscribe(x => {
         onRes();
     });
 }
    public override void OnInitialize(params object[] args)
    {
        base.OnInitialize(args);

        var invenInfoObserv = server.Get("enc/sess/get/itemlist");
        var customerObserv  = server.Get("enc/sess/customer/getlist");
        var orderObserv     = server.Get("enc/sess/order/getlist");
        var achievObserv    = server.Get("enc/sess/achievement/getlist");
        var craftObserv     = server.Get("enc/sess/craft/getcraftinfo");
        var categoryObserv  = server.Get("enc/sess/craft/getcategoryinfo");
        var allReqObserv    = Observable.WhenAll(
            invenInfoObserv,
            customerObserv,
            orderObserv,
            achievObserv,
            craftObserv,
            categoryObserv
            );

        allReqObserv.Subscribe(x => {
            //Check all matches..
            bool isSuccess = true;
            foreach (var res in x)
            {
                if (res.Item1 != FIErr.Okay)
                {
                    isSuccess = false;
                    Debug.LogError("Err=" + res.Item1.ToString());
                    break;
                }
            }
            if (isSuccess == true)
            {
                PreloadFinished();
            }
        });
    }
    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();
    }