New Game - Doug

Adds new game start.
This commit is contained in:
MacDugRPG
2022-02-27 15:27:22 -05:00
parent 6d7009893c
commit 10860a0b71
79 changed files with 1574 additions and 0 deletions

View File

@ -0,0 +1,39 @@
#BUT_HISTORY:
# Unique script attached to the But_History to hide/show history versus
# current game page.
tool
extends Button
onready var game_history_array = get_node("/root/History").historyScreensSingleton.output_history_array
var is_history = false
func _on_But_History_button_up():
var history_pager_button = get_node("../../ItemList/But_History_Page")
var history_rows_node = get_node("../../GameInfo/HistoryRows")
var current_text_node = get_node("../../GameInfo/CurrentText")
var option_one = get_node("../../InputArea/VBoxContainer/option1")
var option_two = get_node("../../InputArea/VBoxContainer/option2")
var option_three = get_node("../../InputArea/VBoxContainer/option3")
if(!is_history):
if(game_history_array != null):
history_rows_node.add_child(game_history_array[0])
history_pager_button.show()
history_rows_node.show()
current_text_node.hide()
option_one.hide()
option_two.hide()
option_three.hide()
is_history = true
else:
history_pager_button.hide()
history_rows_node.hide()
current_text_node.show()
option_one.show()
option_two.show()
option_three.show()
is_history = false

View File

@ -0,0 +1,21 @@
#BUT_HISTORY_PAGE:
# Unique paging script for showing next page in the history game's history
# array.
tool
extends Button
var current_page = 0
func _on_But_History_Page_button_up():
var game_history_array = get_node("/root/History").historyScreensSingleton.output_history_array
var history_rows_node = get_node("../../GameInfo/HistoryRows")
if(current_page < game_history_array.size()-1):
current_page += 1
else:
current_page = 0
history_rows_node.remove_child(history_rows_node.get_child(0))
history_rows_node.add_child(game_history_array[current_page])

View File

@ -0,0 +1,72 @@
#COMMAND PROCESSOR:
# Handles player input, including navigation on the map
extends Node
var current_locale = null
var current_opt1 = null
var current_opt2 = null
var current_opt3 = null
#Allows us to pass in the starting location
func initialize(starting_locale) -> String:
current_opt1 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option1")
current_opt2 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option2")
current_opt3 = get_node("../Background/MarginContainer/Rows/InputArea/VBoxContainer/option3")
current_opt1.grab_focus()
return change_room(starting_locale)
#DKM TEMP: this must load from files written by toolset
#Function that loads response from the option string chosen
func process_command(option: String) -> String:
var optCmd_Action = option.split(": ", false)
if (optCmd_Action.size() < 2):
return "Error: no valid command and action in option!"
match optCmd_Action[0]:
"Go":
return go(optCmd_Action[1])
"Wait":
return "You rest a bit. Now what?"
"Talk":
return talk(optCmd_Action[1])
"Examine":
return examine(optCmd_Action[1])
"Scream":
return "You yell :'" + optCmd_Action[1].to_upper() +"'!!"
_:
return "Nothing happens! Command word was: " + optCmd_Action[0]
func go(action: String) -> String:
var destination = action.split(" ", false)[0]
if current_locale.exits.keys().has(destination):
var change_response = change_room(current_locale.exits[destination])
return PoolStringArray(["You go %s." % destination, change_response]).join("\n")
else:
return "That is not a valid place to go!"
#DKM TEMP: do an examination dictionary lookup here?
func examine(action: String) -> String:
return action.to_upper() + " looks about how you'd expect. [Dictionary lookup forthcoming]"
#DKM TEMP: dialog entry needed -- temp
func talk(action: String) -> String:
var target = action.split("to ", false)[0].to_upper()
return target + " has little to say! [Dialog forthcoming]"
#Helper:
func change_room(new_room: Locale) -> String:
current_locale = new_room
current_opt1.text = new_room.option1
current_opt2.text = new_room.option2
current_opt3.text = new_room.option3
var exit_string = PoolStringArray(new_room.exits.keys()).join(" ")
var strings = PoolStringArray([
"You are now in: " + new_room.locale_name + ". " +
new_room.locale_description,
"Exits: " + exit_string
]).join("\n")
return strings;

