end turn update
This commit is contained in:
@@ -4,9 +4,8 @@ extends Node
|
||||
signal bullet_selected(object)
|
||||
signal state_changed
|
||||
|
||||
enum GameState { PLAYER1_GUN_LOAD, PLAYER2_GUN_LOAD, GUN_ANIMATION}
|
||||
enum GameState { PLAYER1_GUN_LOAD, PLAYER2_GUN_LOAD, GUN_ANIMATION, PLAYER1_UNLOAD,PLAYER2_UNLOAD}
|
||||
var current_state = GameState.PLAYER1_GUN_LOAD
|
||||
var prev_state: int
|
||||
var bullets: Array
|
||||
|
||||
var player1_revolver: Node3D
|
||||
@@ -40,15 +39,32 @@ func on_bullet_selected(bullet_object: Node3D):
|
||||
player1_revolver.load_bullet(bullet_object)
|
||||
|
||||
func set_state(newState):
|
||||
prev_state = current_state
|
||||
current_state = newState
|
||||
state_changed.emit()
|
||||
|
||||
func check_unloaded_bullets():
|
||||
var unloaded_bullets = Array()
|
||||
for bullet in bullets:
|
||||
if bullet.is_loaded != true:
|
||||
unloaded_bullets.append(bullet)
|
||||
if unloaded_bullets.size() > 0:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
|
||||
func end_player_turn():
|
||||
set_state(GameState.PLAYER2_GUN_LOAD)
|
||||
if check_unloaded_bullets():
|
||||
set_state(GameState.PLAYER2_GUN_LOAD)
|
||||
else:
|
||||
set_state(GameState.PLAYER2_UNLOAD)
|
||||
print("End of Phase 1")
|
||||
func end_enemy_turn():
|
||||
set_state(GameState.PLAYER1_GUN_LOAD)
|
||||
if check_unloaded_bullets():
|
||||
set_state(GameState.PLAYER1_GUN_LOAD)
|
||||
else:
|
||||
set_state(GameState.PLAYER1_UNLOAD)
|
||||
print("End of Phase 1")
|
||||
func get_enemy_revolver() -> Node3D:
|
||||
return player2_revolver
|
||||
|
||||
|
||||
Reference in New Issue
Block a user