feat: ability to share dragons
This commit is contained in:
parent
3919df1805
commit
029ad6d45f
15 changed files with 203 additions and 30 deletions
|
|
@ -15,15 +15,21 @@ func _init(hat_outfits: DragonOutfit, shirt_outfits: DragonOutfit, shoes_outfits
|
|||
self.shoes_outfits = shoes_outfits
|
||||
|
||||
|
||||
func add_dragon(name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D):
|
||||
func add_dragon(name: String, hat: Texture2D, shirt: Texture2D, shoes: Texture2D) -> int:
|
||||
var hat_index: int = hat_outfits.get_index(hat)
|
||||
var shirt_index: int = shirt_outfits.get_index(shirt)
|
||||
var shoes_index: int = shoes_outfits.get_index(shoes)
|
||||
dragons.push_back({'name': name, 'hat': hat_index, 'shirt': shirt_index, 'shoes': shoes_index})
|
||||
var id: int = RandomNumberGenerator.new().randi()
|
||||
_push_dragon(id, name, hat_index, shirt_index, shoes_index)
|
||||
return id
|
||||
|
||||
|
||||
func add_dragons(dragons: Array) -> void:
|
||||
for d in dragons:
|
||||
self.dragons.push_back(
|
||||
{'name': d['name'], 'hat': d['hat'], 'shirt': d['shirt'], 'shoes': d['shoes']}
|
||||
)
|
||||
_push_dragon(d['id'], d['name'], d['hat'], d['shirt'], d['shoes'])
|
||||
|
||||
|
||||
func _push_dragon(id: int, name: String, hat: int, shirt: int, shoes: int):
|
||||
dragons.push_back(
|
||||
{'id': id, 'name': name, 'hat': hat, 'shirt': shirt, 'shoes': shoes}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue