You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			42 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			GDScript
		
	
		
		
			
		
	
	
			42 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			GDScript
		
	
| 
											2 years ago
										 | extends Control | ||
|  | class_name Headbar | ||
|  | 
 | ||
| 
											2 years ago
										 | @onready var hit_text_scene = preload("res://scene/ui/item/hit_text.tscn") | ||
|  | 
 | ||
| 
											2 years ago
										 | @onready var hp_bar = (%HpBar as TextureProgressBar) | ||
|  | @onready var shield_bar = (%ShieldBar as TextureProgressBar) | ||
|  | @onready var stun_bar = (%StunBar as TextureProgressBar) | ||
|  | @onready var mp_bar = (%MpBar as TextureProgressBar) | ||
|  | @onready var mp_sub_bar = (%MpSubBar as TextureProgressBar) | ||
| 
											2 years ago
										 | @onready var pos_lable = (%PosLabel as Label) | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 | var hit_text_damage_cache : HitText | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 | func on_hp_changed(value):hp_bar.value = value | ||
|  | func on_hp_max_changed(value):hp_bar.max_value = value | ||
|  | func on_shield_changed(value):shield_bar.value = value | ||
|  | func on_shield_max_changed(value):shield_bar.max_value = value | ||
|  | func on_stun_changed(value):stun_bar.value = value | ||
|  | func on_stun_max_changed(value):stun_bar.max_value = value | ||
|  | func on_mp_changed(value):mp_bar.value = value | ||
|  | func on_mp_max_changed(value):mp_bar.max_value = value | ||
|  | func on_mp_sub_changed(value):mp_sub_bar.value = value | ||
|  | func on_mp_sub_max_changed(value):mp_sub_bar.max_value = value | ||
| 
											2 years ago
										 | func on_pos2d_changed(value):pos_lable.text = "(%.2f,%.2f)"%[value.x,value.y] | ||
| 
											2 years ago
										 | 
 | ||
|  | func on_hit_text(value:String): | ||
|  | 	var hit_text = get_hit_text_object() | ||
|  | 	hit_text.show_hit_text(value) | ||
|  | 	 | ||
| 
											2 years ago
										 | func on_hit_damage(value:float): | ||
| 
											2 years ago
										 | 	var hit_text = hit_text_damage_cache | ||
|  | 	if not hit_text or hit_text.is_close: | ||
|  | 		hit_text_damage_cache = get_hit_text_object() | ||
|  | 		hit_text = hit_text_damage_cache | ||
|  | 	hit_text.show_hit_damage(value) | ||
|  | 	 | ||
|  | func get_hit_text_object()->HitText: | ||
|  | 	var hit_text = hit_text_scene.instantiate() as HitText | ||
|  | 	add_child(hit_text) | ||
|  | 	return hit_text |