关卡迭代

master
chendian 1 year ago
parent 3c154de4bd
commit beb01f0ea4

@ -0,0 +1,27 @@
[gd_resource type="ShaderMaterial" load_steps=6 format=3 uid="uid://nufv335woq2s"]
[ext_resource type="Shader" path="res://render/shader/wind_grass.gdshader" id="1_crjsp"]
[ext_resource type="Texture2D" uid="uid://bhltn1sfrnb3p" path="res://render/texture/common/common_ramp_green.tres" id="2_eyk30"]
[ext_resource type="Texture2D" uid="uid://6c1yt0vihays" path="res://render/texture/common/common_noise.tres" id="3_183e7"]
[sub_resource type="Curve" id="Curve_05s7l"]
_data = [Vector2(0, 0), 0.0, 1.4, 0, 0, Vector2(1e-05, 0.29661), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 3
[sub_resource type="CurveTexture" id="CurveTexture_cknys"]
curve = SubResource("Curve_05s7l")
[resource]
render_priority = 0
shader = ExtResource("1_crjsp")
shader_parameter/wind_speed = 0.05
shader_parameter/wind_strength = 0.2
shader_parameter/wind_texture_tile_size = 20.0
shader_parameter/wind_vertical_strength = 0.05
shader_parameter/wind_horizontal_direction = Vector2(1, 0.5)
shader_parameter/character_position = Vector3(19.0101, 0.670344, 79.6646)
shader_parameter/character_radius = 0.5
shader_parameter/character_push_strength = 0.75
shader_parameter/color_ramp = ExtResource("2_eyk30")
shader_parameter/wind_noise = ExtResource("3_183e7")
shader_parameter/character_distance_falloff_curve = SubResource("CurveTexture_cknys")

@ -0,0 +1,27 @@
v -0.065078 0.000000 0.000000
v 0.065078 0.000000 0.000000
v 0.000000 0.613708 0.000000
v -0.037539 0.256854 0.000000
v 0.037539 0.256854 0.000000
v -0.041308 0.123427 0.000000
v 0.016769 0.350281 0.000000
v -0.016769 0.350281 0.000000
v 0.041308 0.123427 0.000000
vt 0.621057 0.520384
vt 0.497980 0.979655
vt 0.376628 0.520384
vt 0.744133 0.238847
vt 0.133923 0.098911
vt 0.867209 0.098911
vt 0.012570 0.013663
vt 0.990286 0.013663
vt 0.255275 0.238847
vn 0.0000 0.0000 1.0000
s 1
f 7/1/1 3/2/1 8/3/1
f 5/4/1 6/5/1 9/6/1
f 9/6/1 1/7/1 2/8/1
f 7/1/1 4/9/1 5/4/1
f 5/4/1 4/9/1 6/5/1
f 9/6/1 6/5/1 1/7/1
f 7/1/1 8/3/1 4/9/1

@ -0,0 +1,22 @@
[remap]
importer="wavefront_obj"
importer_version=1
type="Mesh"
uid="uid://ddvgn8mvwnjka"
path="res://.godot/imported/grass_triangle.obj-76bd05e9dc226ecbc80738e219a44af8.mesh"
[deps]
files=["res://.godot/imported/grass_triangle.obj-76bd05e9dc226ecbc80738e219a44af8.mesh"]
source_file="res://render/mesh/grass_triangle.obj"
dest_files=["res://.godot/imported/grass_triangle.obj-76bd05e9dc226ecbc80738e219a44af8.mesh", "res://.godot/imported/grass_triangle.obj-76bd05e9dc226ecbc80738e219a44af8.mesh"]
[params]
generate_tangents=true
scale_mesh=Vector3(1, 1, 1)
offset_mesh=Vector3(0, 0, 0)
optimize_mesh=true
force_disable_mesh_compression=false

@ -57,9 +57,13 @@ void fragment() {
brightness = 1.0; brightness = 1.0;
} }
vec3 world_normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz; vec3 world_normal = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz;
if(world_normal.y<0.1){ bool is_light = c.r+c.g+c.b>2.8;
if(!is_light && world_normal.y<0.1){
brightness = brightness*0.6; brightness = brightness*0.6;
} }
c.rgb = mix(vec3(0.0), c.rgb, brightness); c.rgb = mix(vec3(0.0), c.rgb, brightness);
ALBEDO = c.rgb; ALBEDO = c.rgb;
if(is_light){
EMISSION = c.rgb * 2.0;
}
} }

@ -0,0 +1,77 @@
shader_type spatial;
render_mode cull_disabled;
uniform float wind_speed = 0.2;
uniform float wind_strength = 2.0;
// How big, in world space, is the noise texture
// wind will tile every wind_texture_tile_size
uniform float wind_texture_tile_size = 20.0;
uniform float wind_vertical_strength = 0.3;
uniform vec2 wind_horizontal_direction = vec2(1.0, 0.5);
uniform sampler2D color_ramp : hint_default_black;
// we need a tiling noise here!
uniform sampler2D wind_noise : hint_default_black;
uniform vec3 character_position;
uniform float character_radius = 3.0;
uniform sampler2D character_distance_falloff_curve : hint_default_black;
uniform float character_push_strength = 1.0;
varying float debug_wind;
void vertex() {
vec3 world_vert = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
vec2 normalized_wind_direction = normalize(wind_horizontal_direction);
vec2 world_uv = world_vert.xz / wind_texture_tile_size + normalized_wind_direction * TIME * wind_speed;
// we displace only the top part of the mesh
// note that this means that the mesh needs to have UV in a way that the bottom of UV space
// is at the top of the mesh
float displacement_affect = (1.0 - UV.y);
float wind_noise_intensity = (textureLod(wind_noise, world_uv, 0.0).r - 0.5);
// We convert the direction of the wind into vertex space from world space
// if we used it directly in vertex space, rotated blades of grass wouldn't behave properly
vec2 vert_space_horizontal_dir =
(inverse(MODEL_MATRIX) * vec4(wind_horizontal_direction, 0.0, 0.0)).xy;
vert_space_horizontal_dir = normalize(vert_space_horizontal_dir);
vec3 bump_wind = vec3(
wind_noise_intensity * vert_space_horizontal_dir.x,
1.0 - wind_noise_intensity,
wind_noise_intensity * vert_space_horizontal_dir.y);
normalize(bump_wind);
bump_wind *= vec3(wind_strength, wind_vertical_strength, wind_strength);
VERTEX += bump_wind * displacement_affect;
// At the moment the blades are pushed away in a perfectly circular manner.
// We could distort the distance to the character based on a noise, to break a bit the
// circular shape. We could distort the falloff by sampling in a noise based on the xz coordinates.
// The task is left to the reader
vec3 dir_to_character = character_position - MODEL_MATRIX[3].xyz;
// uncomment the following line to have a horizontal only character push
//dir_to_character.y = 0.0;
float distance_to_character = length(dir_to_character);
float falloff = 1.0 - smoothstep(0.0, 1.0, distance_to_character/character_radius);
// Because we operate in vertex space, we need to convert the direction to the character
// in vertex space. Otherwise, it wouldn't work for rotated blades of grass.
// comment the next line to observe how the blades are not all facing away from the character.
dir_to_character = (inverse(MODEL_MATRIX) * vec4(dir_to_character, 0.0)).xyz;
dir_to_character = normalize(dir_to_character);
// sample the curve based on how far we are from the character, in normalized coordinates
float falloff_curve = texture(character_distance_falloff_curve, vec2(falloff)).x;
// direction to character is inverted because we want to point away from it
VERTEX += normalize(-dir_to_character) * falloff_curve * character_push_strength * displacement_affect;
}
void fragment() {
ALBEDO = texture(color_ramp, vec2(1.0 - UV.y, 0)).rgb ;
}

