Compare commits
3 Commits
e2db1fef29
...
634c9e9d30
Author | SHA1 | Date | |
---|---|---|---|
634c9e9d30 | |||
5bd9d2efb3 | |||
929fc6291e |
@ -13,6 +13,10 @@ func _ready():
|
||||
$UI/CardView.selected = false
|
||||
self.player_to_move = false
|
||||
|
||||
$UI/CardView.draw_card()
|
||||
$UI/CardView.draw_card()
|
||||
$UI/CardView.draw_card()
|
||||
|
||||
$UI/DiceView.roll_dice()
|
||||
$UI/DiceView.roll_dice()
|
||||
$UI/DiceView.roll_dice()
|
||||
@ -40,6 +44,7 @@ func _physics_process(delta):
|
||||
# select the card chooser if dice is selected
|
||||
if (Input.is_action_just_pressed("ui_accept")
|
||||
and $UI/DiceView.selected == true):
|
||||
yield(get_tree().create_timer(0.1), "timeout") #TODO BAD WORKAROUND
|
||||
$UI/DiceView.selected = false
|
||||
$UI/CardView.selected = true
|
||||
|
||||
|
@ -33,14 +33,8 @@
|
||||
1/shape_offset = Vector2( 0, 0 )
|
||||
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
1/shape_one_way = false
|
||||
1/shape_one_way_margin = 1.0
|
||||
1/shapes = [ {
|
||||
"autotile_coord": Vector2( 0, 0 ),
|
||||
"one_way": false,
|
||||
"one_way_margin": 1.0,
|
||||
"shape": null,
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
} ]
|
||||
1/shape_one_way_margin = 0.0
|
||||
1/shapes = [ ]
|
||||
1/z_index = 0
|
||||
|
||||
[node name="BattleScene" type="Node2D"]
|
||||
@ -81,3 +75,5 @@ anchor_top = 0.509722
|
||||
margin_left = 1.52588e-05
|
||||
margin_top = -7.62939e-06
|
||||
grow_horizontal = 0
|
||||
|
||||
[connection signal="dice_selected" from="UI/DiceView" to="UI/CardView" method="set_currently_holding_dice"]
|
||||
|
31
UI/Card.gd
31
UI/Card.gd
@ -11,16 +11,38 @@ const TYPE_COLORS = [
|
||||
Color("#a4a4a4"), # MOVEMENT
|
||||
]
|
||||
|
||||
const dice_node = preload("res://UI/Dice.tscn")
|
||||
|
||||
export (Resource) var card_info
|
||||
|
||||
var input_dice = []
|
||||
var addition_dice_amount : int setget _set_addition_dice
|
||||
var hovering_dice setget _set_hovering_dice
|
||||
|
||||
|
||||
func _set_hovering_dice(dice_value):
|
||||
if hovering_dice == dice_value:
|
||||
return
|
||||
|
||||
hovering_dice = dice_value
|
||||
|
||||
#remove the dice preview if not hovering
|
||||
if dice_value == null:
|
||||
var input_dice_children = $VBox/AutoGrid.get_node_from_grid("InputDice0").get_children()
|
||||
if len(input_dice_children) <= 1:
|
||||
return
|
||||
var old_dice = input_dice_children[1]
|
||||
$VBox/AutoGrid.get_node_from_grid("InputDice0").remove_child(old_dice)
|
||||
return
|
||||
|
||||
var new_dice = dice_node.instance()
|
||||
new_dice.dice_value = dice_value
|
||||
$VBox/AutoGrid.get_node_from_grid("InputDice0").add_child(new_dice)
|
||||
|
||||
|
||||
func _set_addition_dice(new_amount):
|
||||
addition_dice_amount = new_amount
|
||||
$VBox/AutoGrid/InputDice0/Number.text = String(new_amount)
|
||||
$VBox/AutoGrid.get_node_from_grid("InputDice0").get_child("Number").text = String(new_amount)
|
||||
|
||||
|
||||
func _ready():
|
||||
@ -45,11 +67,14 @@ func _ready():
|
||||
self.addition_dice_amount = card_info.addition_amount
|
||||
|
||||
|
||||
func dice_inputted(dice_number : int):
|
||||
func dice_inputted(dice_number):
|
||||
|
||||
# -- SINGLE DICE CHECKS --
|
||||
if dice_number == null:
|
||||
return
|
||||
|
||||
#check if dice is within dice range
|
||||
if dice_number >= 1 and dice_number <= 6:
|
||||
if dice_number < 1 and dice_number > 6:
|
||||
return
|
||||
|
||||
#if accepted dice is specified, check if the dice is in the list
|
||||
|
@ -1,3 +1,76 @@
|
||||
extends Control
|
||||
|
||||
const card = preload("res://UI/Card.tscn")
|
||||
const card_db_string = "res://Assets/CardDB/%s.tres"
|
||||
|
||||
|
||||
var selected : bool = false
|
||||
var hovering_card = null
|
||||
|
||||
var current_cards = []
|
||||
|
||||
var currently_holding_dice = null
|
||||
|
||||
|
||||
func set_currently_holding_dice(dice_number : int):
|
||||
currently_holding_dice = dice_number
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
# no keyboard input if not selected
|
||||
if not selected:
|
||||
hovering_card = null
|
||||
return
|
||||
|
||||
# if selected card is null, add a value
|
||||
if not hovering_card:
|
||||
hovering_card = 0
|
||||
|
||||
# move the selection forward or backward the list depending on input
|
||||
if (Input.is_action_just_pressed("ui_down") or
|
||||
Input.is_action_just_pressed("ui_right")):
|
||||
|
||||
current_cards[hovering_card].hovering_dice = null
|
||||
|
||||
hovering_card += 1
|
||||
if hovering_card >= len(current_cards):
|
||||
hovering_card = 0
|
||||
|
||||
if (Input.is_action_just_pressed("ui_up") or
|
||||
Input.is_action_just_pressed("ui_left")):
|
||||
|
||||
current_cards[hovering_card].hovering_dice = null
|
||||
|
||||
hovering_card -= 1
|
||||
if hovering_card < 0:
|
||||
hovering_card = len(current_cards) -1
|
||||
|
||||
# show the dice over the card if hovering
|
||||
current_cards[hovering_card].hovering_dice = currently_holding_dice
|
||||
|
||||
#if the enter key is pressed, input the dice into the card
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
current_cards[hovering_card].dice_inputted(currently_holding_dice)
|
||||
current_cards[hovering_card].hovering_dice = null
|
||||
selected = false
|
||||
|
||||
|
||||
|
||||
func draw_card(specific_card : String = ""):
|
||||
# make a new card instance and add it to the grid container
|
||||
var new_card = card.instance()
|
||||
$Margin/HBox.add_child(new_card)
|
||||
|
||||
# check if a specific card data exists
|
||||
var card_data_check = File.new()
|
||||
var card_data_exists : bool = card_data_check.file_exists(card_db_string % specific_card)
|
||||
|
||||
# if a specifc card choosen, make new card that type
|
||||
if card_data_exists:
|
||||
new_card.card_info = load(card_db_string % specific_card)
|
||||
else: #no card choosen, pick default
|
||||
new_card.card_info = load(card_db_string % "Default")
|
||||
|
||||
# add the current card to the list of card
|
||||
current_cards.append(new_card)
|
||||
|
@ -1,9 +1,5 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://UI/Card.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Assets/CardDB/Sprint.tres" type="Resource" id=2]
|
||||
[ext_resource path="res://Assets/CardDB/Poisonous apple.tres" type="Resource" id=3]
|
||||
[ext_resource path="res://Assets/CardDB/Broadsword.tres" type="Resource" id=4]
|
||||
[ext_resource path="res://UI/CardView.gd" type="Script" id=5]
|
||||
|
||||
[node name="CardView" type="Control"]
|
||||
@ -24,26 +20,3 @@ margin_right = 1220.0
|
||||
margin_bottom = 660.0
|
||||
rect_min_size = Vector2( 0, 300 )
|
||||
custom_constants/separation = 50
|
||||
|
||||
[node name="Card1" parent="Margin/HBox" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 373.0
|
||||
margin_bottom = 660.0
|
||||
card_info = ExtResource( 2 )
|
||||
|
||||
[node name="Card2" parent="Margin/HBox" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 423.0
|
||||
margin_right = 796.0
|
||||
margin_bottom = 660.0
|
||||
card_info = ExtResource( 4 )
|
||||
|
||||
[node name="Card3" parent="Margin/HBox" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 846.0
|
||||
margin_right = 1220.0
|
||||
margin_bottom = 660.0
|
||||
card_info = ExtResource( 3 )
|
||||
|
12
UI/Dice.gd
12
UI/Dice.gd
@ -4,7 +4,7 @@ extends Control
|
||||
const dice_image_string = "res://Assets/Dice/Dice%s.png"
|
||||
const selected_shader = preload("res://UI/RainbowOutline.tres")
|
||||
|
||||
export (int, 1, 6) var dice_value : int setget _set_dice_value
|
||||
export (int, 0, 6) var dice_value : int = 0
|
||||
export var selected : bool setget _set_selected
|
||||
|
||||
|
||||
@ -16,14 +16,16 @@ func _set_selected(new_value):
|
||||
self.material = null
|
||||
|
||||
|
||||
func _set_dice_value(new_value):
|
||||
dice_value = new_value
|
||||
self.texture = load(dice_image_string % new_value)
|
||||
func _physics_process(delta):
|
||||
self.texture = load(dice_image_string % dice_value)
|
||||
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
||||
self.dice_value = int(round(rand_range(0.5, 6.49999999)))
|
||||
if dice_value == 0:
|
||||
self.dice_value = int(round(rand_range(0.5, 6.49999999)))
|
||||
|
||||
_physics_process(0)
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Dice/Dice6.png" type="Texture" id=1]
|
||||
[ext_resource path="res://UI/Dice.gd" type="Script" id=2]
|
||||
|
||||
[node name="Dice" type="TextureRect"]
|
||||
@ -7,6 +8,7 @@ margin_right = 100.0
|
||||
margin_bottom = 100.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
texture = ExtResource( 1 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
script = ExtResource( 2 )
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends Control
|
||||
|
||||
signal dice_selected (dice_value)
|
||||
|
||||
const dice = preload("res://UI/Dice.tscn")
|
||||
|
||||
var selected : bool = false
|
||||
@ -42,6 +44,15 @@ func _physics_process(delta):
|
||||
# enable the selected shader
|
||||
current_dice[selected_dice].selected = true
|
||||
|
||||
#if the enter key is pressed, remove the selected dice and emit the signal
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
emit_signal("dice_selected", current_dice[selected_dice].dice_value)
|
||||
|
||||
current_dice[selected_dice].queue_free()
|
||||
current_dice.remove(selected_dice)
|
||||
selected_dice = null
|
||||
selected = false
|
||||
|
||||
|
||||
func roll_dice(specific_value : int = 0):
|
||||
# make a new dice instance and add it to the grid container
|
||||
|
@ -21,6 +21,7 @@ _global_script_class_icons={
|
||||
[application]
|
||||
|
||||
config/name="Quit Rolling Around"
|
||||
run/main_scene="res://Scenes/BattleScene.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[display]
|
||||
|
Loading…
x
Reference in New Issue
Block a user