Merge branch 'master' of https://git.sjkillen.ca/sjkillen/everything_has_a_price_jam
This commit is contained in:
commit
7e21fa7c5c
8 changed files with 102 additions and 22 deletions
|
|
@ -8,7 +8,7 @@ func _ready() -> void:
|
|||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
var mouse: = get_viewport().get_mouse_position()
|
||||
var size: = get_viewport().get_visible_rect().size
|
||||
if (mouse.x < (0.10*size.x)):
|
||||
|
|
@ -24,14 +24,18 @@ func _process(delta: float) -> void:
|
|||
func _input(event):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
|
||||
|
||||
zoom.x +=1
|
||||
zoom.y +=1
|
||||
|
||||
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
|
||||
|
||||
zoom.x -=1
|
||||
zoom.y -=1
|
||||
if zoom.x - 1 < 1:
|
||||
zoom.x = 1
|
||||
else:
|
||||
zoom.x -= 1
|
||||
if zoom.y - 1 < 1:
|
||||
zoom.y = 1
|
||||
else:
|
||||
zoom.y -= 1
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
37
economy.gd
37
economy.gd
|
|
@ -6,6 +6,19 @@ signal production_log(producer: Currency, p: Production)
|
|||
@export var currencies: Array[Production]
|
||||
@export var members: Array
|
||||
|
||||
|
||||
@onready var events: Array[Event] = load_events()
|
||||
|
||||
|
||||
func load_events() -> Array[Event]:
|
||||
var dir := "res://random events"
|
||||
var es: Array[Event] = []
|
||||
for event_name in ResourceLoader.list_directory(dir):
|
||||
var event: Event = load(dir + "/" + event_name)
|
||||
es.push_back(event)
|
||||
return es
|
||||
|
||||
|
||||
func get_currency(c: Currency) -> Production:
|
||||
sync_currency.call_deferred()
|
||||
for p in currencies:
|
||||
|
|
@ -18,6 +31,8 @@ func get_currency(c: Currency) -> Production:
|
|||
return p
|
||||
|
||||
func do_bribing(p: Production) -> bool:
|
||||
if get_currency_amount(p.currency) < p.amount:
|
||||
return false
|
||||
produce(negate_production(p))
|
||||
return true
|
||||
|
||||
|
|
@ -50,7 +65,7 @@ func produce(production: Production):
|
|||
var c := get_currency(production.currency)
|
||||
c.amount += production.amount
|
||||
|
||||
func simulate():
|
||||
func update_currencies():
|
||||
productions_update.emit.call_deferred(currencies)
|
||||
for c in currencies:
|
||||
for p in c.currency.production:
|
||||
|
|
@ -58,7 +73,18 @@ func simulate():
|
|||
pp.currency = p.currency
|
||||
pp.amount = c.amount * p.amount
|
||||
produce(pp)
|
||||
|
||||
|
||||
func simulate():
|
||||
update_currencies()
|
||||
for e in events:
|
||||
if e.requirements_satisfied() and e.will_happen():
|
||||
var outcome := e.outcome()
|
||||
for o in outcome:
|
||||
produce(o)
|
||||
production_log.emit(null, o)
|
||||
if e.timeline != null:
|
||||
Dialogic.start(e.timeline)
|
||||
|
||||
|
||||
func get_all_currencies_in(dir: StringName):
|
||||
var reses := ResourceLoader.list_directory(dir)
|
||||
|
|
@ -75,4 +101,11 @@ func get_all_inanimate_currencies() -> Array:
|
|||
return get_all_currencies_in("res://currency/inanimate")
|
||||
|
||||
func _ready() -> void:
|
||||
%SimulateTickTimer.start()
|
||||
update_currencies()
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if Dialogic.current_timeline != null:
|
||||
%SimulateTickTimer.start()
|
||||
return
|
||||
simulate()
|
||||
|
|
|
|||
|
|
@ -62,3 +62,8 @@ metadata/_custom_type_script = "uid://dddyxbkq0ienn"
|
|||
[node name="Economy" type="Node" unique_id=1950923383]
|
||||
script = ExtResource("1_csm0v")
|
||||
currencies = Array[ExtResource("2_tljx8")]([SubResource("Resource_g3220"), SubResource("Resource_bb1uu"), SubResource("Resource_vw3jp"), SubResource("Resource_xg8li"), SubResource("Resource_f6kxb"), SubResource("Resource_6u4g3"), SubResource("Resource_aqv3t"), SubResource("Resource_g2km3")])
|
||||
|
||||
[node name="SimulateTickTimer" type="Timer" parent="." unique_id=1726107261]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[connection signal="timeout" from="SimulateTickTimer" to="." method="_on_timer_timeout"]
|
||||
|
|
|
|||
24
event.gd
24
event.gd
|
|
@ -4,3 +4,27 @@ class_name Event
|
|||
@export var extra_mods: Array[Production]
|
||||
@export var timeline: DialogicTimeline
|
||||
@export var requirements: Array[Production]
|
||||
|
||||
enum EventNature {
|
||||
Random,
|
||||
Certain,
|
||||
}
|
||||
@export var probability: float = 0.005
|
||||
@export var nature: EventNature = EventNature.Random
|
||||
|
||||
func requirements_satisfied() -> bool:
|
||||
for requirement in requirements:
|
||||
if Economy.get_currency_amount(requirement.currency) < requirement.amount:
|
||||
return false
|
||||
return true
|
||||
|
||||
func will_happen() -> bool:
|
||||
if nature == EventNature.Certain:
|
||||
return true
|
||||
return randf() <= probability
|
||||
|
||||
func outcome() -> Array[Production]:
|
||||
var stuff: Array[Production] = [modified_resource]
|
||||
stuff.append_array(extra_mods)
|
||||
return stuff
|
||||
|
||||
|
|
|
|||
12
game.tscn
Normal file
12
game.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene format=3 uid="uid://dkui3dlb4vu1c"]
|
||||
|
||||
[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"]
|
||||
|
||||
[node name="Game" type="Node2D" unique_id=1791439508]
|
||||
|
||||
[node name="map" parent="." unique_id=575553336 instance=ExtResource("1_e2o6t")]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1213874033]
|
||||
|
||||
[node name="TestEconomy" parent="CanvasLayer" unique_id=629898212 instance=ExtResource("2_feb5d")]
|
||||
|
|
@ -3,15 +3,12 @@
|
|||
[ext_resource type="Script" uid="uid://bkptc7j6c1r7p" path="res://gui/currency_inspector_panel.gd" id="1_tj5vo"]
|
||||
[ext_resource type="Texture2D" uid="uid://bplvus0ytk2f8" path="res://thumbnails/beer.png" id="2_p4bd1"]
|
||||
|
||||
[node name="CurrencyInspectorPanel" type="Control" unique_id=169191981]
|
||||
custom_minimum_size = Vector2(0, 100)
|
||||
layout_mode = 3
|
||||
[node name="CurrencyInspectorPanel" type="Panel" unique_id=1489159816]
|
||||
custom_minimum_size = Vector2(500, 100)
|
||||
anchors_preset = 11
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -188.0
|
||||
offset_right = -188.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_tj5vo")
|
||||
|
|
@ -19,14 +16,10 @@ script = ExtResource("1_tj5vo")
|
|||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=362599487]
|
||||
custom_minimum_size = Vector2(400, 0)
|
||||
custom_maximum_size = Vector2(400, -1)
|
||||
layout_mode = 1
|
||||
anchors_preset = 5
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
offset_left = -253.0
|
||||
offset_right = 47.0
|
||||
offset_bottom = 149.0
|
||||
grow_horizontal = 2
|
||||
layout_mode = 0
|
||||
offset_left = 50.0
|
||||
offset_right = 450.0
|
||||
offset_bottom = 503.0
|
||||
|
||||
[node name="InspectedCurrency" type="Label" parent="VBoxContainer" unique_id=1206438498]
|
||||
unique_name_in_owner = true
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ config_version=5
|
|||
|
||||
[application]
|
||||
|
||||
run/main_scene="uid://d06w1wtct0mfs"
|
||||
run/main_scene="uid://dkui3dlb4vu1c"
|
||||
config/features=PackedStringArray("4.7")
|
||||
|
||||
[autoload]
|
||||
|
|
@ -136,5 +136,6 @@ dialogic_default_action={
|
|||
|
||||
[rendering]
|
||||
|
||||
textures/canvas_textures/default_texture_filter=0
|
||||
rendering_device/driver.windows="d3d12"
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
|
|
|
|||
|
|
@ -19,8 +19,13 @@ grow_horizontal = 2
|
|||
grow_vertical = 2
|
||||
script = ExtResource("1_s48qe")
|
||||
|
||||
[node name="ProductionChart" parent="." unique_id=1301678172 instance=ExtResource("2_jd86c")]
|
||||
[node name="ScrollContainer2" type="ScrollContainer" parent="." unique_id=872959271]
|
||||
layout_mode = 0
|
||||
offset_right = 432.0
|
||||
offset_bottom = 297.0
|
||||
|
||||
[node name="ProductionChart" parent="ScrollContainer2" unique_id=1301678172 instance=ExtResource("2_jd86c")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ScrollContainer" parent="." unique_id=587807919 instance=ExtResource("3_n4oyp")]
|
||||
layout_mode = 1
|
||||
|
|
@ -51,6 +56,7 @@ grow_horizontal = 0
|
|||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control" unique_id=74649172]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
|
@ -71,6 +77,7 @@ text = "OpenInbox"
|
|||
layout_mode = 1
|
||||
|
||||
[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
|
||||
|
|
@ -79,6 +86,7 @@ offset_right = -189.0
|
|||
layout_mode = 1
|
||||
|
||||
[node name="MemberSprite" parent="." unique_id=283117283 instance=ExtResource("6_vua3v")]
|
||||
visible = false
|
||||
instance_shader_parameters/border_color = Color(1, 0, 0, 1)
|
||||
instance_shader_parameters/border_width = 0.16
|
||||
instance_shader_parameters/fill_color = Color(1, 0.7529412, 0.79607844, 1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue