Exemple #1
0
 public static object AddVideoProduct(string path, Unity.UIWidgets.widgets.BuildContext context)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) =>
     {
         GameObject instance = GameObject.Instantiate(Globals.instance.templetes[2]);
         instance.tag = "video";
         instance.SetActive(false);
         instance.GetComponentInChildren <VideoPlayer>().url = "File:////" + path;
         Prop product = new Prop {
             type = (int)ProductType.Video, instance = instance
         };
         if (getState().settingState.products.Count < 3)
         {
             dispatcher.dispatch(new AddProductAction {
                 product = product
             });
             dispatcher.dispatch(new ChangeAppearStateAction {
                 state = true, index = getState().settingState.products.Count - 1
             });
             return 0;
         }
         dispatcher.dispatch(new ChangeProductIndexAction());
         dispatcher.dispatch(new ChangeAppearStateAction {
             state = false, index = 2
         });
         if (Window.instance == null)
         {
             Debug.Log("null");
         }
         using (Unity.UIWidgets.widgets.WindowProvider.of(context).getScope())
         {
             Window.instance.startCoroutine(
                 TapOnUtils.WaitSomeTime(
                     time: 0.3f,
                     after: () =>
             {
                 Debug.Log("xs");
                 dispatcher.dispatch(new AddProductAction {
                     product = product
                 });
                 Window.instance.startCoroutine(
                     TapOnUtils.WaitSomeTime(
                         time: 0.3f,
                         after: (() =>
                                 { dispatcher.dispatch(new ChangeAppearStateAction {
                         state = true, index = 2
                     }); })));
             }
                     ));
         }
         return 0;
     }));
 }
Exemple #2
0
 public static object AddTextProduct(string text)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) =>
     {
         GameObject instance = GameObject.Instantiate(Globals.instance.templetes[0]);
         instance.tag = "word";
         instance.SetActive(false);
         TextMesh tm = instance.GetComponentInChildren <TextMesh>();
         tm.text = text;
         Prop product = new Prop {
             type = (int)ProductType.Text, text = text, instance = instance
         };
         if (getState().settingState.products.Count < 3)
         {
             dispatcher.dispatch(new AddProductAction {
                 product = product
             });
             dispatcher.dispatch(new ChangeAppearStateAction {
                 state = true, index = getState().settingState.products.Count - 1
             });
             return 0;
         }
         dispatcher.dispatch(new ChangeProductIndexAction());
         dispatcher.dispatch(new ChangeAppearStateAction {
             state = false, index = 2
         });
         Window.instance.startCoroutine(
             TapOnUtils.WaitSomeTime(
                 time: 0.3f,
                 after: () =>
         {
             dispatcher.dispatch(new AddProductAction {
                 product = product
             });
             Window.instance.startCoroutine(
                 TapOnUtils.WaitSomeTime(
                     time: 0.3f,
                     after: (() =>
                             { dispatcher.dispatch(new ChangeAppearStateAction {
                     state = true, index = 2
                 }); })));
         }
                 ));
         return 0;
     }));
 }
Exemple #3
0
 public static object AddModelProduct(GameObject model, string id)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) =>
     {
         model.tag = "model";
         BmobModel m = new BmobModel();
         m.objectId = id;
         Prop product = new Prop {
             type = (int)ProductType.Model, model = m, instance = model
         };
         if (getState().settingState.products.Count < 3)
         {
             dispatcher.dispatch(new AddProductAction {
                 product = product
             });
             dispatcher.dispatch(new ChangeAppearStateAction {
                 state = true, index = getState().settingState.products.Count - 1
             });
             return 0;
         }
         dispatcher.dispatch(new ChangeProductIndexAction());
         dispatcher.dispatch(new ChangeAppearStateAction {
             state = false, index = 2
         });
         Window.instance.startCoroutine(
             TapOnUtils.WaitSomeTime(
                 time: 0.3f,
                 after: () =>
         {
             dispatcher.dispatch(new AddProductAction {
                 product = product
             });
             Window.instance.startCoroutine(
                 TapOnUtils.WaitSomeTime(
                     time: 0.3f,
                     after: (() =>
                             { dispatcher.dispatch(new ChangeAppearStateAction {
                     state = true, index = 2
                 }); })));
         }
                 ));
         return 0;
     }));
 }
