@@ -15,30 +15,40 @@ class_name CommonGemCell
1515const SPRITE_SCALE: Vector2 = Vector2(0.5 , 0.5 )
1616const DROP_OFFSET: int = 128 # (the sprite is centered in the 128x128 container, and uses a 64,64 position)
1717var gem_color: Enums.GemColor
18+ var gem_dict: Enums.GemDict
1819# Declare and preload textures
19- var gem_textures : Dictionary = {
20+ const gem_textures_gems : Dictionary = {
2021 Enums.GemColor.WHITE: preload(" res://assets/gems/space/gem1.png" ),
2122 Enums.GemColor.RED: preload(" res://assets/gems/space/gem2.png" ),
2223 Enums.GemColor.YELLOW: preload(" res://assets/gems/space/gem3.png" ),
2324 Enums.GemColor.GREEN: preload(" res://assets/gems/space/gem4.png" ),
24- Enums.GemColor.BROWN : preload(" res://assets/gems/space/gem5.png" ),
25- Enums.GemColor.PURPLE : preload(" res://assets/gems/space/gem6.png" )
25+ Enums.GemColor.PURPLE : preload(" res://assets/gems/space/gem5.png" ),
26+ Enums.GemColor.BROWN : preload(" res://assets/gems/space/gem6.png" )
2627}
27- var gem_textures_food: Dictionary = {
28+ const gem_textures_food: Dictionary = {
2829 Enums.GemColor.WHITE: preload(" res://assets/gems/characters_0001.png" ),
2930 Enums.GemColor.RED: preload(" res://assets/gems/characters_0002.png" ),
3031 Enums.GemColor.YELLOW: preload(" res://assets/gems/characters_0003.png" ),
3132 Enums.GemColor.GREEN: preload(" res://assets/gems/characters_0005.png" ),
32- Enums.GemColor.BROWN : preload(" res://assets/gems/characters_0006 .png" ),
33- Enums.GemColor.PURPLE : preload(" res://assets/gems/characters_0007 .png" )
33+ Enums.GemColor.PURPLE : preload(" res://assets/gems/characters_0007 .png" ),
34+ Enums.GemColor.BROWN : preload(" res://assets/gems/characters_0006 .png" )
3435}
36+ var gem_textures: Dictionary = {}
3537
36- func initialize(colorIn: Enums.GemColor):
38+ func initialize(colorIn: Enums.GemColor, dictIn : Enums.GemDict ):
3739 # A:
3840 gem_color = colorIn
41+ gem_dict = dictIn
3942 # B:
40- update_texture()
43+ if dictIn == Enums.GemDict.FOOD:
44+ gem_textures = gem_textures_food
45+ elif dictIn == Enums.GemDict.GEMS:
46+ gem_textures = gem_textures_gems
47+ else :
48+ print(" ERROR: Unknown `GemDict`!" )
4149 # C:
50+ update_texture()
51+ # D:
4252 # panel_hover.visible = false
4353
4454func explode_gem(colorIn: Enums.GemColor, pointsIn: int):
@@ -65,7 +75,7 @@ func replace_gem(colorIn: Enums.GemColor, rows_to_drop: int = 1):
6575 sprite.visible = true
6676
6777 # Initialize the gem with the new color and ensure it's visible
68- initialize(colorIn)
78+ initialize(colorIn, gem_dict )
6979 sprite.visible = true # Make sure the sprite is visible if it was hidden after explosion
7080
7181 # Call the drop animation deferred to ensure it starts after other logic
@@ -81,7 +91,8 @@ func update_texture():
8191 sprite.texture = gem_textures[ gem_color]
8292 # print("[gem_cell] loaded sprite.texture: ", gem_color)
8393 else :
84- print(" ERROR: Texture for gem color not found" )
94+ print(" ERROR: Texture for gem color not found!" )
95+ print(" gem_textures: " , gem_textures)
8596
8697# =========================================================
8798
0 commit comments