@ -0,0 +1,7 @@
[gd_resource type="NoiseTexture2D" load_steps=2 format=3 uid="uid://6c1yt0vihays"]
[sub_resource type="FastNoiseLite" id="5"]
[resource]
seamless = true
noise = SubResource("5")

@ -0,0 +1,8 @@
[gd_resource type="GradientTexture2D" load_steps=2 format=3 uid="uid://bhltn1sfrnb3p"]
[sub_resource type="Gradient" id="3"]
offsets = PackedFloat32Array(0, 0.312741, 1)
colors = PackedColorArray(0.392157, 0.678431, 0.501961, 1, 0.561011, 0.752926, 0.46223, 1, 0.658824, 0.796078, 0.439216, 1)
[resource]
gradient = SubResource("3")

@ -0,0 +1,18 @@
[remap]
importer="MagicaVoxel.With.Extensions.To.Mesh"
type="Mesh"
uid="uid://nstmr6xqlvw6"
path="res://.godot/imported/a_grass_high.vox-b3f8d621c6f7439063d3684054e5ce4b.mesh"
[deps]
source_file="res://resource/mesh_level/a_grass_high.vox"
dest_files=["res://.godot/imported/a_grass_high.vox-b3f8d621c6f7439063d3684054e5ce4b.mesh"]
[params]
Scale=0.02
GreedyMeshGenerator=true
SnapToGround=false
FirstKeyframeOnly=true

@ -0,0 +1,18 @@
[remap]
importer="MagicaVoxel.With.Extensions.To.Mesh"
type="Mesh"
uid="uid://dfnb4fb1734wi"
path="res://.godot/imported/a_grass_short.vox-a142a969f3f4d81df7c9b8a622160369.mesh"
[deps]
source_file="res://resource/mesh_level/a_grass_short.vox"
dest_files=["res://.godot/imported/a_grass_short.vox-a142a969f3f4d81df7c9b8a622160369.mesh"]
[params]
Scale=0.02
GreedyMeshGenerator=true
SnapToGround=false
FirstKeyframeOnly=true

@ -0,0 +1,18 @@
[remap]
importer="MagicaVoxel.With.Extensions.To.Mesh"
type="Mesh"
uid="uid://dor0xgw6mvwnj"
path="res://.godot/imported/a_grass_tiny.vox-5649b282be35301cf0799eff3a3270f9.mesh"
[deps]
source_file="res://resource/mesh_level/a_grass_tiny.vox"
dest_files=["res://.godot/imported/a_grass_tiny.vox-5649b282be35301cf0799eff3a3270f9.mesh"]
[params]
Scale=0.02
GreedyMeshGenerator=true
SnapToGround=false
FirstKeyframeOnly=true

Binary file not shown.

@ -0,0 +1,18 @@
[remap]
importer="MagicaVoxel.With.Extensions.To.Mesh"
type="Mesh"
uid="uid://cj5enoj8mjpfx"
path="res://.godot/imported/a_light01.vox-fbcf673ae8a560d03094ae6e13722ce5.mesh"
[deps]
source_file="res://resource/mesh_level/a_light01.vox"
dest_files=["res://.godot/imported/a_light01.vox-fbcf673ae8a560d03094ae6e13722ce5.mesh"]
[params]
Scale=0.02
GreedyMeshGenerator=true
SnapToGround=false
FirstKeyframeOnly=true

@ -0,0 +1,18 @@
[remap]
importer="MagicaVoxel.With.Extensions.To.Mesh"
type="Mesh"
uid="uid://b7lfv8vmivrfc"
path="res://.godot/imported/f_light_wood1.vox-2532402a903726374384541932800d9f.mesh"
[deps]
source_file="res://resource/mesh_level/f_light_wood1.vox"
dest_files=["res://.godot/imported/f_light_wood1.vox-2532402a903726374384541932800d9f.mesh"]
[params]
Scale=0.02
GreedyMeshGenerator=true
SnapToGround=false
FirstKeyframeOnly=true

@ -0,0 +1,18 @@
[remap]
importer="MagicaVoxel.With.Extensions.To.Mesh"
type="Mesh"
uid="uid://dirug661oej5n"
path="res://.godot/imported/s_light_wood1.vox-478dbf5754104c0582fd553479469c1d.mesh"
[deps]
source_file="res://resource/mesh_level/s_light_wood1.vox"
dest_files=["res://.godot/imported/s_light_wood1.vox-478dbf5754104c0582fd553479469c1d.mesh"]
[params]
Scale=0.02
GreedyMeshGenerator=true
SnapToGround=false
FirstKeyframeOnly=true