Exemple #4
0
        public static object AddImageProduct(Texture2D texture, Unity.UIWidgets.widgets.BuildContext context)
        {
            return(new ThunkAction <AppState>((dispatcher, getState) =>
            {
                GameObject instance = GameObject.Instantiate(Globals.instance.templetes[1]);
                instance.tag = "texture";
                instance.SetActive(false);
                Renderer rd = instance.GetComponentInChildren <Renderer>();

                UnityEngine.Transform tf = instance.transform.Find("Cube");
                if (saveImgTf)
                {
                    saveImgTf = false;
                    imageTF = instance.transform.Find("Cube").localScale;
                    ratio = imageTF.y * 1.0f / imageTF.x;
                }
                float ratio_tex = texture.height * 1.0f / texture.width;
                Debug.Log("ratio: " + ratio + " ratio_text: " + ratio_tex);

                tf.localScale = ratio_tex > ratio ?
                                new Vector3(ratio / ratio_tex * imageTF.x, imageTF.y, imageTF.z) :
                                new Vector3(imageTF.x, ratio_tex / ratio * imageTF.y, imageTF.z);

                rd.material.mainTexture = texture;
                Prop product = new Prop {
                    type = (int)ProductType.Picture, texture_byte = texture.EncodeToPNG(), instance = instance
                };
                if (getState().settingState.products.Count < 3)
                {
                    dispatcher.dispatch(new AddProductAction {
                        product = product
                    });
                    dispatcher.dispatch(new ChangeAppearStateAction {
                        state = true, index = getState().settingState.products.Count - 1
                    });
                    return 0;
                }
                dispatcher.dispatch(new ChangeProductIndexAction());
                dispatcher.dispatch(new ChangeAppearStateAction {
                    state = false, index = 2
                });
                if (Window.instance == null)
                {
                    Debug.Log("null");
                }
                using (Unity.UIWidgets.widgets.WindowProvider.of(context).getScope())
                {
                    Window.instance.startCoroutine(
                        TapOnUtils.WaitSomeTime(
                            time: 0.3f,
                            after: () =>
                    {
                        Debug.Log("xs");
                        dispatcher.dispatch(new AddProductAction {
                            product = product
                        });
                        Window.instance.startCoroutine(
                            TapOnUtils.WaitSomeTime(
                                time: 0.3f,
                                after: (() =>
                                        { dispatcher.dispatch(new ChangeAppearStateAction {
                                state = true, index = 2
                            }); })));
                    }
                            ));
                }
                return 0;
            }));
        }
Exemple #5
0
        /*public static IEnumerator getAllProps()
         * {
         *
         * }*/
        public static async void addMarktoServer(Mark mark)
        {
            CreateCallbackData callback_mark = await Bmob.CreateTaskAsync(Mark.table_name, mark);

            if (callback_mark == null || callback_mark.objectId == null || callback_mark.objectId.Length == 0)
            {
                Debug.LogError("BmobRrror: Mark hasn't upload!");
                return;
            }
            Globals.instance.uploading = false;
            ((Unity.UIWidgets.widgets.Element)Globals.instance.nowContext).markNeedsBuild();

            using (Unity.UIWidgets.widgets.WindowProvider.of(Globals.instance.nowContext).getScope())
            {
                Window.instance.startCoroutine(
                    TapOnUtils.WaitSomeTime(
                        time: 0.5f,
                        after: () =>
                {
                    Debug.Log("in back home!");
                    Globals.instance.returnHome(() => { Globals.instance.returnMap(); });
                })
                    );
                Window.instance.startCoroutine(
                    TapOnUtils.upLoadFile(
                        "img_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".jpg",
                        "application/x-jpg",
                        mark.snapShot_byte,
                        wr =>
                {
                    Restful_FileUpLoadCallBack t = TapOnUtils.fileUpLoadCallBackfromJson(wr.downloadHandler.text);
                    BmobFile bf = new BmobFile {
                        filename = t.filename, url = t.url, group = t.cdnname
                    };
                    Mark m = new Mark {
                        snapShot = bf
                    };
                    Bmob.Update(
                        Mark.table_name,
                        callback_mark.objectId,
                        m,
                        (resp, exception) =>
                    {
                        if (exception != null)
                        {
                            Debug.Log("修改失败, 失败原因为: " + exception.Message);
                            return;
                        }

                        Debug.Log("修改成功, @" + resp.updatedAt);
                    });
                }));
                Window.instance.startCoroutine(
                    TapOnUtils.upLoadFile(
                        "Props_" + DateTime.Now.ToString("yyyy-MM-,") + ".json",
                        "application/json",
                        mark.meta_byte,
                        wr =>
                {
                    Restful_FileUpLoadCallBack t = TapOnUtils.fileUpLoadCallBackfromJson(wr.downloadHandler.text);
                    BmobFile bf = new BmobFile {
                        filename = t.filename, url = t.url, group = t.cdnname
                    };
                    Mark m = new Mark {
                        metaFile = bf
                    };
                    Bmob.Update(
                        Mark.table_name,
                        callback_mark.objectId,
                        m,
                        (resp, exception) =>
                    {
                        if (exception != null)
                        {
                            Debug.Log("修改失败, 失败原因为: " + exception.Message);
                            return;
                        }

                        Debug.Log("修改成功, @" + resp.updatedAt);
                    });
                }));
            }
        }