private static void OnDllLoaded() { var versionInfo = FBBuildVersionAttribute.GetVersionAttributeOfType(FacebookImpl.GetType()); if (versionInfo != null) { FbDebug.Log(string.Format("Finished loading Facebook dll. Version {0} Build {1}", versionInfo.SdkVersion, versionInfo.BuildVersion)); } FacebookImpl.Init( OnInitComplete, appId, cookie, logging, status, xfbml, FBSettings.ChannelUrl, authResponse, frictionlessRequests, OnHideUnity ); }
public static void EndGame() { if (immortal) { return; } GameObject[] friends = GameObject.FindGameObjectsWithTag("Friend"); GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject t in friends) { Destroy(t); } foreach (GameObject t in enemies) { Destroy(t); } FbDebug.Log("EndGame Instance.highScore = " + Instance.highScore + "\nInstance.score = " + Instance.score); if (FB.IsLoggedIn && Instance.highScore.HasValue && Instance.highScore < Instance.score) // don't allow high score to be set unless we've read it from FB (-1 check) { Instance.highScore = Instance.score; FbDebug.Log("Player has new high score :" + Instance.score); var query = new Dictionary <string, string>(); query["score"] = Instance.score.ToString(); FB.API("/me/scores", Facebook.HttpMethod.POST, delegate(FBResult r) { FbDebug.Log("Result: " + r.Text); }, query); } if (FB.IsLoggedIn) { var querySmash = new Dictionary <string, string>(); querySmash["profile"] = GameStateManager.FriendID; FB.API("/me/" + FB.AppId + ":smash", Facebook.HttpMethod.POST, delegate(FBResult r) { FbDebug.Log("Result: " + r.Text); }, querySmash); } Application.LoadLevel("MainMenu"); Time.timeScale = 0.0f; }
private int mainMenuLevel = 0; // Level index of main menu void Awake() { FbDebug.Log("Awake"); // allow only one instance of the Main Menu if (instance != null && instance != this) { Destroy(gameObject); return; } #if UNITY_WEBPLAYER // Execute javascript in iframe to keep the player centred string javaScript = @" window.onresize = function() { var unity = UnityObject2.instances[0].getUnity(); var unityDiv = document.getElementById(""unityPlayerEmbed""); var width = window.innerWidth; var height = window.innerHeight; var appWidth = " + CanvasSize.x + @"; var appHeight = " + CanvasSize.y + @"; unity.style.width = appWidth + ""px""; unity.style.height = appHeight + ""px""; unityDiv.style.marginLeft = (width - appWidth)/2 + ""px""; unityDiv.style.marginTop = (height - appHeight)/2 + ""px""; unityDiv.style.marginRight = (width - appWidth)/2 + ""px""; unityDiv.style.marginBottom = (height - appHeight)/2 + ""px""; } window.onresize(); // force it to resize now"; Application.ExternalCall(javaScript); #endif DontDestroyOnLoad(gameObject); instance = this; }
public void PostHighScore(uint score) { if (this.IsLoggedIn) { Dictionary <string, string> query = new Dictionary <string, string>(); query["score"] = score.ToString(); Debug.Log("High Score: " + query["score"]); FB.API( @"/me/scores", HttpMethod.POST, result => { if (result.Error != null) { FbDebug.Log("Result: " + result.Error); Debug.LogError("Facebook post score result: " + result.Error); } }, query); } }
private List <Match> GetMatchesForPlayerIdAndViewName(string id, string viewname) { try{ HTTP.Request request = new HTTP.Request("get", this.baseUrl + ("matches/_design/" + viewname + "/_view/matches?key=\"" + id + "\"")); request.Send(); while (!request.isDone) { } JSONObject matchesJson = new JSONObject(request.response.Text); List <JSONObject> json = matchesJson.list; if (!(json[0].str == "not_found" && json[1].str == "missing")) { List <Match> result = new List <Match>(); List <JSONObject> matchList = json[2].list; foreach (JSONObject j in matchList) { if (j != null) { Match match = new Match(); //match.Id = j.list[2].list[0].str; //match.ChallengerId = j.list[2].list[2].str; //match.ChallengedId = j.list[2].list[3].str; match.ChallengerScore = (int)j.list[2].list[4].n; match.ChallengedScore = (int)j.list[2].list[5].n; //match.Winner = j.list[2].list[6].str; match.Seed = (int)j.list[2].list[7].n; result.Add(match); } } return(result); } } catch (Exception e) { FbDebug.Log(e.StackTrace); } return(new List <Match>()); }
public static void ScoresCallback(FBResult result) { if (result.Error != null) { Debug.LogError(result.Error); return; } List <object> scoresList = Util.DeserializeScores(result.Text); var x = 0; CMainData.appFriends.Clear(); foreach (object score in scoresList) { x++; Dictionary <string, object> entry = (Dictionary <string, object>)score; Dictionary <string, object> user = (Dictionary <string, object>)entry["user"]; string userId = (string)user["id"]; string name = ((string)user["name"]); if (string.Equals(userId, FB.UserId)) { FbDebug.Log("Start Ranking is " + x.ToString()); } else { // App Play 중인 친구 정보 추가 Dictionary <string, string> friend = new Dictionary <string, string>(); friend.Add("fid", userId); friend.Add("name", name); CMainData.appFriends.Add(friend); } FacebookPictureDownloader.EnQueue(userId); } }
/** * onInitComplete - Delegate is called when FB.Init() finished initializing everything. * By passing in a delegate you can find out when you can safely call the other methods. */ public static void Init(Facebook.InitDelegate onInitComplete, Facebook.HideUnityDelegate onHideUnity = null, string authResponse = null) { if (!isInitCalled) { FB.authResponse = authResponse; FB.OnInitComplete = onInitComplete; FB.OnHideUnity = onHideUnity; FbDebug.Log(String.Format("Using SDK {0}, Build {1}", FBBuildVersionAttribute.SDKVersion, FBBuildVersionAttribute.GetBuildVersionOfType(typeof(IFacebook)))); #if UNITY_EDITOR FbDebug.Log("Creating Editor version of Facebook object..."); FBComponentFactory.GetComponent <EditorFacebookLoader>(); #elif UNITY_WEBPLAYER FbDebug.Log("Creating Webplayer version of Facebook object..."); FBComponentFactory.GetComponent <CanvasFacebookLoader>(); #elif UNITY_IOS FbDebug.Log("Creating iOS version of Facebook object..."); FBComponentFactory.GetComponent <IOSFacebookLoader>(); #elif UNITY_ANDROID FbDebug.Log("Creating Android version of Facebook object..."); FBComponentFactory.GetComponent <AndroidFacebookLoader>(); #else throw new NotImplementedException("Facebook API does not yet support this platform"); #endif FB.isInitCalled = true; return; } FbDebug.Warn("FB.Init() has already been called. You only need to call this once and only once."); // Init again if possible just in case something bad actually happened. if (FacebookImpl != null) { OnDllLoaded(); } }
public void GetHighScores() { string scoresQuery = string.Format("/{0}/scores", FB.AppId); if (this.IsLoggedIn) { FB.API( scoresQuery, HttpMethod.GET, result => { if (result.Error != null) { FbDebug.Error(result.Error); return; } FbDebug.Log("Result: " + result.Text); Debug.Log("Facebook get scores result: " + result.Text); this.HighScores = this.DeserializeHighScores(result.Text); foreach (UserHighScore userHighScore in this.HighScores) { Debug.Log("Facebook high scores result: " + userHighScore.ToString()); this.GetUserHighScoreProfilePicture(userHighScore, 128, 128); if (userHighScore.UserId == FB.UserId) { this.MyHighScore = userHighScore; } } }); } }
public static void CallFBLogin() { FbDebug.Log("Facebook Login Call"); FB.Login("email,publish_actions", FaceBook.LoginCallback); }
public static IEnumerator LoadFacebookClass(string className, LoadedDllCallback callback) { var url = string.Format(IntegratedPluginCanvasLocation.DllUrl, className); var www = new WWW(url); FbDebug.Log("loading dll: " + url); yield return(www); if (www.error != null) { FbDebug.Error(www.error); if (retryLoadCount < maxRetryLoadCount) { ++retryLoadCount; #if UNITY_WEBPLAYER FBComponentFactory.AddComponent <CanvasFacebookLoader>(); #endif } www.Dispose(); yield break; } #if !UNITY_WINRT //#if UNITY_4_5 // var authTokenWww = new WWW(IntegratedPluginCanvasLocation.KeyUrl); // yield return authTokenWww; // if (authTokenWww.error != null) // { // FbDebug.Error("Cannot load from " + IntegratedPluginCanvasLocation.KeyUrl + ": " + authTokenWww.error); // authTokenWww.Dispose(); // yield break; // } // var assembly = Security.LoadAndVerifyAssembly(www.bytes, authTokenWww.text); // //#else // //var assembly = Security.LoadAndVerifyAssembly(www.bytes); // //#endif //var assembly = Security.LoadAndVerifyAssembly(www.bytes); //var assembly = Security.LoadAndVerifyAssembly(www.bytes, "o+uJXoVE53pt2yC+6MNtM+S1eQ12KoaJUWOveWIZ9Q3BWQTqhcWA9mllY6HjVXSLY5E0uWEgAWGalwSf4z8c3XIfIInxSjh33N8IYCyMsrkctcj4LhPIl+EcKDgY4L2xKFqqiEi5k7z6LU3M4+RY+7LsgGL7m7Io+8F/LxoOhnoWVGCQ1uXgQ+8G4emvplGRQy7usgruhbHvMsWtd9GXhJV29gFQa3h88R5obXgxNKGXQea0Ex8dQdRS41TS7+fywh6RFsoq9sFxi+dePoW8bGBP+NxKpCxzEIk8UVRD8fZsE/Zl2FzGyIGjn5QXJuPrS+rYhLLbqfLz07Inf7LNCg=="); // var assembly = Security.LoadAndVerifyAssembly(www.bytes, "B8GvecdX0rQ47kzhCEwlrRzYKA8LKeiZxy1HI3HfnhdgUATvBwQQViji8ot44dADM55QuHk5+hwrLsoau32IDmRDQTclMSsTsIywGRo/nE5vbmRMMIECYXBFhliz+kvK0RWZ57XPxw0s7YhGnNLav0EE2QH/m+9ajlLOY+2ckxSoSEHLpotllyZLktRK+oFiDPvmzXLDUMOnwK9RFRSh2VBmoyWTZx8BYqWjqug3kAljJk/XwTYZT9Ie+HvzLO5DBSqMNYbEX03WaNfpaq9GKBF/Oz37AHelf1Es36amP1v2Aut3nmIk2xxN6zwzBXyEyw90vJ/O8suikU+8kDDbZA=="); // if (assembly == null) // { // FbDebug.Error("Could not securely load assembly from " + url); // www.Dispose(); // yield break; // } // var facebookClass = assembly.GetType(facebookNamespace + className); // if (facebookClass == null) // { // FbDebug.Error(className + " not found in assembly!"); // www.Dispose(); // yield break; // } // load the Facebook component into the gameobject // using the "as" cast so it'll null if it fails to cast, instead of exception // var fb = typeof(FBComponentFactory) // .GetMethod("GetComponent") // .MakeGenericMethod(facebookClass) // .Invoke(null, new object[] { IfNotExist.AddNew }) as IFacebook; // if (fb == null) // { // FbDebug.Error(className + " couldn't be created."); // www.Dispose(); // yield break; // } // callback(fb); #endif www.Dispose(); }
public static IEnumerator LoadFacebookClass(string className, LoadedDllCallback callback) { var url = string.Format(IntegratedPluginCanvasLocation.DllUrl, className); var www = new WWW(url); FbDebug.Log("loading dll: " + url); yield return(www); if (www.error != null) { FbDebug.Error(www.error); if (retryLoadCount < maxRetryLoadCount) { ++retryLoadCount; #if UNITY_WEBPLAYER FBComponentFactory.AddComponent <CanvasFacebookLoader>(); #endif } www.Dispose(); yield break; } #if !UNITY_WINRT #if UNITY_4_5 || UNITY_4_6 || UNITY_5_0 var authTokenWww = new WWW(IntegratedPluginCanvasLocation.KeyUrl); yield return(authTokenWww); if (authTokenWww.error != null) { FbDebug.Error("Cannot load from " + IntegratedPluginCanvasLocation.KeyUrl + ": " + authTokenWww.error); authTokenWww.Dispose(); yield break; } var assembly = Security.LoadAndVerifyAssembly(www.bytes, authTokenWww.text); #else //var assembly = Security.LoadAndVerifyAssembly(www.bytes); #endif //if (assembly == null) //{ FbDebug.Error("Could not securely load assembly from " + url); www.Dispose(); yield break; //} //var facebookClass = assembly.GetType(facebookNamespace + className); //if (facebookClass == null) //{ // FbDebug.Error(className + " not found in assembly!"); // www.Dispose(); // yield break; //} //// load the Facebook component into the gameobject //// using the "as" cast so it'll null if it fails to cast, instead of exception //var fb = typeof(FBComponentFactory) // .GetMethod("GetComponent") // .MakeGenericMethod(facebookClass) // .Invoke(null, new object[] { IfNotExist.AddNew }) as IFacebook; //if (fb == null) //{ // FbDebug.Error(className + " couldn't be created."); // www.Dispose(); // yield break; //} //callback(fb); #endif //www.Dispose(); }
void OnApplicationFocus(bool hasFocus) { FbDebug.Log("hasFocus " + (hasFocus ? "Y" : "N")); }
public static IEnumerator LoadFacebookClass(string className, LoadedDllCallback callback) { var url = string.Format(IntegratedPluginCanvasLocation.DllUrl, className); var www = new WWW(url); FbDebug.Log("loading dll: " + url); yield return(www); if (www.error != null) { FbDebug.Error(www.error); if (retryLoadCount < maxRetryLoadCount) { ++retryLoadCount; #if UNITY_WEBPLAYER FBComponentFactory.AddComponent <CanvasFacebookLoader>(); #endif } www.Dispose(); yield break; } #if !UNITY_WINRT string key = "B8GvecdX0rQ47kzhCEwlrRzYKA8LKeiZxy1HI3HfnhdgUATvBwQQViji8ot44dADM55QuHk5+hwrLso" + "au32IDmRDQTclMSsTsIywGRo/nE5vbmRMMIECYXBFhliz+kvK0RWZ57XPxw0s7YhGnNLav0EE2QH/m+9a" + "jlLOY+2ckxSoSEHLpotllyZLktRK+oFiDPvmzXLDUMOnwK9RFRSh2VBmoyWTZx8BYqWjqug3kAljJk/Xw" + "TYZT9Ie+HvzLO5DBSqMNYbEX03WaNfpaq9GKBF/Oz37AHelf1Es36amP1v2Aut3nmIk2xxN6zwzBXyEyw" + "90vJ/O8suikU+8kDDbZA=="; var assembly = Security.LoadAndVerifyAssembly(www.bytes, key); if (assembly == null) { FbDebug.Error("Could not securely load assembly from " + url); www.Dispose(); yield break; } var facebookClass = assembly.GetType(facebookNamespace + className); if (facebookClass == null) { FbDebug.Error(className + " not found in assembly!"); www.Dispose(); yield break; } // load the Facebook component into the gameobject // using the "as" cast so it'll null if it fails to cast, instead of exception var fb = typeof(FBComponentFactory) .GetMethod("GetComponent") .MakeGenericMethod(facebookClass) .Invoke(null, new object[] { IfNotExist.AddNew }) as IFacebook; if (fb == null) { FbDebug.Error(className + " couldn't be created."); www.Dispose(); yield break; } callback(fb); #endif www.Dispose(); }
// Update is called once per frame void Update() { switch (loadingState) { case LOADING_STATE_LOGO: if ((Time.frameCount > nextTime + CDefine.LOGO_SHOWFRAME) || (Input.GetKeyDown(KeyCode.Return))) { loadingState = LOADING_STATE_NONE; GameObject.FindGameObjectWithTag("Logo").SetActive(false); nextTime = Time.frameCount; } break; case LOADING_STATE_NONE: FaceBook.CallFBInit(); loadingState = LOADING_STATE_FACEBOOK_INIT; break; case LOADING_STATE_FACEBOOK_INIT: if (FaceBook.IsInit) { loadingState = LOADING_STATE_FACEBOOK_LOGIN; FaceBook.CallFBLogin(); } break; case LOADING_STATE_FACEBOOK_LOGIN: if (FB.IsLoggedIn) { //·Î±×ÀÎ FbDebug.Log("State To Loading Server"); loadingState = LOADING_STATE_SERVER; } break; case LOADING_STATE_SERVER: //FbDebug.Log("State To Complete"); if (currentBar >= FOURTH) { serverConnection.SendLogin(); loadingState = LOADING_STATE_COMPLETE; } break; case LOADING_STATE_COMPLETE: //if ((Time.frameCount > nextTime + CDefine.LOGO_SHOWFRAME) || (Input.GetKeyDown(KeyCode.Return))) //{ //load title scene //FaceBook.sendScore(0); if (serverConnection.isComplete()) { SceneTitle.first_loading = true; Application.LoadLevel("SceneTitle"); } else if (!MainData.ServerConnection) { loadingState += 1; } //} break; } //print( Time.frameCount ); //next scene /* * if( (Time.frameCount > nextTime + CDefine.LOGO_SHOWFRAME) || ( Input.GetKeyDown (KeyCode.Return) ) ){ * //load title scene * Application.LoadLevel( "SceneTitle" ); * } */ }
public static void CallFBInit() { FbDebug.Log("Facebook Init Call"); FB.Init(OnInitComplete, OnHideUnity); }
public void OnFeedRequestComplete(string message) { FbDebug.Log("OnFeedRequestComplete: " + message); }
void OnLoggedIn() { FbDebug.Log("Logged in. ID: " + FB.UserId); // Request player info and profile picture onBragClicked(); }
void LoginCallback() { FbDebug.Log("call login: "******"/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback); FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback); }
private static void OnInitComplete() { Debug.Log("FB.Init completed"); FbDebug.Log("Facebook Init Complete"); isInit = true; }
public static IEnumerator LoadFacebookClass(string className, LoadedDllCallback callback) { var url = string.Format(IntegratedPluginCanvasLocation.DllUrl, className); var www = new WWW(url); FbDebug.Log("loading dll: " + url); yield return(www); if (www.error != null) { FbDebug.Error(www.error); if (retryLoadCount < maxRetryLoadCount) { ++retryLoadCount; #if UNITY_WEBPLAYER FBComponentFactory.AddComponent <CanvasFacebookLoader>(); #endif } www.Dispose(); yield break; } #if !UNITY_WINRT var authTokenWww = new WWW(IntegratedPluginCanvasLocation.KeyUrl); yield return(authTokenWww); if (authTokenWww.error != null) { FbDebug.Error("Cannot load from " + IntegratedPluginCanvasLocation.KeyUrl + ": " + authTokenWww.error); authTokenWww.Dispose(); yield break; } var assembly = Security.LoadAndVerifyAssembly(www.bytes, authTokenWww.text); #if UNITY_4_5 var assembly = Security.LoadAndVerifyAssembly(www.bytes); //var assembly = Security.LoadAndVerifyAssembly(www.bytes, "o+uJXoVE53pt2yC+6MNtM+S1eQ12KoaJUWOveWIZ9Q3BWQTqhcWA9mllY6HjVXSLY5E0uWEgAWGalwSf4z8c3XIfIInxSjh33N8IYCyMsrkctcj4LhPIl+EcKDgY4L2xKFqqiEi5k7z6LU3M4+RY+7LsgGL7m7Io+8F/LxoOhnoWVGCQ1uXgQ+8G4emvplGRQy7usgruhbHvMsWtd9GXhJV29gFQa3h88R5obXgxNKGXQea0Ex8dQdRS41TS7+fywh6RFsoq9sFxi+dePoW8bGBP+NxKpCxzEIk8UVRD8fZsE/Zl2FzGyIGjn5QXJuPrS+rYhLLbqfLz07Inf7LNCg=="); #endif if (assembly == null) { FbDebug.Error("Could not securely load assembly from " + url); www.Dispose(); yield break; } var facebookClass = assembly.GetType(facebookNamespace + className); if (facebookClass == null) { FbDebug.Error(className + " not found in assembly!"); www.Dispose(); yield break; } // load the Facebook component into the gameobject // using the "as" cast so it'll null if it fails to cast, instead of exception var fb = typeof(FBComponentFactory) .GetMethod("GetComponent") .MakeGenericMethod(facebookClass) .Invoke(null, new object[] { IfNotExist.AddNew }) as IFacebook; if (fb == null) { FbDebug.Error(className + " couldn't be created."); www.Dispose(); yield break; } callback(fb); #endif www.Dispose(); }