@ -1,6 +1,10 @@
[gd_resource type="MeshLibrary" load_steps=2 format=3 uid="uid://cnmlppi3r8sl0"] [gd_resource type="MeshLibrary" load_steps=6 format=3 uid="uid://cnmlppi3r8sl0"]
[ext_resource type="ArrayMesh" uid="uid://3mgx1q8pqlsu" path="res://resource/mesh_level/c_monster01.vox" id="1_fi3ob"] [ext_resource type="ArrayMesh" uid="uid://3mgx1q8pqlsu" path="res://resource/mesh_level/c_monster01.vox" id="1_fi3ob"]
[ext_resource type="ArrayMesh" path="res://.godot/imported/a_grass_short.vox-a142a969f3f4d81df7c9b8a622160369.mesh" id="2_ksnfs"]
[ext_resource type="ArrayMesh" path="res://.godot/imported/a_grass_high.vox-b3f8d621c6f7439063d3684054e5ce4b.mesh" id="3_egou0"]
[ext_resource type="ArrayMesh" path="res://.godot/imported/a_grass_tiny.vox-5649b282be35301cf0799eff3a3270f9.mesh" id="4_07cnl"]
[ext_resource type="ArrayMesh" path="res://.godot/imported/a_light01.vox-fbcf673ae8a560d03094ae6e13722ce5.mesh" id="5_kvpgw"]
[resource] [resource]
item/0/name = "c_monster01" item/0/name = "c_monster01"
@ -9,3 +13,27 @@ item/0/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/0/shapes = [] item/0/shapes = []
item/0/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) item/0/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/0/navigation_layers = 1 item/0/navigation_layers = 1
item/1/name = "a_grass_short"
item/1/mesh = ExtResource("2_ksnfs")
item/1/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/1/shapes = []
item/1/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/1/navigation_layers = 1
item/2/name = "a_grass_high"
item/2/mesh = ExtResource("3_egou0")
item/2/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/2/shapes = []
item/2/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/2/navigation_layers = 1
item/3/name = "a_grass_tiny"
item/3/mesh = ExtResource("4_07cnl")
item/3/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/3/shapes = []
item/3/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/3/navigation_layers = 1
item/4/name = "a_light01"
item/4/mesh = ExtResource("5_kvpgw")
item/4/mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/4/shapes = []
item/4/navigation_mesh_transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
item/4/navigation_layers = 1

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,9 @@
[gd_resource type="MultiMesh" load_steps=2 format=3 uid="uid://c4c48jwymol5p"]
[ext_resource type="ArrayMesh" uid="uid://ddvgn8mvwnjka" path="res://render/mesh/grass_triangle.obj" id="1_ysu63"]
[resource]
transform_format = 1
instance_count = 40
mesh = ExtResource("1_ysu63")
buffer = PackedFloat32Array(0.593346, 0, 0, -0.014561, 0, 0.593346, 0, 0, 0, 0, 0.593346, 0.304959, 0.528941, 0, 0, -0.0812566, 0, 0.528941, 0, 0, 0, 0, 0.528941, -0.153579, 0.518527, 0, 0, -0.263115, 0, 0.518527, 0, 0, 0, 0, 0.518527, 0.0665171, 0.533469, 0, 0, -0.29753, 0, 0.533469, 0, 0, 0, 0, 0.533469, 0.0692717, 0.599702, 0, 0, 0.174908, 0, 0.599702, 0, 0, 0, 0, 0.599702, 0.0734421, 0.512787, 0, 0, -0.274268, 0, 0.512787, 0, 0, 0, 0, 0.512787, 0.0610742, 0.587945, 0, 0, -0.177917, 0, 0.587945, 0, 0, 0, 0, 0.587945, 0.223959, 0.522266, 0, 0, 0.229345, 0, 0.522266, 0, 0, 0, 0, 0.522266, 0.267337, 0.550558, 0, 0, 0.0684025, 0, 0.550558, 0, 0, 0, 0, 0.550558, 0.234046, 0.56802, 0, 0, -0.173274, 0, 0.56802, 0, 0, 0, 0, 0.56802, 0.124238, 0.507971, 0, 0, -0.177169, 0, 0.507971, 0, 0, 0, 0, 0.507971, -0.273, 0.550957, 0, 0, 0.189633, 0, 0.550957, 0, 0, 0, 0, 0.550957, -0.0446369, 0.532202, 0, 0, -0.0530272, 0, 0.532202, 0, 0, 0, 0, 0.532202, 0.236718, 0.527759, 0, 0, 0.133338, 0, 0.527759, 0, 0, 0, 0, 0.527759, 0.160105, 0.586381, 0, 0, 0.106946, 0, 0.586381, 0, 0, 0, 0, 0.586381, -0.237511, 0.551625, 0, 0, 0.19931, 0, 0.551625, 0, 0, 0, 0, 0.551625, -0.259457, 0.57482, 0, 0, 0.0300521, 0, 0.57482, 0, 0, 0, 0, 0.57482, -0.191896, 0.582328, 0, 0, -0.138756, 0, 0.582328, 0, 0, 0, 0, 0.582328, -0.0839549, 0.571152, 0, 0, 0.0727414, 0, 0.571152, 0, 0, 0, 0, 0.571152, 0.185911, 0.534168, 0, 0, -0.214688, 0, 0.534168, 0, 0, 0, 0, 0.534168, 0.120443, 0.533942, 0, 0, -0.179296, 0, 0.533942, 0, 0, 0, 0, 0.533942, 0.0910147, 0.500055, 0, 0, 0.166125, 0, 0.500055, 0, 0, 0, 0, 0.500055, 0.0336831, 0.518797, 0, 0, 0.163382, 0, 0.518797, 0, 0, 0, 0, 0.518797, 0.107313, 0.539886, 0, 0, 0.213398, 0, 0.539886, 0, 0, 0, 0, 0.539886, -0.031926, 0.503416, 0, 0, 0.0827026, 0, 0.503416, 0, 0, 0, 0, 0.503416, 0.236787, 0.518657, 0, 0, 0.0726334, 0, 0.518657, 0, 0, 0, 0, 0.518657, 0.0883227, 0.571196, 0, 0, 0.0718163, 0, 0.571196, 0, 0, 0, 0, 0.571196, -0.092512, 0.530995, 0, 0, 0.263376, 0, 0.530995, 0, 0, 0, 0, 0.530995, -0.200072, 0.560601, 0, 0, -0.141765, 0, 0.560601, 0, 0, 0, 0, 0.560601, 0.0424267, 0.501458, 0, 0, -0.0562232, 0, 0.501458, 0, 0, 0, 0, 0.501458, -0.250739, 0.538194, 0, 0, 0.21396, 0, 0.538194, 0, 0, 0, 0, 0.538194, 0.0776592, 0.505306, 0, 0, 0.0539699, 0, 0.505306, 0, 0, 0, 0, 0.505306, -0.234806, 0.594271, 0, 0, -0.134172, 0, 0.594271, 0, 0, 0, 0, 0.594271, -0.165001, 0.546853, 0, 0, -0.217937, 0, 0.546853, 0, 0, 0, 0, 0.546853, 0.314648, 0.516057, 0, 0, -0.15844, 0, 0.516057, 0, 0, 0, 0, 0.516057, -0.280375, 0.572652, 0, 0, -0.136556, 0, 0.572652, 0, 0, 0, 0, 0.572652, -0.0736368, 0.586385, 0, 0, -0.232492, 0, 0.586385, 0, 0, 0, 0, 0.586385, -0.109916, 0.58201, 0, 0, -0.0545374, 0, 0.58201, 0, 0, 0, 0, 0.58201, 0.286521, 0.556101, 0, 0, -0.249918, 0, 0.556101, 0, 0, 0, 0, 0.556101, -0.00196204, 0.593149, 0, 0, -0.03498, 0, 0.593149, 0, 0, 0, 0, 0.593149, 0.106612)

