feat: added town name setting
This commit is contained in:
parent
a8b292aa03
commit
fc177656c5
8 changed files with 134 additions and 24 deletions
|
@ -4,15 +4,19 @@ class_name DragonOutfit
|
|||
|
||||
@export var allow_null: bool
|
||||
@export var outfits: Array[SpriteFrames]
|
||||
var index: int = 0
|
||||
var _index: int = 0
|
||||
|
||||
|
||||
func _init(outfits: Array[SpriteFrames] = []):
|
||||
self.outfits = outfits
|
||||
|
||||
|
||||
func reset() -> void:
|
||||
_index = 0
|
||||
|
||||
|
||||
func pick_next() -> SpriteFrames:
|
||||
index += 1
|
||||
_index += 1
|
||||
if allow_null:
|
||||
return _pick_nullable()
|
||||
else:
|
||||
|
@ -20,7 +24,7 @@ func pick_next() -> SpriteFrames:
|
|||
|
||||
|
||||
func pick_previous() -> SpriteFrames:
|
||||
index -= 1
|
||||
_index -= 1
|
||||
if allow_null:
|
||||
return _pick_nullable()
|
||||
else:
|
||||
|
@ -28,16 +32,16 @@ func pick_previous() -> SpriteFrames:
|
|||
|
||||
|
||||
func _pick_nullable() -> SpriteFrames:
|
||||
index %= (len(outfits) + 1)
|
||||
if index == 0:
|
||||
_index %= (len(outfits) + 1)
|
||||
if _index == 0:
|
||||
return null
|
||||
|
||||
return outfits[index - 1]
|
||||
return outfits[_index - 1]
|
||||
|
||||
|
||||
func _pick_non_nullable() -> SpriteFrames:
|
||||
index %= len(outfits)
|
||||
return outfits[index]
|
||||
_index %= len(outfits)
|
||||
return outfits[_index]
|
||||
|
||||
|
||||
func get_texture(index: int) -> SpriteFrames:
|
||||
|
@ -45,3 +49,10 @@ func get_texture(index: int) -> SpriteFrames:
|
|||
return null
|
||||
|
||||
return outfits[index]
|
||||
|
||||
|
||||
func get_current_index() -> int:
|
||||
if allow_null:
|
||||
return _index - 1
|
||||
else:
|
||||
return _index
|
||||
|
|
|
@ -25,6 +25,7 @@ func load() -> void:
|
|||
contents_to_save.get_or_add('coins', 0)
|
||||
contents_to_save.get_or_add('dragons', [])
|
||||
contents_to_save.get_or_add('items', [])
|
||||
contents_to_save.get_or_add('tower_name', "")
|
||||
|
||||
|
||||
func get_coins() -> int:
|
||||
|
@ -35,6 +36,14 @@ func set_coins(coins: int) -> void:
|
|||
contents_to_save['coins'] = coins
|
||||
|
||||
|
||||
func get_tower_name() -> String:
|
||||
return contents_to_save['tower_name']
|
||||
|
||||
|
||||
func set_tower_name(name: String) -> void:
|
||||
contents_to_save['tower_name'] = name
|
||||
|
||||
|
||||
func clear_dragons() -> void:
|
||||
contents_to_save['dragons'] = []
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue