1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 09:34:24 +00:00

Complete Gold entity

This commit is contained in:
Steffo 2024-04-14 04:39:45 +02:00
parent 3b7c49b8cf
commit f1c2c5233b
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 22 additions and 1 deletions

View file

@ -2,5 +2,18 @@ extends Node2D
class_name Gold
@export var value: int = 1
func _on_move(movement: Vector2) -> void:
position += movement
func _on_collected(tag: StringName) -> void:
var game = MainGame.get_ancestor(self)
# TODO: Perhaps use a dictionary in game to store multiple currencies?
match tag:
&"Gold":
game.gold_counter.increase(value)
queue_free()

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://uoxwjpmgg27a"]
[gd_scene load_steps=5 format=3 uid="uid://uoxwjpmgg27a"]
[ext_resource type="Script" path="res://entities/gold.gd" id="1_lbls1"]
[ext_resource type="PackedScene" uid="uid://bvrxvrjlo5130" path="res://behaviours/move_towards_mouse.tscn" id="2_lso1v"]
[ext_resource type="PackedScene" uid="uid://dj72yshd25ucx" path="res://behaviours/collectable.tscn" id="3_q0bno"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_1f58t"]
@ -13,5 +14,12 @@ scale = Vector2(12, 12)
texture = SubResource("PlaceholderTexture2D_1f58t")
[node name="MoveTowardsMouse" parent="." instance=ExtResource("2_lso1v")]
scale = Vector2(5, 5)
speed = 333.0
[node name="Collectable" parent="." instance=ExtResource("3_q0bno")]
scale = Vector2(0.87, 0.87)
tag = &"Gold"
[connection signal="move" from="MoveTowardsMouse" to="." method="_on_move"]
[connection signal="collected" from="Collectable" to="." method="_on_collected"]