@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://bowb22her54ay"]
[ext_resource type="PackedScene" uid="uid://bscaegmui5h5s" path="res://scene/level_active/grass_high.tscn" id="1_yhtq5"]
[node name="SceneActive" type="Node3D"]
[node name="GrassMesh" parent="." instance=ExtResource("1_yhtq5")]

File diff suppressed because one or more lines are too long

@ -0,0 +1,19 @@
[gd_scene load_steps=5 format=3 uid="uid://bscaegmui5h5s"]
[ext_resource type="Material" uid="uid://nufv335woq2s" path="res://render/material/wind_grass.tres" id="1_7v81s"]
[ext_resource type="ArrayMesh" uid="uid://ddvgn8mvwnjka" path="res://render/mesh/grass_triangle.obj" id="2_u7lt8"]
[ext_resource type="Script" path="res://script/editor_tool/grass_mesh.gd" id="3_iww1o"]
[sub_resource type="MultiMesh" id="MultiMesh_i0fnp"]
transform_format = 1
instance_count = 40
mesh = ExtResource("2_u7lt8")
buffer = PackedFloat32Array(0.850267, 0, 0, -0.236901, 0, 0.850267, 0, 0, 0, 0, 0.850267, 0.011678, 0.885421, 0, 0, -0.28987, 0, 0.885421, 0, 0, 0, 0, 0.885421, -0.299164, 0.753295, 0, 0, -0.208137, 0, 0.753295, 0, 0, 0, 0, 0.753295, -0.104484, 0.763127, 0, 0, 0.293253, 0, 0.763127, 0, 0, 0, 0, 0.763127, -0.237958, 0.875643, 0, 0, -0.300975, 0, 0.875643, 0, 0, 0, 0, 0.875643, 0.174365, 0.812294, 0, 0, 0.279535, 0, 0.812294, 0, 0, 0, 0, 0.812294, -0.196263, 0.805134, 0, 0, 0.0703121, 0, 0.805134, 0, 0, 0, 0, 0.805134, -0.0421476, 0.762721, 0, 0, -0.0287569, 0, 0.762721, 0, 0, 0, 0, 0.762721, 0.122738, 0.787612, 0, 0, -0.0149276, 0, 0.787612, 0, 0, 0, 0, 0.787612, -0.228186, 0.812725, 0, 0, 0.129561, 0, 0.812725, 0, 0, 0, 0, 0.812725, 0.289499, 0.890968, 0, 0, -0.258548, 0, 0.890968, 0, 0, 0, 0, 0.890968, -0.0983578, 0.722272, 0, 0, -0.142265, 0, 0.722272, 0, 0, 0, 0, 0.722272, 0.00631809, 0.763407, 0, 0, 0.0242455, 0, 0.763407, 0, 0, 0, 0, 0.763407, -0.0644098, 0.798859, 0, 0, 0.0546614, 0, 0.798859, 0, 0, 0, 0, 0.798859, -0.179269, 0.844168, 0, 0, 0.309653, 0, 0.844168, 0, 0, 0, 0, 0.844168, -0.15087, 0.819652, 0, 0, -0.131903, 0, 0.819652, 0, 0, 0, 0, 0.819652, 0.238383, 0.738998, 0, 0, 0.0488455, 0, 0.738998, 0, 0, 0, 0, 0.738998, 0.0430205, 0.7594, 0, 0, 0.206912, 0, 0.7594, 0, 0, 0, 0, 0.7594, -0.281935, 0.781441, 0, 0, 0.183891, 0, 0.781441, 0, 0, 0, 0, 0.781441, -0.221743, 0.704245, 0, 0, 0.290893, 0, 0.704245, 0, 0, 0, 0, 0.704245, -0.137151, 0.807799, 0, 0, 0.239029, 0, 0.807799, 0, 0, 0, 0, 0.807799, -0.0187869, 0.826738, 0, 0, -0.0219874, 0, 0.826738, 0, 0, 0, 0, 0.826738, -0.278481, 0.809137, 0, 0, -0.00259447, 0, 0.809137, 0, 0, 0, 0, 0.809137, 0.0512622, 0.801655, 0, 0, 0.00857547, 0, 0.801655, 0, 0, 0, 0, 0.801655, 0.214294, 0.854602, 0, 0, 0.134782, 0, 0.854602, 0, 0, 0, 0, 0.854602, -0.0262177, 0.70378, 0, 0, -0.148668, 0, 0.70378, 0, 0, 0, 0, 0.70378, 0.148927, 0.856184, 0, 0, 0.235763, 0, 0.856184, 0, 0, 0, 0, 0.856184, 0.178996, 0.713512, 0, 0, -0.0637904, 0, 0.713512, 0, 0, 0, 0, 0.713512, 0.000412762, 0.722176, 0, 0, 0.00617713, 0, 0.722176, 0, 0, 0, 0, 0.722176, -0.193158, 0.775462, 0, 0, 0.0303999, 0, 0.775462, 0, 0, 0, 0, 0.775462, -0.0277684, 0.786996, 0, 0, 0.0209769, 0, 0.786996, 0, 0, 0, 0, 0.786996, -0.206117, 0.89983, 0, 0, 0.180177, 0, 0.89983, 0, 0, 0, 0, 0.89983, 0.286512, 0.802054, 0, 0, -0.0968045, 0, 0.802054, 0, 0, 0, 0, 0.802054, 0.15324, 0.737515, 0, 0, -0.127443, 0, 0.737515, 0, 0, 0, 0, 0.737515, -0.0427554, 0.809675, 0, 0, 0.275429, 0, 0.809675, 0, 0, 0, 0, 0.809675, -0.319483, 0.742134, 0, 0, 0.0211135, 0, 0.742134, 0, 0, 0, 0, 0.742134, 0.212784, 0.798657, 0, 0, 0.0671035, 0, 0.798657, 0, 0, 0, 0, 0.798657, 0.117133, 0.822658, 0, 0, -0.184188, 0, 0.822658, 0, 0, 0, 0, 0.822658, -0.158328, 0.834859, 0, 0, -0.055608, 0, 0.834859, 0, 0, 0, 0, 0.834859, -0.0925495, 0.846971, 0, 0, 0.0535535, 0, 0.846971, 0, 0, 0, 0, 0.846971, 0.24802)
[node name="GrassMesh" type="MultiMeshInstance3D"]
material_override = ExtResource("1_7v81s")
cast_shadow = 2
multimesh = SubResource("MultiMesh_i0fnp")
script = ExtResource("3_iww1o")
extents = Vector2(0.32, 0.32)
scale_basic = 0.8

