Implemented character preview when selecting character

remotes/1711838515240372319/tmp_refs/heads/godot4-port
desktop 2020-12-11 23:57:11 +01:00
parent fe92968dcd
commit c710838793
6 changed files with 40 additions and 23 deletions

View File

@ -2,5 +2,5 @@ extends "res://Player.gd"
func _ready():
if name == String(get_tree().get_network_unique_id()):
print("SELF")
return
#$Throne/Cube.cast_shadow = 3

View File

@ -1,9 +1,11 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func set_character(packed_character):
var character = packed_character.instance()
character.show_healthbar = false
$Viewport.add_child(character)
func _process(delta):
$Viewport.size = rect_size

View File

@ -1,6 +1,5 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Assets/Characters/HerMajestyTheQueen/HerMajestyTheQueen.tscn" type="PackedScene" id=1]
[ext_resource path="res://GUI/CharacterOption.gd" type="Script" id=2]
[sub_resource type="ViewportTexture" id=1]
@ -9,6 +8,9 @@ viewport_path = NodePath("Viewport")
[node name="CharacterOption" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -824.0
margin_bottom = -300.0
rect_min_size = Vector2( 200, 300 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
@ -25,12 +27,14 @@ __meta__ = {
[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 500, 500 )
own_world = true
transparent_bg = true
msaa = 2
render_target_v_flip = true
[node name="Camera" type="Camera" parent="Viewport"]
transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 1.38191, -6.32464 )
transform = Transform( -1, 0, -3.25841e-07, 0, 1, 0, 3.25841e-07, 0, -1, 0, 1.38191, -8.49631 )
fov = 39.6532
[node name="HerMajestyTheQueen" parent="Viewport" instance=ExtResource( 1 )]
[node name="DirectionalLight" type="DirectionalLight" parent="Viewport"]
transform = Transform( 1, 0, 0, 0, -0.361787, 0.932261, 0, -0.932261, -0.361787, 0, 3.34228, -3.37409 )
light_energy = 2.9

View File

@ -5,8 +5,23 @@ onready var game = get_parent().get_parent()
func _ready():
var dir = Directory.new()
dir.open("res://Assets/Characters/")
dir.list_dir_begin()
#$CenterContainer/VBoxContainer/CharacterList.add_child(null)
var file = dir.get_next()
while file != "":
if not file.begins_with("."):
# Add character
add_character(file)
file = dir.get_next()
func add_character(character_name):
var path = "res://Assets/Characters/" + character_name + "/" + character_name + ".tscn"
var packed_character = load(path)
var character_option = preload("res://GUI/CharacterOption.tscn").instance()
$CenterContainer/VBoxContainer/CharacterList.add_child(character_option)
character_option.set_character(packed_character)
func spawn():
get_parent().get_parent().spawn(get_tree().get_network_unique_id())

View File

@ -22,28 +22,21 @@ __meta__ = {
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = -177.0
margin_top = -50.0
margin_top = -26.0
margin_right = 176.0
margin_bottom = 50.0
margin_bottom = 26.0
[node name="CharacterList" type="HBoxContainer" parent="CenterContainer/VBoxContainer"]
margin_right = 353.0
margin_bottom = 48.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Button" type="Button" parent="CenterContainer/VBoxContainer/CharacterList"]
margin_left = 30.0
margin_right = 322.0
margin_bottom = 48.0
text = "Her Majesty the Queen"
[node name="Options" type="HBoxContainer" parent="CenterContainer/VBoxContainer"]
margin_top = 52.0
margin_top = 4.0
margin_right = 353.0
margin_bottom = 100.0
margin_bottom = 52.0
alignment = 1
[node name="SelectButton" type="Button" parent="CenterContainer/VBoxContainer/Options"]

View File

@ -11,6 +11,7 @@ const WALK_DECEL = 0.1
const MOUSE_SENSITIVITY = 1.0 / 1000
export var show_healthbar = true
export var max_health = 150
onready var health = max_health setget set_health
@ -310,7 +311,7 @@ func set_local_player():
# Called when the node enters the scene tree for the first time.
func _ready():
set_health(150)
set_health(max_health)
# disabled the ragdoll collider
#for i in $Player/Gibs.get_children():
# i.get_child(1).disabled = true
@ -318,6 +319,8 @@ func _ready():
#$"Player/Gibs/PlayerGibs _cell /shape0".set_disabled(true)
rset_config("translation", MultiplayerAPI.RPC_MODE_SYNC)
if !show_healthbar:
$Billboard.hide()
# only show the debug label on local machine
if name != String(get_tree().get_network_unique_id()):