View File

@ -0,0 +1,80 @@
#GAME:
# Controls output space, loading descriptions and options for each locale and
# appending to the history array.
extends Control
onready var history_source = get_node("/root/History").historyScreensSingleton
#Abstract class we instance when wanted in game as child of HistoryReference
const TextOutput = preload("res://UserInterface/Response.tscn")
const InputResponse = preload("res://UserInterface/InputResponse.tscn")
onready var command_processor = $CommandProcessor
onready var current_text = $Background/MarginContainer/Rows/GameInfo/CurrentText
onready var history_rows = $Background/MarginContainer/Rows/GameInfo/HistoryRows
onready var history_pager = $Background/MarginContainer/Rows/ItemList/But_History_Page
onready var locale_manager = $LocaleManager
onready var option_one = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option1
onready var option_two= $Background/MarginContainer/Rows/InputArea/VBoxContainer/option2
onready var option_three = $Background/MarginContainer/Rows/InputArea/VBoxContainer/option3
func _ready() -> void:
history_pager.hide()
history_rows.hide()
current_text.show()
option_one.show()
option_two.show()
option_three.show()
var opening_text = "The game has begun! You can select from the available options below. "
#create_response("The game has begun! You can select from the available options below.")
var starting_locale_response = command_processor.initialize(locale_manager.get_child(0))
create_response(opening_text + " " + starting_locale_response)
#Below temporarily takes user selection and appends it to responses; adding new instances
# of our input row with an input and response pair for each
func handleUserInput(user_choice: String) -> void:
var input_response = InputResponse.instance()
var inputText = "User selected: " + user_choice
var response = command_processor.process_command(user_choice)
input_response.set_text(inputText, response)
add_response_to_game(input_response)
#Handles input text
func create_response(response_text: String):
var response = TextOutput.instance()
response.text = response_text
add_response_to_game(response)
#Copies the response output to add to both current game output, and the
# history array.
func add_response_to_game(response: Control):
var response_history = response.duplicate()
#DKM TEMP: stopped here, trying to add page number to history text
#var history_page_number = HISTORY_SOURCE.output_history_array.size() + 1
#var history_string = "Page " + str(history_page_number) + "; "
if(history_source.output_history_array != null):
history_source.output_history_array.append(response_history)
if(current_text.get_child_count() > 0):
current_text.remove_child(current_text.get_child(0))
current_text.add_child(response)
func _on_option1_button_down() -> void:
var option1 = get_node("Background/MarginContainer/Rows/InputArea/VBoxContainer/option1")
handleUserInput(option1.get_text())
func _on_option2_button_down() -> void:
var option2 = get_node("Background/MarginContainer/Rows/InputArea/VBoxContainer/option2")
handleUserInput(option2.get_text())
func _on_option3_button_down() -> void:
var option3 = get_node("Background/MarginContainer/Rows/InputArea/VBoxContainer/option3")
handleUserInput(option3.get_text())

View File