@ -0,0 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://cugqj3mjnb3k8"]
[ext_resource type="Material" uid="uid://nufv335woq2s" path="res://render/material/wind_grass.tres" id="1_mi2yd"]
[ext_resource type="ArrayMesh" uid="uid://ddvgn8mvwnjka" path="res://render/mesh/grass_triangle.obj" id="2_mqml2"]
[ext_resource type="Script" path="res://script/editor_tool/grass_mesh.gd" id="3_sbbi8"]
[sub_resource type="MultiMesh" id="MultiMesh_i0fnp"]
transform_format = 1
instance_count = 60
mesh = ExtResource("2_mqml2")
buffer = PackedFloat32Array(0.422679, 0, 0, -0.31932, 0, 0.422679, 0, 0, 0, 0, 0.422679, 0.222035, 0.565589, 0, 0, -0.163921, 0, 0.565589, 0, 0, 0, 0, 0.565589, 0.166128, 0.557743, 0, 0, 0.231122, 0, 0.557743, 0, 0, 0, 0, 0.557743, 0.157646, 0.436782, 0, 0, -0.108736, 0, 0.436782, 0, 0, 0, 0, 0.436782, -0.213432, 0.472302, 0, 0, -0.0302663, 0, 0.472302, 0, 0, 0, 0, 0.472302, -0.101251, 0.459377, 0, 0, -0.0367711, 0, 0.459377, 0, 0, 0, 0, 0.459377, -0.0663798, 0.41596, 0, 0, 0.143099, 0, 0.41596, 0, 0, 0, 0, 0.41596, 0.309669, 0.462596, 0, 0, 0.122331, 0, 0.462596, 0, 0, 0, 0, 0.462596, 0.236068, 0.588548, 0, 0, -0.0276043, 0, 0.588548, 0, 0, 0, 0, 0.588548, 0.0835775, 0.592027, 0, 0, 0.0622364, 0, 0.592027, 0, 0, 0, 0, 0.592027, 0.240621, 0.482222, 0, 0, -0.0598195, 0, 0.482222, 0, 0, 0, 0, 0.482222, -0.185888, 0.508889, 0, 0, -0.31975, 0, 0.508889, 0, 0, 0, 0, 0.508889, -0.0251259, 0.57917, 0, 0, 0.116746, 0, 0.57917, 0, 0, 0, 0, 0.57917, 0.207793, 0.476953, 0, 0, -0.0256726, 0, 0.476953, 0, 0, 0, 0, 0.476953, 0.313863, 0.552328, 0, 0, -0.140257, 0, 0.552328, 0, 0, 0, 0, 0.552328, 0.131966, 0.534333, 0, 0, -0.309444, 0, 0.534333, 0, 0, 0, 0, 0.534333, -0.080676, 0.480466, 0, 0, 0.143088, 0, 0.480466, 0, 0, 0, 0, 0.480466, -0.0384474, 0.595769, 0, 0, -0.0051313, 0, 0.595769, 0, 0, 0, 0, 0.595769, 0.173477, 0.471711, 0, 0, -0.0842564, 0, 0.471711, 0, 0, 0, 0, 0.471711, -0.149921, 0.493693, 0, 0, 0.0253143, 0, 0.493693, 0, 0, 0, 0, 0.493693, 0.163388, 0.524832, 0, 0, 0.119908, 0, 0.524832, 0, 0, 0, 0, 0.524832, 0.00929523, 0.517474, 0, 0, 0.229999, 0, 0.517474, 0, 0, 0, 0, 0.517474, 0.0641421, 0.43585, 0, 0, 0.252399, 0, 0.43585, 0, 0, 0, 0, 0.43585, -0.291608, 0.408826, 0, 0, 0.209503, 0, 0.408826, 0, 0, 0, 0, 0.408826, -0.267097, 0.474232, 0, 0, 0.187525, 0, 0.474232, 0, 0, 0, 0, 0.474232, -0.192769, 0.415695, 0, 0, -0.22959, 0, 0.415695, 0, 0, 0, 0, 0.415695, 0.317299, 0.459235, 0, 0, 0.133561, 0, 0.459235, 0, 0, 0, 0, 0.459235, -0.105574, 0.515192, 0, 0, 0.261943, 0, 0.515192, 0, 0, 0, 0, 0.515192, 0.216434, 0.550368, 0, 0, 0.127448, 0, 0.550368, 0, 0, 0, 0, 0.550368, 0.0934071, 0.57073, 0, 0, 0.0705428, 0, 0.57073, 0, 0, 0, 0, 0.57073, -0.064085, 0.542206, 0, 0, -0.080071, 0, 0.542206, 0, 0, 0, 0, 0.542206, -0.24098, 0.599446, 0, 0, 0.229488, 0, 0.599446, 0, 0, 0, 0, 0.599446, 0.230828, 0.562075, 0, 0, -0.121035, 0, 0.562075, 0, 0, 0, 0, 0.562075, 0.205745, 0.477919, 0, 0, 0.0221415, 0, 0.477919, 0, 0, 0, 0, 0.477919, -0.136622, 0.408849, 0, 0, 0.235256, 0, 0.408849, 0, 0, 0, 0, 0.408849, 0.200507, 0.577776, 0, 0, -0.316105, 0, 0.577776, 0, 0, 0, 0, 0.577776, 0.109228, 0.489896, 0, 0, 0.039913, 0, 0.489896, 0, 0, 0, 0, 0.489896, 0.266593, 0.55952, 0, 0, -0.251103, 0, 0.55952, 0, 0, 0, 0, 0.55952, -0.237683, 0.424979, 0, 0, -0.0163222, 0, 0.424979, 0, 0, 0, 0, 0.424979, -0.135474, 0.544441, 0, 0, -0.114926, 0, 0.544441, 0, 0, 0, 0, 0.544441, -0.125013, 0.441275, 0, 0, 0.276719, 0, 0.441275, 0, 0, 0, 0, 0.441275, -0.0566853, 0.441208, 0, 0, 0.284965, 0, 0.441208, 0, 0, 0, 0, 0.441208, -0.170354, 0.545374, 0, 0, 0.22708, 0, 0.545374, 0, 0, 0, 0, 0.545374, -0.0750098, 0.483538, 0, 0, 0.166933, 0, 0.483538, 0, 0, 0, 0, 0.483538, -0.0592494, 0.501156, 0, 0, 0.0648109, 0, 0.501156, 0, 0, 0, 0, 0.501156, 0.310273, 0.416906, 0, 0, -0.101839, 0, 0.416906, 0, 0, 0, 0, 0.416906, 0.114669, 0.580051, 0, 0, -0.0869363, 0, 0.580051, 0, 0, 0, 0, 0.580051, 0.0148138, 0.486025, 0, 0, -0.0506034, 0, 0.486025, 0, 0, 0, 0, 0.486025, -0.111222, 0.561763, 0, 0, -0.132322, 0, 0.561763, 0, 0, 0, 0, 0.561763, -0.279143, 0.588378, 0, 0, -0.156966, 0, 0.588378, 0, 0, 0, 0, 0.588378, 0.264466, 0.587942, 0, 0, 0.00191143, 0, 0.587942, 0, 0, 0, 0, 0.587942, -0.271856, 0.422839, 0, 0, -0.180986, 0, 0.422839, 0, 0, 0, 0, 0.422839, -0.257386, 0.583304, 0, 0, 0.166498, 0, 0.583304, 0, 0, 0, 0, 0.583304, 0.299894, 0.469133, 0, 0, -0.0869951, 0, 0.469133, 0, 0, 0, 0, 0.469133, 0.258686, 0.501141, 0, 0, -0.0690251, 0, 0.501141, 0, 0, 0, 0, 0.501141, 0.211844, 0.445388, 0, 0, 0.0627016, 0, 0.445388, 0, 0, 0, 0, 0.445388, 0.196344, 0.505713, 0, 0, 0.267159, 0, 0.505713, 0, 0, 0, 0, 0.505713, -0.315608, 0.561086, 0, 0, 0.231257, 0, 0.561086, 0, 0, 0, 0, 0.561086, -0.190699, 0.544177, 0, 0, 0.169978, 0, 0.544177, 0, 0, 0, 0, 0.544177, 0.167157, 0.487531, 0, 0, -0.274127, 0, 0.487531, 0, 0, 0, 0, 0.487531, 0.245489)
[node name="GrassMesh" type="MultiMeshInstance3D"]
material_override = ExtResource("1_mi2yd")
multimesh = SubResource("MultiMesh_i0fnp")
script = ExtResource("3_sbbi8")
extents = Vector2(0.32, 0.32)
scale_basic = 0.5

