public static async void Update_build(Req_update_build req_Update_Build, Action <Result_Update> Result_update) { var www = UnityWebRequest.Get(map_url.Url_update_build); www.SetRequestHeader("username", req_Update_Build.Username); www.SetRequestHeader("password", req_Update_Build.Password); www.SetRequestHeader("type_build", ((int)req_Update_Build.Type_build).ToString()); www.SetRequestHeader("id_build", req_Update_Build.ID_Build); www.SendWebRequest(); while (true) { if (www.isDone) { if (www.downloadHandler.text.Length > 2) { print(www.downloadHandler.text); Result_update(ChilligamesJson.DeserializeObject <Result_Update>(www.downloadHandler.text)); } www.Abort(); break; } else { if (www.isHttpError || www.isNetworkError || www.timeout == 1) { www.Abort(); break; } await Task.Delay(1); } } }
void OnEnable() { //starter if (Entity_my_servers != null) { for (int i = 0; i < Entity_my_servers.Length; i++) { Destroy(Entity_my_servers[i]); } Entity_my_servers = null; } if (Entity_servers != null) { for (int i = 0; i < Entity_servers.Length; i++) { Destroy(Entity_servers[i]); } Entity_servers = null; } Curent_content = Content_Servers; //recive all server Chilligames_SDK.API_Client.Recive_all_servers(new Req_recive_all_server { Count = 50, Name_App = "Venomic" }, result => { Entity_servers = new GameObject[result.Length]; for (int i = 0; i < result.Length; i++) { Entity_servers[i] = Instantiate(Raw_model_fild_server, Place_instant_servers); Entity_servers[i].GetComponent <Raw_fild_servers>().Change_value(ChilligamesJson.DeserializeObject <Model_server>(result[i].ToString())._id); } }, ERR => { }); }
public static async void Recive_worker_detail(Req_recive_worker_detail req_Recive_Worker_Detail, Action <Result_recive_worker_detail> result) { var www = UnityWebRequest.Get(map_url.Url_recive_worker_detail); www.SetRequestHeader("username", req_Recive_Worker_Detail.Username); www.SetRequestHeader("password", req_Recive_Worker_Detail.Password); www.SendWebRequest(); while (true) { if (www.isDone) { www.Abort(); result(ChilligamesJson.DeserializeObject <Result_recive_worker_detail>(www.downloadHandler.text)); break; } else { if (www.isHttpError || www.isNetworkError || www.timeout == 1) { www.Abort(); break; } await Task.Delay(1); } } }
public static async void Recive_info_pos(Req_recive_info_pos req_Recive_Info_Pos, Action <Result_recive_postion_info> Builds) { var www = UnityWebRequest.Get(map_url.Url_recive_info_pos); www.SetRequestHeader("postions", JsonUtility.ToJson(req_Recive_Info_Pos.postions_camera)); www.SendWebRequest(); while (true) { if (www.isDone) { if (www.downloadHandler.text.Length >= 1) { Builds(ChilligamesJson.DeserializeObject <Result_recive_postion_info>(www.downloadHandler.text)); } break; } else { if (www.isHttpError || www.isNetworkError || www.timeout == 1) { www.Abort(); break; } await Task.Delay(1); } } }
public static async void Recive_value_per_Values(Req_recive_per_value req_Recive_Per_Value, Action <Result_recive_resource_value.Deserilse_Per_values> Result_per_value, Action <Result_recive_resource_value.Deserilise_values> Result_values, Action <int> Storage) { var www = UnityWebRequest.Get(map_url.Url_recive_resource_value_per_value); www.SetRequestHeader("username", req_Recive_Per_Value.Username); www.SetRequestHeader("password", req_Recive_Per_Value.Password); www.SendWebRequest(); while (true) { if (www.isDone) { if (www.downloadHandler.text.Length >= 1) { var Deserilise_values = ChilligamesJson.DeserializeObject <Result_recive_resource_value>(www.downloadHandler.text); Result_per_value(ChilligamesJson.DeserializeObject <Result_recive_resource_value.Deserilse_Per_values>(Deserilise_values.Per_Values.ToString())); Result_values(ChilligamesJson.DeserializeObject <Result_recive_resource_value.Deserilise_values>(Deserilise_values.Values.ToString())); Storage(Deserilise_values.Storage); } break; } else { if (www.isHttpError || www.isNetworkError || www.timeout == 1) { www.Abort(); break; } await Task.Delay(1); } } }
public void Change_value(object[] messages, string _id, string ID, string Last_date, int?status, GameObject Raw_model_chat, GameObject Raw_model_each_message) { Chilligames_SDK.API_Client.Recive_Info_other_User <schema_other_player>(new Req_recive_Info_player { _id = ID }, result => { Text_sender.text = ChilligamesJson.DeserializeObject <schema_other_player.deserilise_info>(result.Info.ToString()).Nickname; }, err => { }); Text_Last_messege.text = ChilligamesJson.DeserializeObject <Chilligames_SDK.API_Client.Result_each_messege>(messages[messages.Length - 1].ToString()).PM; Text_Last_date.text = Last_date; Raw_model_each_messege = Raw_model_each_message; BTN_Enter_chatroom.onClick.AddListener(() => { Curent_panel_chat = Instantiate(Raw_model_chat); Curent_panel_chat.AddComponent <Raw_model_chat>().Change_values(ID, Raw_model_each_messege, Text_sender.text); }); BTN_delete_category.onClick.AddListener(() => { Chilligames_SDK.API_Client.Delete_category_message(new Req_delete_message_category { _id = _id, _id_other_player = ID }, () => { }, err => { }); Destroy(gameObject); }); }
void Start() { //frist change Curent_panel = Content_panel_editprofile; Curent_BTN_tap = BTN_Editprofile; //tab change BTN_Editprofile.onClick.AddListener(() => { Curent_panel.SetActive(false); Curent_panel = Content_panel_editprofile; Curent_panel.SetActive(true); Curent_BTN_tap.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; Curent_BTN_tap = BTN_Editprofile; BTN_Editprofile.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; }); BTN_Friend_list.onClick.AddListener(() => { Curent_panel.SetActive(false); Curent_panel = Content_panel_firend; Curent_panel.SetActive(true); Curent_BTN_tap.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; Curent_BTN_tap = BTN_Friend_list; BTN_Friend_list.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; Chilligames_SDK.API_Client.Recive_list_friend(new Req_recive_list_friend { _id = _id }, result => { Friend_list = new GameObject[result.Friends.Length]; for (int i = 0; i < result.Friends.Length; i++) { Friend_list[i] = Instantiate(Raw_model_friend, Place_friend_list); Friend_list[i].AddComponent <Raw_model_Friend>().Change_value(Raw_model_profile, _id, ChilligamesJson.DeserializeObject <Chilligames_SDK.API_Client.Result_list_freind.Deserilse_friend>(result.Friends[i].ToString()).ID, (int)ChilligamesJson.DeserializeObject <Chilligames_SDK.API_Client.Result_list_freind.Deserilse_friend>(result.Friends[i].ToString()).Status); } }, ERRORS => { }); }); BTN_Login.onClick.AddListener(() => { Curent_panel.SetActive(false); Curent_panel = Content_panel_login; Curent_panel.SetActive(true); Curent_BTN_tap.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; Curent_BTN_tap = BTN_Login; BTN_Login.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; }); //change input edit profile InputField_nickname.onSelect.AddListener(text => { InputField_nickname.GetComponent <Image>().color = Color_edit; }); InputField_nickname.onDeselect.AddListener(Text => { if (InputField_nickname.text == "") { InputField_nickname.GetComponent <Image>().color = Color_Pass; } else if (InputField_nickname.text.Length >= 5) { Chilligames_SDK.API_Client.Cheack_nick_name(new Req_cheack_nickname { Nickname = InputField_nickname.text }, result => { if (result == "1") { InputField_nickname.GetComponent <Image>().color = Color_Pass; } else if (result == "0") { InputField_nickname.GetComponent <Image>().color = Color_error; } }, err => { }); } else if (InputField_nickname.text.Length < 5) { InputField_nickname.GetComponent <Image>().color = Color_error; } }); InputField_Username.onSelect.AddListener(Text => { InputField_Username.GetComponent <Image>().color = Color_edit; }); InputField_Username.onDeselect.AddListener(Text => { if (InputField_Username.text == "") { InputField_Username.GetComponent <Image>().color = Color_Pass; } else if (InputField_Username.text.Length >= 5) { Chilligames_SDK.API_Client.Cheack_user_name(new Req_cheack_username { Username = Text }, result => { if (result == "1") { InputField_Username.GetComponent <Image>().color = Color_Pass; } else if (result == "0") { InputField_Username.GetComponent <Image>().color = Color_error; } }, ERR => { }); } else if (InputField_Username.text.Length < 5) { InputField_Username.GetComponent <Image>().color = Color_error; } }); InputField_Email.onSelect.AddListener(Text => { InputField_Email.GetComponent <Image>().color = Color_edit; }); InputField_Email.onDeselect.AddListener(Text => { if (InputField_Email.text == "") { InputField_Email.GetComponent <Image>().color = Color_Pass; } if (InputField_Email.text.Length >= 1 && InputField_Email.text.Length < 5) { InputField_Email.GetComponent <Image>().color = Color_error; } else { InputField_Email.GetComponent <Image>().color = Color_Pass; } int find = 0; for (int i = 0; i < Text.Length; i++) { if (Text[i] == '@') { find = 1; } } if (find == 1) { InputField_Email.GetComponent <Image>().color = Color_Pass; } else if (find == 0 && Text.Length > 0) { InputField_Email.GetComponent <Image>().color = Color_error; } }); InputField_Password.onSelect.AddListener(text => { InputField_Password.GetComponent <Image>().color = Color_edit; }); InputField_Password.onDeselect.AddListener(text => { if (InputField_Password.text == "") { InputField_Password.GetComponent <Image>().color = Color_Pass; } else if (InputField_Password.text.Length <= 5) { InputField_Password.GetComponent <Image>().color = Color_error; } else if (InputField_Password.text.Length > 5) { InputField_Password.GetComponent <Image>().color = Color_Pass; } }); InputFieldSatatus.onSelect.AddListener(text => { InputFieldSatatus.GetComponent <Image>().color = Color_edit; }); InputFieldSatatus.onDeselect.AddListener(Text => { InputFieldSatatus.GetComponent <Image>().color = Color_Pass; }); BTN_Change.onClick.AddListener(() => { Chilligames_SDK.API_Client.Update_User_Info(new Req_Update_User_Info { Nickname = InputField_nickname.text, Username = InputField_Username.text, Email = InputField_Email.text, Password = InputField_Password.text, status = InputFieldSatatus.text, _id = _id }, () => { SceneManager.LoadScene(0); }, err => { }); }); //panel login BTN_login_panel_login.onClick.AddListener(() => { Chilligames_SDK.API_Client.Login_with_username_Password(new Req_login_with_username_password { Password = InputField_Password_panel_login.text, Username = InputField_Username_panel_login.text }, result => { if (result.Length > 2) { PlayerPrefs.SetString("_id", result); //coin cheack for reset all Chilligames_SDK.API_Client.Recive_Coin_mony(new Req_recive_coin { _id = _id }, result_coin => { PlayerPrefs.SetInt("Coin", (int)result_coin.Coin); }, err => { }); Chilligames_SDK.API_Client.Recive_Data_user <Panel_home.Entity_Player>(new Req_recive_data { Name_App = "Venomic", _id = _id }, result_data => { PlayerPrefs.SetInt("Freeze", result_data.Freeze); PlayerPrefs.SetInt("Minuse", result_data.Minus); PlayerPrefs.SetInt("Delete", result_data.Delete); PlayerPrefs.SetInt("Chance", result_data.Chance); PlayerPrefs.SetInt("Reset", result_data.Reset); PlayerPrefs.SetInt("Level", result_data.Level); SceneManager.LoadScene(0); }, err => { }); } else { print("not login"); } }, err => { }); }); BTN_recovery_panel_login.onClick.AddListener(() => { Content_login.SetActive(false); Content_recovery.SetActive(true); }); BTN_submit_recovery.onClick.AddListener(() => { Chilligames_SDK.API_Client.Recovery_email_send(new Req_send_recovery_email { Email = InputField_email_recovery.text }, result => { if (result == "1") { InputField_Key.gameObject.SetActive(true); BTN_submit_recovery.onClick.RemoveAllListeners(); BTN_submit_recovery.onClick.AddListener(() => { Chilligames_SDK.API_Client.Submit_recovery_email(new Req_submit_recovery_email { Email = InputField_email_recovery.text, Key = InputField_Key.text }, result_submit => { if (result_submit == "1") { InputField_new_password.gameObject.SetActive(true); BTN_submit_recovery.onClick.RemoveAllListeners(); BTN_submit_recovery.onClick.AddListener(() => { Chilligames_SDK.API_Client.Change_password(new Req_change_password { Email = InputField_email_recovery.text, New_Password = InputField_new_password.text }, () => { BTN_submit_recovery.GetComponentInChildren <TextMeshProUGUI>().text = "Changed "; InputField_email_recovery.gameObject.SetActive(false); InputField_Key.gameObject.SetActive(false); BTN_submit_recovery.onClick.RemoveAllListeners(); SceneManager.LoadScene(0); }, err => { }); }); } }, err => { }); }); } }, err => { }); }); BTN_Back_to_login.onClick.AddListener(() => { Content_login.SetActive(true); Content_recovery.SetActive(false); }); }
public void Change_value_model_update(Update_build setting_update_build) { //frist change setting = setting_update_build; Text_level_to.text = setting.To_level - 1 + "►" + setting.To_level; //change icon switch (setting_update_build.type_Build) { case Build.Type_build.Build_wood: Image_icon_update.texture = Wood_Icon; break; case Build.Type_build.Build_food: Image_icon_update.texture = Food_Icon; break; case Build.Type_build.Build_stone: Image_icon_update.texture = Stone_Icon; break; case Build.Type_build.Build_storage: Image_icon_update.texture = Storage_Icon; break; } //fill time Server_side.User_data.Result_data.Result_recive_worker_detail.Deserilse_updates.Deserilse_time deserilse_Time = ChilligamesJson.DeserializeObject <Server_side.User_data.Result_data.Result_recive_worker_detail.Deserilse_updates.Deserilse_time>(setting.time); Future_time = new DateTime(deserilse_Time.Y, deserilse_Time.MO, deserilse_Time.D, deserilse_Time.H, deserilse_Time.M, deserilse_Time.S); Slider_time.maxValue = Future_time.Second + (Future_time.Minute * 60) + ((Future_time.Hour * 60) * 60); Slider_time.minValue = DateTime.Now.Second + (DateTime.Now.Minute * 60) + ((DateTime.Now.Hour * 60) * 60); //start timer StartCoroutine(timer()); }
private void Start() { BTN_Freeze.onClick.RemoveAllListeners(); BTN_Minus.onClick.RemoveAllListeners(); BTN_Delete.onClick.RemoveAllListeners(); BTN_Reset.onClick.RemoveAllListeners(); BTN_Leave_mission.onClick.RemoveAllListeners(); //level QA if (Level <= 10) { int Count = Random.Range(1, 5); BTNS = new GameObject[Count]; for (int i = 0; i < BTNS.Length; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } else if (Level >= 11 && Level <= 20) { int Count = Random.Range(2, 7); BTNS = new GameObject[Count]; for (int i = 0; i < BTNS.Length; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } else if (Level >= 21 && Level <= 40) { int Count = Random.Range(3, 8); BTNS = new GameObject[Count]; for (int i = 0; i < BTNS.Length; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } else if (Level >= 41) { int Count = Random.Range(3, 9); BTNS = new GameObject[Count]; for (int i = 0; i < Count; i++) { BTNS[i] = Instantiate(Raw_model_BTN, Place_BTNS); } } //insert value to btn for (int i = 0; i < BTNS.Length; i++) { BTNS[i].AddComponent <BTN>(); BTNS[i].GetComponent <BTN>().Change_value(gameObject); } BTN_Freeze.onClick.AddListener(() => { if (Freeze >= 1) { Partical_freeze.Play(); BTN_Freeze.GetComponent <AudioSource>().Play(); foreach (var BTN in BTNS) { BTN.GetComponent <BTN>().Freeze_time = 0.005f; BTN.GetComponent <BTN>().Show_anim_freeze(); } Freeze -= 1; } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Minus.onClick.AddListener(() => { if (Minues >= 1) { BTN_Minus.GetComponent <AudioSource>().Play(); Partical_Minus.Play(); Minues -= 1; foreach (var BTN in BTNS) { if (BTN.GetComponent <BTN>().Count > 1) { if (BTN.GetComponent <BTN>().Count - 1 < BTN.GetComponent <BTN>().Tap) { BTN.GetComponent <BTN>().Tap -= 1; } BTN.GetComponent <BTN>().Count -= 1; BTN.GetComponent <BTN>().Show_anim_minuse(); } else { print("One btn cant minus"); } } } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Delete.onClick.AddListener(() => { if (Delete >= 1 && BTNS.Length > 2) { BTN_Delete.GetComponent <AudioSource>().Play(); Partical_delete.Play(); //animation delete BTNS[BTNS.Length - 1].GetComponent <BTN>().Anim = 1; //work Delete -= 1; GameObject[] New_BTNS = new GameObject[BTNS.Length - 1]; for (int i = 0; i < New_BTNS.Length; i++) { New_BTNS[i] = BTNS[i]; } BTNS = New_BTNS; } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Reset.onClick.AddListener(() => { if (Reset >= 1) { BTN_Reset.GetComponent <AudioSource>().Play(); Partical_reset.Play(); Reset -= 1; for (int i = 0; i < BTNS.Length; i++) { Destroy(BTNS[i]); } Start(); } else { Music_reject.Play(); Partical_reject.Play(); } }); BTN_Leave_mission.onClick.AddListener(() => { //camera action Player.Cam.Move_Camera_To_Menu(); //music controller Menu.Play_music_menu(); //destroy game play Destroy(Parent.GetComponent <Raw_model_fild_server_play>().Missions); }); Recive_data(); void Recive_data() { //recive count player Chilligames_SDK.API_Client.Recive_data_server <Panel_Servers.Model_server>(new Chilligames.SDK.Model_Client.Req_data_server { Name_app = "Venomic", _id_server = _id_server }, result => { Count_Player = (int)ChilligamesJson.DeserializeObject <Panel_Servers.Model_server.Setting_servers>(result.Setting.ToString()).Player; }, ERR => { }); // recive ranking Chilligames_SDK.API_Client.Recive_data_server <Panel_Servers.Model_server>(new Req_data_server { Name_app = "Venomic", _id_server = _id_server }, result => { var leader_board = ChilligamesJson.DeserializeObject <Panel_Servers.Model_server.Setting_servers>(result.Setting.ToString()).Leader_board; int[] score = new int[leader_board.Length]; for (int i = 0; i < leader_board.Length; i++) { score[i] = (int)ChilligamesJson.DeserializeObject <Raw_model_info_server.Deserilies_leader_board>(leader_board[i].ToString()).Score; } int curent_score = Level + Freeze + Minues + Delete + Chance + Reset; for (int i = 0; i < leader_board.Length; i++) { if (curent_score < score[i]) { Rank_player = i; } } }, err => { }); } }
IEnumerator recive_data_postion() { while (true) { yield return(new WaitForSeconds(0.2f)); Server_side.User_data.Recive_info_pos(new Server_side.Models.Req_recive_info_pos { postions_camera = new Vector3(Mathf.RoundToInt(Camera.main.transform.position.x), 0, Mathf.RoundToInt(Camera.main.transform.position.z)) }, result => { if (All_build_recive.Length >= 1 /*&& Camera.main.transform.position != Camera_pos*/) { foreach (var item in result.Builds) { Desrilse_build Info_build = new Desrilse_build { ID = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).ID, Name = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Name, Level = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Level, Storage = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Storage, Postion = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Postion, Health = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Health, Type_build = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Type_build }; switch ((Build.Type_build)Info_build.Type_build) { case Build.Type_build.Build_wood: { var postion = JsonUtility.FromJson <Vector3>(Info_build.Postion.ToString()); //cheak for new build bool can_build = true; try { foreach (var WoodBuilds in GetComponentsInChildren <Wooder>()) { if (WoodBuilds.GetComponent <Wooder>().Setting_build.ID == Info_build.ID) { can_build = false; break; } } } catch (System.Exception) { } //build new build if (can_build && Lock_recive) { //lock recive Lock_recive = false; //recive work var old_build = All_build_recive; All_build_recive = new GameObject[result.Builds.Length + All_build_recive.Length]; //cheack for (int A = 0; A < old_build.Length; A++) { All_build_recive[A] = old_build[A]; } try { for (int i = 0; i < All_build_recive.Length; i++) { if (All_build_recive[i] == null) { All_build_recive[i] = Instantiate(Raw_wood_build, postion, transform.rotation, transform); All_build_recive[i].GetComponent <Wooder>().Change_value(Build.Status_build.Befor_build, new Build.Setting_Build_ressures { Health = Info_build.Health, Status_build = Build.Status_build.Befor_build, ID = Info_build.ID, Level = Info_build.Level, Name = Info_build.Name, postion_build = postion, Storage = Info_build.Storage, Type_build = Build.Type_build.Build_wood }); break; } } } catch (System.Exception) { } } //recive unlock Lock_recive = true; } break; case Build.Type_build.Build_food: { //cheak for new build var postion = JsonUtility.FromJson <Vector3>(Info_build.Postion.ToString()); bool can_build = true; try { foreach (var food_build in GetComponentsInChildren <Food_build>()) { if (food_build.GetComponent <Food_build>().Setting_build.ID == Info_build.ID) { can_build = false; break; } } } catch (System.Exception) { } //build new build if (can_build && Lock_recive) { //lock recive Lock_recive = false; var old_build = All_build_recive; All_build_recive = new GameObject[result.Builds.Length + old_build.Length]; for (int A = 0; A < old_build.Length; A++) { All_build_recive[A] = old_build[A]; } try { for (int i = 0; i < All_build_recive.Length; i++) { if (All_build_recive[i] == null) { All_build_recive[i] = Instantiate(Raw_food_build, postion, transform.rotation, transform); All_build_recive[i].GetComponent <Food_build>().Change_value(Build.Status_build.Befor_build, new Build.Setting_Build_ressures { Health = Info_build.Health, Status_build = Build.Status_build.Befor_build, ID = Info_build.ID, Level = Info_build.Level, Name = Info_build.Name, postion_build = postion, Storage = Info_build.Storage, Type_build = Build.Type_build.Build_food }); break; } } } catch (System.Exception) { } } //unlock recive Lock_recive = true; } break; case Build.Type_build.Build_stone: { var postion = JsonUtility.FromJson <Vector3>(Info_build.Postion.ToString()); //cheak for new build bool can_build = true; try { foreach (var Stone_build in GetComponentsInChildren <Stone>()) { if (Stone_build.GetComponent <Stone>().Setting_build.ID == Info_build.ID) { can_build = false; break; } } } catch (System.Exception) { } //build new build if (can_build && Lock_recive) { //lock recive Lock_recive = false; var old_build = All_build_recive; All_build_recive = new GameObject[result.Builds.Length + old_build.Length]; for (int A = 0; A < old_build.Length; A++) { All_build_recive[A] = old_build[A]; } try { for (int i = 0; i < All_build_recive.Length; i++) { if (All_build_recive[i] == null) { All_build_recive[i] = Instantiate(Raw_stone_build, postion, transform.rotation, transform); All_build_recive[i].GetComponent <Stone>().Change_value(Build.Status_build.Befor_build, new Build.Setting_Build_ressures { Health = Info_build.Health, Status_build = Build.Status_build.Befor_build, ID = Info_build.ID, Level = Info_build.Level, Name = Info_build.Name, postion_build = postion, Storage = Info_build.Storage, Type_build = Build.Type_build.Build_stone }); break; } } } catch (System.Exception) { } } //unlock recive Lock_recive = true; } break; case Build.Type_build.Build_storage: { var postion = JsonUtility.FromJson <Vector3>(Info_build.Postion.ToString()); //cheak for new build bool can_build = true; try { foreach (var Storage in GetComponentsInChildren <raw_storage>()) { if (Storage.GetComponent <raw_storage>().Setting_build.ID == Info_build.ID) { can_build = false; break; } } } catch (System.Exception) { } //build new build if (can_build && Lock_recive) { //lock recive Lock_recive = false; var old_build = All_build_recive; All_build_recive = new GameObject[result.Builds.Length + old_build.Length]; for (int A = 0; A < old_build.Length; A++) { All_build_recive[A] = old_build[A]; } try { for (int i = 0; i < All_build_recive.Length; i++) { if (All_build_recive[i] == null) { All_build_recive[i] = Instantiate(Raw_storage_build, postion, transform.rotation, transform); All_build_recive[i].GetComponent <raw_storage>().Change_value(Build.Status_build.Befor_build, new Build.Setting_Build_ressures { Health = Info_build.Health, Status_build = Build.Status_build.Befor_build, ID = Info_build.ID, Level = Info_build.Level, Name = Info_build.Name, postion_build = postion, Storage = Info_build.Storage , Type_build = Build.Type_build.Build_storage }); break; } } } catch (System.Exception) { } } //unlock recive Lock_recive = true; } break; } } Camera_pos = Camera.main.transform.position; } else if (All_build_recive.Length <= 0 && Lock_recive) { All_build_recive = new GameObject[result.Builds.Length]; //desrilise from server foreach (var item in result.Builds) { Desrilse_build Info_build = new Desrilse_build { ID = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).ID, Name = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Name, Level = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Level, Storage = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Storage, Postion = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Postion, Health = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Health, Type_build = ChilligamesJson.DeserializeObject <Desrilse_build>(item.ToString()).Type_build }; //build switch ((Build.Type_build)Info_build.Type_build) { case Build.Type_build.Build_wood: { Vector3 postion = JsonUtility.FromJson <Vector3>(Info_build.Postion.ToString()); try { for (int i = 0; i < All_build_recive.Length; i++) { if (All_build_recive[i] == null) { All_build_recive[i] = Instantiate(Raw_wood_build, postion, transform.rotation, transform); All_build_recive[i].GetComponent <Wooder>().Change_value(Build.Status_build.Befor_build, new Build.Setting_Build_ressures { Status_build = Build.Status_build.Befor_build, Health = Info_build.Health, ID = Info_build.ID, Level = Info_build.Level, Name = Info_build.Name, postion_build = postion, Storage = Info_build.Storage, Type_build = Build.Type_build.Build_wood }); break; } } } catch (System.Exception) { } } break; case Build.Type_build.Build_food: { Vector3 postion = JsonUtility.FromJson <Vector3>(Info_build.Postion.ToString()); for (int i = 0; i < All_build_recive.Length; i++) { if (All_build_recive[i] == null) { All_build_recive[i] = Instantiate(Raw_food_build, postion, transform.rotation, transform); All_build_recive[i].GetComponent <Food_build>().Change_value(Build.Status_build.Befor_build, new Build.Setting_Build_ressures { Status_build = Build.Status_build.Befor_build, Health = Info_build.Health, ID = Info_build.ID, Level = Info_build.Level, Name = Info_build.Name, postion_build = postion, Storage = Info_build.Storage, Type_build = Build.Type_build.Build_food }); break; } } } break; case Build.Type_build.Build_stone: { Vector3 postion = JsonUtility.FromJson <Vector3>(Info_build.Postion.ToString()); for (int i = 0; i < All_build_recive.Length; i++) { if (All_build_recive[i] == null) { All_build_recive[i] = Instantiate(Raw_stone_build, postion, transform.rotation, transform); All_build_recive[i].GetComponent <Stone>().Change_value(Build.Status_build.Befor_build, new Build.Setting_Build_ressures { Health = Info_build.Health, ID = Info_build.ID, Status_build = Build.Status_build.Befor_build, Level = Info_build.Level, Name = Info_build.Name, postion_build = postion, Storage = Info_build.Storage, Type_build = Build.Type_build.Build_stone }); break; } } } break; } } } }); } }
private void Start() { //change action btns BTN_Servers.onClick.AddListener(() => { Content_Servers.SetActive(true); Curent_content.SetActive(false); Curent_content = Content_Servers; Curent_content.SetActive(true); Chilligames_SDK.API_Client.Recive_all_servers(new Req_recive_all_server { Count = 50, Name_App = "Venomic" }, result => { Entity_servers = new GameObject[result.Length]; for (int i = 0; i < result.Length; i++) { Entity_servers[i] = Instantiate(Raw_model_fild_server, Place_instant_servers); Entity_servers[i].GetComponent <Raw_fild_servers>().Change_value(ChilligamesJson.DeserializeObject <Model_server>(result[i].ToString())._id); } }, ERR => { }); }); BTN_My_servers.onClick.AddListener(() => { Content_My_servers.SetActive(true); Curent_content.SetActive(false); Curent_content = Content_My_servers; Curent_content.SetActive(true); Chilligames_SDK.API_Client.Recive_List_server_user(new Req_recive_list_servers_User { Name_app = "Venomic", _id = _id_player }, result => { Entity_my_servers = new GameObject[result.Length]; for (int i = 0; i < result.Length; i++) { Entity_my_servers[i] = Instantiate(Raw_model_fild_server, Place_content_my_servers); Entity_my_servers[i].GetComponent <Raw_fild_servers>().Change_value(result[i].ToString()); } }, ERR => { }); }); BTN_Creat_Servers.onClick.AddListener(() => { Content_creat_servers.SetActive(false); Curent_content.SetActive(false); Curent_content = Content_creat_servers; Curent_content.SetActive(true); }); BTN_submit_creat_server.onClick.AddListener(() => { //minuse coin server PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - (int)Coin); Chilligames_SDK.API_Client.Sync_coin_with_server(new Req_sync_coin_with_server { Coin = PlayerPrefs.GetInt("Coin"), _id = _id_player }, () => { }, err => { }); Model_server.Setting_servers setting = new Model_server.Setting_servers { Name_server = Text_name_server.text, Chance = (int)Value_Chance.value, Delete = (int)Value_delete.value, Freeze = (int)Value_Freeze.value, Mines = (int)Value_Mines.value, Reset = (int)Value_Reset.value, Active_Days = (int)DateTime.UtcNow.Subtract(DateTime.UtcNow.AddDays((int)Value_Active_Days.value)).TotalSeconds, Level = (int)Value_Level.value, Coine = Coin * 3, Player = 1, like = 0, Leader_board = new object[0], }; Chilligames_SDK.API_Client.Creat_server(new Req_creat_server { _id = _id_player, Setting = setting, Name_App = "Venomic" }, () => { Content_My_servers.SetActive(true); Curent_content.SetActive(false); Curent_content = Content_My_servers; Curent_content.SetActive(true); Chilligames_SDK.API_Client.Recive_List_server_user(new Req_recive_list_servers_User { Name_app = "Venomic", _id = _id_player }, Result => { if (Entity_my_servers != null) { for (int i = 0; i < Entity_my_servers.Length; i++) { Destroy(Entity_my_servers[i]); } } Entity_my_servers = new GameObject[Result.Length]; for (int i = 0; i < Result.Length; i++) { Entity_my_servers[i] = Instantiate(Raw_model_fild_server, Place_content_my_servers); Entity_my_servers[i].GetComponent <Raw_fild_servers>().Change_value(Result[i].ToString()); } }, err => { }); }, err => { }); }); BTN_Close_Panel_Creat_servers.onClick.AddListener(() => { Content_My_servers.SetActive(true); Curent_content.SetActive(false); Curent_content = Content_My_servers; Curent_content.SetActive(true); }); }
void Recive_Frist_detail_workers() { Server_side.User_data.Recive_worker_detail(new Server_side.Models.Req_recive_worker_detail { Password = "******", Username = "******" }, result => { //fill worker text count Count_worker = result.Count_worker; Count_work = result.Count_work; text_worker_count.text = Count_worker + " / " + Count_work; //instant new work if (Worker == null || Worker.Length <= 0) { Worker = new GameObject[result.Updates.Length]; for (int i = 0; i < result.Updates.Length; i++) { Worker[i] = Instantiate(Raw_model_update_detail, place_update); Server_side.User_data.Result_data.Result_recive_worker_detail.Deserilse_updates deserilse_Updates = ChilligamesJson.DeserializeObject <Server_side.User_data.Result_data.Result_recive_worker_detail.Deserilse_updates>(result.Updates[i].ToString()); Worker[i].GetComponent <Raw_model_update_build>().Change_value_model_update(new Raw_model_update_build.Update_build { To_level = deserilse_Updates.To_level, type_Build = (Build.Type_build)deserilse_Updates.Type_build, time = deserilse_Updates.Deserilze_time.ToString(), ID = deserilse_Updates.ID_Build }); } } }); }
void Start() { BTN_close_profile.onClick.AddListener(() => { Destroy(gameObject); }); BTN_Send_massege.onClick.AddListener(() => { Panel_send_message.GetComponent <Panel_send_massege>()._id = _id; Panel_send_message.GetComponent <Panel_send_massege>()._id_other_player = _id_other_player; Instantiate(Panel_send_message); }); Chilligames_SDK.API_Client.Cheack_status_friend(new Req_status_friend { _id = _id, _id_other_player = _id_other_player }, Result => { if (Result == 0) { BTN_send_req_friend.gameObject.SetActive(false); BTN_Aceept.gameObject.SetActive(false); BTN_Pending.gameObject.SetActive(true); BTN_Remove_friend.gameObject.SetActive(false); } else if (Result == 1) { BTN_send_req_friend.gameObject.SetActive(false); BTN_Aceept.gameObject.SetActive(true); BTN_Pending.gameObject.SetActive(false); BTN_Remove_friend.gameObject.SetActive(false); } else if (Result == 2) { BTN_send_req_friend.gameObject.SetActive(false); BTN_Aceept.gameObject.SetActive(false); BTN_Pending.gameObject.SetActive(false); BTN_Remove_friend.gameObject.SetActive(true); } else if (Result == 3) { BTN_send_req_friend.gameObject.SetActive(true); BTN_Aceept.gameObject.SetActive(false); BTN_Pending.gameObject.SetActive(false); BTN_Remove_friend.gameObject.SetActive(false); } Chilligames_SDK.API_Client.Recive_Info_other_User <Schema_other_player>(new Req_recive_Info_player { _id = _id_other_player }, resul => { Nickname.text = ChilligamesJson.DeserializeObject <Schema_other_player.DeserilseInfoPlayer>(resul.Info.ToString()).Nickname; Panel_send_message.GetComponent <Panel_send_massege>().Nickname_player = ChilligamesJson.DeserializeObject <Schema_other_player.DeserilseInfoPlayer>(resul.Info.ToString()).Nickname; Status.text = ChilligamesJson.DeserializeObject <Schema_other_player.DeserilseInfoPlayer>(resul.Info.ToString()).Status; }, err => { }); }, ERR => { }); BTN_send_req_friend.onClick.AddListener(() => { BTN_send_req_friend.gameObject.SetActive(false); BTN_Aceept.gameObject.SetActive(false); BTN_Pending.gameObject.SetActive(true); BTN_Remove_friend.gameObject.SetActive(false); Chilligames_SDK.API_Client.Send_friend_requst(new Req_send_friend_requst { _id = _id, _id_other_player = _id_other_player }, () => { }, err => { }); }); BTN_Aceept.onClick.AddListener(() => { BTN_send_req_friend.gameObject.SetActive(false); BTN_Aceept.gameObject.SetActive(false); BTN_Pending.gameObject.SetActive(false); BTN_Remove_friend.gameObject.SetActive(true); Chilligames_SDK.API_Client.Accept_friend_req(new Req_accept_friend_req { }, () => { }, err => { }); }); BTN_Pending.onClick.AddListener(() => { BTN_send_req_friend.gameObject.SetActive(true); BTN_Aceept.gameObject.SetActive(false); BTN_Pending.gameObject.SetActive(false); BTN_Remove_friend.gameObject.SetActive(false); Chilligames_SDK.API_Client.Cancel_and_dellet_friend_requst(new req_cancel_and_dellet_send_freiend { }, () => { }, err => { }); }); BTN_Remove_friend.onClick.AddListener(() => { BTN_send_req_friend.gameObject.SetActive(true); BTN_Aceept.gameObject.SetActive(false); BTN_Pending.gameObject.SetActive(false); BTN_Remove_friend.gameObject.SetActive(false); Chilligames_SDK.API_Client.Cancel_and_dellet_friend_requst(new req_cancel_and_dellet_send_freiend { }, () => { }, err => { }); }); }
public void Change_Values(string Server_name, string Freeze_number, string mines_number, string delet_number, string Chace_number, string Reset_number, int Active_day, string Player_number, string Like_number, string Coin_number, string Level_number, object[] Leader_board_server, string _id) { Text_Name_server.text = Server_name; Text_Freeze_number.text = Freeze_number; Text_Mines_number.text = mines_number; Text_Delete_number.text = delet_number; Text_Chance_number.text = Chace_number; Text_Reset_number.text = Reset_number; Text_Active_day_number.text = Active_day.ToString(); Text_Player_number.text = Player_number; Text_Like_number.text = Like_number; Text_Coine_number.text = Coin_number; Text_Level_number.text = Level_number; //sort score player int?[] scores = new int?[Leader_board_server.Length]; string[] IDs = new string[Leader_board_server.Length]; for (int i = 0; i < Leader_board_server.Length; i++) { scores[i] = ChilligamesJson.DeserializeObject<Deserilies_leader_board>(Leader_board_server[i].ToString()).Score; } for (int i = 0; i < Leader_board_server.Length; i++) { IDs[i] = ChilligamesJson.DeserializeObject<Deserilies_leader_board>(Leader_board_server[i].ToString()).ID; } Array.Sort(scores); Array.Reverse(scores); string[] id_sort = new string[Leader_board_server.Length]; for (int i = 0; i < Leader_board_server.Length; i++) { for (int A = 0; A < Leader_board_server.Length; A++) { if (scores[i] == ChilligamesJson.DeserializeObject<Deserilies_leader_board>(Leader_board_server[A].ToString()).Score) { id_sort[i] = ChilligamesJson.DeserializeObject<Deserilies_leader_board>(Leader_board_server[A].ToString()).ID; break; } } } //instatn fild rankking for (int i = 0; i < id_sort.Length; i++) { var fild_rankin = Instantiate(Raw_model_fild_ranking, Place_fild_ranking); foreach (var Texts in fild_rankin.GetComponentsInChildren<TextMeshProUGUI>()) { switch (Texts.name) { case "Postin": { Texts.text = i.ToString(); } break; case "Name_player": { Chilligames_SDK.API_Client.Recive_info_user(new Chilligames.SDK.Model_Client.Req_recive_Info_player { _id = id_sort[i] }, result => { Texts.text = result.Nickname; }, err => { }); Texts.text = id_sort[i]; } break; case "Score": { Texts.text = scores[i].ToString(); } break; } } var id_other_player = id_sort[i]; fild_rankin.GetComponent<Button>().onClick.AddListener(() => { Instantiate(Raw_model_profile).GetComponent<Raw_model_user_profile>().Change_value(id_player, id_other_player); }); } }
public void Change_value(string _id_server) { Chilligames_SDK.API_Client.Recive_data_server <Deserilse_data_server>(new Req_data_server { Name_app = "Venomic", _id_server = _id_server }, (result) => { string Name_server = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Name_server; string Freeze = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Freeze.ToString(); string Mines = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Mines.ToString(); string Delete = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Delete.ToString(); string Chance = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Chance.ToString(); string Reset = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Reset.ToString(); string Player = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Player.ToString(); string Like = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).like.ToString(); int Active_days = (int)ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Active_Days; string Level = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Level.ToString(); string Coines = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Coine.ToString(); object[] leader_board = ChilligamesJson.DeserializeObject <Deserilse_data_server.Desrilise_setting_server>(result.Setting.ToString()).Leader_board; Active_days = Mathf.Abs(Active_days) / 60 / 60 / 24 + 1; Text_Name_server.text = Name_server; Text_Freeze.text = Freeze; Text_Mines.text = Mines; Text_Delete.text = Delete; Text_Chance.text = Chance; Text_Reset.text = Reset; Text_Active_day.text = Active_days.ToString(); Text_player.text = Player; Text_Like.text = Like; Text_Levels.text = Level; Text_Coines.text = Coines; Chilligames_SDK.API_Client.Cheack_Server_In_Profile(new Req_cheack_server_in_profile { Name_App = "Venomic", _id = _id_player, _id_server = _id_server }, Status => { if (Status == "1") { BTN_Exit_server.gameObject.SetActive(true); } if (Status == "0") { BTN_Enter_server.gameObject.SetActive(true); } }, ERR => { }); //change action btns BTN_info.onClick.AddListener(() => { GameObject Info_server = Instantiate(Raw_model_info_server); Info_server.GetComponent <Raw_model_info_server>().Change_Values(Name_server, Freeze, Mines, Delete, Chance, Reset, Active_days, Player, Like, Coines, Level, leader_board, _id_server); }); BTN_Exit_server.onClick.AddListener(() => { Destroy(gameObject); Chilligames_SDK.API_Client.Exit_server(new Req_Exit_server { _id = _id_player, _id_server = _id_server, Name_App = "Venomic" }, () => { }, Error => { }); Chilligames_SDK.API_Client.Pluse_or_minuse_value_fild_server(new Req_change_server_data_fild { Name_app = "Venomic", Pipe_line_data = "Setting.Player", _id_server = _id_server, Data_inject = "-1" }, null, null); }); BTN_Enter_server.onClick.AddListener(() => { int count_player = int.Parse(Text_player.text); count_player += 1; Text_player.text = count_player.ToString(); Chilligames_SDK.API_Client.Enter_to_server(new Req_enter_to_server { Name_App = "Venomic", _id = _id_player, _id_server = _id_server }, () => { }, ERR => { }); BTN_Enter_server.gameObject.SetActive(false); BTN_Exit_server.gameObject.SetActive(true); Chilligames_SDK.API_Client.Pluse_or_minuse_value_fild_server(new Req_change_server_data_fild { Data_inject = "1", _id_server = _id_server, Pipe_line_data = "Setting.Player", Name_app = "Venomic" }, null, null); }); BTN_Like.onClick.AddListener(() => { BTN_Like.gameObject.SetActive(false); Chilligames_SDK.API_Client.Pluse_or_minuse_value_fild_server(new Req_change_server_data_fild { _id_server = _id_server, Name_app = "Venomic", Pipe_line_data = "Setting.like", Data_inject = "1" }, () => { }, () => { }); Text_Like.text = (int.Parse(Like) + 1).ToString(); }); }, ERROR => { }); }
void Start() { //starter Curent_content = Content_Chatroom; Curent_BTN_tab = BTN_Chatroom; //change action btn BTN_Chatroom.onClick.AddListener(() => { Curent_content.SetActive(false); Curent_content = Content_Chatroom; Curent_content.SetActive(true); Curent_BTN_tab.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; Curent_BTN_tab = BTN_Chatroom; BTN_Chatroom.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; StartCoroutine(Recive_messages_in_chatroom()); }); BTN_Messages.onClick.AddListener(() => { Curent_content.SetActive(false); Curent_content = Content_Messages; Curent_content.SetActive(true); Curent_BTN_tab.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; Curent_BTN_tab = BTN_Messages; BTN_Messages.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; Chilligames_SDK.API_Client.Recive_message_User(new Req_recive_messages { _id = _id_player }, result => { Messages = new GameObject[result.Length]; for (int i = 0; i < result.Length; i++) { Messages[i] = Instantiate(Raw_model_Category_message, Place_messages); Messages[i].AddComponent <Raw_model_Category>().Change_value(result[i].Message, _id_player, result[i].ID, result[i].Last_Date, result[i].Status, Raw_model_Chat, Raw_model_each_message); } }, ERRORS => { }); }); BTN_Notifaction.onClick.AddListener(() => { Curent_content.SetActive(false); Curent_content = Content_Notifactions; Curent_content.SetActive(true); Curent_BTN_tab.GetComponentInChildren <TextMeshProUGUI>().color = Color.black; Curent_BTN_tab = BTN_Notifaction; BTN_Notifaction.GetComponentInChildren <TextMeshProUGUI>().color = Color.white; Chilligames_SDK.API_Client.Recive_notifactions(new Req_recive_notifactions { _id = _id_player, Name_App = "Venomic" }, Result => { Notifactions = new GameObject[Result.Length]; for (int i = 0; i < Result.Length; i++) { Notifactions[i] = Instantiate(Raw_model_notifactions, Place_notifaction); Notifactions[i].AddComponent <Raw_model_notifaction>().Change_value(Result[i].Body, Result[i].Title); } }, ERR => { }); }); BTN_Send_message.onClick.AddListener(() => { if (Input_Message.text != "") { Chilligames_SDK.API_Client.Send_message_to_Chatroom(new Req_send_message_to_chatroom { _id = _id_player, Name_App = "Venomic", Message = Input_Message.text }, () => { }, ERR => { }); Input_Message.text = ""; } }); BTN_Remove_notifactions.onClick.AddListener(() => { Chilligames_SDK.API_Client.Remove_Notifaction(new Req_remove_notifactions { Name_App = "Venomic", _id = _id_player }, () => { }, ERRORS => { }); if (Notifactions != null) { for (int i = 0; i < Notifactions.Length; i++) { Destroy(Notifactions[i]); } } }); //serche user Input_search.onValueChanged.AddListener((Text_typed) => { Chilligames_SDK.API_Client.Search_Users(new Req_search_user { Nickname = Text_typed }, () => { Text_not_find.gameObject.SetActive(true); }, result => { string Nickname = ChilligamesJson.DeserializeObject <Chilligames_SDK.API_Client.Result_search_user.Deserilseinfo>(result.Info.ToString()).Nickname; string _id_other_player = result._id; Text_not_find.gameObject.SetActive(false); Result_search = Instantiate(Raw_model_search, Place_search); Result_search.AddComponent <Raw_model_fild_search>().Change_value(_id_player, _id_other_player, Nickname, Raw_model_profile); }, err => { }); }); }