public void Refresh_panel() { //Elements _database = new Database_module (); translations = GlobalVariables.translations; _title.GetComponent<Text>().text = translations.getString ("skills"); _subtitle.GetComponent<Text>().text = translations.getString ("activities"); skill_id = GlobalVariables.selected_skill_id; player_id = GlobalVariables.selected_player_id; loadSkills (); // If there are skills it shows them if (skills.Count > 0) { if (skill_id == -1) { skill_id = skills [0].id; GlobalVariables.selected_skill_id = skill_id; } loadSkillActivities (skill_id); } else { } }
// Use this for initialization void Start() { _database = new Database_module (); GlobalVariables.locale = "es"; GlobalVariables.user_id = 1; translations = new Lang (Path.Combine (Application.dataPath, "Resources/lang.xml"), GlobalVariables.locale, false); GlobalVariables.translations = translations; }
void Start() { //Data of the player Database_module _database = new Database_module (); int user_id = GlobalVariables.user_id; int player_id = GlobalVariables.selected_player_id; Player player; if (player_id != 0) { player = _database.getPlayer (player_id); heading_title.GetComponent<Text> ().text=player.name+" "+player.surname; } }
void Start() { state = play_and_learn_scenario._play_scenario_state; _database = new Database_module (); }
void Start() { _database = new Database_module(); }
void Start() { state = coach_and_train_scenario._coach_scenario_state; _database = new Database_module (); }
void Start() { //Elements /*GUI_parent = new GameObject(); GUI_parent.name = "Team_list"; GUI_parent.transform.parent = _team_canvas.transform;*/ //GUI_parent.transform.position = _team_canvas.transform.position; _database = new Database_module(); //Refresh_panel(); }
public void Refresh_panel() { translations = GlobalVariables.translations; _tab_personaldata.SetActive(true); _tab_statistics.SetActive(true); _tab_feedbacks.SetActive(true); //Translations _subtitle.GetComponent<Text> ().text= translations.getString ("feedbacks"); _tab_personaldata.GetComponent<Button> ().GetComponentsInChildren<Text> () [0].text = translations.getString ("personal_data"); _tab_activities.GetComponent<Button> ().GetComponentsInChildren<Text> () [0].text = translations.getString ("activities"); _tab_statistics.GetComponent<Button> ().GetComponentsInChildren<Text> () [0].text = translations.getString ("statistics"); _tab_feedbacks.GetComponent<Button> ().GetComponentsInChildren<Text> () [0].text = translations.getString ("feedbacks"); //Data of the player Database_module _database = new Database_module (); int user_id = GlobalVariables.user_id; int player_id = GlobalVariables.selected_player_id; int team_id = GlobalVariables.selected_team_id; Player player; if (player_id != 0) { player = _database.getPlayer (player_id); heading_title.GetComponent<Text> ().text=player.name+" "+player.surname; List<Feedback> feedbacks = _database.getPlayerFeedbacksFromTeam(player_id,team_id); if (feedbacks.Count>0) { itemCount = feedbacks.Count; columnCount = 1; RectTransform rowRectTransform = itemPrefab.GetComponent<RectTransform>(); RectTransform containerRectTransform = GUI_parent.GetComponent<RectTransform>(); //calculate the width and height of each child item. float width = containerRectTransform.rect.width / columnCount; float ratio = 1 /*width / rowRectTransform.rect.width*/; float height = rowRectTransform.rect.height * ratio; for (int i = GUI_parent.transform.childCount - 1; i >= 0; i--) { // objectA is not the attached GameObject, so you can do all your checks with it. GameObject objectA = GUI_parent.transform.GetChild(i).gameObject; objectA.transform.parent = null; // Optionally destroy the objectA if not longer needed } int rowCount = itemCount / columnCount; if (rowCount == 0) rowCount = 1; if (itemCount % rowCount > 0) rowCount++; //adjust the height of the container so that it will just barely fit all its children float scrollHeight = height * rowCount; float scrollWidth = width * itemCount; containerRectTransform.offsetMin = new Vector2(containerRectTransform.offsetMin.x, -scrollHeight); containerRectTransform.offsetMax = new Vector2(containerRectTransform.offsetMax.x, 0); int j = 0; for (int i = 0; i < itemCount; i++) { //this is used instead of a double for loop because itemCount may not fit perfectly into the rows/columns if (i % columnCount == 0) j++; Feedback feedback = feedbacks[i]; int id = feedback.id; string datetime = feedback.datetime; int activity_id = feedback.activity_id; Activity activity = _database.getActivity(activity_id); int skill_id = activity.skill_id; int statistics_id = activity.statistics_id; GameObject.Find("ccpf_feedback").GetComponent<Text> ().text=feedback.text; GameObject.Find("ccpf_label_datetime").GetComponent<Text> ().text=feedback.datetime; string photo = player.photo; string player_name = player.name; string player_surname = player.surname; int club_id = player.club_id; Skill skill = _database.getSkill(skill_id); string skill_name = skill.name; Statistics statistics = _database.getStatistics(statistics_id); double score = statistics.overall_score; GameObject.Find("ccpf_label_player_name").GetComponent<Text> ().text=player_name+" "+player_surname; GameObject.Find("ccpf_skill").GetComponent<Text> ().text=skill_name; GameObject.Find("ccpf_score").GetComponent<Text> ().text=score.ToString(); string[] parts = photo.Split('.'); photo = "images/"+parts[0]; Texture image = (Texture)Resources.Load(photo, typeof(Texture)); GameObject.Find("ccpf_image").GetComponent<RawImage> ().texture=image; GameObject newItem = Instantiate(itemPrefab) as GameObject; newItem.name = id.ToString(); newItem.transform.parent = GUI_parent.transform; newItem.transform.localScale = Vector3.one; //Debug.Log("textos dentro: "+newItem.GetComponentsInChildren<Button>().Length.ToString()); Button[] buttons = newItem.GetComponentsInChildren<Button>(); foreach (Button button in buttons) { if (button.name=="ccpf_button_edit_feedback") { button.onClick.AddListener(() => { GlobalVariables.selected_activity_id = activity_id; GlobalVariables.selected_player_id = player_id; GlobalVariables.selected_club_id = club_id; GlobalVariables.selected_team_id = team_id; GlobalVariables.selected_feedback_id = id; Debug.Log("activity id: "+id); coach_and_train_scenario.GoToFeedback(); }); } } Debug.Log (newItem.name); //move and size the new item RectTransform rectTransform = newItem.GetComponent<RectTransform>(); float x = -containerRectTransform.rect.width / 2 + width * (i % columnCount); float y = containerRectTransform.rect.height / 2 - height * j; rectTransform.offsetMin = new Vector2(x, y); x = rectTransform.offsetMin.x + width; y = rectTransform.offsetMin.y + height; rectTransform.offsetMax = new Vector2(x, y); } _scrollbar.SetActive(true); _no_elements_label.SetActive(false); } else { Debug.Log ("No elements to show"); _no_elements_label.GetComponent<Text>().text = translations.getString ("no_elements"); _scrollbar.SetActive(false); _no_elements_label.SetActive(true); } } }
void Start() { //Elements Database_module _database = new Database_module (); int user_id = GlobalVariables.user_id; int discipline_id = GlobalVariables.selected_discipline_id; List<Skill> skills = _database.getSkills (discipline_id); itemCount = skills.Count; columnCount = 3; RectTransform rowRectTransform = itemPrefab.GetComponent<RectTransform>(); RectTransform containerRectTransform = gameObject.GetComponent<RectTransform>(); //calculate the width and height of each child item. float width = containerRectTransform.rect.width / columnCount; float ratio = 1 /*width / rowRectTransform.rect.width*/; float height = rowRectTransform.rect.height * ratio; /*float height = containerRectTransform.rect.height; float ratio = height / rowRectTransform.rect.height; float width = rowRectTransform.rect.width * ratio;*/ int rowCount = itemCount / columnCount; if (rowCount == 0) rowCount = 1; if (itemCount % rowCount > 0) rowCount++; //adjust the height of the container so that it will just barely fit all its children float scrollHeight = height * rowCount; float scrollWidth = width * itemCount; containerRectTransform.offsetMin = new Vector2(containerRectTransform.offsetMin.x, -scrollHeight); containerRectTransform.offsetMax = new Vector2(containerRectTransform.offsetMax.x, 0); int j = 0; for (int i = 0; i < itemCount; i++) { //this is used instead of a double for loop because itemCount may not fit perfectly into the rows/columns if (i % columnCount == 0) j++; //create a new item, name it, and set the parent string name = skills[i].name; int id = skills[i].id; //string photo = players[i].photo; GameObject.Find("ccp_button_player_name").GetComponent<Text> ().text=name; /*string[] parts = photo.Split('.'); photo = "images/"+parts[0]; Texture image = (Texture)Resources.Load(photo, typeof(Texture)); GameObject.Find("ccp_button_player_image").GetComponent<RawImage> ().texture=image;*/ GameObject newItem = Instantiate(itemPrefab) as GameObject; newItem.name = id.ToString(); newItem.transform.parent = gameObject.transform; newItem.transform.localScale = Vector3.one; newItem.GetComponent<Button>().onClick.AddListener(() => { GlobalVariables.selected_skill_id = id; Debug.Log("clicked button id: "+id+", and name: "+name); //coach_and_train_scenario.GoTos(); }); Debug.Log (newItem.name); //move and size the new item RectTransform rectTransform = newItem.GetComponent<RectTransform>(); float x = -containerRectTransform.rect.width / 2 + width * (i % columnCount); float y = containerRectTransform.rect.height / 2 - height * j; rectTransform.offsetMin = new Vector2(x, y); x = rectTransform.offsetMin.x + width; y = rectTransform.offsetMin.y + height; rectTransform.offsetMax = new Vector2(x, y); } }
public void Login(string username, string password) { //string username = GameObject.Find("cl_input_username").GetComponent<InputField>().value; //string password = GameObject.Find("cl_input_password").GetComponent<InputField>().value; _database = new Database_module (); User user = _database.login (username, password); GlobalVariables.user = user; bool internet = _database.hasInternetAccess (); Debug.Log (internet); if (user.id != 0) { if (user.usertype_id==(int)User_type.COACH) { //It's a coach Coach coach = _database.getCoach(user.id); GlobalVariables.coach = coach; //Application.LoadLevel ("Coach_and_train"); _user_interface.SetLoginMenuVisibility(false); _user_interface.SetCoachMainMenuVisibility(true); _user_interface.SetCoachLeftPanelVisibility(true); } else if (user.usertype_id==(int)User_type.PLAYER) { //It's a player _user_interface.SetLoginMenuVisibility(false); _user_interface.SetPlayerMainMenuVisibility(true); _user_interface.SetPlayerLeftPanelVisibility(true); } _coach_scenario_state = Coach_scenario_state.MAIN_MENU; } else { Debug.Log ("no user"); _user_interface.SetLoginErrorVisibility(true); _user_interface.CleanLoginTextfields(); } Debug.Log(username+" "+password); }