@ -0,0 +1,18 @@
[gd_scene load_steps=5 format=3 uid="uid://bjqr42b8i5aqe"]
[ext_resource type="Material" uid="uid://nufv335woq2s" path="res://render/material/wind_grass.tres" id="1_l4t4d"]
[ext_resource type="ArrayMesh" uid="uid://ddvgn8mvwnjka" path="res://render/mesh/grass_triangle.obj" id="2_7id7u"]
[ext_resource type="Script" path="res://script/editor_tool/grass_mesh.gd" id="3_4bfc1"]
[sub_resource type="MultiMesh" id="MultiMesh_i0fnp"]
transform_format = 1
instance_count = 20
mesh = ExtResource("2_7id7u")
buffer = PackedFloat32Array(0.447556, 0, 0, 0.214988, 0, 0.447556, 0, 0, 0, 0, 0.447556, -0.179775, 0.402864, 0, 0, 0.00355405, 0, 0.402864, 0, 0, 0, 0, 0.402864, 0.153977, 0.466052, 0, 0, -0.0347098, 0, 0.466052, 0, 0, 0, 0, 0.466052, -0.0682281, 0.377455, 0, 0, -0.0436905, 0, 0.377455, 0, 0, 0, 0, 0.377455, -0.312027, 0.388893, 0, 0, 0.0321143, 0, 0.388893, 0, 0, 0, 0, 0.388893, 0.316336, 0.433887, 0, 0, 0.00524941, 0, 0.433887, 0, 0, 0, 0, 0.433887, -0.0804169, 0.423926, 0, 0, 0.177719, 0, 0.423926, 0, 0, 0, 0, 0.423926, -0.0279486, 0.386352, 0, 0, 0.24718, 0, 0.386352, 0, 0, 0, 0, 0.386352, 0.217906, 0.372492, 0, 0, 0.10613, 0, 0.372492, 0, 0, 0, 0, 0.372492, -0.129829, 0.482979, 0, 0, 0.215392, 0, 0.482979, 0, 0, 0, 0, 0.482979, -0.301264, 0.403461, 0, 0, -0.304334, 0, 0.403461, 0, 0, 0, 0, 0.403461, 0.28521, 0.305712, 0, 0, 0.133187, 0, 0.305712, 0, 0, 0, 0, 0.305712, 0.237432, 0.467374, 0, 0, 0.242138, 0, 0.467374, 0, 0, 0, 0, 0.467374, 0.276226, 0.340186, 0, 0, 0.196599, 0, 0.340186, 0, 0, 0, 0, 0.340186, -0.0352196, 0.359262, 0, 0, -0.286212, 0, 0.359262, 0, 0, 0, 0, 0.359262, -0.290231, 0.428309, 0, 0, -0.296598, 0, 0.428309, 0, 0, 0, 0, 0.428309, -0.132031, 0.307916, 0, 0, 0.135875, 0, 0.307916, 0, 0, 0, 0, 0.307916, -0.0619626, 0.331092, 0, 0, -0.0777463, 0, 0.331092, 0, 0, 0, 0, 0.331092, 0.202209, 0.342283, 0, 0, -0.187628, 0, 0.342283, 0, 0, 0, 0, 0.342283, -0.000626862, 0.454191, 0, 0, 0.311841, 0, 0.454191, 0, 0, 0, 0, 0.454191, 0.106484)
[node name="GrassMesh" type="MultiMeshInstance3D"]
material_override = ExtResource("1_l4t4d")
multimesh = SubResource("MultiMesh_i0fnp")
script = ExtResource("3_4bfc1")
extents = Vector2(0.32, 0.32)
scale_basic = 0.4

