Add some input logic for diceview

This commit is contained in:
CactiChameleon9 2022-07-17 13:05:20 +01:00
parent 7b5d7f5ee7
commit e78931e55e
3 changed files with 45 additions and 21 deletions

View File

@ -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

View File

@ -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()

View File

@ -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