diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2025-02-12 20:05:59 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2025-02-12 20:05:59 +0100 |
commit | 218748f67a6a6b35efc4a732ad11426d0f528709 (patch) | |
tree | e58504dd758ce6525844872007221cda2a8b6926 /stage/dice_throw/dice_throw.gd | |
parent | f6c81b065cf4d7f1302a50f2f72cfab32204a1ec (diff) |
Diffstat (limited to 'stage/dice_throw/dice_throw.gd')
-rw-r--r-- | stage/dice_throw/dice_throw.gd | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/stage/dice_throw/dice_throw.gd b/stage/dice_throw/dice_throw.gd index d06a8f7..c6573be 100644 --- a/stage/dice_throw/dice_throw.gd +++ b/stage/dice_throw/dice_throw.gd @@ -8,21 +8,23 @@ 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 := %DiceThrow3D/Dice.get_children() - var top_faces := [] + var dices: Array[Dice] + dices.assign(%DiceThrow3D/Dice.get_children()) + var top_faces: Array[DiceFace] = [] var tween := create_tween().set_parallel() - #tween.tween_property(%Camera3D, "rotation_degrees", Vector3(-90, 0, 0), 0.5) - #tween.tween_property(%Camera3D, "position", Vector3(0, %Camera3D.position.y, 0), 0.5) - + # move to center and rotate to camera for idx in dices.size(): - var dice: RigidBody3D = dices[idx] + var dice := dices[idx] dice.freeze = true tween.tween_property( @@ -32,20 +34,21 @@ func _on_dice_throw_3d_throw_finished() -> void: 0.25 ) - var face: Node3D = dice.get_top() + var face := dice.get_top() top_faces.append(face) - var up_rotation: Vector3 = face.get_meta("up") + 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.get_meta("up") + transform_vector, 0.25) + 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: @@ -56,17 +59,32 @@ func _on_dice_throw_3d_throw_finished() -> void: 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: RigidBody3D = dices[idx] - var node := get_node("%" + top_faces[idx].get_meta("type")) + 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_faces[idx].get_meta("type") == "move": - Network.current_player.set_current_move_points(Network.current_player.current_move_points + 1) + 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: |