// Changes the text in each item holder. If the avatar has been bought by the user, this method will // change the text from the price of the avatar to "SOLD". public void update_sprite(int weapon_id) { for (int i = 0; i < item_holder_list.Count; i++) { item_holder holder_script = item_holder_list[i].GetComponent <item_holder>(); if (holder_script.item_id == weapon_id) { for (int j = 0; j < weapon_list.Count; j++) { if (weapon_list[j].weapon_id == weapon_id) { // If the avatar has been bought, change the text to "SOLD". if (weapon_list[j].bought) { holder_script.item_price.text = "SOLD"; } } } } } }
// Used to populate the avatar shop list with all the avatars and their prices, etc. void fillList() { for (int i = 0; i < weapon_list.Count; i++) { GameObject holder = Instantiate(item_holder_prefab, grid, false); item_holder holder_script = holder.GetComponent <item_holder>(); holder_script.item_name.text = weapon_list[i].weapon_name; holder_script.item_price.text = weapon_list[i].weapon_price.ToString(); holder_script.item_id = weapon_list[i].weapon_id; // can check here if the char is male or female then load in the appropriate image holder_script.item_image.sprite = Resources.Load <Sprite>("Sprites/" + game_manager.gameManager.gender + "/" + "hero" + weapon_list[i].weapon_id + "/1"); //BUY button holder_script.buy_button.GetComponent <buy_button>().weapon_id = weapon_list[i].weapon_id; item_holder_list.Add(holder); buy_button_list.Add(holder_script.buy_button); } }