extends Control signal throw_finished func _ready() -> void: %Side.position.x = -%Side.size.x %move.text = "Move: %s" % str(Network.current_player.current_move_points) %attack.text = "Attack: %s" % str(Network.current_player.current_attack_points) %defend.text = "Defend: %s" % str(Network.current_player.current_defend_points) %ability.text = "Ability: %s" % str(Network.current_player.current_ability_points) func _on_dice_throw_3d_throw_finished() -> void: await get_tree().create_timer(0.25).timeout var dices: Array[Dice] dices.assign(%DiceThrow3D/Dice.get_children()) var top_faces: Array[DiceFace] = [] var tween := create_tween().set_parallel() # move to center and rotate to camera for idx in dices.size(): var dice := dices[idx] dice.freeze = true tween.tween_property( dice, "position", %Camera3D.project_position((%SubViewportContainer.size * 0.5) + Vector2(50 * idx, 0) - Vector2(50, 0), 1), 0.25 ) var face := dice.get_top() top_faces.append(face) var up_rotation: Vector3 = face.up_rotation var transform_vector: Vector3 if up_rotation.y != 0 and up_rotation.z != 0: transform_vector = Vector3(0, 0, 60) * sign(up_rotation.y) else: transform_vector = Vector3(60, 0, 0) * (-1 if up_rotation.y > 0 else 1) tween.tween_property(dice, "rotation_degrees", face.up_rotation + transform_vector, 0.25) await tween.finished await get_tree().create_timer(0.25).timeout # show sidebar tween = create_tween().set_parallel() tween.tween_property(%Side, "position", Vector2(0, %Side.position.y), 0.25) for dice in dices: var p2d: Vector2 = %Camera3D.unproject_position(dice.position) var p3d = %Camera3D.project_position(p2d + %Side.size * 0.5, 1) tween.tween_property(dice, "position", Vector3(p3d.x, dice.position.y, dice.position.z), 0.25) await tween.finished await get_tree().create_timer(0.25).timeout # move to labels tween = create_tween().set_parallel() for idx in dices.size(): var dice := dices[idx] var top_face := top_faces[idx] var node := get_node("%" + top_face.configuration.type) var p3d = %Camera3D.project_position(node.position + node.size * 0.5, 1) tween.tween_property(dice, "position", p3d, 0.25) tween.tween_property(dice, "scale", Vector3(0.1, 0.1, 0.1), 0.25) if top_face.configuration.type == "move": #Network.current_player.set_current_move_points(Network.current_player.current_move_points + 1) Network.current_player.current_move_points += top_face.configuration.value %move.text = "Move: %s" % str(Network.current_player.current_move_points) elif top_face.configuration.type == "attack": #Network.current_player.set_current_attack_points(Network.current_player.current_attack_points + 1) Network.current_player.current_attack_points += top_face.configuration.value %attack.text = "Attack: %s" % str(Network.current_player.current_attack_points) elif top_face.configuration.type == "defend": #Network.current_player.set_current_defend_points(Network.current_player.current_defend_points + 1) Network.current_player.current_defend_points += top_face.configuration.value %defend.text = "Defend: %s" % str(Network.current_player.current_defend_points) elif top_face.configuration.type == "ability": #Network.current_player.set_current_ability_points(Network.current_player.current_ability_points + 1) Network.current_player.current_ability_points += top_face.configuration.value %ability.text = "Ability: %s" % str(Network.current_player.current_ability_points) await tween.finished for dice in dices: dice.visible = false await get_tree().create_timer(1.0).timeout throw_finished.emit()