End of lesson 28.
This commit is contained in:
parent
6576c0155c
commit
75cbdf40b2
|
|
@ -3,8 +3,9 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://d3e5mg0gk8u7r" path="res://scenes/game/maps/entities/mob.tscn" id="1_7y2qh"]
|
[ext_resource type="PackedScene" uid="uid://d3e5mg0gk8u7r" path="res://scenes/game/maps/entities/mob.tscn" id="1_7y2qh"]
|
||||||
[ext_resource type="Script" uid="uid://dsguwthn2datq" path="res://scripts/game/maps/entities/Player.gd" id="2_us7jc"]
|
[ext_resource type="Script" uid="uid://dsguwthn2datq" path="res://scripts/game/maps/entities/Player.gd" id="2_us7jc"]
|
||||||
|
|
||||||
[node name="Player" instance=ExtResource("1_7y2qh")]
|
[node name="Player" node_paths=PackedStringArray("camera") instance=ExtResource("1_7y2qh")]
|
||||||
script = ExtResource("2_us7jc")
|
script = ExtResource("2_us7jc")
|
||||||
|
camera = NodePath("Camera2D")
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="." index="3"]
|
[node name="Camera2D" type="Camera2D" parent="." index="3"]
|
||||||
zoom = Vector2(1.5, 1.5)
|
zoom = Vector2(1.5, 1.5)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://c0b5w48jk67qd"]
|
[gd_scene load_steps=12 format=3 uid="uid://c0b5w48jk67qd"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c0uvlwmkm3r8o" path="res://scripts/game/game_screen.gd" id="1_dthvl"]
|
[ext_resource type="Script" uid="uid://c0uvlwmkm3r8o" path="res://scripts/game/game_screen.gd" id="1_dthvl"]
|
||||||
[ext_resource type="Script" uid="uid://dcqqr8b42tn0x" path="res://scripts/game/CommandProcessor.gd" id="2_r01d7"]
|
[ext_resource type="Script" uid="uid://dcqqr8b42tn0x" path="res://scripts/game/CommandProcessor.gd" id="2_r01d7"]
|
||||||
|
|
@ -7,6 +7,11 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://ccxs3ctob15es" path="res://gfx/ui/main_frame.png" id="5_mjl5p"]
|
[ext_resource type="Texture2D" uid="uid://ccxs3ctob15es" path="res://gfx/ui/main_frame.png" id="5_mjl5p"]
|
||||||
[ext_resource type="FontFile" uid="uid://1u28cjgctsn7" path="res://fonts/alagard_by_pix3m-d6awiwp.ttf" id="6_2yu03"]
|
[ext_resource type="FontFile" uid="uid://1u28cjgctsn7" path="res://fonts/alagard_by_pix3m-d6awiwp.ttf" id="6_2yu03"]
|
||||||
[ext_resource type="Script" uid="uid://dv3fd112uj8o1" path="res://scripts/ui/Message Console.gd" id="7_5vo8s"]
|
[ext_resource type="Script" uid="uid://dv3fd112uj8o1" path="res://scripts/ui/Message Console.gd" id="7_5vo8s"]
|
||||||
|
[ext_resource type="Script" uid="uid://ba05sgen1geyk" path="res://scripts/ui/LoadingPanel.gd" id="8_4m8lb"]
|
||||||
|
[ext_resource type="Theme" uid="uid://dnxny0n7ti7eq" path="res://themes/default_theme.tres" id="9_mjl5p"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bpsrg5d3gncnd" path="res://scenes/game/maps/entities/player.tscn" id="10_2yu03"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5vo8s"]
|
||||||
|
|
||||||
[node name="Game" type="Node" node_paths=PackedStringArray("map")]
|
[node name="Game" type="Node" node_paths=PackedStringArray("map")]
|
||||||
script = ExtResource("1_dthvl")
|
script = ExtResource("1_dthvl")
|
||||||
|
|
@ -95,6 +100,39 @@ render_target_update_mode = 4
|
||||||
[node name="MapContainer" type="Node" parent="UI/Map View/SubViewport"]
|
[node name="MapContainer" type="Node" parent="UI/Map View/SubViewport"]
|
||||||
script = ExtResource("3_vnpv3")
|
script = ExtResource("3_vnpv3")
|
||||||
|
|
||||||
|
[node name="LoadingPanel" type="MarginContainer" parent="UI" node_paths=PackedStringArray("player")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 134.0
|
||||||
|
offset_top = 15.0
|
||||||
|
offset_right = 627.0
|
||||||
|
offset_bottom = 250.0
|
||||||
|
script = ExtResource("8_4m8lb")
|
||||||
|
player = NodePath("CenterContainer/VBoxContainer/PanelContainer/Player")
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="UI/LoadingPanel"]
|
||||||
|
layout_mode = 2
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="UI/LoadingPanel"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="UI/LoadingPanel/CenterContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="UI/LoadingPanel/CenterContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme = ExtResource("9_mjl5p")
|
||||||
|
text = "Loading..."
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="UI/LoadingPanel/CenterContainer/VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(0, 16)
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_styles/panel = SubResource("StyleBoxEmpty_5vo8s")
|
||||||
|
|
||||||
|
[node name="Player" parent="UI/LoadingPanel/CenterContainer/VBoxContainer/PanelContainer" instance=ExtResource("10_2yu03")]
|
||||||
|
position = Vector2(26, 0)
|
||||||
|
|
||||||
[connection signal="BROADCAST_COMMAND" from="Command Processor" to="UI/Message Console" method="_on_command"]
|
[connection signal="BROADCAST_COMMAND" from="Command Processor" to="UI/Message Console" method="_on_command"]
|
||||||
[connection signal="timeout" from="Command Processor" to="Command Processor" method="_on_timeout"]
|
[connection signal="timeout" from="Command Processor" to="Command Processor" method="_on_timeout"]
|
||||||
[connection signal="pressed" from="UI/Left Display/Contents/Command Menu/Pass Button" to="UI" method="_on_pass_button_pressed"]
|
[connection signal="pressed" from="UI/Left Display/Contents/Command Menu/Pass Button" to="UI" method="_on_pass_button_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -14,3 +14,4 @@ signal DISPLAY_COMMAND_PROMPT
|
||||||
signal DISPLAY_CLEAR
|
signal DISPLAY_CLEAR
|
||||||
|
|
||||||
signal LOAD_MAP(currentMap, newMapPath, spawnpoint, facing)
|
signal LOAD_MAP(currentMap, newMapPath, spawnpoint, facing)
|
||||||
|
signal LOAD_COMPLETE
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ class_name GameScreen
|
||||||
@export var map:Node
|
@export var map:Node
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
CommandDispatcher.LOAD_MAP.emit(GameManager.startMap, null, Map.Direction.North)
|
CommandDispatcher.LOAD_MAP.emit(GameManager.currentMap, null, Map.Direction.North)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var map:Map
|
var map:Map
|
||||||
|
var loading: bool
|
||||||
|
var newSpawnpoint
|
||||||
|
var newFacing
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
CommandDispatcher.LOAD_MAP.connect(loadMap)
|
CommandDispatcher.LOAD_MAP.connect(loadMap)
|
||||||
|
|
@ -8,21 +11,31 @@ func _ready():
|
||||||
|
|
||||||
func loadMap(newMapPath, spawnpoint, facing):
|
func loadMap(newMapPath, spawnpoint, facing):
|
||||||
var newMap:Map
|
var newMap:Map
|
||||||
|
|
||||||
CommandDispatcher.PAUSE_PROCESSOR.emit()
|
CommandDispatcher.PAUSE_PROCESSOR.emit()
|
||||||
|
|
||||||
|
loading = true
|
||||||
|
|
||||||
if (map != null):
|
if (map != null):
|
||||||
map.queue_free()
|
map.queue_free()
|
||||||
|
|
||||||
map = load(newMapPath).instantiate()
|
|
||||||
|
|
||||||
add_child(map)
|
|
||||||
|
|
||||||
map.get_node("Entities").add_child(map.spawnPlayerAtPosition(spawnpoint, facing))
|
|
||||||
|
|
||||||
GameManager.currentMap = newMapPath
|
GameManager.currentMap = newMapPath
|
||||||
|
|
||||||
CommandDispatcher.WAIT_FOR_COMMAND.emit()
|
ResourceLoader.load_threaded_request(GameManager.currentMap)
|
||||||
|
|
||||||
|
newSpawnpoint = spawnpoint
|
||||||
|
newFacing = facing
|
||||||
|
|
||||||
|
|
||||||
|
#map = load(newMapPath).instantiate()
|
||||||
|
#
|
||||||
|
#add_child(map)
|
||||||
|
#
|
||||||
|
#map.get_node("Entities").add_child(map.spawnPlayerAtPosition(spawnpoint, facing))
|
||||||
|
#
|
||||||
|
#GameManager.currentMap = newMapPath
|
||||||
|
#
|
||||||
|
#CommandDispatcher.WAIT_FOR_COMMAND.emit()
|
||||||
|
|
||||||
|
|
||||||
func _unhandled_key_input(event):
|
func _unhandled_key_input(event):
|
||||||
|
|
@ -42,3 +55,18 @@ func _unhandled_key_input(event):
|
||||||
|
|
||||||
if (direction != null):
|
if (direction != null):
|
||||||
CommandDispatcher.PROCESS_COMMAND.emit(MoveCommand.new(direction))
|
CommandDispatcher.PROCESS_COMMAND.emit(MoveCommand.new(direction))
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if(loading):
|
||||||
|
if(ResourceLoader.load_threaded_get_status(GameManager.currentMap) == ResourceLoader.THREAD_LOAD_LOADED):
|
||||||
|
loading = false
|
||||||
|
|
||||||
|
map = ResourceLoader.load_threaded_get(GameManager.currentMap).instantiate()
|
||||||
|
|
||||||
|
call_deferred("add_child", map)
|
||||||
|
|
||||||
|
map.spawnPlayerAtPosition(newSpawnpoint, newSpawnpoint)
|
||||||
|
|
||||||
|
CommandDispatcher.LOAD_COMPLETE.emit()
|
||||||
|
CommandDispatcher.WAIT_FOR_COMMAND.emit()
|
||||||
|
|
|
||||||
|
|
@ -1 +1,5 @@
|
||||||
extends Mob
|
extends Mob
|
||||||
|
|
||||||
|
class_name Player
|
||||||
|
|
||||||
|
@export var camera:Camera2D
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
extends MarginContainer
|
||||||
|
|
||||||
|
class_name LoadingPanel
|
||||||
|
|
||||||
|
@export var player:Player
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
CommandDispatcher.LOAD_MAP.connect(onLoadMap)
|
||||||
|
CommandDispatcher.LOAD_COMPLETE.connect(onMapLoaded)
|
||||||
|
|
||||||
|
player.camera.enabled = false
|
||||||
|
player.animator.sprite_frames.set_animation_loop("Walk Down", true)
|
||||||
|
|
||||||
|
func onLoadMap(map, spawnpoint, facing):
|
||||||
|
player.animator.play("Walk down")
|
||||||
|
show()
|
||||||
|
|
||||||
|
|
||||||
|
func onMapLoaded():
|
||||||
|
player.animator.stop()
|
||||||
|
hide()
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://ba05sgen1geyk
|
||||||
Loading…
Reference in New Issue