Added money
This commit is contained in:
parent
b4db421450
commit
800ea55d95
|
@ -24,6 +24,10 @@ window/stretch/aspect="expand"
|
|||
|
||||
player=""
|
||||
|
||||
[gui]
|
||||
|
||||
theme/custom="res://etc/default_theme.tres"
|
||||
|
||||
[input]
|
||||
|
||||
up={
|
||||
|
|
14
scenes/gui.gd
Normal file
14
scenes/gui.gd
Normal file
|
@ -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)
|
13
scenes/gui.tscn
Normal file
13
scenes/gui.tscn
Normal file
|
@ -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"
|
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue