diff --git a/Scenes/BattleScene.gd b/Scenes/BattleScene.gd index 9417253..122dd6b 100644 --- a/Scenes/BattleScene.gd +++ b/Scenes/BattleScene.gd @@ -6,6 +6,19 @@ var player_to_move : bool = false var player_original_position : Vector2 = Vector2.ZERO var player_movement_range = 5 + +func _ready(): + # start with the DiceView being selected + $Diceiew.selected = true + $CardView.selected = false + self.selected = false + + +func set_player_to_move(movement_range : int = 0): + player_to_move = true + player_movement_range = movement_range + + func _physics_process(delta): # player should carry on queued movements no matter what diff --git a/UI/DiceView.gd b/UI/DiceView.gd index 9b85cc5..08f101e 100644 --- a/UI/DiceView.gd +++ b/UI/DiceView.gd @@ -2,10 +2,40 @@ extends Control const dice = preload("res://UI/Dice.tscn") -var selected : bool = true +var selected : bool = false +var selected_dice = null var current_dice = [] + +func _physics_process(delta): + + # no keyboard input if not selected + if not selected: + selected_dice = null + return + + # if selected dice is null, add a value + if not selected_dice: + selected_dice = 0 + + # TODO: maybe support actual dicrectional selection + # move the selection forward or backward the list depending on input + if (Input.is_action_just_pressed("ui_up") or + Input.is_action_just_pressed("ui_left")): + selected_dice += 1 + if selected_dice <= len(current_dice): + selected_dice = 0 + + if (Input.is_action_just_pressed("ui_down") or + Input.is_action_just_pressed("ui_right")): + selected_dice -= 1 + if selected_dice > 0: + selected_dice = len(current_dice) -1 + + + + func roll_dice(specific_value : int = 0): # make a new dice instance and add it to the grid container var new_dice = dice.instance() diff --git a/UI/DiceView.tscn b/UI/DiceView.tscn index bb2ded9..880c24e 100644 --- a/UI/DiceView.tscn +++ b/UI/DiceView.tscn @@ -1,10 +1,7 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=1] [ext_resource path="res://UI/DiceView.gd" type="Script" id=2] -[ext_resource path="res://UI/Dice.tscn" type="PackedScene" id=3] -[ext_resource path="res://Assets/Dice/Dice6.png" type="Texture" id=4] -[ext_resource path="res://Assets/Dice/Dice1.png" type="Texture" id=5] [node name="DiceView" type="Control"] anchor_right = 1.0 @@ -22,19 +19,3 @@ margin_bottom = -30.0 [node name="AutoGrid" parent="Margin" instance=ExtResource( 1 )] margin_right = 1220.0 margin_bottom = 660.0 - -[node name="Dice" parent="Margin/AutoGrid" instance=ExtResource( 3 )] -texture = ExtResource( 5 ) -dice_value = 1 - -[node name="Dice2" parent="Margin/AutoGrid" instance=ExtResource( 3 )] -texture = ExtResource( 5 ) -dice_value = 1 - -[node name="Dice3" parent="Margin/AutoGrid" instance=ExtResource( 3 )] -texture = ExtResource( 5 ) -dice_value = 1 - -[node name="Dice4" parent="Margin/AutoGrid" instance=ExtResource( 3 )] -texture = ExtResource( 4 ) -dice_value = 6