more work on the 240p ui
This commit is contained in:
@@ -60,7 +60,6 @@ func process_state(_delta: float) -> void:
|
||||
|
||||
|
||||
func swap_to_slot(num: int) -> void:
|
||||
if hero.unique_cards.size() >= num:
|
||||
if hero.hand.size >= num:
|
||||
hero.hand_selected_index = num - 1
|
||||
hero.swap_card_audio.play()
|
||||
hero.update_selected_box()
|
||||
|
||||
118
PCs/hero.gd
118
PCs/hero.gd
@@ -41,8 +41,6 @@ signal ready_state_changed(state: bool)
|
||||
|
||||
var current_state: HeroState
|
||||
var pre_fighting_state: HeroState
|
||||
var selection_boxes: Array[CardSelectionBox] = []
|
||||
var unique_cards: Array[Card] = []
|
||||
var hand_card_scene: PackedScene = preload("res://Scenes/UI/card_hand.tscn")
|
||||
var card_sprites: Array[CardInHand]
|
||||
var game_manager: GameManager
|
||||
@@ -81,7 +79,7 @@ var selected_card: Card :
|
||||
set(_value):
|
||||
pass
|
||||
get():
|
||||
return unique_cards[hand_selected_index] if unique_cards.size() > 0 else null
|
||||
return hand.item_at(hand_selected_index) if hand.size > 0 else null
|
||||
|
||||
|
||||
func set_zoom_factor(value: float) -> void:
|
||||
@@ -99,7 +97,6 @@ func _ready() -> void:
|
||||
draw_pile.add(card)
|
||||
else:
|
||||
add_card(card)
|
||||
update_selected_box()
|
||||
else:
|
||||
camera.set_visible(false)
|
||||
gun_camera.set_visible(false)
|
||||
@@ -132,44 +129,6 @@ func exit_fighting_state() -> void:
|
||||
update_state(pre_fighting_state)
|
||||
|
||||
|
||||
func add_selection(card: Card) -> void:
|
||||
if !unique_cards.has(card):
|
||||
unique_cards.append(card)
|
||||
var box: CardSelectionBox = card_select_scene.instantiate()
|
||||
box.set_card(card)
|
||||
box.set_key(unique_cards.size() - 1)
|
||||
box.set_amount(1)
|
||||
selection_boxes.append(box)
|
||||
$HUD/selection_boxes.add_child(box)
|
||||
else:
|
||||
var box: CardSelectionBox
|
||||
for existing_box: CardSelectionBox in selection_boxes:
|
||||
if existing_box.card == card:
|
||||
box = existing_box
|
||||
box.set_amount(hand.contents.count(card))
|
||||
|
||||
|
||||
func check_removal() -> void:
|
||||
var index: int = -1
|
||||
for card: Card in unique_cards:
|
||||
if !hand.contents.has(card):
|
||||
index = unique_cards.find(card)
|
||||
for i: int in selection_boxes.size():
|
||||
selection_boxes[i].set_amount(hand.contents.count(unique_cards[i]))
|
||||
if index >= 0:
|
||||
unique_cards.remove_at(index)
|
||||
selection_boxes[index].queue_free()
|
||||
selection_boxes.remove_at(index)
|
||||
if selection_boxes.size() > 0:
|
||||
for i: int in selection_boxes.size():
|
||||
var card: Card = unique_cards[i]
|
||||
selection_boxes[i].set_card(card)
|
||||
selection_boxes[i].set_key(i)
|
||||
if hand_selected_index == index:
|
||||
decrement_selected()
|
||||
update_selected_box()
|
||||
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if !is_multiplayer_authority() or paused:
|
||||
return
|
||||
@@ -223,24 +182,25 @@ func check_world_button() -> void:
|
||||
|
||||
func increment_selected() -> void:
|
||||
hand_selected_index += 1
|
||||
if hand_selected_index >= unique_cards.size():
|
||||
if hand_selected_index >= hand.size:
|
||||
hand_selected_index = 0
|
||||
update_selected_box()
|
||||
|
||||
|
||||
func decrement_selected() -> void:
|
||||
if unique_cards.size() == 0:
|
||||
if hand.size == 0:
|
||||
hand_selected_index = 0
|
||||
return
|
||||
hand_selected_index -= 1
|
||||
if hand_selected_index < 0:
|
||||
hand_selected_index = unique_cards.size() - 1
|
||||
update_selected_box()
|
||||
hand_selected_index = hand.size - 1
|
||||
|
||||
|
||||
func set_card_elements_visibility(value: bool) -> void:
|
||||
if value:
|
||||
hud.show_hot_wheel()
|
||||
else:
|
||||
hud.hide_hot_wheel()
|
||||
$FirstPersonViewport/Head2/LeftHand.visible = value
|
||||
$HUD/selection_boxes.visible = value
|
||||
$HUD/PlaceIcon.visible = value
|
||||
$HUD/SwapIcon.visible = value
|
||||
if cards[0]:
|
||||
@@ -270,7 +230,6 @@ func ready_self() -> void:
|
||||
hud.swap_icon.set_visible(false)
|
||||
hud.shrink_wave_start_label()
|
||||
ready_audio.play()
|
||||
networked_set_ready_state.rpc(ready_state)
|
||||
|
||||
|
||||
func unready_self() -> void:
|
||||
@@ -278,14 +237,12 @@ func unready_self() -> void:
|
||||
ready_state = false
|
||||
hud.grow_wave_start_label()
|
||||
unready_audio.play()
|
||||
networked_set_ready_state(ready_state)
|
||||
|
||||
|
||||
func add_card(new_card: Card) -> void:
|
||||
hand.add(new_card)
|
||||
hud.pickup(new_card)
|
||||
place_card_audio.play()
|
||||
add_selection(new_card)
|
||||
|
||||
|
||||
func unpause() -> void:
|
||||
@@ -322,37 +279,11 @@ func draw_to_hand_size() -> void:
|
||||
display.position = Vector3(0.01 * hand.size, 0.0, -0.001 * hand.size)
|
||||
display.rotation_degrees = Vector3(0.0, 0.0, -10.0 * hand.size)
|
||||
$FirstPersonViewport/Head2/LeftHand/Cards.add_child(display)
|
||||
#var tween: Tween = create_tween()
|
||||
#tween.set_ease(Tween.EASE_OUT)
|
||||
#tween.set_trans(Tween.TRANS_CUBIC)
|
||||
#tween.tween_property(display, "position", Vector2(200.0 * hand.size, 80.0), 0.5)
|
||||
else:
|
||||
for x: int in discard_pile.size:
|
||||
draw_pile.add(discard_pile.remove_at(0))
|
||||
draw_pile.shuffle()
|
||||
unique_cards = []
|
||||
selection_boxes = []
|
||||
for card: Card in hand.contents:
|
||||
if !unique_cards.has(card):
|
||||
unique_cards.append(card)
|
||||
for i: int in $HUD/selection_boxes.get_child_count():
|
||||
$HUD/selection_boxes.get_child(i).queue_free()
|
||||
for i: int in unique_cards.size():
|
||||
var card: Card = unique_cards[i]
|
||||
var box: CardSelectionBox = card_select_scene.instantiate()
|
||||
box.set_card(card)
|
||||
box.set_key(i)
|
||||
box.set_amount(hand.contents.count(unique_cards[i]))
|
||||
selection_boxes.append(box)
|
||||
$HUD/selection_boxes.add_child(box)
|
||||
hand_selected_index = 0
|
||||
update_selected_box()
|
||||
|
||||
|
||||
func update_selected_box() -> void:
|
||||
for box: CardSelectionBox in selection_boxes:
|
||||
box.deselect()
|
||||
selection_boxes[hand_selected_index].select()
|
||||
|
||||
|
||||
func equip_weapon(slot: int = 0) -> void:
|
||||
@@ -381,7 +312,6 @@ func equip_weapon(slot: int = 0) -> void:
|
||||
weapons[slot].stats = cards[slot].weapon_stats
|
||||
weapons[slot].name = str(weapons_spawn_count)
|
||||
weapons[slot].duration = 1
|
||||
networked_equip_weapon.rpc(Data.cards.find(cards[slot]), 0, weapons_spawn_count)
|
||||
weapons_spawn_count += 1
|
||||
weapons[slot].set_multiplayer_authority(multiplayer.get_unique_id())
|
||||
gauntlet_cards[slot].set_card(cards[slot])
|
||||
@@ -394,7 +324,6 @@ func equip_weapon(slot: int = 0) -> void:
|
||||
weapons[slot].set_hero(self)
|
||||
weapons[slot].visible = false
|
||||
right_hand.add_child(weapons[slot])
|
||||
check_removal()
|
||||
if slot == 0:
|
||||
weapons[slot].energy_spent.connect(hud.new_energy_bar.use_energy)
|
||||
weapons[slot].energy_recharged.connect(hud.new_energy_bar.gain_energy)
|
||||
@@ -458,7 +387,6 @@ func _on_timer_timeout() -> void:
|
||||
|
||||
|
||||
func unequip_weapon(slot: int = 0) -> void:
|
||||
networked_unequip_weapon.rpc(slot)
|
||||
gauntlet_cards[slot].visible = false
|
||||
if slot == 0:
|
||||
hud.place_icon.visible = true
|
||||
@@ -472,33 +400,3 @@ func unequip_weapon(slot: int = 0) -> void:
|
||||
add_card(cards[slot])
|
||||
cards[slot] = null
|
||||
place_card_audio.play()
|
||||
|
||||
|
||||
#MULTIPLAYER NETWORKED FUNCTIONS
|
||||
@rpc("reliable")
|
||||
func networked_set_ready_state(state: bool) -> void:
|
||||
ready_state = state
|
||||
|
||||
|
||||
@rpc("reliable")
|
||||
func networked_swap_weapon() -> void:
|
||||
swap_weapons()
|
||||
|
||||
|
||||
@rpc("reliable")
|
||||
func networked_equip_weapon(card_index: int, slot: int, id: int) -> void:
|
||||
var new_card: Card = Data.cards[card_index]
|
||||
var new_weapon: Weapon = new_card.weapon_scene.instantiate()
|
||||
new_weapon.set_multiplayer_authority(multiplayer.get_remote_sender_id())
|
||||
new_weapon.name = str(id)
|
||||
new_weapon.set_hero(self)
|
||||
right_hand.add_child(new_weapon)
|
||||
cards[slot] = new_card
|
||||
weapons[slot] = new_weapon
|
||||
|
||||
|
||||
@rpc("reliable")
|
||||
func networked_unequip_weapon(slot: int) -> void:
|
||||
weapons[slot].queue_free()
|
||||
weapons[slot] = null
|
||||
cards[slot] = null
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=68 format=3 uid="uid://dxgxbtf68lcv5"]
|
||||
[gd_scene load_steps=69 format=3 uid="uid://dxgxbtf68lcv5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1fqpoegbdm6n" path="res://PCs/hero.gd" id="1_pihpe"]
|
||||
[ext_resource type="Resource" uid="uid://b5pc3frhx467q" path="res://Classes/Engineer/class.tres" id="2_dbyo0"]
|
||||
@@ -38,6 +38,7 @@
|
||||
[ext_resource type="AudioStream" uid="uid://val5n418yebw" path="res://Audio/cardSlide3.ogg" id="30_djhlg"]
|
||||
[ext_resource type="Texture2D" uid="uid://up7omskwg0yx" path="res://Assets/Textures/battery.png" id="30_rim6q"]
|
||||
[ext_resource type="AudioStream" uid="uid://ck6g061w7i6ro" path="res://Audio/cardSlide4.ogg" id="31_546e6"]
|
||||
[ext_resource type="PackedScene" uid="uid://ga21hoa8fxmm" path="res://hot_wheel.tscn" id="31_h1yfy"]
|
||||
[ext_resource type="AudioStream" uid="uid://bj8eitlsjdotb" path="res://Audio/cardSlide5.ogg" id="32_tg7y0"]
|
||||
[ext_resource type="AudioStream" uid="uid://d0620p56ad34a" path="res://Audio/cardSlide6.ogg" id="33_2v5co"]
|
||||
[ext_resource type="AudioStream" uid="uid://uvoxbl1fbtu0" path="res://Audio/cardSlide7.ogg" id="34_6acmc"]
|
||||
@@ -320,7 +321,7 @@ max_look_up_angle = 80.0
|
||||
enable_jumping = true
|
||||
weapon_holder = NodePath("../FirstPersonViewport/Head2/RightHand")
|
||||
|
||||
[node name="HUD" type="CanvasLayer" parent="." node_paths=PackedStringArray("player", "wave_count", "lives_count", "currency_count", "minimap_outline", "minimap", "minimap_cam", "minimap_viewport", "fps_label", "hover_text", "enemy_sprites", "enemy_counts", "wave_start_label", "place_icon", "swap_icon", "place_text", "swap_text", "new_energy_bar", "energy_label", "blank_cassette_label")]
|
||||
[node name="HUD" type="CanvasLayer" parent="." node_paths=PackedStringArray("player", "wave_count", "lives_count", "currency_count", "minimap_outline", "minimap", "minimap_cam", "minimap_viewport", "fps_label", "hover_text", "enemy_sprites", "enemy_counts", "wave_start_label", "place_icon", "swap_icon", "place_text", "swap_text", "new_energy_bar", "energy_label", "blank_cassette_label", "feature_preview", "hot_wheel")]
|
||||
script = ExtResource("8_yl6ka")
|
||||
player = NodePath("..")
|
||||
wave_count = NodePath("EnemyTracker/WaveCount")
|
||||
@@ -344,6 +345,8 @@ enemy_card_scene = ExtResource("18_dfkac")
|
||||
new_energy_bar = NodePath("EnergyBar")
|
||||
energy_label = NodePath("Currencies/HBoxContainer/EnergyLabel")
|
||||
blank_cassette_label = NodePath("Currencies/BlankCassetteLabel")
|
||||
feature_preview = NodePath("FeaturePreview")
|
||||
hot_wheel = NodePath("HotWheel")
|
||||
|
||||
[node name="FirstPersonCam" type="TextureRect" parent="HUD"]
|
||||
anchors_preset = 15
|
||||
@@ -715,25 +718,6 @@ texture = ExtResource("26_dfkac")
|
||||
expand_mode = 3
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="selection_boxes" type="HBoxContainer" parent="HUD"]
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.05
|
||||
anchor_top = 0.8
|
||||
anchor_right = 0.2
|
||||
anchor_bottom = 0.8
|
||||
grow_vertical = 0
|
||||
mouse_filter = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Control" parent="HUD/selection_boxes" instance=ExtResource("5_h82f6")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Control2" parent="HUD/selection_boxes" instance=ExtResource("5_h82f6")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Control3" parent="HUD/selection_boxes" instance=ExtResource("5_h82f6")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Currencies" type="VBoxContainer" parent="HUD"]
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.95
|
||||
@@ -779,6 +763,26 @@ layout_mode = 2
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="HotWheel" parent="HUD" instance=ExtResource("31_h1yfy")]
|
||||
visible = false
|
||||
anchors_preset = -1
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.893
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.893
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 0
|
||||
|
||||
[node name="FeaturePreview" type="HBoxContainer" parent="HUD"]
|
||||
anchors_preset = -1
|
||||
anchor_top = 0.6
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 0.8
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="WeaponSwapTimer" type="Timer" parent="."]
|
||||
wait_time = 0.4
|
||||
one_shot = true
|
||||
|
||||
39
PCs/hud.gd
39
PCs/hud.gd
@@ -26,11 +26,14 @@ extends CanvasLayer
|
||||
@export var primary_duration: Label
|
||||
@export var secondary_duration: Label
|
||||
@export var blank_cassette_label: Label
|
||||
@export var feature_preview: HBoxContainer
|
||||
@export var hot_wheel: HotWheel
|
||||
|
||||
var last_lives_count: int = 120
|
||||
var enemy_names: Array[String]
|
||||
var map_anchor: Node3D
|
||||
var cards: Array[EnemyCardUI] = []
|
||||
var feature_preview_tween: Tween
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -40,6 +43,14 @@ func _ready() -> void:
|
||||
energy_label.visible = true
|
||||
|
||||
|
||||
func show_hot_wheel() -> void:
|
||||
hot_wheel.visible = true
|
||||
|
||||
|
||||
func hide_hot_wheel() -> void:
|
||||
hot_wheel.visible = false
|
||||
|
||||
|
||||
func set_blank_cassette_count(value: int) -> void:
|
||||
blank_cassette_label.text = str(value)
|
||||
|
||||
@@ -87,6 +98,33 @@ func _process(_delta: float) -> void:
|
||||
swap_text.text = parse_action_tag("[center]%Secondary Fire%")
|
||||
|
||||
|
||||
func show_features(cassette: Card) -> void:
|
||||
for child: Node in feature_preview.get_children():
|
||||
child.queue_free()
|
||||
var cols: int = max(cassette.tower_stats.features.size(), cassette.weapon_stats.features.size())
|
||||
for x: int in cols:
|
||||
var vbox: VBoxContainer = VBoxContainer.new()
|
||||
vbox.alignment = BoxContainer.ALIGNMENT_END
|
||||
if x < cassette.tower_stats.features.size():
|
||||
vbox.alignment = BoxContainer.ALIGNMENT_BEGIN
|
||||
var tex: TextureRect = TextureRect.new()
|
||||
tex.texture = cassette.tower_stats.features[x].icon
|
||||
vbox.add_child(tex)
|
||||
if x < cassette.weapon_stats.features.size():
|
||||
var tex: TextureRect = TextureRect.new()
|
||||
tex.texture = cassette.weapon_stats.features[x].icon
|
||||
vbox.add_child(tex)
|
||||
feature_preview.add_child(vbox)
|
||||
if feature_preview_tween:
|
||||
feature_preview_tween.kill()
|
||||
feature_preview_tween = create_tween()
|
||||
feature_preview_tween.set_ease(Tween.EASE_OUT)
|
||||
feature_preview_tween.set_trans(Tween.TRANS_CUBIC)
|
||||
feature_preview.modulate = Color.WHITE
|
||||
feature_preview_tween.tween_interval(0.7)
|
||||
feature_preview_tween.tween_property(feature_preview, "modulate", Color8(255, 255, 255, 0), 0.5)
|
||||
|
||||
|
||||
func grow_wave_start_label() -> void:
|
||||
tween_label(300.0)
|
||||
|
||||
@@ -209,6 +247,7 @@ func minimize_minimap() -> void:
|
||||
|
||||
|
||||
func pickup(card: Card) -> void:
|
||||
hot_wheel.add_cassette(card)
|
||||
var notif: PickupNotification = pickup_notif_scene.instantiate()
|
||||
notif.set_card(card)
|
||||
$VBoxContainer.add_child(notif)
|
||||
|
||||
Reference in New Issue
Block a user