建设了一个塔楼,每秒钟加1

This commit is contained in:
xsl
2025-11-16 21:52:22 +08:00
parent 1a766bbcc4
commit a316ba9781
17 changed files with 385 additions and 3 deletions
+53
View File
@@ -0,0 +1,53 @@
using Godot;
using System;
public partial class MyPlayer2 : CharacterBody3D
{
private AnimationPlayer _animationPlayer;
public override void _Ready()
{
_animationPlayer = GetNode<AnimationPlayer>("godette/AnimationPlayer");
}
public const float Speed = 5.0f;
public const float JumpVelocity = 4.5f;
public override void _PhysicsProcess(double delta)
{
Vector3 velocity = Velocity;
// Add the gravity.
if (!IsOnFloor())
{
velocity += GetGravity() * (float)delta;
}
// Handle Jump.
if (Input.IsActionJustPressed("ui_accept") && IsOnFloor())
{
velocity.Y = JumpVelocity;
}
// Get the input direction and handle the movement/deceleration.
// As good practice, you should replace UI actions with custom gameplay actions.
Vector2 inputDir = Input.GetVector("left", "right", "forward", "backward");
Vector3 direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
if (direction != Vector3.Zero)
{
velocity.X = direction.X * Speed;
velocity.Z = direction.Z * Speed;
_animationPlayer.CurrentAnimation = "Running_B";
}
else
{
velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
velocity.Z = Mathf.MoveToward(Velocity.Z, 0, Speed);
_animationPlayer.CurrentAnimation = "Idle";
}
Velocity = velocity;
MoveAndSlide();
}
}
+1
View File
@@ -0,0 +1 @@
uid://cmvtey24s2xfq
BIN
View File
Binary file not shown.
+42
View File
@@ -0,0 +1,42 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://vk2pd3kdvvbe"
path="res://.godot/imported/tower.glb-9d9a9ee01faed9b3adf88092807a0df6.scn"
[deps]
source_file="res://model/tower.glb"
dest_files=["res://.godot/imported/tower.glb-9d9a9ee01faed9b3adf88092807a0df6.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 MiB

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cdfacuka3a587"
path.s3tc="res://.godot/imported/tower_texture_pbr_20250901.png-2a2c65c2f0d3d50a8cb6f07f362f5da0.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "b5ff77c62bdeb8487f53997ba98455f8"
}
[deps]
source_file="res://model/tower_texture_pbr_20250901.png"
dest_files=["res://.godot/imported/tower_texture_pbr_20250901.png-2a2c65c2f0d3d50a8cb6f07f362f5da0.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 MiB

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cldrn5se7y8r3"
path.s3tc="res://.godot/imported/tower_texture_pbr_20250901_metallic-texture_pbr_20250901_roughness.png-1b8e1ad69c54279cd560ee1fed282d12.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "d268ff2f159b2df2b01aa2b5ae08f040"
}
[deps]
source_file="res://model/tower_texture_pbr_20250901_metallic-texture_pbr_20250901_roughness.png"
dest_files=["res://.godot/imported/tower_texture_pbr_20250901_metallic-texture_pbr_20250901_roughness.png-1b8e1ad69c54279cd560ee1fed282d12.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dqg5a2t4lvl1b"
path.s3tc="res://.godot/imported/tower_texture_pbr_20250901_normal.png-be5ed1ec3c4cf52c18f83be9c123f76e.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
generator_parameters={
"md5": "ecdd186b838aae5063e80883c0a19059"
}
[deps]
source_file="res://model/tower_texture_pbr_20250901_normal.png"
dest_files=["res://.godot/imported/tower_texture_pbr_20250901_normal.png-be5ed1ec3c4cf52c18f83be9c123f76e.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=1
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=1
roughness/src_normal="res://model/tower_texture_pbr_20250901_normal.png"
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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=0
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

+40
View File
@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bk8vyeo6u8g1o"
path="res://.godot/imported/生成游戏塔楼图片.png-9e5cd9024da332f53f8f6332fbceecf8.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://png/生成游戏塔楼图片.png"
dest_files=["res://.godot/imported/生成游戏塔楼图片.png-9e5cd9024da332f53f8f6332fbceecf8.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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
+1 -1
View File
@@ -11,7 +11,7 @@ config_version=5
[application]
config/name="Godot BotW"
run/main_scene="uid://biqndtedokpnl"
run/main_scene="uid://4t1deakd15ow"
config/features=PackedStringArray("4.5", "C#", "Forward Plus")
config/icon="res://graphics/icon.png"
+59
View File
@@ -0,0 +1,59 @@
using Godot;
using System;
public partial class add1 : Label3D
{
private int _counter = 0;
private double _timer = 0.0;
// 每秒增加的数值,可以在编辑器中调整
[Export]
public int IncrementPerSecond = 1;
public override void _Ready()
{
// 初始化显示
UpdateDisplay();
}
public override void _Process(double delta)
{
_timer += delta;
// 每经过1秒,计数器增加
if (_timer >= 1.0)
{
_counter += IncrementPerSecond;
_timer -= 1.0; // 减去1秒,保留剩余时间
// 更新显示
UpdateDisplay();
}
}
private void UpdateDisplay()
{
Text = _counter.ToString();
}
// 可选:提供方法来手动重置计数器
public void ResetCounter()
{
_counter = 0;
_timer = 0.0;
UpdateDisplay();
}
// 可选:提供方法来设置计数器的值
public void SetCounter(int value)
{
_counter = value;
UpdateDisplay();
}
// 可选:获取当前计数器的值
public int GetCounter()
{
return _counter;
}
}
+1
View File
@@ -0,0 +1 @@
uid://cvqaqtiafds76
+54
View File
@@ -0,0 +1,54 @@
[gd_scene load_steps=8 format=3 uid="uid://4t1deakd15ow"]
[ext_resource type="PackedScene" uid="uid://vk2pd3kdvvbe" path="res://model/tower.glb" id="1_5kiuu"]
[ext_resource type="Script" uid="uid://cvqaqtiafds76" path="res://scene/add1.cs" id="2_dbls1"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_n4st5"]
sky_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
ground_horizon_color = Color(0.66224277, 0.6717428, 0.6867428, 1)
[sub_resource type="Sky" id="Sky_5kiuu"]
sky_material = SubResource("ProceduralSkyMaterial_n4st5")
[sub_resource type="Environment" id="Environment_dbls1"]
background_mode = 2
sky = SubResource("Sky_5kiuu")
tonemap_mode = 2
glow_enabled = true
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_n4st5"]
albedo_color = Color(0, 0.4509804, 1, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_n4st5"]
size = Vector3(40, 0.5, 40)
[node name="Game" type="Node3D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_dbls1")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.8660254, -0.43301278, 0.25, 0, 0.49999997, 0.86602545, -0.50000006, 0.75, -0.43301266, 0, 0, 0)
light_color = Color(0.69721985, 0.7541449, 0.59896314, 1)
shadow_enabled = true
[node name="StaticBody3D" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.25, 0)
[node name="CSGBox3D" type="CSGBox3D" parent="StaticBody3D"]
transform = Transform3D(40, 0, 0, 0, 0.5, 0, 0, 0, 40, 0, 0, 0)
material = SubResource("StandardMaterial3D_n4st5")
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource("BoxShape3D_n4st5")
[node name="convert" parent="." instance=ExtResource("1_5kiuu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3047613, 0, 1.4814601)
[node name="Label3D" type="Label3D" parent="convert"]
transform = Transform3D(0.9946873, -0.0085846465, 0.1025846, -0.10283655, -0.037522838, 0.99399024, -0.004683794, -0.99925905, -0.03820631, -0.005152464, 1.0267426, -0.011272192)
text = "0"
script = ExtResource("2_dbls1")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(0.97870725, 0.12670153, -0.1614895, 0.13416018, 0.20057866, 0.970448, 0.15534858, -0.97145, 0.17930949, -0.04802704, 3.1602623, 1.9223661)
+2 -2
View File
@@ -1,12 +1,12 @@
[gd_scene load_steps=4 format=3 uid="uid://5qhvowm03lqg"]
[ext_resource type="Script" uid="uid://c8xqu4vvon4sg" path="res://MyPlayer.cs" id="1_2a064"]
[ext_resource type="Script" uid="uid://cmvtey24s2xfq" path="res://MyPlayer2.cs" id="1_i8k2p"]
[ext_resource type="PackedScene" uid="uid://dfp1cuy14cj5p" path="res://actor/girl.tscn" id="2_i8k2p"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_kak5s"]
[node name="MyPlayer2" type="CharacterBody3D"]
script = ExtResource("1_2a064")
script = ExtResource("1_i8k2p")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)