block rotation
This commit is contained in:
parent
24a59ad4ac
commit
bcb17faaed
3 changed files with 27 additions and 0 deletions
|
|
@ -167,4 +167,5 @@ label_settings = SubResource("LabelSettings_y2xp5")
|
|||
|
||||
[connection signal="dropBlock" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_drop_block"]
|
||||
[connection signal="moveBlock" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_move_block"]
|
||||
[connection signal="rotateBlock" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_rotate_block"]
|
||||
[connection signal="startTurn" from="TwitchLink" to="PlayerHand" method="_on_twitch_link_start_turn"]
|
||||
|
|
|
|||
|
|
@ -49,6 +49,17 @@ func _on_twitch_link_move_block(direction, amount):
|
|||
position += dir * amount * moveScale
|
||||
|
||||
|
||||
func _on_twitch_link_rotate_block(direction, amount):
|
||||
var dir : Vector3
|
||||
match direction:
|
||||
"up": dir = Vector3.UP
|
||||
"down" : dir = Vector3.DOWN
|
||||
"north" : dir = Vector3.FORWARD
|
||||
"east" : dir = Vector3.RIGHT
|
||||
"south" : dir = Vector3.BACK
|
||||
"west" : dir = Vector3.LEFT
|
||||
rotation_degrees += dir * amount
|
||||
|
||||
func _on_twitch_link_drop_block():
|
||||
current_block.freeze = false
|
||||
current_block.reparent(blocks_node)
|
||||
|
|
@ -70,3 +81,6 @@ func _on_twitch_link_start_turn():
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
extends Gift
|
||||
|
||||
signal moveBlock(direction : String, amount : float)
|
||||
signal rotateBlock(direction : String, amount : float)
|
||||
signal dropBlock()
|
||||
signal startTurn()
|
||||
|
||||
|
|
@ -72,6 +73,7 @@ func _ready() -> void:
|
|||
|
||||
#move block commands - !move north 10
|
||||
add_command("move", move, 2,2)
|
||||
add_command("rotate", rotate, 2,2)
|
||||
|
||||
add_command("drop", drop)
|
||||
|
||||
|
|
@ -166,6 +168,16 @@ func move(cmd_info : CommandInfo, arg_ary : PackedStringArray) -> void:
|
|||
else:
|
||||
chat("invalid direction :(")
|
||||
|
||||
func rotate(cmd_info : CommandInfo, arg_ary : PackedStringArray) -> void:
|
||||
if(cmd_info.sender_data.tags["display-name"] == jenga_manager.current_player and jenga_manager.turn_started) :
|
||||
var chosenDirection = arg_ary[0].to_lower()
|
||||
var validDirections = ["up","down","north","south","east","west"]
|
||||
if(validDirections.has(chosenDirection)):
|
||||
rotateBlock.emit(arg_ary[0],float(arg_ary[1]))
|
||||
chat("rotating block " + arg_ary[0] + " by " + arg_ary[1] + " degrees")
|
||||
else:
|
||||
chat("invalid direction :(")
|
||||
|
||||
func drop(cmd_info : CommandInfo):
|
||||
#make block child of world and unfreeze the rb
|
||||
if(cmd_info.sender_data.tags["display-name"] == jenga_manager.current_player and jenga_manager.turn_started) :
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue