added notification for picking up card

This commit is contained in:
Lexi Quinn 2023-12-08 18:25:15 +11:00
parent c75ba6461a
commit e97bf84612
7 changed files with 157 additions and 36 deletions

View File

@ -6,37 +6,37 @@ signal spawned
signal died
@export var hero_class: HeroClass
@export var camera : Camera3D
@export var gun_camera : Camera3D
@export var left_hand_sprite : Sprite3D
@export var left_hand : Node3D
@export var right_hand : Node3D
@export var right_hand_animator : AnimationPlayer
@export var edit_tool : EditTool
@export var gauntlet_sprite : Sprite3D
@export var sprite : EightDirectionSprite3D
@export var hand_sprite : Sprite2D
@export var interaction_raycast : RayCast3D
@export var inventory : Inventory
@export var card : CardInHand
@export var gauntlet_card_1 : CardInHand
@export var gauntlet_card_2 : CardInHand
@export var pause_menu_scene : PackedScene
@export var hud : HUD
@export var movement : PlayerMovement
@export var camera: Camera3D
@export var gun_camera: Camera3D
@export var left_hand_sprite: Sprite3D
@export var left_hand: Node3D
@export var right_hand: Node3D
@export var right_hand_animator: AnimationPlayer
@export var edit_tool: EditTool
@export var gauntlet_sprite: Sprite3D
@export var sprite: EightDirectionSprite3D
@export var hand_sprite: Sprite2D
@export var interaction_raycast: RayCast3D
@export var inventory: Inventory
@export var card: CardInHand
@export var gauntlet_card_1: CardInHand
@export var gauntlet_card_2: CardInHand
@export var pause_menu_scene: PackedScene
@export var hud: HUD
@export var movement: PlayerMovement
@export var sprint_zoom_speed := 0.2
@export var player_name_tag : Label
@export var weapon_swap_timer : Timer
@export var ears : AudioListener3D
@export var player_name_tag: Label
@export var weapon_swap_timer: Timer
@export var ears: AudioListener3D
var equipped_card
var offhand_card
var weapon : Weapon
var offhand_weapon : Weapon
var weapon: Weapon
var offhand_weapon: Weapon
var weapons_active = false
var paused := false
var editing_mode := true
var profile : PlayerProfile
var profile: PlayerProfile
var ready_state := false :
set(value):
ready_state = value
@ -111,7 +111,9 @@ func _process(delta: float) -> void:
button.press()
currency -= button.press_cost
if interaction_raycast.get_collider() is ItemCard:
inventory.add(interaction_raycast.get_collider().pick_up())
var pickup = interaction_raycast.get_collider().pick_up()
inventory.add(pickup)
hud.pickup(pickup)
if Input.is_action_just_pressed("Equip In Gauntlet"):
equip_weapon()
if Input.is_action_just_pressed("Secondary Fire"):
@ -175,8 +177,9 @@ func _unhandled_input(event: InputEvent) -> void:
hud.add_child(menu)
func add_card(card: Card):
inventory.add(card)
func add_card(new_card: Card):
inventory.add(new_card)
hud.pickup(new_card)
func unpause():

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=37 format=3 uid="uid://dxgxbtf68lcv5"]
[gd_scene load_steps=38 format=3 uid="uid://dxgxbtf68lcv5"]
[ext_resource type="Script" path="res://PCs/hero.gd" id="1_pihpe"]
[ext_resource type="Resource" uid="uid://b5pc3frhx467q" path="res://PCs/Red/red.tres" id="2_dbyo0"]
@ -19,6 +19,7 @@
[ext_resource type="Texture2D" uid="uid://c60fh34ttgcvh" path="res://Assets/Textures/minimap_player.png" id="15_nhlam"]
[ext_resource type="Texture2D" uid="uid://chhmkmlfrobhu" path="res://Assets/Textures/bubble.png" id="15_q3yot"]
[ext_resource type="Texture2D" uid="uid://cqnapc8cscl7i" path="res://Assets/Textures/border.png" id="16_x1xjr"]
[ext_resource type="PackedScene" uid="uid://chnj376d3lcjd" path="res://Scenes/UI/pickup_notification.tscn" id="17_oyeww"]
[ext_resource type="Script" path="res://PCs/player_movement.gd" id="20_cfhw8"]
[ext_resource type="Shader" path="res://crosshair.gdshader" id="20_gxpgc"]
[ext_resource type="Texture2D" uid="uid://r202vo47jw1q" path="res://Assets/Textures/enemyhealth.png" id="21_apps2"]
@ -82,7 +83,7 @@ shader_parameter/color_1 = Vector4(1, 0, 0, 1)
shader_parameter/color_2 = Vector4(0, 0, 1, 1)
shader_parameter/center_radius = 0.002
shader_parameter/width = 0.002
shader_parameter/len = 0.015
shader_parameter/len = 0.012
shader_parameter/spacing = 0.008
shader_parameter/spread = 1.0
@ -301,6 +302,7 @@ enemy_sprites = [NodePath("EnemyTracker/TextureRect"), NodePath("EnemyTracker/Te
enemy_counts = [NodePath("EnemyTracker/TextureRect/Label"), NodePath("EnemyTracker/TextureRect2/Label2"), NodePath("EnemyTracker/TextureRect3/Label3"), NodePath("EnemyTracker/TextureRect4/Label4"), NodePath("EnemyTracker/TextureRect5/Label5")]
weapon_energy_bar = NodePath("PrimaryEnergyBar")
offhand_energy_bar = NodePath("OffhandEnergyBar")
pickup_notif_scene = ExtResource("17_oyeww")
[node name="FirstPersonCam" type="TextureRect" parent="HUD"]
anchors_preset = 15
@ -595,6 +597,17 @@ texture_progress = ExtResource("21_apps2")
tint_under = Color(0, 1, 1, 0.168627)
tint_progress = Color(0, 1, 1, 1)
[node name="VBoxContainer" type="VBoxContainer" parent="HUD"]
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 15.0
offset_top = -295.0
offset_right = 445.0
offset_bottom = -40.0
grow_vertical = 0
alignment = 2
[node name="WeaponSwapTimer" type="Timer" parent="."]
wait_time = 0.9
one_shot = true

View File

@ -0,0 +1,45 @@
[gd_scene load_steps=3 format=3 uid="uid://chnj376d3lcjd"]
[ext_resource type="Script" path="res://Scripts/pickup_notification.gd" id="1_cgy5u"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cdnv4"]
resource_local_to_scene = true
content_margin_left = 7.0
content_margin_top = 3.0
content_margin_right = 7.0
content_margin_bottom = 3.0
bg_color = Color(0.717647, 0.0941176, 0.392157, 0.784314)
corner_radius_top_left = 15
corner_radius_top_right = 15
corner_radius_bottom_right = 15
corner_radius_bottom_left = 2
[node name="PanelContainer" type="PanelContainer"]
script = ExtResource("1_cgy5u")
fade_out_time = 2.0
style = SubResource("StyleBoxFlat_cdnv4")
text_style = Color(0, 0, 0, 0.862745)
common_background = Color(1, 1, 1, 0.784314)
uncommon_background = Color(0.196078, 0.8, 0.141176, 0.784314)
rare_background = Color(0.141176, 0.231373, 0.8, 0.784314)
epic_background = Color(0.709804, 0.141176, 0.8, 0.784314)
legendary_background = Color(0.882353, 0.478431, 0.117647, 0.784314)
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="Label2" type="Label" parent="HBoxContainer"]
layout_mode = 2
text = "+1"
[node name="Label" type="Label" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "Rocket Launcher 50"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Timer" type="Timer" parent="."]
one_shot = true
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]

View File

@ -165,16 +165,16 @@ func networked_spawn_wall(pos : Vector3, name_id : int, caller_id : int):
@rpc("reliable", "call_local", "any_peer")
func networked_remove_wall(wall_id: int):
var wall = tower_base_ids[wall_id]
func networked_remove_wall(new_wall_id: int):
var wall = tower_base_ids[new_wall_id]
Game.connected_players_nodes[wall.owner_id].currency += Data.wall_cost
tower_bases.erase(wall)
tower_base_ids.erase(wall_id)
tower_base_ids.erase(new_wall_id)
wall.queue_free()
var north_point = get_north_point(wall_id)
var south_point = get_south_point(wall_id)
var east_point = get_east_point(wall_id)
var west_point = get_west_point(wall_id)
var north_point = get_north_point(new_wall_id)
var south_point = get_south_point(new_wall_id)
var east_point = get_east_point(new_wall_id)
var west_point = get_west_point(new_wall_id)
if north_point >= 0 and astar.is_point_disabled(north_point):
tower_base_ids[north_point].set_south_wall(false)
if south_point >= 0 and astar.is_point_disabled(south_point):

View File

@ -18,6 +18,7 @@ var enemy_names = []
@export var enemy_counts : Array[Label]
@export var weapon_energy_bar : TextureProgressBar
@export var offhand_energy_bar : TextureProgressBar
@export var pickup_notif_scene : PackedScene
func set_energy_visible(value):
@ -119,3 +120,9 @@ func minimize_minimap(anchor):
minimap_cam.size = 15
minimap_outline.set_visible(true)
currency_count.set_visible(true)
func pickup(card: Card) -> void:
var notif = pickup_notif_scene.instantiate()
notif.set_card(card)
$VBoxContainer.add_child(notif)

View File

@ -38,6 +38,9 @@ func _process(delta: float) -> void:
ray_collider = null
ray_point = null
wall_preview.set_visible(false)
if is_instance_valid(last_collider):
Game.level.a_star_graph_3d.tower_base_ids[last_collider.point_id].set_material(null)
last_collider = null
return
if interact_key_held and !interacted_once and valid_point and hero.currency >= Data.wall_cost and ray.is_colliding() and Game.level.a_star_graph_3d.point_is_build_location(point_id):

View File

@ -0,0 +1,50 @@
extends PanelContainer
@export var fade_out_time: float
@export var style: StyleBoxFlat
@export var text_style: Color
@export var common_background: Color
@export var uncommon_background: Color
@export var rare_background: Color
@export var epic_background: Color
@export var legendary_background: Color
var fade_time = 0.0
var fading = false
func _ready() -> void:
add_theme_stylebox_override("panel", style)
$HBoxContainer/Label.add_theme_color_override("font_color", text_style)
$HBoxContainer/Label2.add_theme_color_override("font_color", text_style)
$Timer.start()
func _process(delta: float) -> void:
if fading:
fade_time += delta
style.bg_color.a = lerp(200.0 / 255.0, 0.0, fade_time / fade_out_time)
text_style.a = lerp(220.0 / 255.0, 0.0, fade_time / fade_out_time)
$HBoxContainer/Label.add_theme_color_override("font_color", text_style)
$HBoxContainer/Label2.add_theme_color_override("font_color", text_style)
if fade_time >= fade_out_time:
queue_free()
func set_card(card: Card) -> void:
$HBoxContainer/Label.text = card.display_name
match(card.rarity):
Data.Rarity.COMMON:
style.bg_color = common_background
Data.Rarity.UNCOMMON:
style.bg_color = uncommon_background
Data.Rarity.RARE:
style.bg_color = rare_background
Data.Rarity.EPIC:
style.bg_color = epic_background
Data.Rarity.LEGENDARY:
style.bg_color = legendary_background
func _on_timer_timeout() -> void:
fading = true