Add FinalMenu and tweak signals

Signals are not correctly connected yet.
I need to extract the Player from the Level scene.
master
Fabien Freling 2019-02-14 14:20:44 +01:00
parent acacbc65e8
commit 3aeeaab1ba
9 changed files with 130 additions and 23 deletions

BIN
fonts/Montserrat-ExtraBold.otf Executable file

Binary file not shown.

View File

@ -0,0 +1,9 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://fonts/Montserrat-ExtraBold.otf" type="DynamicFontData" id=1]
[resource]
size = 32
font_data = ExtResource( 1 )

View File

@ -1,6 +1,20 @@
extends Node
func _process(delta):
var player = get_node("Player")
if player.has_reached_goal:
get_node("Panel").visible = true
onready var final_menu := $FinalMenu
onready var player := $Player
signal level_completed()
#func _process(delta):
# var player = get_node("Player")
# if player.has_reached_goal:
# get_node("Panel").visible = true
#func _on_Goal_body_entered(body):
# if body.t is player.:
# emit_signal("level_completed")
func _on_Level_01_level_completed():
player.queue_free()
final_menu.show()
pass # Replace with function body.

View File

@ -1,16 +1,20 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://levels/Level_01.gd" type="Script" id=1]
[ext_resource path="res://models/mlib.meshlib" type="MeshLibrary" id=2]
[ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/Goal.tscn" type="PackedScene" id=4]
[ext_resource path="res://levels/Level_01_env.tres" type="Environment" id=5]
[ext_resource path="res://levels/Level_01_env.tres" type="Environment" id=2]
[ext_resource path="res://models/mlib.meshlib" type="MeshLibrary" id=3]
[ext_resource path="res://scenes/Player.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/Goal.tscn" type="PackedScene" id=5]
[ext_resource path="res://scenes/FinalMenu.tscn" type="PackedScene" id=6]
[node name="Level_01" type="Node"]
script = ExtResource( 1 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource( 2 )
[node name="GridMap" type="GridMap" parent="."]
mesh_library = ExtResource( 2 )
mesh_library = ExtResource( 3 )
data = {
"cells": PoolIntArray( 0, 0, 1441792, 65534, 0, 1441792, 65535, 0, 1441792, 0, 65534, 1441792, 65534, 65534, 1441792, 65535, 65534, 1441792, 0, 65535, 1441792, 65534, 65535, 1441792 )
}
@ -23,16 +27,20 @@ __meta__ = {
transform = Transform( 1, 0, 0, 0, 0.939693, 0.34202, 0, -0.34202, 0.939693, 0, 6, 7 )
fov = 54.1445
[node name="Player" parent="." instance=ExtResource( 3 )]
[node name="Player" parent="." instance=ExtResource( 4 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, -2.88637, 2.79728, -2.72332 )
[node name="Goal" parent="." instance=ExtResource( 4 )]
[node name="Goal" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0.993621, 1.99794, 1.00068 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource( 5 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.701566, 0, -0.712605, 0.386011, 0.840578, 0.380031, 0.599, -0.541691, 0.589721, 0, 5.28645, 0 )
[node name="FinalMenu" parent="." instance=ExtResource( 6 )]
visible = false
[node name="Panel" type="Panel" parent="."]
editor/display_folded = true
visible = false
margin_left = 330.0
margin_top = 180.0
@ -49,6 +57,5 @@ You reached the goal!"
align = 1
valign = 1
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.701566, 0, -0.712605, 0.386011, 0.840578, 0.380031, 0.599, -0.541691, 0.589721, 0, 5.28645, 0 )
[connection signal="level_completed" from="." to="." method="_on_Level_01_level_completed"]
[connection signal="body_entered" from="Goal" to="." method="_on_Goal_body_entered"]

9
scenes/FinalMenu.gd Normal file
View File

@ -0,0 +1,9 @@
extends Control
signal retried
func _on_TryAgain_pressed():
emit_signal("retried")
func _on_Exit_pressed():
get_tree().quit()

62
scenes/FinalMenu.tscn Normal file
View File

@ -0,0 +1,62 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scenes/FinalMenu.gd" type="Script" id=1]
[ext_resource path="res://fonts/Montserrat-ExtraBold.otf" type="DynamicFontData" id=2]
[ext_resource path="res://fonts/montserrat_eb_32.tres" type="DynamicFont" id=3]
[sub_resource type="DynamicFont" id=1]
size = 48
font_data = ExtResource( 2 )
[node name="FinalMenu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="CenterContainer" type="CenterContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Column" type="VBoxContainer" parent="CenterContainer"]
margin_left = 329.0
margin_top = 223.0
margin_right = 695.0
margin_bottom = 377.0
[node name="Title" type="Label" parent="CenterContainer/Column"]
margin_right = 366.0
margin_bottom = 60.0
custom_fonts/font = SubResource( 1 )
text = "Success!"
align = 1
[node name="Label" type="Label" parent="CenterContainer/Column"]
margin_top = 64.0
margin_right = 366.0
margin_bottom = 104.0
custom_fonts/font = ExtResource( 3 )
text = "You finished Level 01."
[node name="Row" type="HBoxContainer" parent="CenterContainer/Column"]
margin_top = 108.0
margin_right = 366.0
margin_bottom = 154.0
[node name="TryAgain" type="Button" parent="CenterContainer/Column/Row"]
margin_right = 181.0
margin_bottom = 46.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 3 )
text = "Try again"
[node name="Exit" type="Button" parent="CenterContainer/Column/Row"]
margin_left = 185.0
margin_right = 366.0
margin_bottom = 46.0
size_flags_horizontal = 3
custom_fonts/font = ExtResource( 3 )
text = "Exit"
[connection signal="pressed" from="CenterContainer/Column/Row/TryAgain" to="." method="_on_TryAgain_pressed"]
[connection signal="pressed" from="CenterContainer/Column/Row/Exit" to="." method="_on_Exit_pressed"]

View File

@ -1,5 +1,7 @@
extends Spatial
signal body_entered()
func _ready():
get_node("Area").connect("body_entered", self, "collided")
@ -14,3 +16,6 @@ func collided(body):
# var camera_pos = get_viewport().get_camera().global_transform.origin
# camera_pos.y = 0
# look_at(camera_pos, Vector3(0, 1, 0))
func _on_Area_body_entered(body):
emit_signal("body_entered", body)

View File

@ -63,7 +63,7 @@ shader_param/PI = 3.1415
gradient = SubResource( 4 )
width = 2
[node name="Scene Root" index="0" instance=ExtResource( 1 )]
[node name="Goal" instance=ExtResource( 1 )]
script = ExtResource( 2 )
[node name="Pole" parent="." index="0"]
@ -93,3 +93,4 @@ transform = Transform( 250, 0, 0, 0, 500, 0, 0, 0, 1, 0, 2.91655, 0 )
material_override = SubResource( 3 )
texture = SubResource( 5 )
[connection signal="body_entered" from="Area" to="." method="_on_Area_body_entered"]

View File

@ -39,10 +39,10 @@ func _physics_process(delta):
velocity = move_and_slide(direction, floor_normal, 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
func _process(delta):
# Called every frame. Delta is time since last frame.
# Update game logic here.
pass
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
func reach_goal():
has_reached_goal = true