@ -0,0 +1,8 @@
[gd_scene format=3 uid="uid://dbbv668bdbepx"]
[node name="Light01" type="Node3D"]
[node name="OmniLight3D" type="OmniLight3D" parent="."]
light_color = Color(1, 1, 0.258824, 1)
light_energy = 0.2
shadow_enabled = true

@ -124,7 +124,7 @@ func refresh_mesh_library(path_list: Array, from_editor_tool: bool = false):
var is_ground = mesh_name.begins_with("g_") var is_ground = mesh_name.begins_with("g_")
if is_ground: if is_ground:
mesh_name = mesh_name.trim_prefix("g_") mesh_name = mesh_name.trim_prefix("g_")
var is_character = mesh_name.begins_with("c_") var is_character: bool = mesh_name.begins_with("c_") or mesh_name.begins_with("a_")
var mesh: Mesh = load(file_name_full) as Mesh var mesh: Mesh = load(file_name_full) as Mesh
var mesh_library: MeshLibrary = mesh_library_ground if is_ground else (mesh_library_character if is_character else mesh_library_level) var mesh_library: MeshLibrary = mesh_library_ground if is_ground else (mesh_library_character if is_character else mesh_library_level)
var mesh_library_id_list: Array[int] = mesh_library_ground_id_list if is_ground else mesh_library_level_id_list var mesh_library_id_list: Array[int] = mesh_library_ground_id_list if is_ground else mesh_library_level_id_list
@ -137,7 +137,7 @@ func refresh_mesh_library(path_list: Array, from_editor_tool: bool = false):
mesh_library.set_item_mesh(mesh_id, mesh) mesh_library.set_item_mesh(mesh_id, mesh)
var material: Material = mesh.surface_get_material(0) as Material var material: Material = mesh.surface_get_material(0) as Material
var material_set: Material = material_block_link if mesh_name.ends_with("_link") else material_block_normal var material_set: Material = material_block_link if mesh_name.ends_with("_link") else material_block_normal
if (mesh.get_surface_count() >0) and (not material) or (material.get_path() != material_set.get_path()): if (mesh.get_surface_count() >0) and ((not material) or (material.get_path() != material_set.get_path())):
if from_editor_tool: if from_editor_tool:
reimport_files.append(file_name_full) reimport_files.append(file_name_full)
else: else:
@ -151,7 +151,7 @@ func refresh_mesh_library(path_list: Array, from_editor_tool: bool = false):
"h": item_shapes = default_shape_normal_half if not is_ground else default_shape_large_half "h": item_shapes = default_shape_normal_half if not is_ground else default_shape_large_half
"s1": item_shapes = default_shape_normal_stair1 if not is_ground else default_shape_large_stair1 "s1": item_shapes = default_shape_normal_stair1 if not is_ground else default_shape_large_stair1
"s2": item_shapes = default_shape_normal_stair2 if not is_ground else default_shape_large_stair2 "s2": item_shapes = default_shape_normal_stair2 if not is_ground else default_shape_large_stair2
"c": pass "c", "a": pass
_: item_shapes = [mesh.create_convex_shape(), Transform3D.IDENTITY] _: item_shapes = [mesh.create_convex_shape(), Transform3D.IDENTITY]
if item_shapes: if item_shapes:
mesh_library.set_item_shapes(mesh_id, item_shapes) mesh_library.set_item_shapes(mesh_id, item_shapes)
@ -287,3 +287,10 @@ func get_character_cfg_by_name(name: String) -> CharacterCfg:
if res is CharacterCfg: if res is CharacterCfg:
return res return res
return null return null
func get_level_active_scene_by_name(name: String) -> PackedScene:
var path_default: String = "res://scene/level_active/%s.tscn" % name
if ResourceLoader.exists(path_default):
var res = load(path_default)
return res
return null

@ -0,0 +1,25 @@
@tool
extends MultiMeshInstance3D
@export var extents := Vector2.ONE
@export var scale_basic := 1.0
@export var refresh: bool:
get: return false
set(_value):
refresh_grass()
func refresh_grass() -> void:
var rng := RandomNumberGenerator.new()
rng.randomize()
for instance_index in multimesh.instance_count:
var scale: float = rng.randf_range(scale_basic - 0.1, scale_basic + 0.1)
var transform := Transform3D().rotated(Vector3.UP, 0).scaled(Vector3.ONE * scale)
var x: float
var z: float
x = rng.randf_range(-extents.x, extents.x)
z = rng.randf_range(-extents.y, extents.y)
transform.origin = Vector3(x, 0, z)
multimesh.set_instance_transform(instance_index, transform)

@ -6,6 +6,7 @@ var born_pos: Vector3
@onready var grid_block_material: Material = load("res://render/material/grid_block.tres") as Material @onready var grid_block_material: Material = load("res://render/material/grid_block.tres") as Material
@onready var grid_block_link_material: Material = load("res://render/material/grid_block_link.tres") as Material @onready var grid_block_link_material: Material = load("res://render/material/grid_block_link.tres") as Material
@onready var grass_material: Material = load("res://render/material/wind_grass.tres") as Material
func init() -> void: func init() -> void:
@ -20,6 +21,7 @@ func get_level_instance_list() -> Array[LevelInstance]:
level_instance_list = [] level_instance_list = []
var rooms_node: Node3D = %Levels as Node3D var rooms_node: Node3D = %Levels as Node3D
var level_character: GridMap = %LevelCharacter as GridMap var level_character: GridMap = %LevelCharacter as GridMap
level_character.visible = false
for rooms_node_child in rooms_node.get_children(): for rooms_node_child in rooms_node.get_children():
if not rooms_node_child is LevelArea: if not rooms_node_child is LevelArea:
continue continue
@ -47,5 +49,4 @@ func get_born_pos() -> Vector3:
func set_player_position(pos: Vector3) -> void: func set_player_position(pos: Vector3) -> void:
grid_block_material.set_shader_parameter("target_position", pos) grid_block_material.set_shader_parameter("target_position", pos)
grid_block_link_material.set_shader_parameter("target_position", pos) grid_block_link_material.set_shader_parameter("target_position", pos)
grass_material.set_shader_parameter("character_position", pos)