@ -0,0 +1,222 @@
[gd_scene load_steps=15 format=2]
[ext_resource path="res://UserInterface/But_ChangeScene.tscn" type="PackedScene" id=1]
[ext_resource path="res://gamePlay/Game.gd" type="Script" id=2]
[ext_resource path="res://assets/ui_controlNode_dark_theme.tres" type="Theme" id=3]
[ext_resource path="res://gamePlay/CommandProcessor.gd" type="Script" id=4]
[ext_resource path="res://userInterface/Locale.tscn" type="PackedScene" id=5]
[ext_resource path="res://gamePlay/LocaleManager.gd" type="Script" id=6]
[ext_resource path="res://userInterface/But_History.gd" type="Script" id=7]
[ext_resource path="res://userInterface/But_History_Page.gd" type="Script" id=8]
[ext_resource path="res://_toArchive/ui_theme.tres" type="Theme" id=9]
[ext_resource path="res://_toArchive/ui_gameplay_theme.tres" type="Theme" id=10]
[ext_resource path="res://assets/liberation_serif_30pt.tres" type="DynamicFont" id=11]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.117647, 0.117647, 0.117647, 1 )
[sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 0.243137, 0.235294, 0.235294, 1 )
[sub_resource type="StyleBoxFlat" id=3]
bg_color = Color( 0.286275, 0.286275, 0.286275, 1 )
[node name="Game" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 3 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CommandProcessor" type="Node" parent="."]
script = ExtResource( 4 )
[node name="LocaleManager" type="Node" parent="."]
script = ExtResource( 6 )
[node name="Loc_Boat" parent="LocaleManager" instance=ExtResource( 5 )]
margin_left = 41.38
margin_top = -513.913
margin_right = 291.381
margin_bottom = -313.913
locale_name = "the boat"
locale_description = "You have been shipwrecked."
option1 = "Go: east off the boat"
option2 = "Examine: this boat"
option3 = "Wait: a while"
[node name="Loc_Shore" parent="LocaleManager" instance=ExtResource( 5 )]
margin_left = 509.38
margin_top = -512.913
margin_right = 759.381
margin_bottom = -312.913
locale_name = "the beach outside the wrecked ship"
locale_description = "You are standing on a white sand beach beside the crashing waves. You can go west, back onto the boat, or go north into the woods."
option1 = "Go: west to boat"
option2 = "Go: north to woods"
option3 = "Talk: to yourself"
[node name="Loc_WoodsA1" parent="LocaleManager" instance=ExtResource( 5 )]
margin_left = 510.439
margin_top = -806.384
margin_right = 760.44
margin_bottom = -606.384
locale_name = "the island woods"
option1 = "Go: south back to the beach"
option2 = "Go: north deeper in"
[node name="Loc_WoodsA2" parent="LocaleManager" instance=ExtResource( 5 )]
margin_left = 509.439
margin_top = -1083.38
margin_right = 759.44
margin_bottom = -883.384
locale_name = "deeper into the woods"
locale_description = "The woods are very thick. You feel like someone -- or something, may be watching you."
option1 = "Go: south back in the direction of the beach"
option2 = "Go: east into the thicket"
[node name="Loc_WoodsA3" parent="LocaleManager" instance=ExtResource( 5 )]
margin_left = 882.439
margin_top = -1084.38
margin_right = 1132.44
margin_bottom = -884.38
locale_name = "a clearing"
option1 = "Go: north after the creature"
option2 = "Go: west back into the thicket"
option3 = "Listen: to the sounds"
[node name="Loc_WoodsA4" parent="LocaleManager" instance=ExtResource( 5 )]
margin_left = 878.439
margin_top = -1361.38
margin_right = 1128.44
margin_bottom = -1161.38
locale_name = "a cliff top"
option1 = "Go: south back to the clearing "
[node name="Background" type="PanelContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
custom_styles/panel = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="Background"]
margin_right = 1024.0
margin_bottom = 600.0
custom_constants/margin_right = 20
custom_constants/margin_top = 10
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
[node name="Rows" type="VBoxContainer" parent="Background/MarginContainer"]
margin_left = 20.0
margin_top = 10.0
margin_right = 1004.0
margin_bottom = 580.0
custom_constants/separation = 10
[node name="ItemList" type="ItemList" parent="Background/MarginContainer/Rows"]
margin_right = 984.0
margin_bottom = 40.0
rect_min_size = Vector2( 0, 40 )
[node name="But_ChangeScene" parent="Background/MarginContainer/Rows/ItemList" instance=ExtResource( 1 )]
margin_right = 82.0
margin_bottom = 30.0
theme = ExtResource( 10 )
text = "Menu"
next_scene_path = "res://Screens/MenuScreen.tscn"
[node name="But_History" type="Button" parent="Background/MarginContainer/Rows/ItemList"]
margin_left = 96.0
margin_right = 167.0
margin_bottom = 33.0
theme = ExtResource( 10 )
text = "Toggle History"
script = ExtResource( 7 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="But_History_Page" type="Button" parent="Background/MarginContainer/Rows/ItemList"]
anchor_left = 1.0
anchor_right = 1.0
margin_left = -103.0
margin_bottom = 33.0
theme = ExtResource( 10 )
text = "Next Page"
script = ExtResource( 8 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GameInfo" type="PanelContainer" parent="Background/MarginContainer/Rows"]
margin_top = 50.0
margin_right = 984.0
margin_bottom = 440.0
size_flags_vertical = 3
theme = ExtResource( 9 )
custom_styles/panel = SubResource( 2 )
[node name="CurrentText" type="VBoxContainer" parent="Background/MarginContainer/Rows/GameInfo"]
margin_right = 984.0
margin_bottom = 390.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = ExtResource( 9 )
custom_constants/separation = 20
[node name="HistoryRows" type="VBoxContainer" parent="Background/MarginContainer/Rows/GameInfo"]
margin_right = 984.0
margin_bottom = 390.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 20
[node name="InputArea" type="PanelContainer" parent="Background/MarginContainer/Rows"]
margin_top = 450.0
margin_right = 984.0
margin_bottom = 570.0
rect_min_size = Vector2( 0, 120 )
custom_styles/panel = SubResource( 3 )
[node name="VBoxContainer" type="VBoxContainer" parent="Background/MarginContainer/Rows/InputArea"]
margin_right = 984.0
margin_bottom = 120.0
theme = ExtResource( 9 )
custom_constants/separation = 5
[node name="option1" type="Button" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
margin_right = 984.0
margin_bottom = 36.0
theme = ExtResource( 9 )
custom_fonts/font = ExtResource( 11 )
text = "Option 1"
align = 0
[node name="option2" type="Button" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
margin_top = 41.0
margin_right = 984.0
margin_bottom = 77.0
theme = ExtResource( 9 )
custom_fonts/font = ExtResource( 11 )
text = "Option 2"
align = 0
[node name="option3" type="Button" parent="Background/MarginContainer/Rows/InputArea/VBoxContainer"]
margin_top = 82.0
margin_right = 984.0
margin_bottom = 118.0
theme = ExtResource( 9 )
custom_fonts/font = ExtResource( 11 )
text = "Option 3"
align = 0
[connection signal="button_up" from="Background/MarginContainer/Rows/ItemList/But_History" to="Background/MarginContainer/Rows/ItemList/But_History" method="_on_But_History_button_up"]
[connection signal="button_up" from="Background/MarginContainer/Rows/ItemList/But_History_Page" to="Background/MarginContainer/Rows/ItemList/But_History_Page" method="_on_But_History_Page_button_up"]
[connection signal="button_down" from="Background/MarginContainer/Rows/InputArea/VBoxContainer/option1" to="." method="_on_option1_button_down"]
[connection signal="button_down" from="Background/MarginContainer/Rows/InputArea/VBoxContainer/option2" to="." method="_on_option2_button_down"]
[connection signal="button_down" from="Background/MarginContainer/Rows/InputArea/VBoxContainer/option3" to="." method="_on_option3_button_down"]

View File

@ -0,0 +1,17 @@
#LOCALE MANAGER:
# Temporary script holds connections between map items, using the two-way
# connect_exit script available on Location class to wire up map.
extends Node
#DKM TEMP: must load from toolset
func _ready() -> void:
$Loc_Boat.connect_exit("east", $Loc_Shore)
$Loc_Shore.connect_exit("north", $Loc_WoodsA1)
$Loc_WoodsA1.connect_exit("north", $Loc_WoodsA2)
$Loc_WoodsA2.connect_exit("east", $Loc_WoodsA3)
$Loc_WoodsA3.connect_exit("north", $Loc_WoodsA4)