.
This commit is contained in:
parent
0591c91ac0
commit
40eee3e533
29 changed files with 197 additions and 16 deletions
5
command.gd
Normal file
5
command.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extends Resource
|
||||
class_name Command
|
||||
|
||||
@export var name: String
|
||||
@export var modal_name: String
|
||||
1
command.gd.uid
Normal file
1
command.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cn8rc6jyllrf0
|
||||
14
commands/command_button.gd
Normal file
14
commands/command_button.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
extends Button
|
||||
|
||||
signal command_succcess(c: Command)
|
||||
|
||||
@export var command: Command
|
||||
|
||||
func _ready() -> void:
|
||||
sync()
|
||||
|
||||
func sync():
|
||||
text = command.name
|
||||
|
||||
func _on_pressed() -> void:
|
||||
command_succcess.emit(command)
|
||||
1
commands/command_button.gd.uid
Normal file
1
commands/command_button.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://m5qf37ordikh
|
||||
8
commands/command_button.tscn
Normal file
8
commands/command_button.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[gd_scene format=3 uid="uid://cno33rgilttxt"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dqb4a1igddv71" path="res://gui/bribe_button.tscn" id="1_j6j61"]
|
||||
[ext_resource type="Script" uid="uid://m5qf37ordikh" path="res://commands/command_button.gd" id="2_0fnf4"]
|
||||
|
||||
[node name="CommandButton" unique_id=1084248382 instance=ExtResource("1_j6j61")]
|
||||
script = ExtResource("2_0fnf4")
|
||||
command = null
|
||||
2
commands/move.gd
Normal file
2
commands/move.gd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
extends Command
|
||||
class_name MoveCommand
|
||||
1
commands/move.gd.uid
Normal file
1
commands/move.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://jxfw3ptlwg8d
|
||||
9
commands/move_command.tres
Normal file
9
commands/move_command.tres
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[gd_resource type="Resource" script_class="MoveCommand" format=3 uid="uid://u6lls6n0xw3n"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://jxfw3ptlwg8d" path="res://commands/move.gd" id="1_cox6k"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_cox6k")
|
||||
name = "Move"
|
||||
modal_name = "Moving!"
|
||||
metadata/_custom_type_script = "uid://jxfw3ptlwg8d"
|
||||
|
|
@ -7,3 +7,4 @@ class_name Currency
|
|||
@export var thumbnail: Texture2D
|
||||
@export var color: Color = Color.PINK
|
||||
@export var wants: Array[Production]
|
||||
@export var commands: Array[Command] = [preload("res://commands/move_command.tres")]
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ shader = ExtResource("1_tm326")
|
|||
[sub_resource type="CanvasTexture" id="CanvasTexture_wgite"]
|
||||
|
||||
[node name="MemberSprite" type="TextureRect" unique_id=283117283]
|
||||
z_index = 100
|
||||
material = SubResource("ShaderMaterial_tm326")
|
||||
mouse_default_cursor_shape = 2
|
||||
texture = SubResource("CanvasTexture_wgite")
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
[ext_resource type="Script" uid="uid://dddyxbkq0ienn" path="res://currency/production.gd" id="1_35xhy"]
|
||||
[ext_resource type="Script" uid="uid://hcvynq5fjypj" path="res://currency/sentient_currency.gd" id="1_kipvp"]
|
||||
[ext_resource type="Script" uid="uid://cn8rc6jyllrf0" path="res://command.gd" id="1_uh6l7"]
|
||||
[ext_resource type="Resource" uid="uid://u6lls6n0xw3n" path="res://commands/move_command.tres" id="2_7lva1"]
|
||||
[ext_resource type="Resource" uid="uid://boshkhnywnk27" path="res://currency/production/human_production_shared_1.tres" id="2_jkjll"]
|
||||
[ext_resource type="Resource" uid="uid://mgb7y1r3eapq" path="res://currency/production/human_production_shared_2.tres" id="3_kfqfp"]
|
||||
[ext_resource type="Resource" uid="uid://b5qok0rcalr" path="res://currency/sentient/cow.tres" id="5_uddvy"]
|
||||
|
|
|
|||
|
|
@ -83,7 +83,9 @@ func simulate():
|
|||
produce(o)
|
||||
production_log.emit(null, o)
|
||||
if e.timeline != null:
|
||||
Dialogic.start(e.timeline)
|
||||
GameState.add_letter.emit(e.into_letter())
|
||||
if randf() < 0.01:
|
||||
LetterGeneration.try_generate_offer()
|
||||
|
||||
|
||||
func get_all_currencies_in(dir: StringName):
|
||||
|
|
|
|||
10
event.gd
10
event.gd
|
|
@ -9,8 +9,10 @@ enum EventNature {
|
|||
Random,
|
||||
Certain,
|
||||
}
|
||||
@export var probability: float = 0.005
|
||||
@export var probability: float = 0.01
|
||||
@export var nature: EventNature = EventNature.Random
|
||||
@export var email_source: Currency = preload("res://currency/sentient/town_crier.tres")
|
||||
@export var email_subject: String = "Something is amok!"
|
||||
|
||||
func requirements_satisfied() -> bool:
|
||||
for requirement in requirements:
|
||||
|
|
@ -28,3 +30,9 @@ func outcome() -> Array[Production]:
|
|||
stuff.append_array(extra_mods)
|
||||
return stuff
|
||||
|
||||
func into_letter() -> EventLetter:
|
||||
var el := EventLetter.new()
|
||||
el.source = email_source
|
||||
el.subject_field = email_subject
|
||||
el.timeline = timeline
|
||||
return el
|
||||
|
|
|
|||
11
game.tscn
11
game.tscn
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
[ext_resource type="PackedScene" uid="uid://bdk1r2u8clllr" path="res://map.tscn" id="1_e2o6t"]
|
||||
[ext_resource type="PackedScene" uid="uid://d06w1wtct0mfs" path="res://test/test_economy.tscn" id="2_feb5d"]
|
||||
[ext_resource type="PackedScene" uid="uid://coebykrbnhlif" path="res://currency/members/MemberSprite.tscn" id="3_7jktm"]
|
||||
[ext_resource type="Resource" uid="uid://dn0c1pfq04obw" path="res://currency/sentient/farmer.tres" id="4_ryrav"]
|
||||
[ext_resource type="Resource" uid="uid://b7lxfjhx4qhts" path="res://allegiance/good.tres" id="5_eow3j"]
|
||||
|
||||
[node name="Game" type="Node2D" unique_id=1791439508]
|
||||
|
||||
|
|
@ -10,3 +13,11 @@
|
|||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1213874033]
|
||||
|
||||
[node name="TestEconomy" parent="CanvasLayer" unique_id=629898212 instance=ExtResource("2_feb5d")]
|
||||
|
||||
[node name="MemberSprite" parent="." unique_id=283117283 instance=ExtResource("3_7jktm")]
|
||||
offset_left = 294.0
|
||||
offset_top = 1177.0
|
||||
offset_right = 345.0
|
||||
offset_bottom = 1219.0
|
||||
currency = ExtResource("4_ryrav")
|
||||
allegiance = ExtResource("5_eow3j")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
[ext_resource type="Script" uid="uid://olr6663hny8n" path="res://bribe_button.gd" id="1_2abdb"]
|
||||
|
||||
[node name="BribeButton" type="Button" unique_id=1084248382]
|
||||
custom_minimum_size = Vector2(0, 50)
|
||||
text = "< num > of < currency >"
|
||||
script = ExtResource("1_2abdb")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,12 @@ var currency: Currency = null
|
|||
func _ready() -> void:
|
||||
UserContext.currency_inspect.connect(currency_inspect)
|
||||
UserContext.member_inspect.connect(member_inspect)
|
||||
UserContext.modal_command_change.connect(modal_command_change)
|
||||
update()
|
||||
|
||||
func modal_command_change(_c: Command):
|
||||
visible = false
|
||||
|
||||
func member_inspect(_m: CurrencyMemberSprite):
|
||||
visible = false
|
||||
|
||||
|
|
|
|||
8
gui/inbox_event_only.tscn
Normal file
8
gui/inbox_event_only.tscn
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[gd_scene format=3 uid="uid://choixlqgx0jo7"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://da2ldx7una0a2" path="res://gui/inbox_message_subject.tscn" id="1_nc3yv"]
|
||||
|
||||
[node name="InboxEvent" unique_id=1590519653 instance=ExtResource("1_nc3yv")]
|
||||
|
||||
[node name="ReplyButton" parent="MarginContainer/HBoxContainer" parent_id_path=PackedInt32Array(1418860833) index="2" unique_id=803741826]
|
||||
visible = false
|
||||
|
|
@ -7,8 +7,9 @@ func _ready() -> void:
|
|||
%Source.text = letter.source.name
|
||||
%Subject.text = letter.subject_field
|
||||
|
||||
func on_remove_letter(_l: Letter):
|
||||
queue_free()
|
||||
func on_remove_letter(l: Letter):
|
||||
if letter == l:
|
||||
queue_free()
|
||||
|
||||
func _on_pressed() -> void:
|
||||
letter.start()
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@ func _ready() -> void:
|
|||
visible = false
|
||||
|
||||
func add_letter(l: Letter):
|
||||
var ldis := preload("res://gui/inbox_message_subject.tscn").instantiate()
|
||||
var ldis: Button
|
||||
if l is EventLetter:
|
||||
ldis = preload("res://gui/inbox_event_only.tscn").instantiate()
|
||||
else:
|
||||
ldis = preload("res://gui/inbox_message_subject.tscn").instantiate()
|
||||
ldis.letter = l
|
||||
%Letters.add_child(ldis)
|
||||
|
||||
|
||||
func open():
|
||||
visible = true
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ extends VBoxContainer
|
|||
|
||||
func _ready() -> void:
|
||||
Economy.productions_update.connect(sync)
|
||||
UserContext.modal_command_change.connect(modal_command_change)
|
||||
|
||||
func modal_command_change(c: Command):
|
||||
visible = c == null
|
||||
|
||||
func sync(productions: Array[Production]):
|
||||
for child in get_children():
|
||||
|
|
|
|||
10
letters/event_letter.gd
Normal file
10
letters/event_letter.gd
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
extends Letter
|
||||
class_name EventLetter
|
||||
|
||||
func start():
|
||||
Dialogic.start(timeline)
|
||||
await Dialogic.timeline_ended
|
||||
GameState.remove_letter.emit(self)
|
||||
|
||||
func reply():
|
||||
push_error("reply Not implemented!")
|
||||
1
letters/event_letter.gd.uid
Normal file
1
letters/event_letter.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d30k84i53crwu
|
||||
|
|
@ -5,8 +5,12 @@ extends "res://gui/currency_inspector_panel.gd"
|
|||
func _ready() -> void:
|
||||
UserContext.currency_inspect.connect(currency_inspect)
|
||||
UserContext.member_inspect.connect(member_inspect)
|
||||
UserContext.modal_command_change.connect(modal_command_change)
|
||||
update()
|
||||
|
||||
func modal_command_change(_c: Command):
|
||||
visible = false
|
||||
|
||||
func member_inspect(m: CurrencyMemberSprite):
|
||||
if member != null:
|
||||
member.tree_exiting.disconnect(member_left)
|
||||
|
|
@ -22,6 +26,9 @@ func member_left():
|
|||
func clear_bribes():
|
||||
for child in %BribesList.get_children():
|
||||
child.queue_free()
|
||||
func clear_commands():
|
||||
for child in %CommandsList.get_children():
|
||||
child.queue_free()
|
||||
|
||||
func bribe_success():
|
||||
member.allegiance = preload("res://allegiance/good.tres")
|
||||
|
|
@ -35,6 +42,13 @@ func load_bribes():
|
|||
btn.bribe_succees.connect(bribe_success)
|
||||
%BribesList.add_child(btn)
|
||||
|
||||
func load_commands():
|
||||
for p in member.currency.commands:
|
||||
var btn := preload("res://commands/command_button.tscn").instantiate()
|
||||
btn.command = p
|
||||
btn.command_succcess.connect(UserContext.modal)
|
||||
%CommandsList.add_child(btn)
|
||||
|
||||
|
||||
func currency_inspect(_c: Currency):
|
||||
visible = false
|
||||
|
|
@ -47,8 +61,13 @@ func update():
|
|||
%CurrencyMemberSprite.allegiance = member.allegiance
|
||||
%CurrencyMemberSprite.sync()
|
||||
clear_bribes()
|
||||
clear_commands()
|
||||
%Bribes.visible = false
|
||||
%Commands.visible = true
|
||||
if member.allegiance != preload("res://allegiance/good.tres"):
|
||||
load_bribes()
|
||||
%Bribes.visible = true
|
||||
%Commands.visible = false
|
||||
else:
|
||||
load_commands()
|
||||
|
||||
|
|
|
|||
|
|
@ -39,3 +39,12 @@ text = "Bribe with"
|
|||
[node name="BribesList" type="VBoxContainer" parent="VBoxContainer" parent_id_path=PackedInt32Array(362599487) index="10" unique_id=476203914]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Commands" type="Label" parent="VBoxContainer" parent_id_path=PackedInt32Array(362599487) index="11" unique_id=87746800]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Command"
|
||||
|
||||
[node name="CommandsList" type="VBoxContainer" parent="VBoxContainer" parent_id_path=PackedInt32Array(362599487) index="12" unique_id=73835062]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
|
|
|||
12
test/command_modal.gd
Normal file
12
test/command_modal.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
extends Label
|
||||
|
||||
func _ready() -> void:
|
||||
UserContext.modal_command_change.connect(modal_command_change)
|
||||
modal_command_change(null)
|
||||
|
||||
func modal_command_change(c: Command):
|
||||
if c == null:
|
||||
visible = false
|
||||
return
|
||||
visible = true
|
||||
text = c.modal_name + " " + UserContext.selected_member.currency.name
|
||||
1
test/command_modal.gd.uid
Normal file
1
test/command_modal.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cvwxv4hfw4u0o
|
||||
|
|
@ -6,11 +6,9 @@ func _on_get_cow_pressed() -> void:
|
|||
p.amount += 1
|
||||
|
||||
|
||||
|
||||
func _on_run_simulate_pressed() -> void:
|
||||
Economy.simulate()
|
||||
|
||||
|
||||
func _on_open_inbox_pressed() -> void:
|
||||
UserContext.open_inbox.emit()
|
||||
LetterGeneration.try_generate_offer()
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://coebykrbnhlif" path="res://currency/members/MemberSprite.tscn" id="6_vua3v"]
|
||||
[ext_resource type="Resource" uid="uid://ihsvxienxbeu" path="res://currency/sentient/knight.tres" id="7_s0mui"]
|
||||
[ext_resource type="Resource" uid="uid://dfbgxc6nlcjct" path="res://allegiance/bad.tres" id="8_i7808"]
|
||||
[ext_resource type="Script" uid="uid://cvwxv4hfw4u0o" path="res://test/command_modal.gd" id="10_ccsa3"]
|
||||
|
||||
[node name="TestEconomy" type="Control" unique_id=629898212]
|
||||
layout_mode = 3
|
||||
|
|
@ -17,6 +18,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1_s48qe")
|
||||
|
||||
[node name="ScrollContainer2" type="ScrollContainer" parent="." unique_id=872959271]
|
||||
|
|
@ -69,18 +71,15 @@ text = "Get cow"
|
|||
layout_mode = 2
|
||||
text = "Run simulate"
|
||||
|
||||
[node name="OpenInbox" type="Button" parent="Control/VBoxContainer" unique_id=1148713984]
|
||||
layout_mode = 2
|
||||
text = "OpenInbox"
|
||||
|
||||
[node name="CurrencyInspectorPanel" parent="." unique_id=169191981 instance=ExtResource("4_7ya5o")]
|
||||
layout_mode = 1
|
||||
offset_left = -467.0
|
||||
offset_right = 33.0
|
||||
|
||||
[node name="MemberInspectorPanel" parent="." unique_id=1641024074 instance=ExtResource("5_i7808")]
|
||||
custom_minimum_size = Vector2(0, 100)
|
||||
layout_mode = 1
|
||||
offset_left = -189.0
|
||||
offset_right = -189.0
|
||||
offset_left = -468.0
|
||||
offset_right = 32.0
|
||||
|
||||
[node name="InboxPanel" parent="." unique_id=534578339 instance=ExtResource("5_n4oyp")]
|
||||
layout_mode = 1
|
||||
|
|
@ -99,8 +98,37 @@ offset_bottom = 406.0
|
|||
currency = ExtResource("7_s0mui")
|
||||
allegiance = ExtResource("8_i7808")
|
||||
|
||||
[node name="CommandModal" type="Label" parent="." unique_id=562980582]
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -63.0
|
||||
offset_top = 19.0
|
||||
offset_right = 64.0
|
||||
offset_bottom = 42.0
|
||||
grow_horizontal = 2
|
||||
theme_override_font_sizes/font_size = 52
|
||||
text = "<Commanding!>"
|
||||
script = ExtResource("10_ccsa3")
|
||||
|
||||
[node name="OpenInbox" type="Button" parent="." unique_id=1148713984]
|
||||
layout_mode = 1
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -114.0
|
||||
offset_top = -64.0
|
||||
offset_right = -20.0
|
||||
offset_bottom = -33.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
text = "OpenInbox"
|
||||
|
||||
[connection signal="pressed" from="Control/VBoxContainer/GetCow" to="." method="_on_get_cow_pressed"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer/RunSimulate" to="." method="_on_run_simulate_pressed"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer/OpenInbox" to="." method="_on_open_inbox_pressed"]
|
||||
[connection signal="pressed" from="OpenInbox" to="." method="_on_open_inbox_pressed"]
|
||||
|
||||
[editable path="MemberSprite"]
|
||||
|
|
|
|||
|
|
@ -13,14 +13,30 @@ var selected_member: CurrencyMemberSprite = null
|
|||
var focused_members: Array[CurrencyMemberSprite] = []
|
||||
signal selected_member_change(current: CurrencyMemberSprite)
|
||||
|
||||
var modal_command: Command
|
||||
signal modal_command_change(c: Command)
|
||||
|
||||
func modal(c: Command):
|
||||
modal_command = c
|
||||
modal_command_change.emit(c)
|
||||
|
||||
func select_focused_member():
|
||||
var candidate := focused_member()
|
||||
if candidate == null:
|
||||
return
|
||||
if selected_member != null:
|
||||
unselect_member()
|
||||
selected_member = candidate
|
||||
selected_member.tree_exiting.connect(unselect_member)
|
||||
selected_member_change.emit(selected_member)
|
||||
UserContext.member_inspect.emit(selected_member)
|
||||
|
||||
func unselect_member():
|
||||
if selected_member == null:
|
||||
return
|
||||
selected_member.tree_exiting.disconnect(unselect_member)
|
||||
selected_member = null
|
||||
|
||||
func focused_member() -> CurrencyMemberSprite:
|
||||
if focused_members.size() == 0:
|
||||
return null
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue