Completely refractor the project so the code isn't so terrible #7
BIN
Assets/DiceInputBold.kra
Normal file
BIN
Assets/DiceInputBold.kra
Normal file
Binary file not shown.
BIN
Assets/DiceInputBold.png
Normal file
BIN
Assets/DiceInputBold.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
35
Assets/DiceInputBold.png.import
Normal file
35
Assets/DiceInputBold.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/DiceInputBold.png-dc499cd822102d68e5e44449ce5835a3.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Assets/DiceInputBold.png"
|
||||
dest_files=[ "res://.import/DiceInputBold.png-dc499cd822102d68e5e44449ce5835a3.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
@ -12,6 +12,7 @@ script = ExtResource( 1 )
|
||||
[node name="Scroll" type="ScrollContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_clip_content = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
scroll_horizontal_enabled = false
|
||||
|
@ -11,10 +11,22 @@ var map_position : Vector2 = Vector2.ZERO
|
||||
onready var target_position : Vector2 = position
|
||||
var moving : bool = false
|
||||
|
||||
var cards = [] setget ,get_cards
|
||||
var dice = []
|
||||
|
||||
|
||||
func get_cards():
|
||||
for child in get_children():
|
||||
if "Card" in child.name:
|
||||
cards.append(child)
|
||||
|
||||
return cards
|
||||
|
||||
|
||||
func level_change(new_level):
|
||||
# when leveing up restore health
|
||||
health = base_max_health * pow(level, 1.5)
|
||||
level = new_level
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
@ -27,11 +39,13 @@ func _physics_process(delta):
|
||||
#TODO: Replace with tween magic
|
||||
position += (target_position - position)/2.5
|
||||
|
||||
|
||||
func take_damage(damage):
|
||||
health -= damage
|
||||
if health <= 0:
|
||||
die()
|
||||
|
||||
|
||||
func die():
|
||||
#Animation here
|
||||
queue_free()
|
||||
|
49
Management/ActiveController.gd
Normal file
49
Management/ActiveController.gd
Normal file
@ -0,0 +1,49 @@
|
||||
extends Node
|
||||
|
||||
var current_active : int = 0
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
the_connecting()
|
||||
the_pausing()
|
||||
|
||||
|
||||
func the_pausing():
|
||||
# iterate through the children, allowing only the current active node to run
|
||||
for i in len(get_children()):
|
||||
if get_child(i).has_signal("scene_finished"): # only change if active var should exist
|
||||
get_child(i).active = true if i == current_active else false
|
||||
|
||||
|
||||
func the_connecting():
|
||||
# iterate through the children and connect up the child_finished method
|
||||
for i in len(get_children()):
|
||||
|
||||
# connect the finished signal if it exists and
|
||||
# if the failed finished isn't already connected
|
||||
if (get_child(i).has_signal("scene_finished") and
|
||||
get_child(i).get_signal_connection_list("scene_finished") == []):
|
||||
|
||||
get_child(i).connect("scene_finished", self, "child_finished")
|
||||
|
||||
|
||||
# connect the failed signal if it exists and
|
||||
# if the failed signal isn't already connected
|
||||
if (get_child(i).has_signal("scene_failed") and
|
||||
get_child(i).get_signal_connection_list("scene_failed") == []):
|
||||
|
||||
get_child(i).connect("scene_failed", self, "child_failed")
|
||||
|
||||
|
||||
func child_finished():
|
||||
# designed to be called from a signal
|
||||
current_active += 1
|
||||
if current_active >= len(get_children()):
|
||||
current_active = 0
|
||||
|
||||
|
||||
func child_failed():
|
||||
# designed to be called from a signal
|
||||
current_active -= 1
|
||||
if current_active < 0:
|
||||
current_active = len(get_children()) - 1
|
6
Management/ActiveController.tscn
Normal file
6
Management/ActiveController.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Management/ActiveController.gd" type="Script" id=1]
|
||||
|
||||
[node name="ActiveController" type="Node"]
|
||||
script = ExtResource( 1 )
|
86
Scenes/Battle.gd
Normal file
86
Scenes/Battle.gd
Normal file
@ -0,0 +1,86 @@
|
||||
extends Node2D
|
||||
|
||||
signal scene_finished
|
||||
signal scene_failed
|
||||
|
||||
var active : bool = false
|
||||
|
||||
var character = null setget new_character
|
||||
var movement_queue = []
|
||||
var character_original_position : Vector2 = Vector2.ZERO
|
||||
var character_movement_range = 5
|
||||
|
||||
|
||||
|
||||
func new_character(chara):
|
||||
|
||||
# don't allow non-character characters
|
||||
if not chara.is_in_group("OnMap"):
|
||||
return
|
||||
|
||||
# clear the movement queue upon a change in character
|
||||
movement_queue = []
|
||||
|
||||
# set the character's map postiton
|
||||
chara.map_position = $TileMap.world_to_map(chara.position)
|
||||
chara.target_position = $TileMap.map_to_world(chara.map_position)
|
||||
chara.target_position += $TileMap.cell_size/2
|
||||
|
||||
# set the original_position
|
||||
character_original_position = chara.map_position
|
||||
|
||||
character = chara
|
||||
|
||||
|
||||
func character_movement_input():
|
||||
if Input.is_action_just_pressed("ui_up"):
|
||||
movement_queue.append(Vector2.UP)
|
||||
if Input.is_action_just_pressed("ui_down"):
|
||||
movement_queue.append(Vector2.DOWN)
|
||||
if Input.is_action_just_pressed("ui_left"):
|
||||
movement_queue.append(Vector2.LEFT)
|
||||
if Input.is_action_just_pressed("ui_right"):
|
||||
movement_queue.append(Vector2.RIGHT)
|
||||
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
emit_signal("scene_finished")
|
||||
|
||||
|
||||
func character_movement():
|
||||
#remove uneeded inputs from the queue
|
||||
for i in len(movement_queue) - 1:
|
||||
#remove if adjacent values are opposites
|
||||
if (movement_queue[i].x * movement_queue[i+1].x == -1 or
|
||||
movement_queue[i].y * movement_queue[i+1].y == -1):
|
||||
movement_queue[i] = Vector2.ZERO
|
||||
movement_queue[i+1] = Vector2.ZERO
|
||||
#remove null values
|
||||
for i in len(movement_queue):
|
||||
if movement_queue.find(Vector2.ZERO) != -1:
|
||||
movement_queue.remove(movement_queue.find(Vector2.ZERO))
|
||||
|
||||
if len(movement_queue) == 0:
|
||||
return
|
||||
|
||||
if not character.moving:
|
||||
|
||||
var total_distance = character.map_position + movement_queue[0]
|
||||
total_distance -= character_original_position
|
||||
|
||||
#if the character is moving too far, cancel movement and empty queue
|
||||
if total_distance.length() > character_movement_range:
|
||||
movement_queue = []
|
||||
return
|
||||
|
||||
#move the character once space in the queue if not moving
|
||||
character.map_position += movement_queue.pop_front()
|
||||
character.target_position = $TileMap.map_to_world(character.map_position)
|
||||
character.target_position += $TileMap.cell_size/2
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
if not active:
|
||||
return
|
||||
|
||||
character_movement()
|
||||
character_movement_input()
|
48
Scenes/Battle.tscn
Normal file
48
Scenes/Battle.tscn
Normal file
@ -0,0 +1,48 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Assets/TestTile.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Scenes/Battle.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="TileSet" id=1]
|
||||
0/name = "icon.png 0"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 8, 4, 51, 19 )
|
||||
0/tile_mode = 0
|
||||
0/occluder_offset = Vector2( 0, 0 )
|
||||
0/navigation_offset = Vector2( 0, 0 )
|
||||
0/shape_offset = Vector2( 0, 0 )
|
||||
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
0/shape_one_way = false
|
||||
0/shape_one_way_margin = 0.0
|
||||
0/shapes = [ ]
|
||||
0/z_index = 0
|
||||
1/name = "TestTile.png 1"
|
||||
1/texture = ExtResource( 2 )
|
||||
1/tex_offset = Vector2( 16, 0 )
|
||||
1/modulate = Color( 1, 1, 1, 1 )
|
||||
1/region = Rect2( 0, 0, 160, 64 )
|
||||
1/tile_mode = 0
|
||||
1/occluder_offset = Vector2( 0, 0 )
|
||||
1/navigation_offset = Vector2( 0, 0 )
|
||||
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 = 0.0
|
||||
1/shapes = [ ]
|
||||
1/z_index = 0
|
||||
|
||||
[node name="Battle" type="Node2D"]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="."]
|
||||
mode = 2
|
||||
tile_set = SubResource( 1 )
|
||||
cell_size = Vector2( 128, 64 )
|
||||
cell_custom_transform = Transform2D( 128, 0, 32, 64, 0, 0 )
|
||||
centered_textures = true
|
||||
format = 1
|
||||
tile_data = PoolIntArray( 65538, 1, 0, 65539, 1, 0, 65540, 1, 0, 65541, 1, 0, 131074, 1, 0, 131075, 1, 0, 131076, 1, 0, 131077, 1, 0, 131078, 0, 0, 196610, 1, 0, 196611, 1, 0, 196612, 1, 0, 196613, 1, 0, 196614, 0, 0, 262144, 0, 0, 262145, 0, 0, 262146, 1, 0, 262147, 1, 0, 262148, 1, 0, 262149, 0, 0, 262150, 0, 0, 327681, 0, 0, 327682, 0, 0, 327683, 0, 0, 327684, 0, 0, 327685, 0, 0, 327686, 0, 0, 393217, 0, 0, 393218, 0, 0, 393219, 0, 0, 393220, 0, 0, 393221, 0, 0, 393222, 0, 0, 458754, 0, 0, 458755, 0, 0, 458756, 0, 0, 458757, 0, 0, 524291, 0, 0, 524292, 0, 0 )
|
@ -1,121 +1,7 @@
|
||||
extends Node2D
|
||||
|
||||
var movement_queue = []
|
||||
|
||||
var player_to_move : bool = false
|
||||
var player_original_position : Vector2 = Vector2.ZERO
|
||||
var player_movement_range = 5
|
||||
extends Node
|
||||
|
||||
|
||||
func _ready():
|
||||
# start with the DiceView being selected
|
||||
$UI/DiceView.selected = true
|
||||
$UI/CardView.selected = false
|
||||
self.player_to_move = false
|
||||
|
||||
$UI/CardView.draw_card("Broadsword")
|
||||
$UI/CardView.draw_card("Sprint")
|
||||
$UI/CardView.draw_card("Magic Carving Knife")
|
||||
|
||||
$UI/DiceView.roll_dice()
|
||||
$UI/DiceView.roll_dice()
|
||||
$UI/DiceView.roll_dice()
|
||||
|
||||
|
||||
# generate all of the OnTile nodes's tile positions
|
||||
for child in get_children():
|
||||
if child.is_in_group("OnMap"):
|
||||
child.map_position = $TileMap.world_to_map(child.position)
|
||||
child.target_position = $TileMap.map_to_world(child.map_position)
|
||||
child.target_position += $TileMap.cell_size/2
|
||||
|
||||
|
||||
func do_damage_around_player(damage, damage_range):
|
||||
for enemy in get_children():
|
||||
|
||||
if not enemy.is_in_group("Enemy"):
|
||||
continue
|
||||
|
||||
if ($Player.map_position - enemy.map_position).length() > damage_range:
|
||||
continue
|
||||
|
||||
enemy.take_damage(damage)
|
||||
|
||||
func do_effect_around_player(effect, effect_range):
|
||||
pass
|
||||
|
||||
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
|
||||
player_movement()
|
||||
|
||||
# note down the player position before moving
|
||||
if not player_to_move:
|
||||
player_original_position = $Player.map_position
|
||||
|
||||
# if the player needs to move, allow the input to be for the player
|
||||
if player_to_move:
|
||||
player_movement_input()
|
||||
return
|
||||
|
||||
# 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
|
||||
|
||||
# if all 3 parts are done, select the DiceView again
|
||||
if ($UI/DiceView.selected == false and
|
||||
$UI/CardView.selected == false and
|
||||
self.player_to_move == false):
|
||||
|
||||
$UI/DiceView.selected = true
|
||||
|
||||
|
||||
func player_movement_input():
|
||||
if Input.is_action_just_pressed("ui_up"):
|
||||
movement_queue.append(Vector2.UP)
|
||||
if Input.is_action_just_pressed("ui_down"):
|
||||
movement_queue.append(Vector2.DOWN)
|
||||
if Input.is_action_just_pressed("ui_left"):
|
||||
movement_queue.append(Vector2.LEFT)
|
||||
if Input.is_action_just_pressed("ui_right"):
|
||||
movement_queue.append(Vector2.RIGHT)
|
||||
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
player_to_move = false
|
||||
|
||||
|
||||
func player_movement():
|
||||
#remove uneeded inputs from the queue
|
||||
for i in len(movement_queue) - 1:
|
||||
#remove if adjacent values are opposites
|
||||
if (movement_queue[i].x * movement_queue[i+1].x == -1 or
|
||||
movement_queue[i].y * movement_queue[i+1].y == -1):
|
||||
movement_queue[i] = Vector2.ZERO
|
||||
movement_queue[i+1] = Vector2.ZERO
|
||||
#remove null values
|
||||
for i in len(movement_queue):
|
||||
if movement_queue.find(Vector2.ZERO) != -1:
|
||||
movement_queue.remove(movement_queue.find(Vector2.ZERO))
|
||||
|
||||
if len(movement_queue) == 0:
|
||||
return
|
||||
|
||||
if not $Player.moving:
|
||||
#if the player is moving too far, cancel movement and empty queue
|
||||
if (($Player.map_position + movement_queue[0]
|
||||
- player_original_position).length() > player_movement_range):
|
||||
movement_queue = []
|
||||
return
|
||||
|
||||
#move the character once space in the queue if not moving
|
||||
$Player.map_position += movement_queue.pop_front()
|
||||
$Player.target_position = $TileMap.map_to_world($Player.map_position)
|
||||
$Player.target_position += $TileMap.cell_size/2
|
||||
$"%Battle".character = $Player
|
||||
$"%CardContainer".character = $Player
|
||||
$"%DiceContainer".character = $Player
|
||||
|
@ -1,93 +1,41 @@
|
||||
[gd_scene load_steps=9 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Scenes/Battle.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Characters/Player.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Scenes/BattleScene.gd" type="Script" id=3]
|
||||
[ext_resource path="res://UI/CardView.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://UI/DiceView.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://Assets/TestTile.png" type="Texture" id=6]
|
||||
[ext_resource path="res://Characters/Enemy.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://UI/CardContainer.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://UI/DiceContainer.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://UI/Card.gd" type="Script" id=6]
|
||||
[ext_resource path="res://Assets/CardDB/Broadsword.tres" type="Resource" id=7]
|
||||
[ext_resource path="res://Management/ActiveController.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://Assets/CardDB/Poisonous apple.tres" type="Resource" id=9]
|
||||
|
||||
[sub_resource type="TileSet" id=1]
|
||||
0/name = "icon.png 0"
|
||||
0/texture = ExtResource( 1 )
|
||||
0/tex_offset = Vector2( 0, 0 )
|
||||
0/modulate = Color( 1, 1, 1, 1 )
|
||||
0/region = Rect2( 8, 4, 51, 19 )
|
||||
0/tile_mode = 0
|
||||
0/occluder_offset = Vector2( 0, 0 )
|
||||
0/navigation_offset = Vector2( 0, 0 )
|
||||
0/shape_offset = Vector2( 0, 0 )
|
||||
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
0/shape_one_way = false
|
||||
0/shape_one_way_margin = 0.0
|
||||
0/shapes = [ ]
|
||||
0/z_index = 0
|
||||
1/name = "TestTile.png 1"
|
||||
1/texture = ExtResource( 6 )
|
||||
1/tex_offset = Vector2( 16, 0 )
|
||||
1/modulate = Color( 1, 1, 1, 1 )
|
||||
1/region = Rect2( 0, 0, 160, 64 )
|
||||
1/tile_mode = 0
|
||||
1/occluder_offset = Vector2( 0, 0 )
|
||||
1/navigation_offset = Vector2( 0, 0 )
|
||||
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 = 0.0
|
||||
1/shapes = [ ]
|
||||
1/z_index = 0
|
||||
|
||||
[node name="BattleScene" type="Node2D"]
|
||||
[node name="BattleScene" type="Node"]
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="."]
|
||||
mode = 2
|
||||
tile_set = SubResource( 1 )
|
||||
cell_size = Vector2( 128, 64 )
|
||||
cell_custom_transform = Transform2D( 128, 0, 32, 64, 0, 0 )
|
||||
centered_textures = true
|
||||
format = 1
|
||||
tile_data = PoolIntArray( 65538, 1, 0, 65539, 1, 0, 65540, 1, 0, 65541, 1, 0, 131074, 1, 0, 131075, 1, 0, 131076, 1, 0, 131077, 1, 0, 131078, 0, 0, 196610, 1, 0, 196611, 1, 0, 196612, 1, 0, 196613, 1, 0, 196614, 0, 0, 262144, 0, 0, 262145, 0, 0, 262146, 1, 0, 262147, 1, 0, 262148, 1, 0, 262149, 0, 0, 262150, 0, 0, 327681, 0, 0, 327682, 0, 0, 327683, 0, 0, 327684, 0, 0, 327685, 0, 0, 327686, 0, 0, 393217, 0, 0, 393218, 0, 0, 393219, 0, 0, 393220, 0, 0, 393221, 0, 0, 393222, 0, 0, 458754, 0, 0, 458755, 0, 0, 458756, 0, 0, 458757, 0, 0, 524291, 0, 0, 524292, 0, 0 )
|
||||
[node name="ActiveController" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
[node name="Battle" parent="ActiveController" instance=ExtResource( 1 )]
|
||||
|
||||
[node name="CardContainer" parent="ActiveController" instance=ExtResource( 4 )]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 351.0
|
||||
margin_right = -425.0
|
||||
|
||||
[node name="DiceContainer" parent="ActiveController" instance=ExtResource( 5 )]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 782.0
|
||||
margin_top = 375.0
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||
position = Vector2( 195, 283 )
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="Player"]
|
||||
offset = Vector2( 0, 200 )
|
||||
current = true
|
||||
drag_margin_h_enabled = true
|
||||
drag_margin_v_enabled = true
|
||||
drag_margin_left = 0.3
|
||||
drag_margin_top = 0.05
|
||||
drag_margin_right = 0.3
|
||||
[node name="Card1" type="Node" parent="Player"]
|
||||
script = ExtResource( 6 )
|
||||
card_info = ExtResource( 7 )
|
||||
|
||||
[node name="Enemy" parent="." instance=ExtResource( 7 )]
|
||||
position = Vector2( 565, 218 )
|
||||
[node name="Card2" type="Node" parent="Player"]
|
||||
script = ExtResource( 6 )
|
||||
|
||||
[node name="Enemy2" parent="." instance=ExtResource( 7 )]
|
||||
position = Vector2( 916, 218 )
|
||||
|
||||
[node name="Enemy3" parent="." instance=ExtResource( 7 )]
|
||||
position = Vector2( 1140, 630 )
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="CardView" parent="UI" instance=ExtResource( 4 )]
|
||||
anchor_top = 0.509722
|
||||
anchor_right = 0.754687
|
||||
margin_top = -7.62939e-06
|
||||
margin_right = 1.52588e-05
|
||||
|
||||
[node name="DiceView" parent="UI" instance=ExtResource( 5 )]
|
||||
anchor_left = 0.754687
|
||||
anchor_top = 0.509722
|
||||
margin_left = 1.52588e-05
|
||||
margin_top = -7.62939e-06
|
||||
grow_horizontal = 0
|
||||
|
||||
[connection signal="do_damage" from="UI/CardView" to="." method="do_damage_around_player"]
|
||||
[connection signal="do_effect" from="UI/CardView" to="." method="do_effect_around_player"]
|
||||
[connection signal="do_movement" from="UI/CardView" to="." method="set_player_to_move"]
|
||||
[connection signal="return_dice" from="UI/CardView" to="UI/DiceView" method="roll_dice"]
|
||||
[connection signal="dice_selected" from="UI/DiceView" to="UI/CardView" method="set_currently_holding_dice"]
|
||||
[node name="Card3" type="Node" parent="Player"]
|
||||
script = ExtResource( 6 )
|
||||
card_info = ExtResource( 9 )
|
||||
|
109
UI/Card.gd
109
UI/Card.gd
@ -1,90 +1,16 @@
|
||||
tool
|
||||
extends Control
|
||||
extends Node
|
||||
class_name Card
|
||||
|
||||
signal return_dice(dice_number)
|
||||
signal do_movement(movement_range)
|
||||
signal do_damage(damage, damage_range)
|
||||
signal do_effect(effect, effect_range)
|
||||
signal card_removed(card_self)
|
||||
signal card_removed()
|
||||
|
||||
const TYPE_COLORS = [
|
||||
Color("#db4758"), # DAMAGE
|
||||
Color("#3cc361"), # UTILITY
|
||||
Color("#bcb64f"), # SPECIAL
|
||||
Color("#bc5ec6"), # EFFECT
|
||||
Color("#a4a4a4"), # MOVEMENT
|
||||
]
|
||||
|
||||
const dice_node = preload("res://UI/Dice.tscn")
|
||||
const dice_texture_string : String = "res://Assets/Dice/Dice%s.png"
|
||||
|
||||
export (Resource) var card_info
|
||||
export (Resource) var card_info = preload("res://Assets/CardDB/Default.tres")
|
||||
|
||||
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):
|
||||
var input_dice0 = $VBox/AutoGrid.get_node_from_grid("InputDice0")
|
||||
|
||||
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 = input_dice0.get_children()
|
||||
if len(input_dice_children) <= 1:
|
||||
return
|
||||
var old_dice = input_dice_children[1]
|
||||
input_dice0.remove_child(old_dice)
|
||||
return
|
||||
|
||||
var new_dice = dice_node.instance()
|
||||
new_dice.dice_value = dice_value
|
||||
input_dice0.add_child(new_dice)
|
||||
|
||||
|
||||
func _set_addition_dice(new_amount):
|
||||
addition_dice_amount = new_amount
|
||||
$VBox/AutoGrid.get_node_from_grid("InputDice0").get_child("Number").text = String(new_amount)
|
||||
|
||||
|
||||
func _ready():
|
||||
|
||||
# change the color of the panel to match the appropriate type
|
||||
var card_style = $PanelContainer.get('custom_styles/panel').duplicate(true)
|
||||
card_style.set_bg_color(TYPE_COLORS[card_info.type])
|
||||
$PanelContainer.set('custom_styles/panel', card_style)
|
||||
|
||||
# add more input dice if needed
|
||||
for i in range(1, card_info.number_of_dice):
|
||||
var new_input_dice = get_node("VBox/AutoGrid/InputDice0").duplicate(true)
|
||||
new_input_dice.name = "InputDice%s" % i
|
||||
$VBox/AutoGrid.add_child(new_input_dice)
|
||||
|
||||
# change the name and description
|
||||
$VBox/Name.text = card_info.name
|
||||
$VBox/Description.text = card_info.description
|
||||
|
||||
#maybe set the addition amount
|
||||
if card_info.addition_dice:
|
||||
self.addition_dice_amount = card_info.addition_amount
|
||||
|
||||
# show the requirements for a dice
|
||||
# TODO more difference from addition, smaller font, >, <, etc.
|
||||
if len(card_info.accepted_dice) != 0:
|
||||
var dice_string : String = ""
|
||||
for num in card_info.accepted_dice:
|
||||
dice_string += String(num)
|
||||
dice_string += ","
|
||||
|
||||
dice_string = dice_string.trim_suffix(",")
|
||||
|
||||
$VBox/AutoGrid/InputDice0/Number.text = dice_string
|
||||
|
||||
var addition_dice_amount = card_info.addition_amount
|
||||
|
||||
func dice_inputted(dice_number):
|
||||
|
||||
@ -122,20 +48,19 @@ func dice_inputted(dice_number):
|
||||
input_dice.remove(0)
|
||||
|
||||
|
||||
# Put the Dice in the slot
|
||||
var input_dice0 = $VBox/AutoGrid.get_node_from_grid("InputDice0")
|
||||
input_dice0.texture = load(dice_texture_string % dice_number)
|
||||
|
||||
|
||||
# -- RUN DICE CHECKS --
|
||||
if card_info.addition_dice:
|
||||
self.addition_dice_amount -= dice_number
|
||||
input_dice.remove(0)
|
||||
if addition_dice_amount > 0:
|
||||
return
|
||||
else:
|
||||
run_card()
|
||||
|
||||
# if the addition type, then lower the counter by the input dice
|
||||
# also check (and run) if the amount is reaches and
|
||||
if card_info.addition_dice:
|
||||
|
||||
addition_dice_amount -= dice_number
|
||||
|
||||
if addition_dice_amount <= 0:
|
||||
run_card()
|
||||
return
|
||||
|
||||
# run the card if the correct number of dice have been inputted (and normal dice)
|
||||
if (len(input_dice) == card_info.number_of_dice
|
||||
and not card_info.addition_dice):
|
||||
run_card()
|
||||
@ -213,6 +138,6 @@ func run_card():
|
||||
input_dice = []
|
||||
|
||||
#card is used, disappear
|
||||
emit_signal("card_removed", self)
|
||||
emit_signal("card_removed")
|
||||
queue_free()
|
||||
|
||||
|
100
UI/Card.tscn
100
UI/Card.tscn
@ -1,100 +0,0 @@
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://UI/Card.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Assets/CardDB/Default.tres" type="Resource" id=2]
|
||||
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Bold.ttf" type="DynamicFontData" id=3]
|
||||
[ext_resource path="res://Assets/DiceInput.png" type="Texture" id=4]
|
||||
[ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Medium.ttf" type="DynamicFontData" id=6]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=8]
|
||||
bg_color = Color( 0.858824, 0.278431, 0.345098, 1 )
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 20
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[sub_resource type="DynamicFontData" id=4]
|
||||
font_path = "res://Assets/Metropolis-font/Metropolis-Bold.ttf"
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
size = 30
|
||||
use_filter = true
|
||||
font_data = SubResource( 4 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=7]
|
||||
size = 64
|
||||
use_filter = true
|
||||
font_data = ExtResource( 6 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=5]
|
||||
size = 20
|
||||
use_filter = true
|
||||
font_data = ExtResource( 3 )
|
||||
|
||||
[node name="Card" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
card_info = ExtResource( 2 )
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_styles/panel = SubResource( 8 )
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -10.0
|
||||
|
||||
[node name="Name" type="Label" parent="VBox"]
|
||||
margin_right = 1260.0
|
||||
margin_bottom = 31.0
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
text = "Default"
|
||||
align = 1
|
||||
autowrap = true
|
||||
|
||||
[node name="AutoGrid" parent="VBox" instance=ExtResource( 5 )]
|
||||
margin_top = 35.0
|
||||
margin_right = 1260.0
|
||||
margin_bottom = 606.0
|
||||
|
||||
[node name="InputDice0" type="TextureRect" parent="VBox/AutoGrid"]
|
||||
margin_left = 42.0
|
||||
margin_top = 5.0
|
||||
margin_right = 192.0
|
||||
margin_bottom = 155.0
|
||||
rect_min_size = Vector2( 75, 75 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
texture = ExtResource( 4 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="Number" type="Label" parent="VBox/AutoGrid/InputDice0"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
custom_fonts/font = SubResource( 7 )
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="Description" type="Label" parent="VBox"]
|
||||
margin_top = 610.0
|
||||
margin_right = 1260.0
|
||||
margin_bottom = 700.0
|
||||
rect_min_size = Vector2( 0, 90 )
|
||||
custom_fonts/font = SubResource( 5 )
|
||||
text = "Default Description"
|
||||
align = 1
|
||||
valign = 1
|
||||
autowrap = true
|
27
UI/CardContainer.tscn
Normal file
27
UI/CardContainer.tscn
Normal file
@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://UI/CardView.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://UI/ItemContainer.gd" type="Script" id=2]
|
||||
|
||||
[node name="CardContainer" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 2 )
|
||||
item_view_scene = ExtResource( 1 )
|
||||
child_holder = NodePath("Margin/HBox")
|
||||
character_property = "cards"
|
||||
view_property = "card"
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 30.0
|
||||
margin_top = 30.0
|
||||
margin_right = -30.0
|
||||
margin_bottom = -30.0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Margin"]
|
||||
margin_right = 1220.0
|
||||
margin_bottom = 660.0
|
||||
rect_min_size = Vector2( 0, 300 )
|
||||
custom_constants/separation = 50
|
192
UI/CardView.gd
192
UI/CardView.gd
@ -1,106 +1,136 @@
|
||||
extends Control
|
||||
|
||||
signal return_dice(dice_number)
|
||||
signal do_movement(movement_range)
|
||||
signal do_damage(damage, damage_range)
|
||||
signal do_effect(effect, effect_range)
|
||||
signal card_view_removed(card_view)
|
||||
|
||||
const card = preload("res://UI/Card.tscn")
|
||||
const card_db_string = "res://Assets/CardDB/%s.tres"
|
||||
const TYPE_COLORS = [
|
||||
Color("#db4758"), # DAMAGE
|
||||
Color("#3cc361"), # UTILITY
|
||||
Color("#bcb64f"), # SPECIAL
|
||||
Color("#bc5ec6"), # EFFECT
|
||||
Color("#a4a4a4"), # MOVEMENT
|
||||
]
|
||||
|
||||
const input_dice_view = preload("res://UI/InputDiceView.tscn")
|
||||
var input_dice_views = []
|
||||
|
||||
var hovering : bool = false setget set_hovering
|
||||
|
||||
var card : Card = Card.new() setget update_cardview
|
||||
|
||||
|
||||
var selected : bool = false
|
||||
var hovering_card = null
|
||||
func update_cardview(new_card = null):
|
||||
|
||||
var current_cards = []
|
||||
# allow the update card function to work with and without setget
|
||||
if new_card != null and new_card != card:
|
||||
disconnect_signals()
|
||||
card = new_card
|
||||
connect_signals()
|
||||
|
||||
var currently_holding_dice = null
|
||||
# change the color of the panel to match the appropriate type
|
||||
var card_style = $"%Background".get('custom_styles/panel').duplicate(true)
|
||||
card_style.set_bg_color(TYPE_COLORS[card.card_info.type])
|
||||
$"%Background".set('custom_styles/panel', card_style)
|
||||
|
||||
# change the name and description
|
||||
$"%Name".text = card.card_info.name
|
||||
$"%Description".text = card.card_info.description
|
||||
|
||||
# remove the old input dice views
|
||||
for i in input_dice_views:
|
||||
i.queue_free()
|
||||
input_dice_views = []
|
||||
|
||||
# add the correct number of input dice views
|
||||
for i in card.card_info.number_of_dice:
|
||||
add_input_dice_view()
|
||||
|
||||
# set the extra info
|
||||
var extra_text = ""
|
||||
if card.card_info.addition_dice == true:
|
||||
# set the dice to have the remaining addition
|
||||
extra_text = str(card.addition_dice_amount)
|
||||
|
||||
else:
|
||||
# set the dice to have a list of accepted dice
|
||||
for dice in card.card_info.accepted_dice:
|
||||
extra_text += str(dice) + ", "
|
||||
extra_text = extra_text.trim_suffix(", ")
|
||||
|
||||
for i in input_dice_views:
|
||||
i.set_extra_info(extra_text)
|
||||
|
||||
# set bold dice if addition dice
|
||||
if card.card_info.addition_dice == true:
|
||||
for i in input_dice_views:
|
||||
i.bold = true
|
||||
|
||||
#TODO: same dice UI support
|
||||
#TODO: hover UI support maybe
|
||||
|
||||
|
||||
func emit_return_dice(dice_number):
|
||||
emit_signal("return_dice", dice_number)
|
||||
func emit_do_movement(movement_range):
|
||||
emit_signal("do_movement", movement_range)
|
||||
func emit_do_damage(damage, damage_range):
|
||||
emit_signal("do_damage", damage, damage_range)
|
||||
func emit_do_effect(effect, effect_range):
|
||||
emit_signal("do_effect", effect, effect_range)
|
||||
# add an input_dice_view to the array (for easy management)
|
||||
# and to the autogrid
|
||||
func add_input_dice_view():
|
||||
var dice_view = input_dice_view.instance()
|
||||
input_dice_views.append(dice_view)
|
||||
$"%AutoGrid".add_child(dice_view)
|
||||
|
||||
|
||||
func set_currently_holding_dice(dice_number : int):
|
||||
currently_holding_dice = dice_number
|
||||
# this is run once the card emits card_removed
|
||||
func card_view_run(do_emit_signal : bool = true):
|
||||
# emit card_view_removed signal
|
||||
if do_emit_signal: emit_signal("card_view_removed", self)
|
||||
|
||||
# play the disappearing input dice animation
|
||||
play_input_dice_animations()
|
||||
|
||||
# play the using animation
|
||||
$AnimationPlayer.play("Fly Off")
|
||||
yield($AnimationPlayer, "animation_finished")
|
||||
|
||||
# remove the card completely once used
|
||||
queue_free()
|
||||
|
||||
|
||||
func remove_card(card):
|
||||
var card_index = current_cards.find(card)
|
||||
current_cards.remove(card_index)
|
||||
func card_view_remove(do_emit_signal : bool = true):
|
||||
# emit card_view_removed signal
|
||||
if do_emit_signal: emit_signal("card_view_removed", self)
|
||||
|
||||
# play the remove animation
|
||||
$AnimationPlayer.play("Drop Off")
|
||||
yield($AnimationPlayer, "animation_finished")
|
||||
|
||||
# remove the card completely once used
|
||||
queue_free()
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
func play_input_dice_animations():
|
||||
for i in input_dice_views:
|
||||
i.run_disappear_animation()
|
||||
|
||||
# no keyboard input if not selected
|
||||
if not selected:
|
||||
hovering_card = null
|
||||
|
||||
func disconnect_signals():
|
||||
if card.get_signal_connection_list("card_removed") == []:
|
||||
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].hovering_dice = null
|
||||
current_cards[hovering_card].dice_inputted(currently_holding_dice)
|
||||
hovering_card = 0
|
||||
selected = false
|
||||
card.disconnect("card_removed", self, "card_view_run")
|
||||
|
||||
|
||||
func draw_card(specific_card : String = ""):
|
||||
# make a new card instance and add it to the grid container
|
||||
var new_card = card.instance()
|
||||
func connect_signals():
|
||||
card.connect("card_removed", self, "card_view_run")
|
||||
|
||||
# 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")
|
||||
func set_hovering(value : bool):
|
||||
# set the hovering value
|
||||
hovering = value
|
||||
|
||||
$Margin/HBox.add_child(new_card)
|
||||
# wait until the old animation is finished
|
||||
if ($AnimationPlayer.current_animation != "Hovering"
|
||||
and $AnimationPlayer.current_animation != ""):
|
||||
yield($AnimationPlayer, "animation_finished")
|
||||
|
||||
# connect new_card.x signal to self.x
|
||||
new_card.connect("return_dice", self, "emit_return_dice")
|
||||
new_card.connect("do_movement", self, "emit_do_movement")
|
||||
new_card.connect("do_damage", self, "emit_do_damage")
|
||||
new_card.connect("do_effect", self, "emit_do_effect")
|
||||
if hovering:
|
||||
$AnimationPlayer.play("Hovering")
|
||||
|
||||
# connect the signal remove card signal
|
||||
new_card.connect("card_removed", self, "remove_card")
|
||||
|
||||
# add the current card to the list of card
|
||||
current_cards.append(new_card)
|
||||
if not hovering:
|
||||
$AnimationPlayer.play("RESET")
|
||||
|
193
UI/CardView.tscn
193
UI/CardView.tscn
@ -1,22 +1,189 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://UI/CardView.gd" type="Script" id=5]
|
||||
[ext_resource path="res://UI/CardView.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Assets/Metropolis-font/Metropolis-Bold.ttf" type="DynamicFontData" id=4]
|
||||
[ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=6]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=9]
|
||||
bg_color = Color( 0.858824, 0.278431, 0.345098, 1 )
|
||||
corner_radius_top_left = 20
|
||||
corner_radius_top_right = 20
|
||||
corner_radius_bottom_right = 20
|
||||
corner_radius_bottom_left = 20
|
||||
|
||||
[sub_resource type="DynamicFontData" id=4]
|
||||
font_path = "res://Assets/Metropolis-font/Metropolis-Bold.ttf"
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
size = 30
|
||||
use_filter = true
|
||||
font_data = SubResource( 4 )
|
||||
|
||||
[sub_resource type="DynamicFont" id=5]
|
||||
size = 20
|
||||
use_filter = true
|
||||
font_data = ExtResource( 4 )
|
||||
|
||||
[sub_resource type="Animation" id=10]
|
||||
resource_name = "Drop Off"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("LocalPosition:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.5 ),
|
||||
"transitions": PoolRealArray( 0.297304, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, 800 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=7]
|
||||
resource_name = "Fly Off"
|
||||
length = 1.5
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("LocalPosition:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.4, 0.65, 1.3 ),
|
||||
"transitions": PoolRealArray( 0.647041, 0.647041, 4, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, 0 ), Vector2( 0, 20 ), Vector2( 0, -700 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath(".:rect_scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.65, 1.3 ),
|
||||
"transitions": PoolRealArray( 1, 6.06286, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ), Vector2( 1, 1 ), Vector2( 1, 1.4 ) ]
|
||||
}
|
||||
tracks/2/type = "method"
|
||||
tracks/2/path = NodePath(".")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"values": [ {
|
||||
"args": [ ],
|
||||
"method": "play_input_dice_animations"
|
||||
} ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=11]
|
||||
resource_name = "Hovering"
|
||||
length = 0.15
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("LocalPosition:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.15 ),
|
||||
"transitions": PoolRealArray( 6.9644, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, -40 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("LocalPosition:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath(".:rect_scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ) ]
|
||||
}
|
||||
|
||||
[node name="CardView" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 5 )
|
||||
margin_right = -965.0
|
||||
margin_bottom = -325.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
[node name="LocalPosition" type="Control" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 30.0
|
||||
margin_top = 30.0
|
||||
margin_right = -30.0
|
||||
margin_bottom = -30.0
|
||||
margin_bottom = 6.10352e-05
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Margin"]
|
||||
margin_right = 1220.0
|
||||
margin_bottom = 660.0
|
||||
rect_min_size = Vector2( 0, 300 )
|
||||
custom_constants/separation = 50
|
||||
[node name="Background" type="PanelContainer" parent="LocalPosition"]
|
||||
unique_name_in_owner = true
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_styles/panel = SubResource( 9 )
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="LocalPosition"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 10.0
|
||||
margin_top = 10.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = -10.0
|
||||
|
||||
[node name="Name" type="Label" parent="LocalPosition/VBox"]
|
||||
unique_name_in_owner = true
|
||||
margin_right = 295.0
|
||||
margin_bottom = 31.0
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
text = "Default"
|
||||
align = 1
|
||||
autowrap = true
|
||||
|
||||
[node name="AutoGrid" parent="LocalPosition/VBox" instance=ExtResource( 6 )]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 35.0
|
||||
margin_right = 295.0
|
||||
margin_bottom = 281.0
|
||||
|
||||
[node name="Description" type="Label" parent="LocalPosition/VBox"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 285.0
|
||||
margin_right = 295.0
|
||||
margin_bottom = 375.0
|
||||
rect_min_size = Vector2( 0, 90 )
|
||||
custom_fonts/font = SubResource( 5 )
|
||||
text = "Default Description"
|
||||
align = 1
|
||||
valign = 1
|
||||
autowrap = true
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
"anims/Drop Off" = SubResource( 10 )
|
||||
"anims/Fly Off" = SubResource( 7 )
|
||||
anims/Hovering = SubResource( 11 )
|
||||
anims/RESET = SubResource( 8 )
|
||||
|
31
UI/Dice.gd
31
UI/Dice.gd
@ -1,31 +0,0 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
const dice_image_string = "res://Assets/Dice/Dice%s.png"
|
||||
const selected_shader = preload("res://UI/RainbowOutline.tres")
|
||||
|
||||
export (int, 0, 6) var dice_value : int = 0
|
||||
export var selected : bool setget _set_selected
|
||||
|
||||
|
||||
func _set_selected(new_value):
|
||||
selected = new_value
|
||||
if selected:
|
||||
self.material = selected_shader
|
||||
else:
|
||||
self.material = null
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
self.texture = load(dice_image_string % dice_value)
|
||||
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
||||
if dice_value == 0:
|
||||
self.dice_value = int(round(rand_range(0.5, 6.49999999)))
|
||||
|
||||
_physics_process(0)
|
||||
|
||||
|
14
UI/Dice.tscn
14
UI/Dice.tscn
@ -1,14 +0,0 @@
|
||||
[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"]
|
||||
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 )
|
26
UI/DiceContainer.tscn
Normal file
26
UI/DiceContainer.tscn
Normal file
@ -0,0 +1,26 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://UI/ItemContainer.gd" type="Script" id=2]
|
||||
[ext_resource path="res://UI/DiceView.tscn" type="PackedScene" id=3]
|
||||
|
||||
[node name="DiceContainer" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 2 )
|
||||
item_view_scene = ExtResource( 3 )
|
||||
child_holder = NodePath("Margin/AutoGrid")
|
||||
character_property = "dice"
|
||||
view_property = "dice_value"
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 30.0
|
||||
margin_top = 30.0
|
||||
margin_right = -30.0
|
||||
margin_bottom = -30.0
|
||||
|
||||
[node name="AutoGrid" parent="Margin" instance=ExtResource( 1 )]
|
||||
margin_right = 1220.0
|
||||
margin_bottom = 660.0
|
@ -1,72 +1,22 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
signal dice_selected (dice_value)
|
||||
const dice_image_string = "res://Assets/Dice/Dice%s.png"
|
||||
const hovering_shader = preload("res://UI/RainbowOutline.tres")
|
||||
|
||||
const dice = preload("res://UI/Dice.tscn")
|
||||
|
||||
var selected : bool = false
|
||||
var selected_dice = null
|
||||
|
||||
var current_dice = []
|
||||
export (int, 0, 6) var dice_value : int = 0
|
||||
export var hovering : bool setget set_hovering
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
# no keyboard input if not selected
|
||||
if not selected:
|
||||
selected_dice = null
|
||||
return
|
||||
|
||||
# skip turn if the list is empty
|
||||
if len(current_dice) == 0:
|
||||
selected = false
|
||||
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")):
|
||||
|
||||
current_dice[selected_dice].selected = false
|
||||
|
||||
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")):
|
||||
|
||||
current_dice[selected_dice].selected = false
|
||||
|
||||
selected_dice -= 1
|
||||
if selected_dice < 0:
|
||||
selected_dice = len(current_dice) -1
|
||||
|
||||
# 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 set_hovering(new_value):
|
||||
hovering = new_value
|
||||
if hovering:
|
||||
self.material = hovering_shader
|
||||
else:
|
||||
self.material = null
|
||||
|
||||
|
||||
func roll_dice(specific_value : int = 0):
|
||||
# make a new dice instance and add it to the grid container
|
||||
var new_dice = dice.instance()
|
||||
$Margin/AutoGrid.add_child(new_dice)
|
||||
func _physics_process(_delta):
|
||||
self.texture = load(dice_image_string % dice_value)
|
||||
|
||||
# if a specifc dice choosen, make new dice that type
|
||||
if specific_value in [1, 2, 3, 4, 5, 6]:
|
||||
new_dice.dice_value = specific_value
|
||||
|
||||
# add the current dice to the list of dice
|
||||
current_dice.append(new_dice)
|
||||
|
@ -1,21 +1,15 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://AutoGridContainer - Full Version/AutoGridContainer.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Assets/Dice/Dice6.png" type="Texture" id=1]
|
||||
[ext_resource path="res://UI/DiceView.gd" type="Script" id=2]
|
||||
|
||||
[node name="DiceView" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
[node name="DiceView" type="TextureRect"]
|
||||
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 )
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 30.0
|
||||
margin_top = 30.0
|
||||
margin_right = -30.0
|
||||
margin_bottom = -30.0
|
||||
|
||||
[node name="AutoGrid" parent="Margin" instance=ExtResource( 1 )]
|
||||
margin_right = 1220.0
|
||||
margin_bottom = 660.0
|
||||
dice_value = 6
|
||||
|
30
UI/InputDiceView.gd
Normal file
30
UI/InputDiceView.gd
Normal file
@ -0,0 +1,30 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
export var bold : bool setget set_bold
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
|
||||
# update the pivot offset to make sure the object's animations
|
||||
# are always centered
|
||||
$Sprite.rect_pivot_offset = rect_size/2
|
||||
$Particles2D.position = rect_size/2
|
||||
|
||||
|
||||
func set_extra_info(text : String):
|
||||
$"%ExtraInfo".text = text
|
||||
|
||||
|
||||
func set_bold(is_bold : bool = true):
|
||||
if is_bold:
|
||||
$Sprite.texture = load("res://Assets/DiceInputBold.png")
|
||||
else:
|
||||
$Sprite.texture = load("res://Assets/DiceInput.png")
|
||||
|
||||
bold = is_bold
|
||||
|
||||
|
||||
func run_disappear_animation():
|
||||
$AnimationPlayer.play("Disappear")
|
||||
yield($AnimationPlayer, "animation_finished")
|
180
UI/InputDiceView.tscn
Normal file
180
UI/InputDiceView.tscn
Normal file
@ -0,0 +1,180 @@
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Metropolis-font/Metropolis-SemiBold.ttf" type="DynamicFontData" id=1]
|
||||
[ext_resource path="res://Assets/DiceInput.png" type="Texture" id=2]
|
||||
[ext_resource path="res://UI/InputDiceView.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="Curve" id=10]
|
||||
_data = [ Vector2( 0, 0.121591 ), 0.0, 4.0026, 0, 0, Vector2( 1, 0 ), -1.48166, 0.0, 0, 0 ]
|
||||
|
||||
[sub_resource type="CurveTexture" id=11]
|
||||
curve = SubResource( 10 )
|
||||
|
||||
[sub_resource type="ParticlesMaterial" id=12]
|
||||
lifetime_randomness = 0.12
|
||||
flag_disable_z = true
|
||||
direction = Vector3( 0, 0, 0 )
|
||||
spread = 180.0
|
||||
gravity = Vector3( 0, 0, 0 )
|
||||
initial_velocity = 44.59
|
||||
orbit_velocity = 0.56
|
||||
orbit_velocity_random = 0.48
|
||||
linear_accel = -1.37
|
||||
radial_accel = -11.78
|
||||
scale = 0.01
|
||||
scale_curve = SubResource( 11 )
|
||||
hue_variation = 0.03
|
||||
hue_variation_random = 1.0
|
||||
|
||||
[sub_resource type="DynamicFont" id=7]
|
||||
size = 64
|
||||
use_filter = true
|
||||
font_data = ExtResource( 1 )
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
resource_name = "Disappear"
|
||||
length = 0.8
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:rect_scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.09, 0.11, 0.5 ),
|
||||
"transitions": PoolRealArray( 0.406125, 0.392292, 2.07053, 3.36359 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ), Vector2( 1.2, 1.2 ), Vector2( 1.2, 1.2 ), Vector2( 1e-05, 1e-05 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:rect_rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0, 0.09, 0.11, 0.5 ),
|
||||
"transitions": PoolRealArray( 0.406125, 0.392292, 2.92817, 3.36359 ),
|
||||
"update": 0,
|
||||
"values": [ 0.0, 55.0, 55.0, -155.0 ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Particles2D:emitting")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 1,
|
||||
"values": [ false, true ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("Sprite/ExtraInfo:modulate")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"times": PoolRealArray( 0, 0.25 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=9]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:rect_scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1, 1 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:rect_rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ 0.0 ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Particles2D:emitting")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ false ]
|
||||
}
|
||||
tracks/3/type = "value"
|
||||
tracks/3/path = NodePath("Sprite/ExtraInfo:modulate")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
|
||||
[node name="InputDiceView" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 75, 75 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Particles2D" type="Particles2D" parent="."]
|
||||
position = Vector2( 640, 360 )
|
||||
scale = Vector2( 5, 5 )
|
||||
emitting = false
|
||||
amount = 6
|
||||
lifetime = 0.75
|
||||
one_shot = true
|
||||
speed_scale = 2.0
|
||||
process_material = SubResource( 12 )
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="Sprite" type="TextureRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 640, 360 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
texture = ExtResource( 2 )
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="ExtraInfo" type="Label" parent="Sprite"]
|
||||
unique_name_in_owner = true
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
custom_fonts/font = SubResource( 7 )
|
||||
align = 1
|
||||
valign = 1
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/Disappear = SubResource( 8 )
|
||||
anims/RESET = SubResource( 9 )
|
80
UI/ItemContainer.gd
Normal file
80
UI/ItemContainer.gd
Normal file
@ -0,0 +1,80 @@
|
||||
extends Control
|
||||
|
||||
signal scene_finished
|
||||
signal scene_failed
|
||||
|
||||
var active : bool = false
|
||||
|
||||
export (PackedScene) var item_view_scene
|
||||
export (NodePath) var child_holder
|
||||
export (String) var character_property = "items"
|
||||
export (String) var view_property = "item"
|
||||
|
||||
var character : Character = Character.new() setget update_items_shown
|
||||
var item_views = []
|
||||
|
||||
var hovering_view : int = -1
|
||||
|
||||
func update_items_shown(new_character = null):
|
||||
|
||||
# allow the update item shown function to work with and without setget
|
||||
if new_character != null:
|
||||
character = new_character
|
||||
|
||||
# remove the old items
|
||||
for item_view in item_views:
|
||||
yield(item_view.item_view_remove(false), "completed")
|
||||
item_views = []
|
||||
|
||||
# add items the new items from the character
|
||||
for item in character.get(character_property):
|
||||
var new_item_view = item_view_scene.instance()
|
||||
new_item_view.set(view_property, item)
|
||||
get_node(child_holder).add_child(new_item_view)
|
||||
item_views.append(new_item_view)
|
||||
new_item_view.connect("item_view_removed", self, "remove_from_item_views")
|
||||
|
||||
|
||||
func remove_from_item_views(item_view):
|
||||
var to_remove : int = item_views.find(item_view)
|
||||
if to_remove != -1:
|
||||
item_views.remove(to_remove)
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
if not active:
|
||||
hovering_view = -1
|
||||
return
|
||||
|
||||
# set the hovering view if just selected
|
||||
if hovering_view == -1:
|
||||
hovering_view = 0
|
||||
item_views[hovering_view].hovering = false
|
||||
|
||||
# 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")):
|
||||
|
||||
# disable hovering on the previous item
|
||||
item_views[hovering_view].hovering = false
|
||||
|
||||
# cycle forward
|
||||
hovering_view += 1
|
||||
if hovering_view >= len(item_views):
|
||||
hovering_view = 0
|
||||
|
||||
# enable hovering on the present item
|
||||
item_views[hovering_view].hovering = true
|
||||
|
||||
if (Input.is_action_just_pressed("ui_up") or
|
||||
Input.is_action_just_pressed("ui_left")):
|
||||
|
||||
item_views[hovering_view].hovering = false
|
||||
|
||||
hovering_view -= 1
|
||||
if hovering_view < 0:
|
||||
hovering_view = len(item_views) -1
|
||||
|
||||
item_views[hovering_view].hovering = true
|
||||
|
||||
|
@ -9,6 +9,11 @@
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "Node",
|
||||
"class": "Card",
|
||||
"language": "GDScript",
|
||||
"path": "res://UI/Card.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": "CardResource",
|
||||
"language": "GDScript",
|
||||
@ -20,6 +25,7 @@ _global_script_classes=[ {
|
||||
"path": "res://Characters/Character.gd"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Card": "",
|
||||
"CardResource": "",
|
||||
"Character": ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user