コード例 #1
0
    public override void run()
    {
        if(BuildSetting.UseServerConfig){
            Debug.LogError("Use Server Configs");
        }else{
            Debug.LogError("Use local Configs");
        }

        if(BuildSetting.UseServerConfig){
            Test_AllMetaCommand cmd = new Test_AllMetaCommand ("noid", "no authToken", "[\"content\"][\"objects\"]",
            delegate(Hashtable data){
                process( data );
                this.complete();
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("load artoo content error:"+err_code);
                CommonDlg dlg = DlgManager.instance.ShowCommonDlg("Load content error: "+err_code);
                dlg.setOneBtnDlg();
                dlg.onOk = () => {
                    Application.Quit();
                };
            }
            );
            cmd.excute ();
        }else{
            TextAsset ta = Resources.Load("configData/ArtooBase") as TextAsset;
            Hashtable h = MiniJSON.jsonDecode(ta.text) as Hashtable ;
            h=h["content"]as Hashtable;
            h=h["objects"]as Hashtable;
            process(h);
            this.complete();
        }
    }
コード例 #2
0
ファイル: CommandTest.cs プロジェクト: rogeryuan99/Hello
    void OnGUI()
    {
        GUILayout.Label (BuildSetting.gameServerUrl);
        secret = GUILayout.TextField (secret);
        playerId = GUILayout.TextField (playerId);
        authToken = GUILayout.TextField (authToken);
        if (GUILayout.Button ("registerPlayerAndGetAuthToken")) {
            Auth_RegisterPlayerAndGetAuthTokenCommand cmd = new Auth_RegisterPlayerAndGetAuthTokenCommand (playerId, secret,
            delegate(Hashtable data){
                Debug.Log ("authToken = " + data ["result"]);
                authToken = data ["result"] as string;
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error " + err_code);
            }
            );
            cmd.excute ();
        }

        if (GUILayout.Button ("GetAutoTokenCommand")) {
            Auth_GetAutoTokenCommand cmd = new Auth_GetAutoTokenCommand (playerId, secret,
            delegate(Hashtable data){
                Debug.Log ("authToken = " + data ["result"]);
                authToken = data ["result"] as string;
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error " + err_code);
            }
            );
            cmd.excute ();
        }

        if (GUILayout.Button ("Player_GetCommand")) {
            Player_GetCommand cmd = new Player_GetCommand (playerId, authToken,
            delegate(Hashtable data){
                result = Utils.dumpHashTable (data);
                Debug.Log ("complete");
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error");
            }
            );
            cmd.excute ();
        }
        //		if (GUILayout.Button ("Player_BuyItemCommand")) {
        //			Player_BuyItemCommand cmd = new Player_BuyItemCommand(playerId,authToken,"1111",1,
        //			delegate(Hashtable data){
        //				result = Utils.dumpHashTable(data);
        //				Debug.Log("complete");
        //			},
        //			delegate(string err_code,string err_msg,Hashtable data){
        //				Debug.Log("error");
        //			}
        //			);
        //			cmd.excute();
        //		}
        //		if (GUILayout.Button ("Player_HeroHireCommand")) {
        //			Player_HeroHireCommand cmd = new Player_HeroHireCommand(playerId,authToken,"STARLORD",
        //			delegate(Hashtable data){
        //				result = Utils.dumpHashTable(data);
        //				Debug.Log("complete");
        //			},
        //			delegate(string err_code,string err_msg,Hashtable data){
        //				Debug.Log("error");
        //			}
        //			);
        //			cmd.excute();
        //		}
        //		if (GUILayout.Button ("Player_HeroUnhireCommand")) {
        //			Player_HeroUnhireCommand cmd = new Player_HeroUnhireCommand(playerId,authToken,"STARLORD",
        //			delegate(Hashtable data){
        //				result = Utils.dumpHashTable(data);
        //				Debug.Log("complete");
        //			},
        //			delegate(string err_code,string err_msg,Hashtable data){
        //				Debug.Log("error");
        //			}
        //			);
        //			cmd.excute();
        //		}
        //		if (GUILayout.Button ("Player_HeroSkillEditCommand")) {
        //			Player_HeroSkillEditCommand cmd = new Player_HeroSkillEditCommand(playerId,authToken,"STARLORD",null,
        //			delegate(Hashtable data){
        //				result = Utils.dumpHashTable(data);
        //				Debug.Log("complete");
        //			},
        //			delegate(string err_code,string err_msg,Hashtable data){
        //				Debug.Log("error");
        //			}
        //			);
        //			cmd.excute();
        //		}
        if (GUILayout.Button ("Player_PackageUpdateCommand")) {
            Player_PackageUpdateCommand cmd = new Player_PackageUpdateCommand (playerId, authToken,
            delegate(Hashtable data){
                result = Utils.dumpHashTable (data);
                Debug.Log ("complete");
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error");
            }
            );
            cmd.excute ();
        }
        if (GUILayout.Button ("Player_MapUpdateCommand")) {
            Player_MapUpdateCommand cmd = new Player_MapUpdateCommand (playerId, authToken,
            delegate(Hashtable data){
                result = Utils.dumpHashTable (data);
                Debug.Log ("complete");
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error");
            }
            );
            cmd.excute ();
        }
        if (GUILayout.Button ("Player_UpdateAllCommand")) {
            Player_UpdateAllCommand cmd = new Player_UpdateAllCommand (playerId, authToken,
            delegate(Hashtable data){
                result = Utils.dumpHashTable (data);
                Debug.Log ("complete");
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error");
            }
            );
            cmd.excute ();
        }
        if (GUILayout.Button ("Player_LoginCommand")) {
            Player_LoginCommand cmd = new Player_LoginCommand (playerId, authToken,
            delegate(Hashtable data){
                result = Utils.dumpHashTable (data);
                Debug.Log ("complete");
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error");
            }
            );
            cmd.excute ();
        }

        if (GUILayout.Button ("guid")) {
            Debug.Log ("GUID: " + SystemInfo.deviceUniqueIdentifier);
        }
        //		if (GUILayout.Button ("load file")) {
        //			FileCommand cmd = new FileCommand("crossdomain.xml",
        //			delegate(Hashtable data){
        //				result = Utils.dumpHashTable(data);
        //				Debug.Log("complete");
        //			},
        //			delegate(string err_code,string err_msg,Hashtable data){
        //				Debug.Log("error");
        //			}
        //			);
        //			cmd.excute();
        //		}

        if (GUILayout.Button ("test.getGameContent")) {
            Test_GetGameContentCommand cmd = new Test_GetGameContentCommand (playerId, authToken,
            delegate(Hashtable data){
                result = Utils.dumpHashTable (data);
                Debug.Log ("complete");
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error");
            }
            );
            cmd.excute ();
        }
        if (GUILayout.Button ("test.allMeta")) {
            //path may be "[\"content\"][\"objects\"][\"Gift\"]" , or null,
            Test_AllMetaCommand cmd = new Test_AllMetaCommand (playerId, authToken, "[\"content\"][\"objects\"]",
            delegate(Hashtable data){
                result = Utils.dumpHashTable (data);
                Debug.Log ("complete");
            },
            delegate(string err_code,string err_msg,Hashtable data){
                Debug.Log ("error");
            }
            );
            cmd.excute ();
        }
        if (GUILayout.Button ("on key get")) {
            RegisterOrGetToken();
        }

        sp = GUILayout.BeginScrollView (sp);
        result = GUILayout.TextArea (result);
        GUILayout.EndScrollView ();
    }