feat: instantiate dragons in different spots
This commit is contained in:
parent
029ad6d45f
commit
48b6cd42cf
2 changed files with 15 additions and 6 deletions
|
@ -40,9 +40,5 @@ func _on_change_shoes_pressed() -> void:
|
|||
func _on_create_pressed() -> void:
|
||||
if dragon_name.text.is_empty():
|
||||
return
|
||||
var result: String = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits).encrypt(hat.texture, shirt.texture, shoes.texture, dragon_name.text)
|
||||
print(result)
|
||||
var decrypted: Dictionary = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits).descrypt(result)
|
||||
print(decrypted)
|
||||
on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture, dragon_name.text)
|
||||
queue_free()
|
||||
|
|
|
@ -6,6 +6,8 @@ class_name GameManager
|
|||
@export var dragon_ingame: PackedScene
|
||||
@export var dragon_spots: Array[Node2D]
|
||||
|
||||
var _filled_spots: Dictionary[Node2D, int]
|
||||
|
||||
@export var hat_outfits: DragonOutfit
|
||||
@export var shirt_outfits: DragonOutfit
|
||||
@export var shoes_outfits: DragonOutfit
|
||||
|
@ -27,6 +29,10 @@ func _ready():
|
|||
_load_game()
|
||||
|
||||
|
||||
func _instantiate_random_dragon():
|
||||
pass
|
||||
|
||||
|
||||
func move_window_to_bottom_right():
|
||||
var display_index: int = DisplayServer.window_get_current_screen()
|
||||
|
||||
|
@ -42,9 +48,12 @@ func move_window_to_bottom_right():
|
|||
|
||||
|
||||
func add_dragon(hat: Texture2D, shirt: Texture2D, shoes: Texture2D, dragon_name: String):
|
||||
# TODO: Check for free positon
|
||||
var id: int = _library.add_dragon(dragon_name, hat, shirt, shoes)
|
||||
_instantiate_dragon_ingame(dragon_spots[0].position, hat, shirt, shoes, dragon_name, id)
|
||||
for spot in dragon_spots:
|
||||
if not _filled_spots.has(spot):
|
||||
_instantiate_dragon_ingame(spot.position, hat, shirt, shoes, dragon_name, id)
|
||||
_filled_spots[spot] = id
|
||||
break
|
||||
|
||||
|
||||
func _load_game():
|
||||
|
@ -76,6 +85,10 @@ func _pick_dragon(id: int, position: Vector2, hat: Texture2D, shirt: Texture2D,
|
|||
_dragon_entities[id] = dragon
|
||||
dragon.place_back.connect(_dragon_place_back)
|
||||
add_child(dragon)
|
||||
|
||||
for spot in _filled_spots:
|
||||
if _filled_spots[spot] == id:
|
||||
_filled_spots.erase(spot)
|
||||
|
||||
|
||||
func _dragon_place_back(dragon: Dragon):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue