This commit is contained in:
2026-08-23 17:33:32 +03:00
parent ee7b1617c1
commit cdba320cbc
10 changed files with 233 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://c2dx4khl7voyd"]
[node name="BearFx" type="Node3D" unique_id=1568304275]
+46
View File
@@ -0,0 +1,46 @@
[gd_scene format=3 uid="uid://by4ifsgxlv0gj"]
[ext_resource type="PackedScene" uid="uid://bm6rmt3xprhjs" path="res://Assets/bear_level_arena.glb" id="1_beararena"]
[ext_resource type="Script" path="res://matador_spawn.gd" id="2_spawn"]
[ext_resource type="PackedScene" path="res://Bear.tscn" id="3_bear"]
[sub_resource type="BoxShape3D" id="BoxShape3D_floor"]
[node name="bear_level" type="Node3D" unique_id=2020009824]
[node name="Node3D" type="Node3D" parent="." unique_id=1366355859]
[node name="StaticBody3D" type="StaticBody3D" parent="Node3D" unique_id=721553462]
[node name="CollisionShape3D" type="CollisionShape3D" parent="Node3D/StaticBody3D" unique_id=474515358]
transform = Transform3D(30, 0, 0, 0, 1, 0, 0, 0, 30, 0, -0.5, 0)
shape = SubResource("BoxShape3D_floor")
[node name="bear_level_arena" parent="." unique_id=948414670 instance=ExtResource("1_beararena")]
transform = Transform3D(2.875, 0, 0, 0, 2.875, 0, 0, 0, 2.875, 0, 0, 0)
[node name="MatadorSpawner" type="Node3D" parent="." unique_id=1869467620]
script = ExtResource("2_spawn")
enemy_scene = ExtResource("3_bear")
[node name="Lights" type="Node3D" parent="." unique_id=1435665429]
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="Lights" unique_id=1814200565]
transform = Transform3D(0.01535992, 0.56825536, -0.82270896, 0.16280846, 0.8104039, 0.56279576, 0.9865382, -0.14258848, -0.08006904, -4.08134, 9.197985, 0.97087634)
light_energy = 0.4
light_indirect_energy = 0.767
shadow_blur = 0.47
[node name="SpotLight3D2" type="SpotLight3D" parent="Lights" unique_id=2071037822]
transform = Transform3D(0.904133, 0.30962402, -0.2944087, 0.3084627, 0.0037425472, 0.9512291, 0.2956252, -0.95085174, -0.0921237, -3.629381, 10.86347, -2.0124264)
light_energy = 16.0
light_indirect_energy = 26.095
distance_fade_enabled = true
spot_range = 32.90586
spot_angle = 73.93
[node name="SUN_DirectionalLight3D2" type="DirectionalLight3D" parent="Lights" unique_id=1003843933]
transform = Transform3D(0.45811793, 0.34843865, -0.81775206, 0.5316611, 0.62986195, 0.56622505, 0.7123655, -0.69416475, 0.10329977, 0, 8.980043, 0)
light_energy = 0.106
shadow_enabled = true
shadow_blur = 10.0
Binary file not shown.
+45
View File
@@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://2e6fbder27w1"
path="res://.godot/imported/cubes_fx_test.glb-29490ce7011d666c1c4917a1a92679e4.scn"
[deps]
source_file="res://Assets/fx/cubes_fx_test.glb"
dest_files=["res://.godot/imported/cubes_fx_test.glb-29490ce7011d666c1c4917a1a92679e4.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1
Binary file not shown.
Binary file not shown.
+104
View File
@@ -0,0 +1,104 @@
extends CanvasLayer
const _GOLD := Color(1.00, 0.78, 0.22)
const _CREAM := Color(0.93, 0.88, 0.72)
const _BAR_W: float = 260.0
const _BAR_H: float = 18.0
const _BAR_BG: Color = Color(0.12, 0.04, 0.04, 0.88)
const _BAR_FILL: Color = Color(0.65, 0.08, 0.06)
const _BAR_ENRAGE: Color = Color(0.90, 0.32, 0.06)
var _bear: Node = null
var _fill: ColorRect = null
var _label: Label = null
var _max_hp: int = 1
var _current_hp: int = 1
func _ready() -> void:
layer = 10
_build_ui()
_find_bear.call_deferred()
func _find_bear() -> void:
var bears := get_tree().get_nodes_in_group(&"bear")
if bears.is_empty():
return
_bear = bears[0]
_bear.health_changed.connect(_on_health_changed)
_bear.killed.connect(_on_bear_killed)
var max_hp := int(DP.f("bear_max_hp"))
_on_health_changed(_bear.get_hp(), max_hp)
func _on_health_changed(current: int, max_hp: int) -> void:
_current_hp = current
_max_hp = max_hp
_update_bar()
func _on_bear_killed() -> void:
_current_hp = 0
_update_bar()
func _update_bar() -> void:
if _fill == null:
return
var frac := 0.0 if _max_hp <= 0 else clampf(float(_current_hp) / float(_max_hp), 0.0, 1.0)
_fill.size.x = _BAR_W * frac
var enrage_frac: float = DP.f("bear_enrage_frac")
_fill.color = _BAR_FILL.lerp(_BAR_ENRAGE, 1.0 - frac / enrage_frac if frac < enrage_frac else 0.0)
if _label != null:
_label.text = "BEAR %d / %d" % [maxi(_current_hp, 0), _max_hp]
func _build_ui() -> void:
var panel := PanelContainer.new()
panel.add_theme_stylebox_override(
"panel", UiTheme.plaque(UiTheme.LEATHER, UiTheme.BORDER, 4, 14.0, 8.0))
panel.anchor_left = 0.5
panel.anchor_right = 0.5
panel.anchor_top = 0.0
panel.anchor_bottom = 0.0
panel.grow_horizontal = Control.GROW_DIRECTION_BOTH
panel.offset_top = 16.0
panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
add_child(panel)
var col := VBoxContainer.new()
col.add_theme_constant_override("separation", 5)
col.mouse_filter = Control.MOUSE_FILTER_IGNORE
panel.add_child(col)
_label = Label.new()
_label.text = "BEAR"
_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_label.add_theme_font_override("font", UiFonts.body())
_label.add_theme_color_override("font_color", _GOLD)
_label.add_theme_color_override("font_outline_color", Color(0, 0, 0, 0.85))
_label.add_theme_constant_override("outline_size", 3)
_label.add_theme_font_size_override("font_size", 13)
_label.mouse_filter = Control.MOUSE_FILTER_IGNORE
col.add_child(_label)
var bar_bg := PanelContainer.new()
bar_bg.custom_minimum_size = Vector2(_BAR_W, _BAR_H)
bar_bg.clip_contents = true
var bg_style := StyleBoxFlat.new()
bg_style.bg_color = _BAR_BG
bg_style.set_corner_radius_all(4)
bg_style.corner_detail = 4
bg_style.border_width_bottom = 2
bg_style.border_color = Color(UiTheme.GOLD.r, UiTheme.GOLD.g, UiTheme.GOLD.b, 0.35)
bar_bg.add_theme_stylebox_override("panel", bg_style)
bar_bg.mouse_filter = Control.MOUSE_FILTER_IGNORE
col.add_child(bar_bg)
_fill = ColorRect.new()
_fill.color = _BAR_FILL
_fill.size = Vector2(_BAR_W, _BAR_H)
_fill.mouse_filter = Control.MOUSE_FILTER_IGNORE
bar_bg.add_child(_fill)
+1
View File
@@ -0,0 +1 @@
uid://dfk7dcvki7rqu
+33
View File
@@ -0,0 +1,33 @@
extends Node3D
signal matador_killed
signal all_defeated
@export var enemy_scene: PackedScene = null
var _alive: int = 0
var _resolved: bool = false
func _ready() -> void:
add_to_group(&"matador_spawn")
_spawn.call_deferred()
func _spawn() -> void:
if enemy_scene == null:
return
var bear: Node3D = enemy_scene.instantiate()
bear.position = Vector3.ZERO
get_parent().add_child(bear)
if bear.has_signal(&"killed"):
bear.killed.connect(_on_bear_killed)
_alive += 1
func _on_bear_killed() -> void:
matador_killed.emit()
_alive -= 1
if not _resolved:
_resolved = true
all_defeated.emit()
+1
View File
@@ -0,0 +1 @@
uid://bbtlwihtlc1wp