Exemplo n.º 1
0
    public WebLoaderTask <UserInfo> register(string nickname)
    {
        var register = new WebLoaderTask <UserInfo>(getUrl() + _register.url);

        register.pack.addField("nickname", nickname);
        return(register);
    }
Exemplo n.º 2
0
    private State getLogin()
    {
        bool  error = false;
        State state = TaskState.Create(delegate() {
            //得到用户数据
            User data = UserModel.Instance.data;
            //创建网络任务
            WebLoaderTask <UserInfo> web = WebAction.Instance.login(data.id, data.password);
            //错误处理
            web.onError += delegate(string msg) {
                error = true;
            };
            //成功处理
            web.onSucceed += delegate(UserInfo info) {
                error = false;
            };
            return(web);
        }, this.fsm_, delegate {
            if (error)
            {
                //登陆错误,删除用户信息,回到检查状态
                UserModel.Instance.clear();
                return(CheckState);
            }
            else
            {
                //成功去Start状态
                return(StartState);
            }
        });

        return(state);
    }
Exemplo n.º 3
0
    public WebLoaderTask <UserInfo> login(string id, string password)
    {
        var login = new WebLoaderTask <UserInfo>(getUrl() + _login.url);

        login.pack.addField("id", id);
        login.pack.addField("password", password);
        return(login);
    }
Exemplo n.º 4
0
    public WebLoaderTask <ResceiveInfo> receiveMessage(string id, string password)
    {
        var receiveMessage = new WebLoaderTask <ResceiveInfo>(getUrl() + _receiveMessage.url);

        receiveMessage.pack.addField("id", id);
        receiveMessage.pack.addField("password", password);

        return(receiveMessage);
    }
Exemplo n.º 5
0
    public WebLoaderTask <TopInfo> submitScore(string id, string password, string score)
    {
        var submitScore = new WebLoaderTask <TopInfo>(getUrl() + _submitScore.url);

        submitScore.pack.addField("id", id);
        submitScore.pack.addField("password", password);
        submitScore.pack.addField("score", score);
        return(submitScore);
    }
Exemplo n.º 6
0
    private State getSubmit()
    {
        State state = TaskState.Create(delegate() {
            User data = UserModel.Instance.data;
            WebLoaderTask <TopInfo> web = WebAction.Instance.submitScore(data.id, data.password, PlayModel.Instance._coin.ToString());
            return(web);
        }, this.fsm_, "resetting");

        return(state);
    }
Exemplo n.º 7
0
    public WebLoaderTask <MessageInfo> sendMessage(string id, string password, string register, string message)
    {
        var sendMessage = new WebLoaderTask <MessageInfo>(getUrl() + _sendMessage.url);

        sendMessage.pack.addField("id", id);
        sendMessage.pack.addField("password", password);
        sendMessage.pack.addField("message", message);
        sendMessage.pack.addField("register", register);

        return(sendMessage);
    }
Exemplo n.º 8
0
 public Task uploadTask()
 {
     return new TaskPack(delegate {
         WebLoaderTask<WebUploadInfo> web = new WebLoaderTask<WebUploadInfo> ("http://gdgeek.com/www/index.php/voxel/upload");
         web.onSucceed += delegate(WebUploadInfo info) {
         };
         web.onError += delegate(string msg) {
             Debug.Log(msg);
         };
         web.pack.addField("image", "llalaa");
         web.pack.addBinaryData ("post", _texture.EncodeToPNG ());
         return web;
     });
 }
Exemplo n.º 9
0
    public State showState()
    {
        State state = TaskState.Create(delegate() {
            WebLoaderTask <TopInfo> web = WebAction.Instance.top10();
            web.onSucceed += delegate(TopInfo info) {
                if (info.top10.Count > 0)
                {
                    FrinedsData.Instance.setupWarpData(info.top10);
                }
            };

            return(web);
        }, this.fsm_, NormalState);

        return(state);
    }
Exemplo n.º 10
0
    private State getRegisterWWW()
    {
        bool  error = true;
        State state = TaskState.Create(delegate() {
            //建立联网任务
            WebLoaderTask <UserInfo> register = WebAction.Instance.register(UserModel.Instance.userName);
            register.onError += delegate(string msg) {
                //如果错误,提示警告
                MenuView.Instance._rigister.warning(msg);

                error = true;
            };
            register.onSucceed += delegate(UserInfo info) {
                //如果正确检查信息是否成功
                if (info.succeed)
                {
                    //成功,保存用户信息
                    error = false;
                    UserModel.Instance.data = info.user;
                }
                else
                {
                    //失败提示警告
                    error = true;
                    MenuView.Instance._rigister.warning(info.message);
                }
            };
            TaskList tl = new TaskList();
            //显示Loading界面
            tl.push(Loading.Instance.show(0.5f));
            tl.push(register);
            //关闭Loading界面
            tl.push(Loading.Instance.hide());

            return(tl);
        }, fsm_, delegate(FSMEvent evt) {
            if (error)
            {
                //如果错误,回去输入界面
                return(RegisterInputState);
            }
            //否则进入游戏开始
            return(StartState);
        });

        return(state);
    }
Exemplo n.º 11
0
    //发送消息
    private State getSendMessage()
    {
        State state = TaskState.Create(delegate() {
            User data = UserModel.Instance.data;
//			Debug.LogError("++sendMessage+"+ data.id +"=="+ data.password +"=="+ MessageModel.Instance.receiveMessageID +"=="+ MessageModel.Instance.sendMessage);

            WebLoaderTask <MessageInfo> web = WebAction.Instance.sendMessage(data.id, data.password, MessageModel.Instance.receiveMessageID, MessageModel.Instance.sendMessage);



            return(web);
        }, this.fsm_, delegate {
            return(NormalState);
        });

        return(state);
    }
Exemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        var loader = new WebLoaderTask <UserInfo>("http://127.0.0.1:8080/");

        loader.pack.addField("name", "name");
        loader.pack.addField("password", "password");
        bool error = false;

        loader.onSucceed += delegate(UserInfo info) {
            Debug.Log("succeed");
            error = false;
        };
        loader.onError += delegate(string msg) {
            Debug.Log("error" + msg);
            error = true;
        };
        TaskManager.Run(loader);
    }
Exemplo n.º 13
0
    public WebLoaderTask <TopInfo> top10()
    {
        var top10 = new WebLoaderTask <TopInfo>(getUrl() + _top10.url);

        return(top10);
    }
Exemplo n.º 14
0
Arquivo: Ctrl.cs Projeto: gdgeek/fly
        private Task logoTask()
        {
            WebLoaderTask<WebMenuInfo> web = new WebLoaderTask<WebMenuInfo> ("http://gdgeek.com/www/index.php/voxel/info");
            web.onSucceed += delegate(WebMenuInfo info) {
                _model.web.menu = info.menu;
            };
            web.onError += delegate(string msg) {
                Debug.Log(msg);
            };
            //tl.push (web);
            TaskManager.PushBack (web, delegate {
                foreach(var item in _model.web.menu.list){

                    _view.itemList.addItem (item.title, item.iconUrl, item.mesh, item.message, item.like, item.postman);
                }
            });
            return web;
        }