@ -27,12 +27,15 @@ class_name LevelInstance
var level_area_cfg: LevelAreaCfg #运行时设置 var level_area_cfg: LevelAreaCfg #运行时设置
var character_spots: Array[ChacacterSpot] #运行时设置 var character_spots: Array[ChacacterSpot] #运行时设置
var level_active_spots: Array[LevelActiveSpot] #运行时设置
class ChacacterSpot: class ChacacterSpot:
var pos: Vector3 var pos: Vector3
var cfg: CharacterCfg var cfg: CharacterCfg
class LevelActiveSpot:
var pos: Vector3
var scene: PackedScene
func _on_size_change() -> void: func _on_size_change() -> void:
var level_range: CSGBox3D = $LevelRange as CSGBox3D var level_range: CSGBox3D = $LevelRange as CSGBox3D
@ -83,26 +86,40 @@ func init_character_spots(level_character: GridMap) -> void:
for y in range(id_min.y, id_max.y+1): for y in range(id_min.y, id_max.y+1):
for z in range(id_min.z, id_max.z+1): for z in range(id_min.z, id_max.z+1):
var pos: Vector3i = Vector3i(x, y, z) var pos: Vector3i = Vector3i(x, y, z)
var float_pos: Vector3 = Util.get_level_float_pos(pos) + Vector3(0.32, 0, 0.32)
var item_id: int = level_character.get_cell_item(pos) var item_id: int = level_character.get_cell_item(pos)
if item_id == GridMap.INVALID_CELL_ITEM: if item_id == GridMap.INVALID_CELL_ITEM:
continue continue
var name: String = mesh_library.get_item_name(item_id) var name: String = mesh_library.get_item_name(item_id)
if not name.begins_with("c_"): if name.begins_with("c_"):
continue var character_name: String = name.trim_prefix("c_")
var character_name: String = name.trim_prefix("c_") var character_cfg: CharacterCfg = Util.get_character_cfg_by_name(character_name)
var character_cfg: CharacterCfg = Util.get_character_cfg_by_name(character_name) if not character_cfg:
if not character_cfg: continue
continue var character_spot = ChacacterSpot.new()
var character_spot = ChacacterSpot.new() character_spot.cfg = character_cfg
character_spot.cfg = character_cfg character_spot.pos = float_pos
character_spot.pos = Util.get_level_float_pos(pos) character_spots.append(character_spot)
character_spots.append(character_spot) if name.begins_with("a_"):
var scene_name: String = name.trim_prefix("a_")
var scene : PackedScene = Util.get_level_active_scene_by_name(scene_name)
if not scene:
continue
var level_active_spot = LevelActiveSpot.new()
level_active_spot.scene = scene
level_active_spot.pos = float_pos
level_active_spots.append(level_active_spot)
func get_character_spots() -> Array[ChacacterSpot]: func get_character_spots() -> Array[ChacacterSpot]:
return character_spots return character_spots
func get_level_active_spots() -> Array[LevelActiveSpot]:
return level_active_spots
func pos_min() -> Vector3: func pos_min() -> Vector3:
return get_global_position() + Vector3(0.640001, 0.640001, 0.640001) return get_global_position() + Vector3(0.640001, 0.640001, 0.640001)
@ -110,4 +127,4 @@ func pos_min() -> Vector3:
func pos_max() -> Vector3: func pos_max() -> Vector3:
var level_range: CSGBox3D = $LevelRange as CSGBox3D var level_range: CSGBox3D = $LevelRange as CSGBox3D
var level_size: Vector3 = level_range.size var level_size: Vector3 = level_range.size
return get_global_position() + level_size - Vector3(0.640001, 0.639999, 0.639999) return get_global_position() + level_size - Vector3(0.640001, 0.639999, 0.639999)

@ -142,6 +142,7 @@ func get_screen_pos(pos: Vector3) -> Vector2:
func add_global_effect(effect_type: Enum.EGlobalEffect, life_time: float, value: float) -> void: func add_global_effect(effect_type: Enum.EGlobalEffect, life_time: float, value: float) -> void:
value *= 0.5
for global_effect: GlobalEffect in global_effect_list: for global_effect: GlobalEffect in global_effect_list:
if global_effect.effect_type == effect_type: if global_effect.effect_type == effect_type:
global_effect.life_time = life_time global_effect.life_time = life_time

@ -6,7 +6,7 @@ var level: Level
var cur_level_instance: LevelInstance var cur_level_instance: LevelInstance
var level_instance_dict: Dictionary = {} var level_instance_dict: Dictionary = {}
var level_loading_rate: float var level_loading_rate: float
var level_active_spots: Array[Node]
func _ready(): func _ready():
Global.level_mgr = self Global.level_mgr = self
@ -67,13 +67,21 @@ func set_player_position(pos: Vector3) -> void:
if new_level_instance == cur_level_instance: if new_level_instance == cur_level_instance:
return return
cur_level_instance.set_focus_from(true) cur_level_instance.set_focus_from(true)
SignalManager.level_loading_start.emit() SignalManager.level_loading_start.emit()
#创建关卡内角色 #创建关卡内角色
for character_spot: LevelInstance.ChacacterSpot in new_level_instance.get_character_spots(): for character_spot: LevelInstance.ChacacterSpot in new_level_instance.get_character_spots():
if not character_spot.cfg:
continue
Global.character_mgr.create_character(character_spot.cfg, Enum.ETeam.Monster, character_spot.pos) Global.character_mgr.create_character(character_spot.cfg, Enum.ETeam.Monster, character_spot.pos)
#创建关卡内活动部件
for level_active_spot: Node in level_active_spots:
level_active_spot.queue_free()
level_active_spots = []
for level_active_spot: LevelInstance.LevelActiveSpot in new_level_instance.get_level_active_spots():
var new_level_active: Node = level_active_spot.scene.instantiate()
add_child(new_level_active)
new_level_active.global_position = level_active_spot.pos
level_active_spots.append(new_level_active)
new_level_instance.set_focus_to(true) new_level_instance.set_focus_to(true)
cur_level_instance = new_level_instance cur_level_instance = new_level_instance
level_loading_rate = 1-level_loading_rate level_loading_rate = 1-level_loading_rate

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Loading…
Cancel
Save