2.5d渲染/ui

master
chendian 2 years ago
parent 52ed16f22f
commit 8885f58b83

@ -0,0 +1,8 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://c8r7kifl8faqr"]
[ext_resource type="Shader" path="res://render/shader/character.gdshader" id="1_ja5hr"]
[resource]
render_priority = 0
shader = ExtResource("1_ja5hr")
shader_parameter/flash_white = null

@ -2,11 +2,13 @@ shader_type spatial;
render_mode depth_prepass_alpha,unshaded;
uniform sampler2D tex : source_color,filter_nearest;
uniform float flash_white;
void fragment() {
vec4 col = texture(tex, UV);
if(col.a<0.5){
discard;
if(col.a<0.5){discard;}
if(flash_white>0.0){
col.rgb = col.rgb * (flash_white + 1.0) * vec3(1,1,1);
}
ALBEDO = col.rgb;
ALPHA = 1.0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bjv7f83tdgq17"
path="res://.godot/imported/explodeDecal.png-f644d5db8c0778f842c076bf4d5a2eb8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://render/texture/explodeDecal.png"
dest_files=["res://.godot/imported/explodeDecal.png-f644d5db8c0778f842c076bf4d5a2eb8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ceu7b4nuktlgy"
path="res://.godot/imported/swordDecal.png-cb01b48f8d07246ce447a89d9248f176.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://render/texture/swordDecal.png"
dest_files=["res://.godot/imported/swordDecal.png-cb01b48f8d07246ce447a89d9248f176.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -18,17 +18,17 @@ dest_files=["res://.godot/imported/basic_move.png-ca2a3b7e7fd156603c8676a90db561
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -23,7 +23,7 @@ compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -3,30 +3,29 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dkcoj30ykgfck"
path.s3tc="res://.godot/imported/hero01_move.png-bcacccbe39aeeae76a6dd3feeffec29f.s3tc.ctex"
path="res://.godot/imported/hero01_move.png-bcacccbe39aeeae76a6dd3feeffec29f.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
"vram_texture": false
}
[deps]
source_file="res://resource/animation/character/hero01_move.png"
dest_files=["res://.godot/imported/hero01_move.png-bcacccbe39aeeae76a6dd3feeffec29f.s3tc.ctex"]
dest_files=["res://.godot/imported/hero01_move.png-bcacccbe39aeeae76a6dd3feeffec29f.ctex"]
[params]
compress/mode=2
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=true
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -18,17 +18,17 @@ dest_files=["res://.godot/imported/monster02_move.png-71e8627cfe4ec225664844395c
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

@ -31,4 +31,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b4ly1exl0owck"
path="res://.godot/imported/headbar_hp.png-4c7bcc4d968ba9ca97f4dfd5f7a72960.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://resource/ui/hud/headbar_hp.png"
dest_files=["res://.godot/imported/headbar_hp.png-4c7bcc4d968ba9ca97f4dfd5f7a72960.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cwhu1ec03t3c8"
path="res://.godot/imported/headbar_hp_empty.png-3162ff30a21804f44a538a5ac31e6fbc.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://resource/ui/hud/headbar_hp_empty.png"
dest_files=["res://.godot/imported/headbar_hp_empty.png-3162ff30a21804f44a538a5ac31e6fbc.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bvaylj7jl2n0c"
path="res://.godot/imported/shield_icon.png-4b43321b9822c003c4aa51e5d91caecc.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://resource/ui/hud/shield_icon.png"
dest_files=["res://.godot/imported/shield_icon.png-4b43321b9822c003c4aa51e5d91caecc.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=0
compress/normal_map=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=false
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

@ -2,7 +2,7 @@
[ext_resource type="Script" path="res://script/character/character.gd" id="1_tonbs"]
[ext_resource type="Script" path="res://script/character/status.gd" id="2_txdip"]
[ext_resource type="Shader" path="res://shader/character.gdshader" id="3_j0vnf"]
[ext_resource type="Shader" path="res://render/shader/character.gdshader" id="3_ed424"]
[ext_resource type="SpriteFrames" uid="uid://ce83cuqwgwwi4" path="res://resource/animation/character/hero01_long_attack.aseprite" id="3_q8i10"]
[ext_resource type="Script" path="res://script/character/move.gd" id="4_66r53"]
[ext_resource type="Texture2D" uid="uid://daqn6aqfp1hva" path="res://resource/animation/character/hero01_long_attack.png" id="4_fcd8a"]
@ -16,7 +16,8 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3u7mw"]
render_priority = 0
shader = ExtResource("3_j0vnf")
shader = ExtResource("3_ed424")
shader_parameter/flash_white = null
shader_parameter/tex = ExtResource("4_fcd8a")
[node name="Character" type="CharacterBody3D"]
@ -36,6 +37,7 @@ break_level = 4
[node name="View" type="AnimatedSprite3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1.414, 0, 0, 0, 1, 0, 0.376646, 0)
layers = 524288
material_override = SubResource("ShaderMaterial_3u7mw")
lod_bias = 0.001
gi_mode = 0

@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=3 uid="uid://bkhnhc6bk3w7l"]
[gd_scene load_steps=11 format=3 uid="uid://bkhnhc6bk3w7l"]
[ext_resource type="Script" path="res://script/manager/game_manager.gd" id="1_q2t80"]
[ext_resource type="ArrayMesh" uid="uid://cap7t5iwpjpi2" path="res://resource/level/levelground0000.vox" id="1_u51ir"]
@ -6,6 +6,9 @@
[ext_resource type="Resource" uid="uid://dmfh54jffhx28" path="res://config/character/monster02.tres" id="3_t5dvy"]
[ext_resource type="Script" path="res://script/manager/character_manager.gd" id="4_oonkb"]
[ext_resource type="Script" path="res://script/editor_tool/editor_tool.gd" id="5_n3qhi"]
[ext_resource type="PackedScene" uid="uid://cc525u8auypjf" path="res://scene/ui/profile_screen.tscn" id="6_u1fxn"]
[ext_resource type="PackedScene" uid="uid://126wph4owvoy" path="res://scene/ui/hud_screen.tscn" id="7_gx646"]
[ext_resource type="Texture2D" uid="uid://bjv7f83tdgq17" path="res://render/texture/explodeDecal.png" id="7_hqv3v"]
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_2mxa4"]
data = PackedVector3Array(-6.4, 0, -6.4, -3.2, 0, -6.4, -3.2, 0, 6.4, -3.2, 0, 6.4, -6.4, 0, 6.4, -6.4, 0, -6.4, -3.2, 0, 3.2, 6.4, 0, 3.2, 6.4, 0, 6.4, 6.4, 0, 6.4, -3.2, 0, 6.4, -3.2, 0, 3.2, -3.2, 0, -3.2, 3.2, 0, -3.2, 3.2, 0, 3.2, 3.2, 0, 3.2, -3.2, 0, 3.2, -3.2, 0, -3.2, -3.2, 0, -6.4, 6.4, 0, -6.4, 6.4, 0, -3.2, 6.4, 0, -3.2, -3.2, 0, -3.2, -3.2, 0, -6.4, 3.2, 0, -3.2, 6.4, 0, -3.2, 6.4, 0, 3.2, 6.4, 0, 3.2, 3.2, 0, 3.2, 3.2, 0, -3.2, -3.2, -0.1, 6.4, -3.2, -0.1, -6.4, -6.4, -0.1, -6.4, -6.4, -0.1, -6.4, -6.4, -0.1, 6.4, -3.2, -0.1, 6.4, 6.4, -0.1, 6.4, 6.4, -0.1, 3.2, -3.2, -0.1, 3.2, -3.2, -0.1, 3.2, -3.2, -0.1, 6.4, 6.4, -0.1, 6.4, 3.2, -0.1, 3.2, 3.2, -0.1, -3.2, -3.2, -0.1, -3.2, -3.2, -0.1, -3.2, -3.2, -0.1, 3.2, 3.2, -0.1, 3.2, 6.4, -0.1, -3.2, 6.4, -0.1, -6.4, -3.2, -0.1, -6.4, -3.2, -0.1, -6.4, -3.2, -0.1, -3.2, 6.4, -0.1, -3.2, 6.4, -0.1, 3.2, 6.4, -0.1, -3.2, 3.2, -0.1, -3.2, 3.2, -0.1, -3.2, 3.2, -0.1, 3.2, 6.4, -0.1, 3.2, -6.4, 0, -6.4, -6.4, 0, 6.4, -6.4, -0.1, 6.4, -6.4, -0.1, 6.4, -6.4, -0.1, -6.4, -6.4, 0, -6.4, 6.4, 0, -6.4, 6.4, -0.1, -6.4, 6.4, -0.1, 6.4, 6.4, -0.1, 6.4, 6.4, 0, 6.4, 6.4, 0, -6.4, -6.4, -0.1, 6.4, -6.4, 0, 6.4, 6.4, 0, 6.4, 6.4, 0, 6.4, 6.4, -0.1, 6.4, -6.4, -0.1, 6.4, 6.4, 0, -6.4, -6.4, 0, -6.4, -6.4, -0.1, -6.4, -6.4, -0.1, -6.4, 6.4, -0.1, -6.4, 6.4, 0, -6.4)
@ -50,5 +53,18 @@ use_collision = true
unique_name_in_owner = true
script = ExtResource("4_oonkb")
[node name="UIManager" type="Node3D" parent="GameManager"]
[node name="ProfileScreen" parent="GameManager/UIManager" instance=ExtResource("6_u1fxn")]
[node name="HudScreen" parent="GameManager/UIManager" instance=ExtResource("7_gx646")]
[node name="EditorTool" type="Node3D" parent="."]
script = ExtResource("5_n3qhi")
[node name="Decal" type="Decal" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.924324, -0.0136981, 0)
size = Vector3(0.5, 0.5, 0.5)
texture_albedo = ExtResource("7_hqv3v")
modulate = Color(0, 0, 0, 1)
cull_mask = 1

@ -0,0 +1,39 @@
[gd_scene load_steps=3 format=3 uid="uid://126wph4owvoy"]
[ext_resource type="Texture2D" uid="uid://cwhu1ec03t3c8" path="res://resource/ui/hud/headbar_hp_empty.png" id="1_flgf6"]
[ext_resource type="Texture2D" uid="uid://b4ly1exl0owck" path="res://resource/ui/hud/headbar_hp.png" id="2_sktwb"]
[node name="HudScreen" type="CanvasLayer"]
[node name="HudPage" type="Control" parent="."]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="Player" type="Control" parent="HudPage"]
anchors_preset = 0
offset_left = 29.0
offset_top = 29.0
offset_right = 29.0
offset_bottom = 29.0
[node name="HpBar" type="TextureProgressBar" parent="HudPage/Player"]
layout_mode = 0
offset_left = -13.0
offset_top = -13.0
offset_right = 51.0
offset_bottom = 3.0
value = 50.0
stretch_margin_left = 10
stretch_margin_top = 10
stretch_margin_right = 10
stretch_margin_bottom = 10
texture_under = ExtResource("1_flgf6")
texture_progress = ExtResource("2_sktwb")
[node name="HeadBarPage" type="Control" parent="."]
layout_mode = 3
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0

@ -0,0 +1,20 @@
[gd_scene load_steps=2 format=3 uid="uid://cc525u8auypjf"]
[ext_resource type="Script" path="res://script/ui/profile/fps.gd" id="1_ay6sg"]
[node name="ProfileScreen" type="CanvasLayer"]
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -41.0
offset_bottom = 56.0
grow_horizontal = 0
size_flags_horizontal = 8
size_flags_vertical = 0
[node name="FPS" type="Label" parent="VBoxContainer"]
layout_mode = 2
text = "123"
script = ExtResource("1_ay6sg")

@ -65,10 +65,11 @@ func settle(hit_info:HitInfo):
character_to.add_buff("hit_up",attack.hit_up_duration)
#抖动
character_to.add_buff("shake_x",0.2)
character_to.add_buff("shake_x",0.2,true)
#闪白
character_to.add_buff("flash_white",0.1)
#卡帧
character_from.add_buff("pause",0.1)
character_to.add_buff("pause",0.1)

@ -8,17 +8,20 @@ class BuffInfo:
var name : String
var duration_max : float
var duration : float
var ignore_pause : bool
var buff_map = {} #命中信息
func _process(delta):
for buff_name in buff_map:
var buff_info = buff_map[buff_name]
if has_buff("pause") and buff_name!="pause":
if has_buff("pause") and buff_name!="pause" and !buff_info.ignore_pause:
continue
if buff_info.duration_max == -1:
trigger_buff_effect(buff_info,"update")
else:
if buff_info.duration == 0:
trigger_buff_effect(buff_info,"second")
buff_info.duration += delta
if buff_info.duration >= buff_info.duration_max:
trigger_buff_effect(buff_info,"end")
@ -36,7 +39,7 @@ func trigger_buff_effect(buff:BuffInfo,trigger_name:String):
func has_buff(buff_name:String) -> bool:
return buff_name in buff_map
func add_buff(buff_name:String,duration:float):
func add_buff(buff_name:String,duration:float,ignore_pause:bool=false):
var buff : BuffInfo
if buff_name in buff_map:
buff = buff_map[buff_name]
@ -46,28 +49,34 @@ func add_buff(buff_name:String,duration:float):
buff_map[buff_name] = buff
buff.duration_max = duration
buff.duration = 0
buff.ignore_pause = ignore_pause
trigger_buff_effect(buff,"start")
func remove_buff(buff_name:String):
buff_map.erase(buff_name)
#==具体实现==
#位移
func on_end_hit_back(rate):status.hit_back_speed = 0
func on_end_hit_up(rate):status.hit_up_speed = 0
func on_start_stagger(rate):status.is_stagger = true
func on_end_stagger(rate):status.is_stagger = false
func on_end_stun(rate):status.is_stun = false
func on_start_jumping(rate):status.is_jumping = true
func on_end_jumping(rate):status.is_jumping = false
func on_update_shake_x(rate):
var offset = sin(rate * PI * 4) - 0.5
status.shake_offset = Vector3(offset*0.02,0,0);
func on_end_shake_x(rate):status.shake_offset = Vector3.ZERO
func on_start_pause(rate):status.is_pause = true
func on_end_pause(rate):status.is_pause = false
func on_start_floating(rate):status.is_floating = true
func on_update_floating(rate):
if status.is_on_floor:
#反弹
status.is_floating=false
#战斗状态
func on_start_stagger(rate):status.is_stagger = true
func on_end_stagger(rate):status.is_stagger = false
func on_end_stun(rate):status.is_stun = false
#表现
func on_start_flash_white(rate):status.flash_white_rate = 1
func on_update_flash_white(rate):status.flash_white_rate = 1 - rate
func on_end_flash_white(rate):status.flash_white_rate = 0
func on_second_pause(rate):status.is_pause = true
func on_end_pause(rate):status.is_pause = false
func on_update_shake_x(rate):status.shake_offset = Vector3((sin(rate * PI * 4) - 0.5)*0.02,0,0);
func on_end_shake_x(rate):status.shake_offset = Vector3.ZERO

@ -33,6 +33,9 @@ func build_battle(cfg:CharacterCfg):
status.shield = cfg.shield_max
status.shield_max = cfg.shield_max
func set_material(material:ShaderMaterial):
view.material_override = material
#==getter==
func manager()->CharacterManager:return character_manager
func id()->int:return status.id
@ -41,7 +44,7 @@ func pos()->Vector2:return Vector2(position.x,position.z)
#==interface==
func set_pos(pos:Vector3):position = pos
func add_buff(buff_name:String,duration:float):buff.add_buff(buff_name,duration)
func add_buff(buff_name:String,duration:float,ignore_pause:bool=false):buff.add_buff(buff_name,duration,ignore_pause)
func set_hit_move(hit_back_dir:Vector2,hit_back_speed:float,hit_up_speed:float):
status.hit_back_dir = hit_back_dir
status.hit_back_speed = hit_back_speed

@ -19,6 +19,7 @@ class_name Status
@export var basic_offset : Vector3 #基本偏移值
@export var shake_offset : Vector3 #抖动偏移值
@export var is_pause : bool #是否暂停
@export var flash_white_rate : float #闪白比例
@export_category("移动状态")
@export var move_dir : Vector2 #移动方向

@ -57,13 +57,16 @@ func _ready():
trans("ground1_loop","ground2","is_stagger","=",false)
run("ground2","idle_loop")
func _process(delta):
update_view()
if not status.is_skill_running and status.is_pause == is_playing():
if status.is_pause:pause();
else:play();
if status.is_pause:return
update_flip()
update_view()
update_trans(false)
update_texture()
update_flash_white()
func init(default:SpriteFrames):
sprite_frames = default
@ -127,3 +130,12 @@ func update_view():
func _on_animation_finished():
update_trans(true)
func update_texture():
var tex = sprite_frames.get_frame_texture(animation,frame)
var material = material_override as ShaderMaterial
material.set_shader_parameter("tex",tex)
func update_flash_white():
var material = material_override as ShaderMaterial
material.set_shader_parameter("flash_white",status.flash_white_rate)

@ -3,6 +3,7 @@ class_name CharacterManager
var scene_player = preload("res://scene/character/player.tscn")
var scene_monster = preload("res://scene/character/monster.tscn")
var character_material = preload("res://render/material/character.tres")
var character_map = {}
var character_idx : int = 0
@ -20,6 +21,7 @@ func create_character(cfg:CharacterCfg,team:Enum.ETeam,pos:Vector3):
character_idx += 1
character_map[character_idx]=character
character.init(self,character_idx,cfg,team)
character.set_material(character_material.duplicate())
character.set_pos(pos)
func get_character(id:int) -> Character:

@ -0,0 +1,4 @@
extends Label
func _process(delta):
set_text("FPS %d" % Engine.get_frames_per_second())
Loading…
Cancel
Save