End of chapter 6. A lot of problems took to much time to solve. It was good to know better Godot internal mechanism.
This commit is contained in:
@@ -4,7 +4,6 @@ signal COMMAND_PROCESSED(label)
|
||||
|
||||
var commandLabel
|
||||
|
||||
|
||||
func execute():
|
||||
COMMAND_PROCESSED.emit(commandLabel)
|
||||
|
||||
|
||||
@@ -3,3 +3,9 @@ extends Node
|
||||
signal PROCESS_COMMAND(command)
|
||||
signal WAIT_FOR_COMMAND
|
||||
signal PAUSE_PROCESSOR
|
||||
|
||||
signal PLAYER_MOVE(direction)
|
||||
|
||||
signal DISPLAY_MESSAGE(message)
|
||||
signal DISPLAY_COMMAND_PROMPT
|
||||
signal DISPLAY_CLEAR
|
||||
|
||||
22
scripts/game/commands/MoveCommand.gd
Normal file
22
scripts/game/commands/MoveCommand.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
extends Command
|
||||
|
||||
class_name MoveCommand
|
||||
|
||||
var direction
|
||||
|
||||
func _init(dir):
|
||||
commandLabel = "Move"
|
||||
direction = dir
|
||||
|
||||
|
||||
func execute():
|
||||
CommandDispatcher.PLAYER_MOVE.emit(direction)
|
||||
emit_signal("COMMAND_PROCESSED", getCommandText())
|
||||
|
||||
|
||||
func getDirectionString() -> String:
|
||||
return Map.Direction.keys()[direction]
|
||||
|
||||
|
||||
func getCommandText():
|
||||
return "%s %s" % [commandLabel, getDirectionString()]
|
||||
1
scripts/game/commands/MoveCommand.gd.uid
Normal file
1
scripts/game/commands/MoveCommand.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c136g73lrccts
|
||||
@@ -2,9 +2,10 @@ extends Command
|
||||
|
||||
class_name PassCommand
|
||||
|
||||
func _init() -> void:
|
||||
func _init():
|
||||
commandLabel = "Pass"
|
||||
|
||||
|
||||
func execute():
|
||||
print("Player passed.")
|
||||
COMMAND_PROCESSED.emit(commandLabel)
|
||||
|
||||
Reference in New Issue
Block a user