private void Start() { login_error = true; version.text = "v" + Application.version; GameManager.manager.logout = false; GameManager.manager.wait_result = true; //PlayerPrefs.DeleteAll(); //Debug.Log(Application.persistentDataPath); GameManager.manager.fail = false; if (GameManager.manager.CheckAccessToken()) { login_method.SetActive(false); tap_to_start.SetActive(true); } else { PlayerPrefs.SetFloat("volume", 50); login_method.SetActive(true); login_method.transform.GetChild(3).gameObject.SetActive(false); tap_to_start.SetActive(false); } GameManager.manager.LoadLocalizedText(PlayerPrefs.GetInt("language")); _api = GetComponent <API>(); Fbook = GetComponent <FbookAPI>(); Fbook.InitFB(); if (PlayerPrefs.GetInt("language") == (int)Language.Chinese) { language_button[(int)Language.Chinese].GetComponent <Image>().sprite = language_icon[0]; } else if (PlayerPrefs.GetInt("language") == (int)Language.English) { language_button[(int)Language.English].GetComponent <Image>().sprite = language_icon[2]; } //get ipaddress and country callback += OnGetCountry; _api.GET("http://ip-api.com/json", callback); callback -= OnGetCountry; //Assign localized text LoadLanguage(); for (int j = 0; j < language_button.Length; j++) { int x = j; language_button[x].GetComponent <Button>().onClick.AddListener(() => OnLanguageClick(x)); } }
//Check If there is existing accessToken stored in device void CheckToken() { if (GameManager.manager.CheckAccessToken()) { string json = JsonUtility.ToJson(GameManager.manager.getPlayerData().data); //Debug.Log(json); callback += OnAccessTokenLogin; _api.POST("/check_access_token", json, callback); callback -= OnAccessTokenLogin; } else { //Do Nothing } }
void SendAPI(IResult result) { facebook_user fb_user_data = new facebook_user(); fb_user_data.setUsername(Fbook.GetID()); fb_user_data.setDisplayName("" + result.ResultDictionary["name"]); fb_user_data.setCountry(country); fb_user_data.setIp(ipAdd); fb_user_data.setMethod(1); fb_user_data.setGame_Id(1); string json = JsonUtility.ToJson(fb_user_data); callback += OnFB; //Debug.Log(json); _api.POST("/sign_up", json, callback); callback -= OnFB; }
//Login button click public void OnLoginclick() { loadingImg.SetActive(true); SoundManager.manager.playClick(); login_user login_user_data = new login_user(); login_user_data.setPassword(password_input.text); login_user_data.setUsername(username_input.text); login_user_data.setIp(country); login_user_data.setCountry(ipAdd); string json = JsonUtility.ToJson(login_user_data); callback += OnLogin; Debug.Log(json); _api.POST("/login", json, callback); callback -= OnLogin; }
private void Start() { Debug.Log(Application.version); _api = GetComponent <API>(); _check_ver.setVer(Application.version); string json = JsonUtility.ToJson(_check_ver); cb += OnCheckVer; _api.POST("/check_version", json, cb); cb -= OnCheckVer; errorMsg = "You Disconnected From the Server!!"; confirm_panel.transform.GetChild(0).GetChild(1).GetChild(1).GetComponent <Button>().onClick.AddListener(() => OnOkClick(2)); confirm_panel.transform.GetChild(0).GetChild(1).GetChild(0).GetComponent <Button>().onClick.AddListener(() => OnOkClick(3)); }
//public void OnGuestClick() //{ // //guest_login.SetActive(true); // login_method.SetActive(false); //} public void OnGuestLoginclick() { loadingImg.SetActive(true); SoundManager.manager.playClick(); guest_user guest_user_data = new guest_user(); //guest_user_data.setUsername(guest_username_input.text); guest_user_data.setCountry(country); guest_user_data.setIp(ipAdd); guest_user_data.setMethod(3); guest_user_data.setGame_Id(1); guest_user_data.setCharacter(1); string json = JsonUtility.ToJson(guest_user_data); callback += OnGuestLogin; Debug.Log(json); _api.POST("/sign_up", json, callback); callback -= OnGuestLogin; }