diff --git a/project.godot b/project.godot index 5dc5a56..375b483 100644 --- a/project.godot +++ b/project.godot @@ -24,6 +24,10 @@ window/stretch/aspect="expand" player="" +[gui] + +theme/custom="res://etc/default_theme.tres" + [input] up={ diff --git a/scenes/gui.gd b/scenes/gui.gd new file mode 100644 index 0000000..6488b7d --- /dev/null +++ b/scenes/gui.gd @@ -0,0 +1,14 @@ +extends CanvasLayer + +@export var Player : Node2D + +@onready var MoneyCounter = $MoneyCounter + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + MoneyCounter.text = "$" + str(Player.Money) diff --git a/scenes/gui.tscn b/scenes/gui.tscn new file mode 100644 index 0000000..767782b --- /dev/null +++ b/scenes/gui.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=3 format=3 uid="uid://cpnkpl8rmrt00"] + +[ext_resource type="Script" path="res://scenes/gui.gd" id="1_42w6u"] +[ext_resource type="Theme" uid="uid://d0ir0t347wqv7" path="res://etc/default_theme.tres" id="2_54lln"] + +[node name="Gui" type="CanvasLayer"] +script = ExtResource("1_42w6u") + +[node name="MoneyCounter" type="Label" parent="."] +offset_right = 40.0 +offset_bottom = 23.0 +theme = ExtResource("2_54lln") +text = "$100" diff --git a/scenes/world.tscn b/scenes/world.tscn index ea3c265..c9e2c11 100644 --- a/scenes/world.tscn +++ b/scenes/world.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=4 uid="uid://72e8cy3uuy8m"] +[gd_scene load_steps=10 format=4 uid="uid://72e8cy3uuy8m"] [ext_resource type="Texture2D" uid="uid://tqbjd6io6qfa" path="res://sprites/ground.jpg" id="1_deahv"] [ext_resource type="PackedScene" uid="uid://bjy3gfpx6h1w5" path="res://scenes/player.tscn" id="2_jm6jq"] @@ -6,6 +6,7 @@ [ext_resource type="PackedScene" uid="uid://cpxco37ip15ev" path="res://scenes/contract_giver.tscn" id="4_0h7cx"] [ext_resource type="PackedScene" uid="uid://cn41xqc3lwaxy" path="res://scenes/contract.tscn" id="5_q4ykf"] [ext_resource type="PackedScene" uid="uid://bm1ptkidbwi36" path="res://scenes/delivery_spot.tscn" id="6_i8g18"] +[ext_resource type="PackedScene" uid="uid://cpnkpl8rmrt00" path="res://scenes/gui.tscn" id="7_fn24d"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_knvup"] texture = ExtResource("3_3e26l") @@ -41,6 +42,7 @@ position = Vector2(779, -1420) [node name="Contract" parent="ContractGiver" node_paths=PackedStringArray("Destination") instance=ExtResource("5_q4ykf")] position = Vector2(6, 779) Destination = NodePath("../../DeliverySpot") +Money = 150 [node name="Contract2" parent="ContractGiver" node_paths=PackedStringArray("Destination") instance=ExtResource("5_q4ykf")] position = Vector2(501, 767) @@ -53,3 +55,6 @@ Address = "1234 Fuck You Lane" [node name="DeliverySpot2" parent="." instance=ExtResource("6_i8g18")] position = Vector2(-1444, -147) Address = "1235 Fuck You Lane" + +[node name="Gui" parent="." node_paths=PackedStringArray("Player") instance=ExtResource("7_fn24d")] +Player = NodePath("../Player") diff --git a/scripts/contract.gd b/scripts/contract.gd index 80c2986..398285d 100644 --- a/scripts/contract.gd +++ b/scripts/contract.gd @@ -7,11 +7,11 @@ extends Area2D var Player : Node2D - +@export var Money : int = 100 # Called when the node enters the scene tree for the first time. func _ready() -> void: - DestinationDialogue.DialogueLabel.text = Destination.Address + DestinationDialogue.DialogueLabel.text = Destination.Address + " - $" + str(Money) Player = get_tree().get_first_node_in_group("player") @@ -19,4 +19,5 @@ func _ready() -> void: func _process(delta: float) -> void: if Input.is_action_pressed("interact") and InteractibleManager.selected and not Player.ActiveContract: Player.ActiveContract = Destination + Destination.WaitingCash = Money queue_free() diff --git a/scripts/delivery_spot.gd b/scripts/delivery_spot.gd index f562553..82b589a 100644 --- a/scripts/delivery_spot.gd +++ b/scripts/delivery_spot.gd @@ -7,6 +7,8 @@ extends Area2D var Player : Node2D +var WaitingCash : int = 0 + # Called when the node enters the scene tree for the first time. func _ready() -> void: Dialogue.DialogueLabel.text = Address @@ -17,3 +19,4 @@ func _ready() -> void: func _process(delta: float) -> void: if Input.is_action_pressed("interact") and InteractibleManager.selected and Player.ActiveContract == self: Player.ActiveContract = null + Player.Money += WaitingCash diff --git a/scripts/player.gd b/scripts/player.gd index 0c054d6..c02786e 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -8,6 +8,8 @@ var SpriteTurningSpeed = 5 var ActiveContract : Node2D +var Money : int = 0 + @onready var PackageSprite = $PackageSprite # Called when the node enters the scene tree for the first time.