Add some input logic for diceview
This commit is contained in:
parent
7b5d7f5ee7
commit
e78931e55e
@ -6,6 +6,19 @@ var player_to_move : bool = false
|
|||||||
var player_original_position : Vector2 = Vector2.ZERO
|
var player_original_position : Vector2 = Vector2.ZERO
|
||||||
var player_movement_range = 5
|
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):
|
func _physics_process(delta):
|
||||||
|
|
||||||
# player should carry on queued movements no matter what
|
# player should carry on queued movements no matter what
|
||||||
|
@ -2,10 +2,40 @@ extends Control
|
|||||||
|
|
||||||
const dice = preload("res://UI/Dice.tscn")
|
const dice = preload("res://UI/Dice.tscn")
|
||||||
|
|
||||||
var selected : bool = true
|
var selected : bool = false
|
||||||
|
var selected_dice = null
|
||||||
|
|
||||||
var current_dice = []
|
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):
|
func roll_dice(specific_value : int = 0):
|
||||||
# make a new dice instance and add it to the grid container
|
# make a new dice instance and add it to the grid container
|
||||||
var new_dice = dice.instance()
|
var new_dice = dice.instance()
|
||||||
|
@ -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://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/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"]
|
[node name="DiceView" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -22,19 +19,3 @@ margin_bottom = -30.0
|
|||||||
[node name="AutoGrid" parent="Margin" instance=ExtResource( 1 )]
|
[node name="AutoGrid" parent="Margin" instance=ExtResource( 1 )]
|
||||||
margin_right = 1220.0
|
margin_right = 1220.0
|
||||||
margin_bottom = 660.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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user