29 lines
929 B
GDScript
29 lines
929 B
GDScript
extends Area2D
|
|
|
|
@export var text : String
|
|
|
|
@onready var Dialogue : Control = $Dialogue
|
|
|
|
@export var ContractSpawnPositions : Array[Node2D]
|
|
|
|
@export var ContractScene : PackedScene
|
|
|
|
var PossibleContracts
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
Dialogue.DialogueLabel.text = text
|
|
PossibleContracts = get_tree().get_nodes_in_group("delivery spot")
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
for i in range(0, ContractSpawnPositions.size()):
|
|
if ContractSpawnPositions[i].get_child_count() == 0:
|
|
var newContract = ContractScene.instantiate()
|
|
newContract.Destination = PossibleContracts.pick_random()
|
|
newContract.Money = (int(newContract.Destination.global_position.distance_to(global_position))/100)*10*newContract.Destination.CashMultiplier
|
|
ContractSpawnPositions[i].add_child(newContract)
|
|
|