Added underscore to unpublic functions names
This commit is contained in:
+21
-22
@@ -28,10 +28,10 @@ signal closed()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
play_animation()
|
||||
_play_animation()
|
||||
|
||||
|
||||
func play_animation() -> void:
|
||||
func _play_animation() -> void:
|
||||
var animation : String = "%s_%s" % [
|
||||
ANIMATIONS_BY_TYPE[type],
|
||||
ANIMATIONS_BY_STATE[state]
|
||||
@@ -39,36 +39,35 @@ func play_animation() -> void:
|
||||
$AnimatedSprite2D.play(animation)
|
||||
|
||||
|
||||
func _on_animated_sprite_2d_animation_finished() -> void:
|
||||
match state:
|
||||
DoorState.CLOSING:
|
||||
state = DoorState.CLOSED
|
||||
$CollisionShape2D.disabled = false
|
||||
_play_animation()
|
||||
DoorState.OPENING:
|
||||
state = DoorState.OPENED
|
||||
$CollisionShape2D.disabled = true
|
||||
_play_animation()
|
||||
DoorState.CLOSED:
|
||||
closed.emit()
|
||||
DoorState.OPENED:
|
||||
opened.emit()
|
||||
|
||||
|
||||
func open() -> void:
|
||||
if state != DoorState.CLOSED:
|
||||
print("Door in state '%s' can't be opened" % DoorState.find_key(state))
|
||||
return
|
||||
|
||||
state = DoorState.OPENING
|
||||
play_animation()
|
||||
|
||||
|
||||
_play_animation()
|
||||
|
||||
|
||||
func close():
|
||||
if state != DoorState.OPENED:
|
||||
print("Door in state '%s' can't be closed" % DoorState.find_key(state))
|
||||
return
|
||||
|
||||
state = DoorState.CLOSING
|
||||
play_animation()
|
||||
|
||||
|
||||
func _on_animated_sprite_2d_animation_finished() -> void:
|
||||
match state:
|
||||
DoorState.CLOSING:
|
||||
state = DoorState.CLOSED
|
||||
$CollisionShape2D.disabled = false
|
||||
play_animation()
|
||||
DoorState.OPENING:
|
||||
state = DoorState.OPENED
|
||||
$CollisionShape2D.disabled = true
|
||||
play_animation()
|
||||
DoorState.CLOSED:
|
||||
closed.emit()
|
||||
DoorState.OPENED:
|
||||
opened.emit()
|
||||
_play_animation()
|
||||
|
||||
+10
-10
@@ -40,17 +40,17 @@ var bottom_door = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
create_level()
|
||||
_create_level()
|
||||
|
||||
|
||||
func create_level() -> void:
|
||||
create_forest()
|
||||
create_field()
|
||||
add_top_door()
|
||||
add_bottom_door()
|
||||
func _create_level() -> void:
|
||||
_create_forest()
|
||||
_create_field()
|
||||
_create_top_door()
|
||||
_create_bottom_door()
|
||||
|
||||
|
||||
func create_forest() -> void:
|
||||
func _create_forest() -> void:
|
||||
$TileMapLayer.set_cell(Vector2i(0,0), 0, TOP_LEFT_FOREST)
|
||||
$TileMapLayer.set_cell(Vector2i(19,0), 0, TOP_RIGHT_FOREST)
|
||||
$TileMapLayer.set_cell(Vector2i(0,10), 0, BOTTOM_LEFT_FOREST)
|
||||
@@ -65,7 +65,7 @@ func create_forest() -> void:
|
||||
$TileMapLayer.set_cell(Vector2i(19,i), 0, RIGHT_FORESTS[randi() % RIGHT_FORESTS.size()])
|
||||
|
||||
|
||||
func create_field() -> void:
|
||||
func _create_field() -> void:
|
||||
$TileMapLayer.set_cell(Vector2i(1,1), 1, CORNER_FIELDS[randi() % CORNER_FIELDS.size()])
|
||||
|
||||
for i in range(2, 19):
|
||||
@@ -78,7 +78,7 @@ func create_field() -> void:
|
||||
for j in range(2, 10):
|
||||
$TileMapLayer.set_cell(Vector2i(i,j), 1, CENTER_FIELDS[randi() % CENTER_FIELDS.size()])
|
||||
|
||||
func add_top_door():
|
||||
func _create_top_door():
|
||||
const y = 0
|
||||
$TileMapLayer.set_cell(Vector2i(top_door_x-1,y), 0, TOP_LEFT_DOOR)
|
||||
$TileMapLayer.set_cell(Vector2i(top_door_x,y), 1, LEFT_FIELDS[randi() % LEFT_FIELDS.size()])
|
||||
@@ -92,7 +92,7 @@ func add_top_door():
|
||||
add_child(top_door)
|
||||
|
||||
|
||||
func add_bottom_door():
|
||||
func _create_bottom_door():
|
||||
const y = 10
|
||||
$TileMapLayer.set_cell(Vector2i(bottom_door_x-1,y), 0, BOTTOM_LEFT_DOOR)
|
||||
$TileMapLayer.set_cell(Vector2i(bottom_door_x,y), 1, LEFT_FIELDS[randi() % LEFT_FIELDS.size()])
|
||||
|
||||
+10
-10
@@ -26,15 +26,10 @@ var ANIMATIONS_BY_STATE : Dictionary = {
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
play_animation()
|
||||
|
||||
|
||||
func highlight() -> void:
|
||||
state = PickupState.HIGHLIGHTING
|
||||
play_animation()
|
||||
_play_animation()
|
||||
|
||||
|
||||
func play_animation() -> void:
|
||||
func _play_animation() -> void:
|
||||
var animation : String
|
||||
if state == PickupState.PREPARING:
|
||||
animation = ANIMATIONS_BY_STATE[state]
|
||||
@@ -50,10 +45,15 @@ func _on_animated_sprite_2d_animation_finished() -> void:
|
||||
match state:
|
||||
PickupState.PREPARING:
|
||||
state = PickupState.SHOWING_UP
|
||||
play_animation()
|
||||
_play_animation()
|
||||
PickupState.SHOWING_UP:
|
||||
state = PickupState.IDLING
|
||||
play_animation()
|
||||
_play_animation()
|
||||
PickupState.HIGHLIGHTING:
|
||||
state = PickupState.IDLING
|
||||
play_animation()
|
||||
_play_animation()
|
||||
|
||||
|
||||
func highlight() -> void:
|
||||
state = PickupState.HIGHLIGHTING
|
||||
_play_animation()
|
||||
|
||||
Reference in New Issue
Block a user