forked from datawhale/whale-town-front
feat: 增加欢迎板
- 增加欢迎板场景 - 增加与玩家的交互,点击E弹出弹出框
This commit is contained in:
BIN
assets/materials/WelcomeBoard.png
Normal file
BIN
assets/materials/WelcomeBoard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 KiB |
40
assets/materials/WelcomeBoard.png.import
Normal file
40
assets/materials/WelcomeBoard.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://v7loa3smfkrd"
|
||||
path="res://.godot/imported/WelcomeBoard.png-bcff7f9bf968cb5d7630e2ad47f2fb42.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/materials/WelcomeBoard.png"
|
||||
dest_files=["res://.godot/imported/WelcomeBoard.png-bcff7f9bf968cb5d7630e2ad47f2fb42.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,4 +1,4 @@
|
||||
[gd_scene load_steps=37 format=4 uid="uid://5cc0c6cpnhe8"]
|
||||
[gd_scene load_steps=38 format=4 uid="uid://5cc0c6cpnhe8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c5ml4722ptwp2" path="res://scenes/Maps/BaseLevel.gd" id="1_m4als"]
|
||||
[ext_resource type="Texture2D" uid="uid://baa5wkuyqouh6" path="res://assets/sprites/environment/standard_brick_128_128.jpg" id="1_rb5kq"]
|
||||
@@ -15,6 +15,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://blre1srim52hs" path="res://assets/sprites/environment/deck_512_282.png" id="15_2rqka"]
|
||||
[ext_resource type="PackedScene" uid="uid://dscbaqkb1klwl" path="res://scenes/Maps/community.tscn" id="16_0xqio"]
|
||||
[ext_resource type="PackedScene" uid="uid://vq5qgk3k6t7e" path="res://scenes/Maps/fountain.tscn" id="16_2rqka"]
|
||||
[ext_resource type="PackedScene" uid="uid://c7k8yay002w4" path="res://scenes/prefabs/items/welcome_board.tscn" id="16_edt5w"]
|
||||
[ext_resource type="PackedScene" uid="uid://bvfyllcy5fi8o" path="res://scenes/Maps/datawhale_home.tscn" id="16_m4als"]
|
||||
[ext_resource type="Script" uid="uid://b068cnbw3a8wt" path="res://scenes/Maps/DoorTeleport.gd" id="18_0xqio"]
|
||||
|
||||
@@ -1090,7 +1091,7 @@ position = Vector2(0, 320)
|
||||
position = Vector2(8, -128)
|
||||
|
||||
[node name="NPC" parent="." instance=ExtResource("15_0xqio")]
|
||||
position = Vector2(-88, -88)
|
||||
position = Vector2(-88, -80)
|
||||
|
||||
[node name="DefaultSpawn" type="Marker2D" parent="."]
|
||||
position = Vector2(647, 500)
|
||||
@@ -1098,6 +1099,9 @@ position = Vector2(647, 500)
|
||||
[node name="FromRoom" type="Marker2D" parent="."]
|
||||
position = Vector2(648, 24)
|
||||
|
||||
[node name="WelcomeBoard" parent="." instance=ExtResource("16_edt5w")]
|
||||
position = Vector2(128, -80)
|
||||
|
||||
[node name="DoorArea" type="Area2D" parent="."]
|
||||
position = Vector2(0, 5)
|
||||
script = ExtResource("18_0xqio")
|
||||
|
||||
@@ -3,7 +3,7 @@ extends CharacterBody2D
|
||||
signal interaction_happened(text)
|
||||
|
||||
@export var npc_name: String = "NPC"
|
||||
@export var dialogue: String = "欢迎来到WhaleTown,我是镇长范鲸鱼"
|
||||
@export var dialogue: String = "欢迎来到WhaleTown,我是镇长范鲸晶"
|
||||
|
||||
func _ready():
|
||||
$Sprite2D.texture = preload("res://assets/characters/npc_286_241.png")
|
||||
|
||||
13
scenes/prefabs/items/WelcomeBoard.gd
Normal file
13
scenes/prefabs/items/WelcomeBoard.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends StaticBody2D
|
||||
|
||||
func interact():
|
||||
# Prevent multiple dialogs
|
||||
if get_tree().root.has_node("WelcomeDialog"):
|
||||
return null
|
||||
|
||||
# Spawn the Welcome Dialog
|
||||
var dialog = preload("res://scenes/ui/welcome_dialog.tscn").instantiate()
|
||||
dialog.name = "WelcomeDialog"
|
||||
# Add to the Scene Root (World) or CanvasLayer if it has one
|
||||
get_tree().root.add_child(dialog)
|
||||
return null # Return null prevents Player from showing a bubble
|
||||
1
scenes/prefabs/items/WelcomeBoard.gd.uid
Normal file
1
scenes/prefabs/items/WelcomeBoard.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d2od22agputjt
|
||||
19
scenes/prefabs/items/welcome_board.tscn
Normal file
19
scenes/prefabs/items/welcome_board.tscn
Normal file
@@ -0,0 +1,19 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c7k8yay002w4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ceg3xogmd82yx" path="res://scenes/prefabs/items/WelcomeBoard.gd" id="1_script"]
|
||||
[ext_resource type="Texture2D" uid="uid://v7loa3smfkrd" path="res://Assets/materials/WelcomeBoard.png" id="2_sprite"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_board"]
|
||||
size = Vector2(40, 30)
|
||||
|
||||
[node name="WelcomeBoard" type="StaticBody2D"]
|
||||
collision_layer = 3
|
||||
script = ExtResource("1_script")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_sprite")
|
||||
scale = Vector2(0.25, 0.25)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0, 10)
|
||||
shape = SubResource("RectangleShape2D_board")
|
||||
20
scenes/ui/WelcomeDialog.gd
Normal file
20
scenes/ui/WelcomeDialog.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
extends CanvasLayer
|
||||
|
||||
func _ready():
|
||||
# Connect close button (X)
|
||||
var header_close = find_child("CloseButton", true, false)
|
||||
if header_close:
|
||||
header_close.pressed.connect(_on_close_pressed)
|
||||
|
||||
# Connect Start button
|
||||
var start_btn = find_child("StartButton", true, false)
|
||||
if start_btn:
|
||||
start_btn.pressed.connect(_on_close_pressed)
|
||||
|
||||
func _on_close_pressed():
|
||||
queue_free()
|
||||
|
||||
func _input(event):
|
||||
# Allow ESC to close
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
queue_free()
|
||||
1
scenes/ui/WelcomeDialog.gd.uid
Normal file
1
scenes/ui/WelcomeDialog.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cu6x4dxhsylw2
|
||||
117
scenes/ui/welcome_dialog.tscn
Normal file
117
scenes/ui/welcome_dialog.tscn
Normal file
@@ -0,0 +1,117 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d8mam0n1a3b5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cu6x4dxhsylw2" path="res://scenes/ui/WelcomeDialog.gd" id="1_vs5b1"]
|
||||
[ext_resource type="Texture2D" uid="uid://v7loa3smfkrd" path="res://assets/materials/WelcomeBoard.png" id="2_dy5hw"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_card"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
corner_radius_top_left = 10
|
||||
corner_radius_top_right = 10
|
||||
corner_radius_bottom_right = 10
|
||||
corner_radius_bottom_left = 10
|
||||
shadow_color = Color(0, 0, 0, 0.2)
|
||||
shadow_size = 10
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_btn_rounded"]
|
||||
bg_color = Color(0.95, 0.95, 0.95, 1)
|
||||
border_width_left = 1
|
||||
border_width_top = 1
|
||||
border_width_right = 1
|
||||
border_width_bottom = 1
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 20
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[node name="WelcomeDialog" type="CanvasLayer"]
|
||||
script = ExtResource("1_vs5b1")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 0.4)
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="CenterContainer"]
|
||||
custom_minimum_size = Vector2(400, 350)
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_card")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 10
|
||||
|
||||
[node name="Header" type="HBoxContainer" parent="CenterContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Spacer" type="Control" parent="CenterContainer/PanelContainer/VBoxContainer/Header"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Title" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer/Header"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_font_sizes/font_size = 18
|
||||
text = "欢迎来到 Datawhale Town!"
|
||||
|
||||
[node name="Spacer2" type="Control" parent="CenterContainer/PanelContainer/VBoxContainer/Header"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="CloseButton" type="Button" parent="CenterContainer/PanelContainer/VBoxContainer/Header"]
|
||||
custom_minimum_size = Vector2(30, 30)
|
||||
layout_mode = 2
|
||||
text = "X"
|
||||
flat = true
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="CenterContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LogoContainer" type="CenterContainer" parent="CenterContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="CenterContainer/PanelContainer/VBoxContainer/LogoContainer"]
|
||||
custom_minimum_size = Vector2(300, 100)
|
||||
layout_mode = 2
|
||||
texture = ExtResource("2_dy5hw")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="BodyText" type="Label" parent="CenterContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.3, 0.3, 0.3, 1)
|
||||
theme_override_font_sizes/font_size = 14
|
||||
text = "连接·共生·见证
|
||||
Datawhale Town —— 学习者的赛博家园与精神坐标。
|
||||
✨ 实时广场:看大家都在学什么。
|
||||
🏠 个人空间:展示你的学习笔记与作品。
|
||||
🤝 开源营地:更有氛围的组队学习体验。"
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="Spacer3" type="Control" parent="CenterContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ActionContainer" type="CenterContainer" parent="CenterContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="StartButton" type="Button" parent="CenterContainer/PanelContainer/VBoxContainer/ActionContainer"]
|
||||
custom_minimum_size = Vector2(150, 40)
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_btn_rounded")
|
||||
text = "开始探索"
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="CenterContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
Reference in New Issue
Block a user