RectTransform get_line_bar_by_type( line_bar type, int loc ) { switch(type){ case line_bar.MAX_HP_LINE: return max_hp_line[loc]; case line_bar.HP_LINE: return hp_line[loc]; case line_bar.MAX_MP_LINE: return max_mp_line[loc]; case line_bar.MP_LINE: return mp_line[loc]; case line_bar.MAX_ACT_LINE: return max_act_line[loc]; case line_bar.ACT_LINE: return act_line[loc]; default: return null; } }
public void update_line_bar(line_bar type, line_bar max_type, Player player, float percent) { RectTransform line = null; RectTransform max_line = null; for(int loc=0 ; loc<player_group.Length ; loc++ ){ if( player_group[loc] == player ){ line = get_line_bar_by_type(type, loc); max_line = get_line_bar_by_type(max_type, loc); } } if (line && max_line) { if (percent >= 1) percent = 1; float ori_width = max_line.rect.width; float ori_height = max_line.rect.height; line.sizeDelta = new Vector2 (ori_width * percent, ori_height); } }