Almost working animations for picking up items

This commit is contained in:
root 2020-10-19 22:44:21 +02:00
parent 2efdaf8aee
commit a3743007c2
4 changed files with 27 additions and 3 deletions

View File

@ -40,6 +40,7 @@ func InteractWithCell():
if plant_cell == 1:
Global.AddInventoryItem(3, 1)
plants_map.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), 4)
AnimationOnInteraction(1)
# plants_map.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), 4)
func _interaction_process():
@ -49,6 +50,16 @@ func _interaction_process():
func _input(event):
pass
func AnimationOnInteraction(Item):
print(Item, "Animation")
var img = load("res://pictures/inventory_iconpictures/food_items/herbs/saffron.png")
$Sprite.draw_texture(img, Vector2(self.position.x/cell_size.x, self.position.y/cell_size.y))
#This works, but changes the sprite..
#$Sprite.set_texture(img)
#img.create(128, 128, false, "res://pictures/inventory_iconpictures/food_items/herbs/saffron.png")
pass
func _ready():
Global.player_inventory_items = Database.GetInventoryItems()

View File

@ -7,15 +7,25 @@ func _ready():
match Global.player_inventory_items[self.id].item_id:
0:
pass
# Id 0-40 - Map foraging - 'Random' spawning
1:
$TextureRect.texture = load("res://pictures/inventory_iconpictures/miscellaneous/magic_formulae.png")
2:
$TextureRect.texture = load("res://pictures/inventory_iconpictures/tools_and_weapons/tools/ploeg.png")
3:
$TextureRect.texture = load("res://pictures/inventory_iconpictures/food_items/herbs/saffron.png")
# Id 41-80 - Tools - Every tool map interaction NOT weapons
41:
$TextureRect.texture = load("res://pictures/inventory_iconpictures/tools_and_weapons/tools/ploeg.png")
# Id 81-160 - Armour/Clothing
# Id 161-240 - Farming and planting
if Global.player_inventory_items[self.id].amount > 0:
var amountlbl = Label.new()
amountlbl.set_position(Vector2(self.position.x+102, self.position.y+102))
amountlbl.set_position(Vector2(self.position.x+105, self.position.y+105))
amountlbl.text = str(Global.player_inventory_items[self.id].amount)
add_child(amountlbl)

View File

@ -0,0 +1,3 @@
[gd_scene format=2]
[node name="Node2D" type="Node2D"]

View File

@ -8,7 +8,7 @@ tool
extends EditorPlugin
func _enter_tree():
pass
pass
func _exit_tree():
pass
pass