This commit is contained in:
TsubakiLoL 2024-10-26 22:17:29 +08:00
parent 19a270cb1e
commit 75b5f001bd
57 changed files with 1240 additions and 158 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://yx6i71kdwm6j"
path="res://.godot/imported/1_Slingshot.png-8a70f8f5f5bd430fbaa9ec05bd5153ce.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/1_Slingshot.png"
dest_files=["res://.godot/imported/1_Slingshot.png-8a70f8f5f5bd430fbaa9ec05bd5153ce.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://0renymshjnfj"
path="res://.godot/imported/1_Slingshot_pull.png-16dce7dfdab330745dc47518256551b1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/1_Slingshot_pull.png"
dest_files=["res://.godot/imported/1_Slingshot_pull.png-16dce7dfdab330745dc47518256551b1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cyrr46lmsbrbx"
path="res://.godot/imported/2_Bow.png-42c406f3dbf3d4c06007d07f5d210e65.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/2_Bow.png"
dest_files=["res://.godot/imported/2_Bow.png-42c406f3dbf3d4c06007d07f5d210e65.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cp3ecqqm2mpoc"
path="res://.godot/imported/2_Bow_pull.png-0ccda659a9989499951af5a122b3b5e1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/2_Bow_pull.png"
dest_files=["res://.godot/imported/2_Bow_pull.png-0ccda659a9989499951af5a122b3b5e1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bs81okrb5bf1"
path="res://.godot/imported/3_Longbow.png-374f2a8c4ff364aeb2656f1a54eb2d7f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/3_Longbow.png"
dest_files=["res://.godot/imported/3_Longbow.png-374f2a8c4ff364aeb2656f1a54eb2d7f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://se3khy8uem13"
path="res://.godot/imported/3_Longbow_pull.png-9b86c2a8250d003f179725c5205d37b8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/3_Longbow_pull.png"
dest_files=["res://.godot/imported/3_Longbow_pull.png-9b86c2a8250d003f179725c5205d37b8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

BIN
TEST/Ranged Weapon/All.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://btwwewwpfdhwu"
path="res://.godot/imported/All.png-a9834e43ab00a8148d501ade9718f255.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/All.png"
dest_files=["res://.godot/imported/All.png-a9834e43ab00a8148d501ade9718f255.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cf5pkf10sn6"
path="res://.godot/imported/1_Stone (1).png-5d53da38b61708e4a89e0087a68bec03.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (1).png"
dest_files=["res://.godot/imported/1_Stone (1).png-5d53da38b61708e4a89e0087a68bec03.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://wcoid17psj8k"
path="res://.godot/imported/1_Stone (2).png-d6610342c5191ebcbdf70c6410b9da15.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (2).png"
dest_files=["res://.godot/imported/1_Stone (2).png-d6610342c5191ebcbdf70c6410b9da15.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://broprsurqu223"
path="res://.godot/imported/1_Stone (3).png-20ba3d170c3181f446ef088049338eab.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (3).png"
dest_files=["res://.godot/imported/1_Stone (3).png-20ba3d170c3181f446ef088049338eab.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bv5xyjlbyftle"
path="res://.godot/imported/1_Stone (4).png-fac442b59a76c7f8916ab594135af36a.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (4).png"
dest_files=["res://.godot/imported/1_Stone (4).png-fac442b59a76c7f8916ab594135af36a.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d01h2gifkwwrk"
path="res://.godot/imported/1_Stone (5).png-af725fa56b3a72b7638b6445536ac1b9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (5).png"
dest_files=["res://.godot/imported/1_Stone (5).png-af725fa56b3a72b7638b6445536ac1b9.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://m4axta8kmju3"
path="res://.godot/imported/1_Stone (6).png-ac181f528405c74bb604c71e9c291350.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (6).png"
dest_files=["res://.godot/imported/1_Stone (6).png-ac181f528405c74bb604c71e9c291350.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dcgpaty41sqvn"
path="res://.godot/imported/1_Stone (7).png-f1c3d6496d68acc00ecddef97b91f312.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (7).png"
dest_files=["res://.godot/imported/1_Stone (7).png-f1c3d6496d68acc00ecddef97b91f312.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dlre68qjbd6wx"
path="res://.godot/imported/1_Stone (8).png-43e804bd99dd10904843efbf035bb839.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/1_Stone (8).png"
dest_files=["res://.godot/imported/1_Stone (8).png-43e804bd99dd10904843efbf035bb839.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bc54jgmswd7x4"
path="res://.godot/imported/2_Arrow.png-ea8717abd702e43c75ee3eb350920cfd.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/2_Arrow.png"
dest_files=["res://.godot/imported/2_Arrow.png-ea8717abd702e43c75ee3eb350920cfd.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dpysapdru7mb6"
path="res://.godot/imported/3_Shuriken.png-416d7026b4cf3a52217d8f9c3ebd31a5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/3_Shuriken.png"
dest_files=["res://.godot/imported/3_Shuriken.png-416d7026b4cf3a52217d8f9c3ebd31a5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://crsldqc14uwrp"
path="res://.godot/imported/4_Kunai.png-1cc98e64aef835d99885d89f1096f865.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/4_Kunai.png"
dest_files=["res://.godot/imported/4_Kunai.png-1cc98e64aef835d99885d89f1096f865.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b3ckn2ypt81yh"
path="res://.godot/imported/5_Snowball.png-71a9f5e8b230b54360d0abc0cb80c583.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://TEST/Ranged Weapon/Bullet/5_Snowball.png"
dest_files=["res://.godot/imported/5_Snowball.png-71a9f5e8b230b54360d0abc0cb80c583.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
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

View File

@ -31,3 +31,35 @@ func get_init_favour(self_type:String,other_type:String):
pass pass
static func pre_proces_data(dic:Dictionary):
var new_dic=dic.duplicate(true)
for i in new_dic.keys():
new_dic[i]["id"]=i
for j in other_unit_data.keys():
new_dic[i][j]=other_unit_data[j]
return new_dic
static var other_unit_data={
"hungry":0,
"fatigue":0,
"rage":0,
"tensity":0,
"panic":0,
#压力
"pressure":0,
"hp_max":100,
"hp":100,
"atk":10,
}
#角色数据
@onready var character_data:Dictionary=pre_proces_data(preload("res://json/character.json").data)
func get_unit_data(id:String):
if character_data.has(id):
return character_data[id].duplicate(true)
else:
return null

24
json/character.json Normal file
View File

@ -0,0 +1,24 @@
{
"test_character_base":{
"unit_id":"default",
"unit_type":"default",
"sprite_frames":"res://res/animation/other_character_default.tres",
"sprite_offset":[0,-80],
"sprite_scale":[5,5],
"hp_base":100,
"atk_base":10,
"speed_base":1,
"attack_scene":"res://scene/character/attack/base/attack_scene_base.tscn",
},
"test_character_ranged":{
"unit_id":"default",
"unit_type":"default",
"sprite_frames":"res://res/animation/other_character_default.tres",
"sprite_offset":[0,-80],
"sprite_scale":[5,5],
"hp_base":100,
"atk_base":10,
"speed_base":1,
"attack_scene":"res://scene/character/attack/ranged/attack_scene_ranged.tscn",
}
}

View File

@ -0,0 +1,67 @@
[gd_scene load_steps=15 format=3 uid="uid://dirg8ytcjol3c"]
[ext_resource type="Script" path="res://addons/beehave/nodes/beehave_tree.gd" id="1_56xd6"]
[ext_resource type="Script" path="res://addons/beehave/nodes/composites/selector.gd" id="2_nj431"]
[ext_resource type="Script" path="res://addons/beehave/nodes/composites/sequence.gd" id="3_gw4kq"]
[ext_resource type="PackedScene" uid="uid://dukqa6ha8aeic" path="res://scene/test/condition_hungry.tscn" id="4_wp4ax"]
[ext_resource type="PackedScene" uid="uid://b65amfq474sv7" path="res://scene/test/action_move_to_target.tscn" id="5_nj8r8"]
[ext_resource type="PackedScene" uid="uid://k7sldgn2joe0" path="res://scene/test/action_eat.tscn" id="6_20yyb"]
[ext_resource type="PackedScene" uid="uid://hgsb64hg78m5" path="res://scene/test/condition_accuse.tscn" id="7_pm41v"]
[ext_resource type="PackedScene" uid="uid://cm7nelq3tbye6" path="res://scene/test/action_move_to_unit.tscn" id="8_gb1l0"]
[ext_resource type="PackedScene" uid="uid://c3pouwk6mbovv" path="res://scene/test/action_accuse.tscn" id="9_qjbcp"]
[ext_resource type="PackedScene" uid="uid://jkwn820drv43" path="res://scene/test/await_time.tscn" id="10_2383g"]
[ext_resource type="PackedScene" uid="uid://qrl0pc72e3q6" path="res://scene/test/condition_attack.tscn" id="11_35qx1"]
[ext_resource type="PackedScene" uid="uid://bcr5oa32fvxwa" path="res://scene/test/action_attack.tscn" id="12_h43ad"]
[ext_resource type="PackedScene" uid="uid://ldjrnwapxefe" path="res://scene/test/action_set_rand_pos.tscn" id="13_vko5r"]
[ext_resource type="PackedScene" uid="uid://dg0gnl5n62gq6" path="res://scene/test/run_await.tscn" id="14_pbpal"]
[node name="BeehaveTree" type="Node" node_paths=PackedStringArray("blackboard", "actor")]
script = ExtResource("1_56xd6")
blackboard = NodePath("@Node@17291")
actor = NodePath("")
[node name="SelectorComposite" type="Node" parent="."]
script = ExtResource("2_nj431")
[node name="eat" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gw4kq")
[node name="condition_hungry" parent="SelectorComposite/eat" instance=ExtResource("4_wp4ax")]
[node name="action_move_to_target" parent="SelectorComposite/eat" instance=ExtResource("5_nj8r8")]
[node name="action_eat" parent="SelectorComposite/eat" instance=ExtResource("6_20yyb")]
[node name="accuse" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gw4kq")
[node name="condition_accuse" parent="SelectorComposite/accuse" instance=ExtResource("7_pm41v")]
[node name="action_move_to_unit" parent="SelectorComposite/accuse" instance=ExtResource("8_gb1l0")]
[node name="action_accuse" parent="SelectorComposite/accuse" instance=ExtResource("9_qjbcp")]
[node name="await_time" parent="SelectorComposite/accuse" instance=ExtResource("10_2383g")]
await_time = 2.0
[node name="attack" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gw4kq")
[node name="condition_attack" parent="SelectorComposite/attack" instance=ExtResource("11_35qx1")]
[node name="action_move_to_unit" parent="SelectorComposite/attack" instance=ExtResource("8_gb1l0")]
[node name="action_attack" parent="SelectorComposite/attack" instance=ExtResource("12_h43ad")]
[node name="await_time" parent="SelectorComposite/attack" instance=ExtResource("10_2383g")]
await_time = 1.0
[node name="rand_walk" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gw4kq")
[node name="await_time" parent="SelectorComposite/rand_walk" instance=ExtResource("10_2383g")]
await_time = 2.0
[node name="action_set_rand_pos" parent="SelectorComposite/rand_walk" instance=ExtResource("13_vko5r")]
[node name="run_await" parent="SelectorComposite/rand_walk" instance=ExtResource("14_pbpal")]

View File

@ -0,0 +1,55 @@
extends ActionLeaf
#执行成功后是否抹除黑板目标数据
@export var should_erase_target_id:bool=false
#用于移动到特定单位的可交互范围内
func tick(actor:Node,black_board:Blackboard):
var unit:Unit=actor
if black_board.has_value("target_unit_id"):
var target_id:String=black_board.get_value("target_unit_id")
if Global.get_unit_instance(target_id)==null:
#移除目标
black_board.erase_value("target_unit_id")
return FAILURE
#获取要移动到的目标实例
var target_instance:Unit=Global.get_unit_instance(target_id)
if not unit.is_unit_instance_in_touch_area(target_instance):
unit.set_target_pos(target_instance.global_position)
match unit.get_dir():
0:
unit.play_animation("up")
1:
unit.play_animation("down")
2:
unit.play_animation("left_right")
3:
unit.play_animation("left_right")
return RUNNING
else:
unit.stop_move()
if should_erase_target_id:
black_board.erase_value("target_unit_id")
match unit.get_dir():
0:
unit.play_animation("up_idle")
1:
unit.play_animation("down_idle")
2:
unit.play_animation("left_right_idle")
3:
unit.play_animation("left_right_idle")
return SUCCESS
else:
black_board.erase_value("target_unit_id")
match unit.get_dir():
0:
unit.play_animation("up_idle")
1:
unit.play_animation("down_idle")
2:
unit.play_animation("left_right_idle")
3:
unit.play_animation("left_right_idle")
return FAILURE

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://sxe0f3fvvkh0"]
[ext_resource type="Script" path="res://scene/behavour_tree/ranged/action_move_to_unit_ranged.gd" id="1_5b1jd"]
[node name="action_move_to_unit_ranged" type="Node"]
script = ExtResource("1_5b1jd")

View File

@ -0,0 +1,67 @@
[gd_scene load_steps=15 format=3 uid="uid://pgntryipq1n5"]
[ext_resource type="Script" path="res://addons/beehave/nodes/beehave_tree.gd" id="1_4oqpx"]
[ext_resource type="Script" path="res://addons/beehave/nodes/composites/selector.gd" id="2_fltu2"]
[ext_resource type="Script" path="res://addons/beehave/nodes/composites/sequence.gd" id="3_gvxjj"]
[ext_resource type="PackedScene" uid="uid://dukqa6ha8aeic" path="res://scene/test/condition_hungry.tscn" id="4_oa75w"]
[ext_resource type="PackedScene" uid="uid://b65amfq474sv7" path="res://scene/test/action_move_to_target.tscn" id="5_ehseb"]
[ext_resource type="PackedScene" uid="uid://k7sldgn2joe0" path="res://scene/test/action_eat.tscn" id="6_2ghtm"]
[ext_resource type="PackedScene" uid="uid://hgsb64hg78m5" path="res://scene/test/condition_accuse.tscn" id="7_68ri4"]
[ext_resource type="PackedScene" uid="uid://cm7nelq3tbye6" path="res://scene/test/action_move_to_unit.tscn" id="8_pawul"]
[ext_resource type="PackedScene" uid="uid://c3pouwk6mbovv" path="res://scene/test/action_accuse.tscn" id="9_qbv7q"]
[ext_resource type="PackedScene" uid="uid://jkwn820drv43" path="res://scene/test/await_time.tscn" id="10_3kn43"]
[ext_resource type="PackedScene" uid="uid://qrl0pc72e3q6" path="res://scene/test/condition_attack.tscn" id="11_5kbxa"]
[ext_resource type="PackedScene" uid="uid://bcr5oa32fvxwa" path="res://scene/test/action_attack.tscn" id="12_p0fu4"]
[ext_resource type="PackedScene" uid="uid://ldjrnwapxefe" path="res://scene/test/action_set_rand_pos.tscn" id="13_gb573"]
[ext_resource type="PackedScene" uid="uid://dg0gnl5n62gq6" path="res://scene/test/run_await.tscn" id="14_ub8eh"]
[node name="BeehaveTree" type="Node" node_paths=PackedStringArray("blackboard", "actor")]
script = ExtResource("1_4oqpx")
blackboard = NodePath("@Node@17286")
actor = NodePath("")
[node name="SelectorComposite" type="Node" parent="."]
script = ExtResource("2_fltu2")
[node name="eat" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gvxjj")
[node name="condition_hungry" parent="SelectorComposite/eat" instance=ExtResource("4_oa75w")]
[node name="action_move_to_target" parent="SelectorComposite/eat" instance=ExtResource("5_ehseb")]
[node name="action_eat" parent="SelectorComposite/eat" instance=ExtResource("6_2ghtm")]
[node name="accuse" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gvxjj")
[node name="condition_accuse" parent="SelectorComposite/accuse" instance=ExtResource("7_68ri4")]
[node name="action_move_to_unit" parent="SelectorComposite/accuse" instance=ExtResource("8_pawul")]
[node name="action_accuse" parent="SelectorComposite/accuse" instance=ExtResource("9_qbv7q")]
[node name="await_time" parent="SelectorComposite/accuse" instance=ExtResource("10_3kn43")]
await_time = 2.0
[node name="attack" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gvxjj")
[node name="condition_attack" parent="SelectorComposite/attack" instance=ExtResource("11_5kbxa")]
[node name="action_move_to_unit" parent="SelectorComposite/attack" instance=ExtResource("8_pawul")]
[node name="action_attack" parent="SelectorComposite/attack" instance=ExtResource("12_p0fu4")]
[node name="await_time" parent="SelectorComposite/attack" instance=ExtResource("10_3kn43")]
await_time = 1.0
[node name="rand_walk" type="Node" parent="SelectorComposite"]
script = ExtResource("3_gvxjj")
[node name="await_time" parent="SelectorComposite/rand_walk" instance=ExtResource("10_3kn43")]
await_time = 2.0
[node name="action_set_rand_pos" parent="SelectorComposite/rand_walk" instance=ExtResource("13_gb573")]
[node name="run_await" parent="SelectorComposite/rand_walk" instance=ExtResource("14_ub8eh")]

View File

@ -0,0 +1,53 @@
extends Area2D
class_name AttackModel
func attack():
player().show_action("伤害")
match player().get_dir():
0:
player().play_animation("up_attack")
1:
player().play_animation("down_attack")
2:
player().play_animation("left_right_attack")
3:
player().play_animation("left_right_attack")
#判断单位是否再攻击范围内
func is_unit_instance_in_attack_area(instance:Node):
if instance is PhysicsBody2D:
return instance in get_overlapping_bodies()
if instance is Area2D:
return instance in get_overlapping_areas()
func _ready() -> void:
player().animation.frame_changed.connect(frame_changed)
pass
var attack_frames=2
func player()->Unit:
return get_parent().get_parent()
func frame_changed():
if player().animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and player().animation.frame==attack_frames:
use_attack_damage()
#在固定帧使用攻击
func use_attack_damage():
print("使用攻击")
for i in %attack_area.get_overlapping_bodies():
print(i)
if i is Unit and i!=player():
i.attacked(player().unit_id,player().get_atk())
#if animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and not animation.is_playing():
#return true
#else:
#return false
func is_attack_finished():
if player().animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and not player().animation.is_playing():
return true
else:
return false
func is_attacking():
return player().animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and player().animation.is_playing()
#攻击复位
func attack_reset():
pass

View File

@ -0,0 +1,22 @@
[gd_scene load_steps=4 format=3 uid="uid://daj4pnrtakfby"]
[ext_resource type="Script" path="res://scene/character/attack/base/attack_scene_base.gd" id="1_wkpgy"]
[sub_resource type="CircleShape2D" id="CircleShape2D_dqxim"]
radius = 104.12
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ho5n7"]
size = Vector2(121, 136)
[node name="attack_scene_base" type="Area2D"]
script = ExtResource("1_wkpgy")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_dqxim")
[node name="attack_area" type="Area2D" parent="."]
unique_name_in_owner = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="attack_area"]
position = Vector2(60.5, 3)
shape = SubResource("RectangleShape2D_ho5n7")

View File

@ -0,0 +1,24 @@
extends Area2D
var speed=1000
var unit_id:String=""
var atk:float=10
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
self.global_position+=Vector2(cos(self.global_rotation),sin(self.global_rotation))*speed*delta
pass
func _on_body_entered(body: Node2D) -> void:
if body is Unit and body!=Global.get_unit_instance(unit_id):
body.attacked(unit_id,atk)
if body!=Global.get_unit_instance(unit_id):
queue_free()
pass # Replace with function body.

View File

@ -0,0 +1,20 @@
[gd_scene load_steps=4 format=3 uid="uid://bpk3f8nuoxeff"]
[ext_resource type="Texture2D" uid="uid://bc54jgmswd7x4" path="res://TEST/Ranged Weapon/Bullet/2_Arrow.png" id="1_2txil"]
[ext_resource type="Script" path="res://scene/character/attack/ranged/attack_range_bullet.gd" id="1_qqft1"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_d6whh"]
size = Vector2(71, 20)
[node name="attack_range_bullet" type="Area2D"]
script = ExtResource("1_qqft1")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.43, 0.43)
texture = ExtResource("1_2txil")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0.5, 0)
shape = SubResource("RectangleShape2D_d6whh")
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@ -0,0 +1,52 @@
extends AttackModel
func attack():
%AnimatedSprite2D.play("attack")
attack_state=1
var attack_state:int=0
#判断单位是否再攻击范围内
func is_unit_instance_in_attack_area(instance:Node):
if instance is PhysicsBody2D:
return instance in get_overlapping_bodies()
if instance is Area2D:
return instance in get_overlapping_areas()
func _ready() -> void:
%AnimatedSprite2D.frame_changed.connect(frame_changed)
pass
func player()->Unit:
return get_parent().get_parent()
func frame_changed():
print(%AnimatedSprite2D.frame)
if %AnimatedSprite2D.frame==attack_frames:
use_attack_damage()
if %AnimatedSprite2D.frame==2:
attack_state=2
const ATTACK_RANGE_BULLET = preload("res://scene/character/attack/ranged/attack_range_bullet.tscn")
#在固定帧使用攻击
func use_attack_damage():
print("使用攻击")
#for i in %attack_area.get_overlapping_bodies():
#print(i)
#if i is Unit and i!=player():
#i.attacked(player().unit_id,player().get_atk())
var new_bullet=ATTACK_RANGE_BULLET.instantiate()
new_bullet.global_position=player().global_position
new_bullet.global_rotation=global_rotation
new_bullet.unit_id=player().unit_id
new_bullet.atk=player().get_atk()
player().get_parent().add_child(new_bullet)
#if animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and not animation.is_playing():
#return true
#else:
#return false
func is_attack_finished():
return attack_state ==2
func is_attacking():
return attack_state ==1
func attack_reset():
attack_state=0
pass

View File

@ -0,0 +1,44 @@
[gd_scene load_steps=6 format=3 uid="uid://dao1drdc1dla6"]
[ext_resource type="Script" path="res://scene/character/attack/ranged/attack_scene_ranged.gd" id="1_rpaof"]
[ext_resource type="Texture2D" uid="uid://bs81okrb5bf1" path="res://TEST/Ranged Weapon/3_Longbow.png" id="2_1o465"]
[ext_resource type="Texture2D" uid="uid://se3khy8uem13" path="res://TEST/Ranged Weapon/3_Longbow_pull.png" id="3_i46q8"]
[sub_resource type="SpriteFrames" id="SpriteFrames_35llq"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_1o465")
}, {
"duration": 1.0,
"texture": ExtResource("3_i46q8")
}, {
"duration": 1.0,
"texture": ExtResource("2_1o465")
}],
"loop": false,
"name": &"attack",
"speed": 5.0
}, {
"frames": [],
"loop": true,
"name": &"normal",
"speed": 5.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_5ekof"]
radius = 486.901
[node name="attack_scene_ranged" type="Area2D"]
z_index = 1
scale = Vector2(0.992374, 0.996413)
script = ExtResource("1_rpaof")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
unique_name_in_owner = true
scale = Vector2(0.515, 0.515)
sprite_frames = SubResource("SpriteFrames_35llq")
animation = &"attack"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_5ekof")

View File

@ -2,6 +2,21 @@
[ext_resource type="Script" path="res://scene/character/dead_scene_sprite/dead_scene.gd" id="1_ugaxh"] [ext_resource type="Script" path="res://scene/character/dead_scene_sprite/dead_scene.gd" id="1_ugaxh"]
[sub_resource type="Animation" id="Animation_mdkhy"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_w6wlf"] [sub_resource type="Animation" id="Animation_w6wlf"]
resource_name = "modulutehide" resource_name = "modulutehide"
length = 0.5 length = 0.5
@ -18,21 +33,6 @@ tracks/0/keys = {
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)] "values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
} }
[sub_resource type="Animation" id="Animation_mdkhy"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_a2cak"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_a2cak"]
_data = { _data = {
"RESET": SubResource("Animation_mdkhy"), "RESET": SubResource("Animation_mdkhy"),

14
scene/class/game_data.gd Normal file
View File

@ -0,0 +1,14 @@
class_name GameData
var data:Dictionary={
}
func _init(use_character_id:String) -> void:
var cdata=Database.get_character_data(use_character_id)
if cdata!=null:
data["character_data"]=cdata
else:
push_error("未找到角色数据")
pass
func get_character_data():
return data["character_data"]

View File

@ -10,6 +10,16 @@ func tick(actor:Node,black_board:Blackboard):
return RUNNING return RUNNING
if unit.is_attack_finished(): if unit.is_attack_finished():
black_board.erase_value("target_unit_id") black_board.erase_value("target_unit_id")
match unit.get_dir():
0:
unit.play_animation("up_idle")
1:
unit.play_animation("down_idle")
2:
unit.play_animation("left_right_idle")
3:
unit.play_animation("left_right_idle")
unit.attack_reset()
return SUCCESS return SUCCESS
if black_board.has_value("target_unit_id") and not unit.is_attacking(): if black_board.has_value("target_unit_id") and not unit.is_attacking():
unit.attack() unit.attack()

View File

@ -14,7 +14,7 @@ func tick(actor:Node,black_board:Blackboard):
#获取要移动到的目标实例 #获取要移动到的目标实例
var target_instance:Unit=Global.get_unit_instance(target_id) var target_instance:Unit=Global.get_unit_instance(target_id)
if not unit.is_unit_instance_in_touch_area(target_instance): if not unit.is_unit_instance_in_attack_area(target_instance):
unit.set_target_pos(target_instance.global_position) unit.set_target_pos(target_instance.global_position)
match unit.get_dir(): match unit.get_dir():
0: 0:

View File

@ -34,19 +34,6 @@ var action_emoji:Dictionary={
#状态值 #状态值
#饥饿,疲劳,怒气,紧张,恐慌,压力 #饥饿,疲劳,怒气,紧张,恐慌,压力
"hungry":0,
"fatigue":0,
"rage":0,
"tensity":0,
"panic":0,
#压力
"pressure":0,
"hp_max":100,
"hp":100,
"atk":10,
} }
#允许的状态队列 #允许的状态队列
var state_value_array:Array=["hungry","fatigue","rage","tensity","panic","pressure","hp_max","hp","atk"] var state_value_array:Array=["hungry","fatigue","rage","tensity","panic","pressure","hp_max","hp","atk"]
@ -109,27 +96,21 @@ const JUMP_VELOCITY = -400.0
##与其他单位交互的范围,目标进入此范围内才进行交互 ##与其他单位交互的范围,目标进入此范围内才进行交互
@export var touch_area:Area2D @export var touch_area:Area2D
##感知范围 ##行为感知范围
@export var sense_area:Area2D @export var sense_area:Area2D
#攻击范围
@export var attack_sense_area:Area2D
#攻击检测
@export var attack_area:Area2D @export var attack_area:Area2D
#攻击模组
var attack_scene:AttackModel
#使用数据进行初始化角色
func init_from_data():
#var hungry:float=0:
#set(val):
#hungry=val
#if %hungry!=null:
#%hungry.text="饥饿值:"+str(val)
func _ready() -> void:
Global.set_unit_instance(unit_id,self) Global.set_unit_instance(unit_id,self)
agent.max_speed=unit_speed agent.max_speed=unit_speed
agent.velocity_computed.connect(safe_speed) agent.velocity_computed.connect(safe_speed)
if animation!=null:
animation.frame_changed.connect(frame_changed)
second_timer=Timer.new() second_timer=Timer.new()
second_timer.autostart=true second_timer.autostart=true
second_timer.one_shot=false second_timer.one_shot=false
@ -141,11 +122,27 @@ func _ready() -> void:
new_sprite_animation.sprite_frames=load(unit_data["sprite_frames"]) new_sprite_animation.sprite_frames=load(unit_data["sprite_frames"])
add_child(new_sprite_animation) add_child(new_sprite_animation)
new_sprite_animation.position=unit_data["sprite_offset"]
new_sprite_animation.scale=unit_data["sprite_scale"] new_sprite_animation.position=Vector2(unit_data["sprite_offset"][0],unit_data["sprite_offset"][1])
new_sprite_animation.scale=Vector2(unit_data["sprite_scale"][0],unit_data["sprite_scale"][1])
animation=new_sprite_animation animation=new_sprite_animation
animation.frame_changed.connect(frame_changed) if unit_data.has("attack_scene"):
#state_machine.launch() if %rotate!=null:
var new_attack_scene=load(unit_data["attack_scene"]).instantiate()
%rotate.add_child(new_attack_scene)
attack_scene=new_attack_scene
#var hungry:float=0:
#set(val):
#hungry=val
#if %hungry!=null:
#%hungry.text="饥饿值:"+str(val)
func _ready() -> void:
unit_data=Database.get_unit_data("test_character_ranged")
init_from_data()
pass
func set_target_pos(target:Vector2): func set_target_pos(target:Vector2):
agent.target_position=target agent.target_position=target
@ -198,15 +195,19 @@ func is_unit_instance_in_touch_area(instance:Node):
#判断单位是否再攻击范围内 #判断单位是否再攻击范围内
func is_unit_instance_in_attack_area(instance:Node): func is_unit_instance_in_attack_area(instance:Node):
if attack_area==null: #if attack_sense_area==null:
#return false
#else:
#if instance is PhysicsBody2D:
#return instance in attack_sense_area.get_overlapping_bodies()
#if instance is Area2D:
#return instance in attack_sense_area.get_overlapping_areas()
#
#pass
if attack_scene==null:
return false return false
else: else:
if instance is PhysicsBody2D: return attack_scene.is_unit_instance_in_attack_area(instance)
return instance in attack_area.get_overlapping_bodies()
if instance is Area2D:
return instance in attack_area.get_overlapping_areas()
pass
#指责(口角) #指责(口角)
func accuse(unit_id:String): func accuse(unit_id:String):
show_action("指责") show_action("指责")
@ -224,36 +225,50 @@ func accused(by_unit_id:String):
#攻击 #攻击
func attack(): func attack():
show_action("伤害") #show_action("伤害")
match get_dir(): #match get_dir():
0: #0:
play_animation("up_attack") #play_animation("up_attack")
1: #1:
play_animation("down_attack") #play_animation("down_attack")
2: #2:
play_animation("left_right_attack") #play_animation("left_right_attack")
3: #3:
play_animation("left_right_attack") #play_animation("left_right_attack")
pass #pass
if attack_scene:
print("攻击")
attack_scene.attack()
func frame_changed(): #func frame_changed():
if animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and animation.frame==attack_frames: #if animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and animation.frame==attack_frames:
use_attack_damage() #use_attack_damage()
func is_attack_finished(): func is_attack_finished():
if animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and not animation.is_playing(): #if animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and not animation.is_playing():
#return true
#else:
#return false
if attack_scene is AttackModel:
return attack_scene.is_attack_finished()
else:
return true return true
func is_attacking():
#return animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and animation.is_playing()
if attack_scene is AttackModel:
return attack_scene.is_attacking()
else: else:
return false return false
func is_attacking(): ##在固定帧使用攻击
return animation.animation in [&"up_attack",&"down_attack",&"left_right_attack"] and animation.is_playing() #func use_attack_damage():
#在固定帧使用攻击 #print("使用攻击")
func use_attack_damage(): #for i in attack_area.get_overlapping_bodies():
print("使用攻击") #if i is Unit and i!=self:
for i in attack_area.get_overlapping_bodies(): #i.attacked(unit_id,get_atk())
if i is Unit and i!=self: #
i.attacked(unit_id,get_atk()) #pass
func attack_reset():
pass if attack_scene:
attack_scene.attack_reset()
func attacked(by_unit_id:String,damage:float): func attacked(by_unit_id:String,damage:float):
show_action("受伤") show_action("受伤")
Global.set_unit_favour(unit_id,by_unit_id,Global.get_unit_favour(unit_id,by_unit_id)-20) Global.set_unit_favour(unit_id,by_unit_id,Global.get_unit_favour(unit_id,by_unit_id)-20)

View File

@ -1,32 +1,16 @@
[gd_scene load_steps=28 format=3 uid="uid://dl1axae8yeeeh"] [gd_scene load_steps=14 format=3 uid="uid://dl1axae8yeeeh"]
[ext_resource type="Script" path="res://scene/test/other_character.gd" id="1_6f8fy"] [ext_resource type="Script" path="res://scene/test/other_character.gd" id="1_6f8fy"]
[ext_resource type="Texture2D" uid="uid://csk8u15wepd1w" path="res://icon.svg" id="2_tbr4x"] [ext_resource type="Texture2D" uid="uid://csk8u15wepd1w" path="res://icon.svg" id="2_tbr4x"]
[ext_resource type="Script" path="res://addons/beehave/nodes/beehave_tree.gd" id="2_twyt5"] [ext_resource type="PackedScene" uid="uid://dirg8ytcjol3c" path="res://scene/behavour_tree/base/base_behaviour_tree.tscn" id="3_5u10o"]
[ext_resource type="Script" path="res://addons/beehave/nodes/composites/selector.gd" id="3_0pv7j"]
[ext_resource type="PackedScene" uid="uid://ldjrnwapxefe" path="res://scene/test/action_set_rand_pos.tscn" id="3_a6loo"]
[ext_resource type="Script" path="res://addons/beehave/nodes/composites/sequence.gd" id="3_gehdk"]
[ext_resource type="PackedScene" uid="uid://jkwn820drv43" path="res://scene/test/await_time.tscn" id="4_hl4be"]
[ext_resource type="PackedScene" uid="uid://dg0gnl5n62gq6" path="res://scene/test/run_await.tscn" id="4_hydke"]
[ext_resource type="PackedScene" uid="uid://hgsb64hg78m5" path="res://scene/test/condition_accuse.tscn" id="5_tomxt"]
[ext_resource type="PackedScene" uid="uid://dukqa6ha8aeic" path="res://scene/test/condition_hungry.tscn" id="6_qkap5"]
[ext_resource type="PackedScene" uid="uid://cm7nelq3tbye6" path="res://scene/test/action_move_to_unit.tscn" id="6_wkm0p"]
[ext_resource type="PackedScene" uid="uid://b65amfq474sv7" path="res://scene/test/action_move_to_target.tscn" id="7_phvf1"]
[ext_resource type="PackedScene" uid="uid://c3pouwk6mbovv" path="res://scene/test/action_accuse.tscn" id="7_wxwf6"]
[ext_resource type="PackedScene" uid="uid://k7sldgn2joe0" path="res://scene/test/action_eat.tscn" id="8_xfqbv"]
[ext_resource type="PackedScene" uid="uid://qrl0pc72e3q6" path="res://scene/test/condition_attack.tscn" id="10_85ndl"]
[ext_resource type="PackedScene" uid="uid://bcr5oa32fvxwa" path="res://scene/test/action_attack.tscn" id="11_7tlfn"]
[sub_resource type="CircleShape2D" id="CircleShape2D_s46hi"] [sub_resource type="CircleShape2D" id="CircleShape2D_s46hi"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_lphpm"]
size = Vector2(121, 136)
[sub_resource type="CircleShape2D" id="CircleShape2D_fp36j"] [sub_resource type="CircleShape2D" id="CircleShape2D_fp36j"]
radius = 104.12 radius = 104.12
[sub_resource type="CircleShape2D" id="CircleShape2D_0d77h"] [sub_resource type="CircleShape2D" id="CircleShape2D_0d77h"]
radius = 472.662 radius = 847.191
[sub_resource type="Animation" id="Animation_tov45"] [sub_resource type="Animation" id="Animation_tov45"]
length = 0.001 length = 0.001
@ -77,13 +61,12 @@ colors = PackedColorArray(0, 1, 0, 1, 0, 1, 0, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_6t72h"] [sub_resource type="GradientTexture1D" id="GradientTexture1D_6t72h"]
gradient = SubResource("Gradient_qd3pc") gradient = SubResource("Gradient_qd3pc")
[node name="other_character" type="CharacterBody2D" node_paths=PackedStringArray("agent", "rotate", "touch_area", "sense_area", "attack_area")] [node name="other_character" type="CharacterBody2D" node_paths=PackedStringArray("agent", "rotate", "touch_area", "sense_area")]
script = ExtResource("1_6f8fy") script = ExtResource("1_6f8fy")
agent = NodePath("agent") agent = NodePath("agent")
rotate = NodePath("rotate") rotate = NodePath("rotate")
touch_area = NodePath("touch_area") touch_area = NodePath("touch_area")
sense_area = NodePath("sense_area") sense_area = NodePath("sense_area")
attack_area = NodePath("rotate/attack_area")
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Sprite2D" type="Sprite2D" parent="."]
visible = false visible = false
@ -99,63 +82,7 @@ debug_enabled = true
shape = SubResource("CircleShape2D_s46hi") shape = SubResource("CircleShape2D_s46hi")
[node name="rotate" type="Node2D" parent="."] [node name="rotate" type="Node2D" parent="."]
unique_name_in_owner = true
[node name="attack_area" type="Area2D" parent="rotate"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="rotate/attack_area"]
position = Vector2(60.5, 3)
shape = SubResource("RectangleShape2D_lphpm")
[node name="BeehaveTree" type="Node" parent="." node_paths=PackedStringArray("blackboard", "actor")]
script = ExtResource("2_twyt5")
blackboard = NodePath("@Node@113329")
actor = NodePath("..")
[node name="SelectorComposite" type="Node" parent="BeehaveTree"]
script = ExtResource("3_0pv7j")
[node name="eat" type="Node" parent="BeehaveTree/SelectorComposite"]
script = ExtResource("3_gehdk")
[node name="condition_hungry" parent="BeehaveTree/SelectorComposite/eat" instance=ExtResource("6_qkap5")]
[node name="action_move_to_target" parent="BeehaveTree/SelectorComposite/eat" instance=ExtResource("7_phvf1")]
[node name="action_eat" parent="BeehaveTree/SelectorComposite/eat" instance=ExtResource("8_xfqbv")]
[node name="accuse" type="Node" parent="BeehaveTree/SelectorComposite"]
script = ExtResource("3_gehdk")
[node name="condition_accuse" parent="BeehaveTree/SelectorComposite/accuse" instance=ExtResource("5_tomxt")]
[node name="action_move_to_unit" parent="BeehaveTree/SelectorComposite/accuse" instance=ExtResource("6_wkm0p")]
[node name="action_accuse" parent="BeehaveTree/SelectorComposite/accuse" instance=ExtResource("7_wxwf6")]
[node name="await_time" parent="BeehaveTree/SelectorComposite/accuse" instance=ExtResource("4_hl4be")]
await_time = 2.0
[node name="attack" type="Node" parent="BeehaveTree/SelectorComposite"]
script = ExtResource("3_gehdk")
[node name="condition_attack" parent="BeehaveTree/SelectorComposite/attack" instance=ExtResource("10_85ndl")]
[node name="action_move_to_unit" parent="BeehaveTree/SelectorComposite/attack" instance=ExtResource("6_wkm0p")]
[node name="action_attack" parent="BeehaveTree/SelectorComposite/attack" instance=ExtResource("11_7tlfn")]
[node name="await_time" parent="BeehaveTree/SelectorComposite/attack" instance=ExtResource("4_hl4be")]
await_time = 1.0
[node name="rand_walk" type="Node" parent="BeehaveTree/SelectorComposite"]
script = ExtResource("3_gehdk")
[node name="await_time" parent="BeehaveTree/SelectorComposite/rand_walk" instance=ExtResource("4_hl4be")]
await_time = 2.0
[node name="action_set_rand_pos" parent="BeehaveTree/SelectorComposite/rand_walk" instance=ExtResource("3_a6loo")]
[node name="run_await" parent="BeehaveTree/SelectorComposite/rand_walk" instance=ExtResource("4_hydke")]
[node name="touch_area" type="Area2D" parent="."] [node name="touch_area" type="Area2D" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
@ -210,5 +137,9 @@ nine_patch_stretch = true
texture_under = SubResource("GradientTexture1D_ioncu") texture_under = SubResource("GradientTexture1D_ioncu")
texture_progress = SubResource("GradientTexture1D_6t72h") texture_progress = SubResource("GradientTexture1D_6t72h")
[node name="BeehaveTree" parent="." node_paths=PackedStringArray("blackboard", "actor") instance=ExtResource("3_5u10o")]
blackboard = NodePath("@Node@34592")
actor = NodePath("..")
[connection signal="state_value_changed" from="." to="." method="_on_state_value_changed"] [connection signal="state_value_changed" from="." to="." method="_on_state_value_changed"]
[connection signal="body_entered" from="sense_area" to="." method="_on_sense_area_body_entered"] [connection signal="body_entered" from="sense_area" to="." method="_on_sense_area_body_entered"]

View File

@ -32,7 +32,7 @@ func get_closest_node(self_node:Node2D,array:Array,target_class):
var node=null var node=null
for i in range(0,array.size()): for i in range(0,array.size()):
print(is_instance_of(i,target_class)) print(is_instance_of(i,target_class))
if is_instance_of(array[i],target_class): if is_instance_of(array[i],target_class) and array[i]!=self_node:
var l=(array[i].global_position-self_node.global_position).length() var l=(array[i].global_position-self_node.global_position).length()
if l<length: if l<length:
length=l length=l