working on items and inventory
This commit is contained in:
@@ -21,13 +21,16 @@ extends CharacterBody2D
|
||||
@onready var next_attack_time := 0
|
||||
@onready var is_attacking := false
|
||||
|
||||
@onready var equipped:Node2D
|
||||
#@onready var equipped:Node2D
|
||||
@onready var active_item:Dictionary = {}
|
||||
@onready var spawned_item:Node2D
|
||||
@onready var invulnerability_timer:Timer = get_node("InvulnerableTimer")
|
||||
@onready var player_disabled := false
|
||||
@onready var player_in_inventory := false
|
||||
@onready var is_searching := false
|
||||
|
||||
@onready var inv_manager = $CanvasLayer/UserInventory
|
||||
|
||||
@onready var item_hovering := false
|
||||
|
||||
@onready var rng = RandomNumberGenerator.new()
|
||||
@@ -54,7 +57,9 @@ func set_spawn_location(spawn_position: Vector2):
|
||||
set_position(spawn_position)
|
||||
|
||||
func _ready():
|
||||
if not is_multiplayer_authority(): return
|
||||
if not is_multiplayer_authority():
|
||||
$CanvasLayer.set_visible(false)
|
||||
return
|
||||
print("Setting IDLE: ", get_position())
|
||||
player_cam.make_current()
|
||||
#player_cam.current = true # for mp to set the camera
|
||||
@@ -151,8 +156,19 @@ func get_input():
|
||||
#anim_tree.set(atk_str, 1)
|
||||
#anim_mode.travel("attack")
|
||||
next_attack_time = now + attack_speed
|
||||
if equipped:
|
||||
pass
|
||||
print("Attacking!", active_item)
|
||||
if active_item:
|
||||
var item_details = ItemDatabase.PU_objects[active_item.item_name]
|
||||
var item_scene = load(item_details.scene)
|
||||
var item = item_scene.instantiate()
|
||||
add_child(item)
|
||||
item.set_position(get_position())
|
||||
print("ITEM IS: ", item)
|
||||
|
||||
item.use_item($".")
|
||||
return
|
||||
# if equipped:
|
||||
# pass
|
||||
#spawned_item = load(ItemDatabase.Castable_objects[equipped.item_name]).instantiate()
|
||||
#var map = get_tree().current_scene
|
||||
#map.add_child(spawned_item)
|
||||
@@ -161,6 +177,7 @@ func get_input():
|
||||
# inventory_ui.set_ammo(-1)
|
||||
#spawned_item.use_item(player, spawned_item, map)
|
||||
#next_attack_time = now + attack_speed
|
||||
# print("RETURNING TO USER INPUT!")
|
||||
velocity = Vector2()
|
||||
var direction : String
|
||||
if Input.is_action_pressed("right") and not is_attacking:
|
||||
@@ -238,5 +255,16 @@ func move_player(c_velocity: Vector2):
|
||||
# collider.apply_central_impulse(-collision.get_normal() * push_power)
|
||||
player_hit.is_player_hit = false
|
||||
|
||||
@rpc("any_peer")
|
||||
func set_context_label(text: String):
|
||||
$CanvasLayer/ContextLabel.set_text(text)
|
||||
|
||||
|
||||
func add_inventory_item(item: Dictionary):
|
||||
inv_manager.add_inventory_item(item)
|
||||
|
||||
|
||||
#signal from the inventory
|
||||
func _on_user_inventory_active_item_changed(new_active_item):
|
||||
print("SETTING ACTIVE ITEM: ", new_active_item)
|
||||
active_item = new_active_item
|
||||
|
@@ -5,10 +5,10 @@
|
||||
[ext_resource type="PackedScene" uid="uid://drr0ptd6k6uch" path="res://UI/Inventory/UserInventory.tscn" id="3_nvr35"]
|
||||
[ext_resource type="FontFile" uid="uid://dj4pldmxeqmtt" path="res://UI/PressStart2P-Regular.ttf" id="4_i8vjo"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_g1om0"]
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_h7cys"]
|
||||
size = Vector2(22, 20)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_5n6gk"]
|
||||
[sub_resource type="Animation" id="Animation_epy5e"]
|
||||
resource_name = "attack"
|
||||
length = 0.65
|
||||
tracks/0/type = "value"
|
||||
@@ -24,7 +24,7 @@ tracks/0/keys = {
|
||||
"values": [Vector2i(0, 5), Vector2i(1, 5), Vector2i(2, 5), Vector2i(3, 5)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_u6kdu"]
|
||||
[sub_resource type="Animation" id="Animation_at62u"]
|
||||
resource_name = "damage"
|
||||
step = 0.01
|
||||
tracks/0/type = "value"
|
||||
@@ -40,7 +40,7 @@ tracks/0/keys = {
|
||||
"values": [Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(0.792157, 0.0901961, 0.0901961, 1), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ybwuj"]
|
||||
[sub_resource type="Animation" id="Animation_708tn"]
|
||||
resource_name = "die"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
@@ -55,7 +55,7 @@ tracks/0/keys = {
|
||||
"values": [Vector2i(0, 4), Vector2i(1, 4), Vector2i(2, 4), Vector2i(3, 4), Vector2i(4, 4)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_h5uv5"]
|
||||
[sub_resource type="Animation" id="Animation_ddmol"]
|
||||
resource_name = "idle"
|
||||
length = 2.0
|
||||
loop_mode = 1
|
||||
@@ -72,7 +72,7 @@ tracks/0/keys = {
|
||||
"values": [Vector2i(0, 0), Vector2i(1, 0), Vector2i(2, 0), Vector2i(3, 0), Vector2i(4, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_cev5d"]
|
||||
[sub_resource type="Animation" id="Animation_al5w0"]
|
||||
resource_name = "walk"
|
||||
loop_mode = 1
|
||||
step = 0.01
|
||||
@@ -89,62 +89,62 @@ tracks/0/keys = {
|
||||
"values": [Vector2i(0, 1), Vector2i(1, 1), Vector2i(2, 1), Vector2i(3, 1), Vector2i(4, 1), Vector2i(5, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_5qwfv"]
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ufoec"]
|
||||
_data = {
|
||||
"attack": SubResource("Animation_5n6gk"),
|
||||
"damage": SubResource("Animation_u6kdu"),
|
||||
"die": SubResource("Animation_ybwuj"),
|
||||
"idle": SubResource("Animation_h5uv5"),
|
||||
"walk": SubResource("Animation_cev5d")
|
||||
"attack": SubResource("Animation_epy5e"),
|
||||
"damage": SubResource("Animation_at62u"),
|
||||
"die": SubResource("Animation_708tn"),
|
||||
"idle": SubResource("Animation_ddmol"),
|
||||
"walk": SubResource("Animation_al5w0")
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_2a8v8"]
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_hrw7i"]
|
||||
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_5013i"]
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_a5dle"]
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_24wrp"]
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jqlyn"]
|
||||
animation = &"attack"
|
||||
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_2lwq2"]
|
||||
[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_pxj46"]
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mfi5b"]
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_y87rp"]
|
||||
animation = &"damage"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_yud6d"]
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_gy8c5"]
|
||||
animation = &"die"
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_0n1hp"]
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_bc1jc"]
|
||||
animation = &"idle"
|
||||
|
||||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_qrdax"]
|
||||
[sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_a7far"]
|
||||
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6pfdq"]
|
||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mcfk5"]
|
||||
animation = &"walk"
|
||||
|
||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_78n1d"]
|
||||
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_fx5ki"]
|
||||
graph_offset = Vector2(-769.911, -161.25)
|
||||
nodes/AttackOneShot/node = SubResource("AnimationNodeOneShot_2a8v8")
|
||||
nodes/AttackOneShot/node = SubResource("AnimationNodeOneShot_hrw7i")
|
||||
nodes/AttackOneShot/position = Vector2(-320, 60)
|
||||
nodes/DieOneShot/node = SubResource("AnimationNodeOneShot_5013i")
|
||||
nodes/DieOneShot/node = SubResource("AnimationNodeOneShot_a5dle")
|
||||
nodes/DieOneShot/position = Vector2(-120, 180)
|
||||
nodes/attack_anim/node = SubResource("AnimationNodeAnimation_24wrp")
|
||||
nodes/attack_anim/node = SubResource("AnimationNodeAnimation_jqlyn")
|
||||
nodes/attack_anim/position = Vector2(-560, 200)
|
||||
nodes/damageOneShot/node = SubResource("AnimationNodeOneShot_2lwq2")
|
||||
nodes/damageOneShot/node = SubResource("AnimationNodeOneShot_pxj46")
|
||||
nodes/damageOneShot/position = Vector2(100, 320)
|
||||
nodes/damage_anim/node = SubResource("AnimationNodeAnimation_mfi5b")
|
||||
nodes/damage_anim/node = SubResource("AnimationNodeAnimation_y87rp")
|
||||
nodes/damage_anim/position = Vector2(-200, 460)
|
||||
nodes/die_anim/node = SubResource("AnimationNodeAnimation_yud6d")
|
||||
nodes/die_anim/node = SubResource("AnimationNodeAnimation_gy8c5")
|
||||
nodes/die_anim/position = Vector2(-440, 340)
|
||||
nodes/idle_anim/node = SubResource("AnimationNodeAnimation_0n1hp")
|
||||
nodes/idle_anim/node = SubResource("AnimationNodeAnimation_bc1jc")
|
||||
nodes/idle_anim/position = Vector2(-940, 60)
|
||||
nodes/output/position = Vector2(400, 340)
|
||||
nodes/walkIdleBlend/node = SubResource("AnimationNodeBlend2_qrdax")
|
||||
nodes/walkIdleBlend/node = SubResource("AnimationNodeBlend2_a7far")
|
||||
nodes/walkIdleBlend/position = Vector2(-660, -40)
|
||||
nodes/walk_anim/node = SubResource("AnimationNodeAnimation_6pfdq")
|
||||
nodes/walk_anim/node = SubResource("AnimationNodeAnimation_mcfk5")
|
||||
nodes/walk_anim/position = Vector2(-920, -80)
|
||||
node_connections = [&"output", 0, &"damageOneShot", &"AttackOneShot", 0, &"walkIdleBlend", &"AttackOneShot", 1, &"attack_anim", &"DieOneShot", 0, &"AttackOneShot", &"DieOneShot", 1, &"die_anim", &"damageOneShot", 0, &"DieOneShot", &"damageOneShot", 1, &"damage_anim", &"walkIdleBlend", 0, &"walk_anim", &"walkIdleBlend", 1, &"idle_anim"]
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_hr3p8"]
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_xv2gm"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/sync = true
|
||||
@@ -163,7 +163,7 @@ motion_mode = 1
|
||||
script = ExtResource("1_6aci1")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_g1om0")
|
||||
shape = SubResource("RectangleShape2D_h7cys")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
z_index = 1
|
||||
@@ -171,15 +171,15 @@ position = Vector2(-1, -2)
|
||||
texture = ExtResource("1_8pmbp")
|
||||
hframes = 6
|
||||
vframes = 6
|
||||
frame = 1
|
||||
frame = 4
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_5qwfv")
|
||||
"": SubResource("AnimationLibrary_ufoec")
|
||||
}
|
||||
|
||||
[node name="AnimationTree" type="AnimationTree" parent="."]
|
||||
tree_root = SubResource("AnimationNodeBlendTree_78n1d")
|
||||
tree_root = SubResource("AnimationNodeBlendTree_fx5ki")
|
||||
anim_player = NodePath("../AnimationPlayer")
|
||||
active = true
|
||||
parameters/AttackOneShot/active = false
|
||||
@@ -209,4 +209,6 @@ size_flags_horizontal = 4
|
||||
theme_override_fonts/font = ExtResource("4_i8vjo")
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_hr3p8")
|
||||
replication_config = SubResource("SceneReplicationConfig_xv2gm")
|
||||
|
||||
[connection signal="active_item_changed" from="CanvasLayer/UserInventory" to="." method="_on_user_inventory_active_item_changed"]
|
||||
|
@@ -5,7 +5,7 @@ extends Node
|
||||
@onready var manager = get_node(".")
|
||||
@onready var main_menu = $CanvasLayer/MainMenu
|
||||
@onready var start_game_menu = $CanvasLayer/StartGameMenu
|
||||
@onready var address_entry = $CanvasLayer/MainMenu/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/AddressEntry
|
||||
#@onready var address_entry = $CanvasLayer/MainMenu/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer2/AddressEntry
|
||||
@onready var notifications = $CanvasLayer/notifications
|
||||
@onready var spawner = $MultiplayerSpawner
|
||||
|
||||
|
72
ItemDatabase/ItemDatabase.gd
Normal file
72
ItemDatabase/ItemDatabase.gd
Normal file
@@ -0,0 +1,72 @@
|
||||
extends Node
|
||||
|
||||
var PU_objects:Dictionary = {}
|
||||
var Powerups:Dictionary = {}
|
||||
|
||||
# For random item drops
|
||||
var AllItems: Dictionary = {}
|
||||
var total_weight:float = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
PU_objects["Nail Gun"] = {
|
||||
"scene": "res://PickupableObjects/NailGun/NailGun.tscn",
|
||||
"spawn_chance": 0.8,
|
||||
"roll_weight": 0.0
|
||||
}
|
||||
PU_objects["Grappling Hook"] = {
|
||||
"scene": "res://pickupable_objects/grappling_hook/grappling_hook.tscn",
|
||||
"spawn_chance": 0.3,
|
||||
"roll_weight": 0.0
|
||||
}
|
||||
PU_objects["Bomb"] = {
|
||||
"scene": "res://PickupableObjects/Bomb/bomb.tscn",
|
||||
"spawn_chance": 0.7,
|
||||
"roll_weight": 0.0
|
||||
}
|
||||
PU_objects["Glue Patch"] = {
|
||||
"scene": "res://PickupableObjects/GluePatch/GluePatch.tscn",
|
||||
"spawn_chance": 1.0,
|
||||
"roll_weight": 0.0
|
||||
}
|
||||
PU_objects["Void Portal"] = {
|
||||
"scene": "res://pickupable_objects/void_portal/void_portal.tscn",
|
||||
"spawn_chance": 0.3,
|
||||
"roll_weight": 0.0
|
||||
}
|
||||
|
||||
Powerups["Speed Up"] = {
|
||||
"scene": "res://powerups/speed_up/speed_up.tscn",
|
||||
"spawn_chance": 1.0,
|
||||
"roll_weight": 0.0
|
||||
}
|
||||
|
||||
# Castable_objects["Nail Gun"] = "res://pickupable_objects/nail_gun/nail_shot.tscn"
|
||||
# Castable_objects["Grappling Hook"] = "res://pickupable_objects/grappling_hook/hook_shot.tscn"
|
||||
# Castable_objects["Bomb"] = "res://pickupable_objects/bomb/bomb_thrown.tscn"
|
||||
# Castable_objects["Glue Patch"] = "res://pickupable_objects/glue_patch/glue_patch_deployed.tscn"
|
||||
# Castable_objects["Void Portal"] = "res://pickupable_objects/void_portal/void_portal_thrown.tscn"
|
||||
create_all_items_dict()
|
||||
calculate_weights()
|
||||
|
||||
func create_all_items_dict():
|
||||
for key in PU_objects.keys():
|
||||
AllItems[key] = PU_objects[key]
|
||||
for key in Powerups.keys():
|
||||
AllItems[key] = Powerups[key]
|
||||
|
||||
func calculate_weights():
|
||||
total_weight = 0
|
||||
for item in AllItems.values():
|
||||
total_weight = total_weight + item.spawn_chance
|
||||
item.roll_weight = total_weight
|
||||
|
||||
func return_random_item() -> Dictionary:
|
||||
var roll: float = randf_range(-0.90, total_weight)
|
||||
if roll < 0:
|
||||
return {}
|
||||
for item in AllItems.values():
|
||||
if item.roll_weight > roll:
|
||||
return item
|
||||
return {}
|
||||
|
@@ -1,8 +1,11 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bfjsdoykr1fcd"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bfjsdoykr1fcd"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://xx7r8n56lx21" path="res://TileSets/Main_Floor.tscn" id="1_1k16l"]
|
||||
[ext_resource type="PackedScene" uid="uid://ca4ghctk5gllj" path="res://PhysicsObjects/HandStatue/HandStatue.tscn" id="2_jwx5u"]
|
||||
[ext_resource type="PackedScene" uid="uid://bfv4b6j4eunqj" path="res://Game Manager/player_spawn_location.tscn" id="3_h26d8"]
|
||||
[ext_resource type="PackedScene" uid="uid://dp6umanf58x5t" path="res://PickupableObjects/Bomb/bomb.tscn" id="4_w3pt4"]
|
||||
[ext_resource type="PackedScene" uid="uid://r0424mbc1jx8" path="res://PickupableObjects/GluePatch/GluePatch.tscn" id="5_r4qoq"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1w6rui20nu63" path="res://PickupableObjects/NailGun/NailGun.tscn" id="6_h8wsc"]
|
||||
|
||||
[node name="Level1" type="Node2D"]
|
||||
|
||||
@@ -14,3 +17,51 @@ position = Vector2(-10, 461)
|
||||
|
||||
[node name="HandStatue" parent="." instance=ExtResource("2_jwx5u")]
|
||||
position = Vector2(89, 378)
|
||||
|
||||
[node name="bomb" parent="." instance=ExtResource("4_w3pt4")]
|
||||
position = Vector2(44, 413)
|
||||
|
||||
[node name="bomb2" parent="." instance=ExtResource("4_w3pt4")]
|
||||
position = Vector2(-47, 383)
|
||||
|
||||
[node name="bomb3" parent="." instance=ExtResource("4_w3pt4")]
|
||||
position = Vector2(42, 328)
|
||||
|
||||
[node name="bomb4" parent="." instance=ExtResource("4_w3pt4")]
|
||||
position = Vector2(154, 330)
|
||||
|
||||
[node name="bomb5" parent="." instance=ExtResource("4_w3pt4")]
|
||||
position = Vector2(157, 393)
|
||||
|
||||
[node name="bomb6" parent="." instance=ExtResource("4_w3pt4")]
|
||||
position = Vector2(125, 465)
|
||||
|
||||
[node name="bomb7" parent="." instance=ExtResource("4_w3pt4")]
|
||||
position = Vector2(43, 484)
|
||||
|
||||
[node name="GluePatch" parent="." instance=ExtResource("5_r4qoq")]
|
||||
position = Vector2(-4, 403)
|
||||
|
||||
[node name="GluePatch2" parent="." instance=ExtResource("5_r4qoq")]
|
||||
position = Vector2(102, 425)
|
||||
|
||||
[node name="GluePatch3" parent="." instance=ExtResource("5_r4qoq")]
|
||||
position = Vector2(92, 320)
|
||||
|
||||
[node name="GluePatch4" parent="." instance=ExtResource("5_r4qoq")]
|
||||
position = Vector2(-57, 435)
|
||||
|
||||
[node name="GluePatch5" parent="." instance=ExtResource("5_r4qoq")]
|
||||
position = Vector2(-40, 502)
|
||||
|
||||
[node name="GluePatch6" parent="." instance=ExtResource("5_r4qoq")]
|
||||
position = Vector2(183, 473)
|
||||
|
||||
[node name="GluePatch7" parent="." instance=ExtResource("5_r4qoq")]
|
||||
position = Vector2(87, 489)
|
||||
|
||||
[node name="NailGun" parent="." instance=ExtResource("6_h8wsc")]
|
||||
position = Vector2(17, 463)
|
||||
|
||||
[node name="NailGun2" parent="." instance=ExtResource("6_h8wsc")]
|
||||
position = Vector2(80, 420)
|
||||
|
@@ -6,7 +6,6 @@ extends RigidBody2D
|
||||
@export var push_strength:int = 20
|
||||
|
||||
@onready var last_velocity:Vector2 = Vector2(0,0)
|
||||
@onready var current_player:CharacterBody2D = null
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
@@ -23,10 +22,9 @@ func _physics_process(delta):
|
||||
func _on_body_entered(body):
|
||||
if body.is_in_group("player"):
|
||||
if last_velocity.length() > damage_speed:
|
||||
current_player = body
|
||||
current_player.player_hit.is_player_hit = true
|
||||
current_player.player_hit.hit_velocity = last_velocity.normalized() * push_strength
|
||||
current_player.health_changed_func(-1)
|
||||
body.player_hit.is_player_hit = true
|
||||
body.player_hit.hit_velocity = last_velocity.normalized() * push_strength
|
||||
body.health_changed_func(-1)
|
||||
# set_freeze_enabled(true)
|
||||
# await get_tree().create_timer(0.5).timeout
|
||||
set_sleeping(true)
|
||||
|
@@ -15,17 +15,22 @@ extends PU_Item
|
||||
|
||||
func _input(event):
|
||||
if Input.is_action_pressed("interact") and is_reachable and current_player:
|
||||
print("ITEM TYPE: ", item_type)
|
||||
# if item_type == 0: # 0 is weapon
|
||||
# print("Weapon!")
|
||||
var result = current_player.add_inventory_item(item_info)
|
||||
if result:
|
||||
current_player.add_inventory_item(item_info)
|
||||
print("Adding inventory item!")
|
||||
cleanup.rpc()
|
||||
|
||||
@rpc("call_local", "any_peer")
|
||||
func cleanup():
|
||||
queue_free()
|
||||
|
||||
func _on_bomb_pu_area_body_entered(body):
|
||||
if body.is_in_group("player"):
|
||||
current_player = body
|
||||
is_reachable = true
|
||||
current_player.set_context_label("Pickup " + item_info.item_name + "?")
|
||||
current_player.set_context_label.rpc_id(current_player.get_multiplayer_authority(), "Pickup " + item_info.item_name + "?")
|
||||
|
||||
|
||||
func _on_bomb_pu_area_body_exited(body):
|
||||
|
@@ -6,8 +6,14 @@
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1taf2"]
|
||||
size = Vector2(20, 34)
|
||||
|
||||
[node name="bomb" type="Node"]
|
||||
[node name="Bomb" type="Node2D"]
|
||||
script = ExtResource("1_0j4vj")
|
||||
item_name = "Bomb"
|
||||
item_description = "Throw and run. Simple and effective."
|
||||
item_type = 0
|
||||
item_clip_size = 1
|
||||
item_ammo = 1
|
||||
item_texture = ExtResource("2_c4hvj")
|
||||
|
||||
[node name="BombPUArea" type="Area2D" parent="."]
|
||||
|
||||
|
45
PickupableObjects/GluePatch/GluePatch.gd
Normal file
45
PickupableObjects/GluePatch/GluePatch.gd
Normal file
@@ -0,0 +1,45 @@
|
||||
extends PU_Item
|
||||
|
||||
@onready var is_reachable := false
|
||||
@onready var current_player:CharacterBody2D = null
|
||||
|
||||
@onready var item_info = {
|
||||
"item_name": item_name,
|
||||
"item_description": item_description,
|
||||
"item_type": item_type,
|
||||
"item_clip_size": item_clip_size,
|
||||
"item_ammo": item_ammo,
|
||||
"item_cooldown": item_cooldown,
|
||||
"item_texture": item_texture,
|
||||
}
|
||||
|
||||
func _input(event):
|
||||
if Input.is_action_pressed("interact") and is_reachable and current_player:
|
||||
print("ITEM TYPE: ", item_type)
|
||||
# if item_type == 0: # 0 is weapon
|
||||
# print("Weapon!")
|
||||
current_player.add_inventory_item(item_info)
|
||||
print("Adding inventory item!")
|
||||
cleanup.rpc()
|
||||
|
||||
@rpc("call_local", "any_peer")
|
||||
func cleanup():
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_glue_patch_pu_area_body_exited(body):
|
||||
if body.is_in_group("player"):
|
||||
current_player.set_context_label("")
|
||||
current_player = null
|
||||
is_reachable = false
|
||||
|
||||
|
||||
func _on_glue_patch_pu_area_body_entered(body):
|
||||
if body.is_in_group("player"):
|
||||
current_player = body
|
||||
is_reachable = true
|
||||
current_player.set_context_label.rpc_id(current_player.get_multiplayer_authority(), "Pickup " + item_info.item_name + "?")
|
||||
|
||||
|
||||
|
||||
|
28
PickupableObjects/GluePatch/GluePatch.tscn
Normal file
28
PickupableObjects/GluePatch/GluePatch.tscn
Normal file
@@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://r0424mbc1jx8"]
|
||||
|
||||
[ext_resource type="Script" path="res://PickupableObjects/GluePatch/GluePatch.gd" id="1_j7usm"]
|
||||
[ext_resource type="Texture2D" uid="uid://t7jsxx1bf6dl" path="res://PickupableObjects/GluePatch/glue_patch.png" id="2_aflxg"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dpesl"]
|
||||
size = Vector2(17, 25)
|
||||
|
||||
[node name="GluePatch" type="Node2D"]
|
||||
script = ExtResource("1_j7usm")
|
||||
item_name = "Glue Patch"
|
||||
item_description = "Lay down to slow down enemies!"
|
||||
item_type = 0
|
||||
item_clip_size = 3
|
||||
item_ammo = 3
|
||||
item_texture = ExtResource("2_aflxg")
|
||||
|
||||
[node name="GluePatchPUArea" type="Area2D" parent="."]
|
||||
|
||||
[node name="GluePatchImage" type="Sprite2D" parent="GluePatchPUArea"]
|
||||
texture = ExtResource("2_aflxg")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GluePatchPUArea"]
|
||||
position = Vector2(0.5, 3.5)
|
||||
shape = SubResource("RectangleShape2D_dpesl")
|
||||
|
||||
[connection signal="body_entered" from="GluePatchPUArea" to="." method="_on_glue_patch_pu_area_body_entered"]
|
||||
[connection signal="body_exited" from="GluePatchPUArea" to="." method="_on_glue_patch_pu_area_body_exited"]
|
BIN
PickupableObjects/GluePatch/glue_patch.png
Normal file
BIN
PickupableObjects/GluePatch/glue_patch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 517 B |
34
PickupableObjects/GluePatch/glue_patch.png.import
Normal file
34
PickupableObjects/GluePatch/glue_patch.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://t7jsxx1bf6dl"
|
||||
path="res://.godot/imported/glue_patch.png-0c65bf8d7d6c6677dda74b8b236a0fa9.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://PickupableObjects/GluePatch/glue_patch.png"
|
||||
dest_files=["res://.godot/imported/glue_patch.png-0c65bf8d7d6c6677dda74b8b236a0fa9.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
69
PickupableObjects/NailGun/NailGun.gd
Normal file
69
PickupableObjects/NailGun/NailGun.gd
Normal file
@@ -0,0 +1,69 @@
|
||||
extends PU_Item
|
||||
|
||||
@onready var is_reachable := false
|
||||
@onready var current_player:CharacterBody2D = null
|
||||
@onready var controlling_player:CharacterBody2D
|
||||
@onready var item_info = {
|
||||
"item_name": item_name,
|
||||
"item_description": item_description,
|
||||
"item_type": item_type,
|
||||
"item_clip_size": item_clip_size,
|
||||
"item_ammo": item_ammo,
|
||||
"item_cooldown": item_cooldown,
|
||||
"item_texture": item_texture,
|
||||
}
|
||||
|
||||
func _input(event):
|
||||
if Input.is_action_pressed("interact") and is_reachable and current_player:
|
||||
print("ITEM TYPE: ", item_type)
|
||||
# if item_type == 0: # 0 is weapon
|
||||
# print("Weapon!")
|
||||
current_player.add_inventory_item(item_info)
|
||||
print("Adding inventory item!")
|
||||
cleanup.rpc()
|
||||
|
||||
@rpc("call_local", "any_peer")
|
||||
func cleanup():
|
||||
queue_free()
|
||||
|
||||
func use_item(player: CharacterBody2D):
|
||||
controlling_player = player
|
||||
print("PLAYER FACING!", player.player_facing)
|
||||
var player_pos = controlling_player.get_position()
|
||||
var nail = preload("res://PickupableObjects/NailGun/NailShot.tscn").instantiate()
|
||||
var facing_vector = Vector2(0, -nail.nail_velocity)
|
||||
var spawn_pos = player_pos + Vector2(0, -nail.spawn_offset)
|
||||
nail.set_position(spawn_pos)
|
||||
match controlling_player.player_facing:
|
||||
"down":
|
||||
nail.set_rotation(deg_to_rad(180))
|
||||
facing_vector = Vector2(0, nail.nail_velocity)
|
||||
spawn_pos = player_pos + Vector2(0, nail.spawn_offset)
|
||||
"right":
|
||||
nail.set_rotation(deg_to_rad(90))
|
||||
facing_vector = Vector2(nail.nail_velocity, 0)
|
||||
spawn_pos = player_pos + Vector2(nail.spawn_offset, 0)
|
||||
"left":
|
||||
nail.set_rotation(deg_to_rad(-90))
|
||||
facing_vector = Vector2(-nail.nail_velocity, 0)
|
||||
spawn_pos = player_pos + Vector2(-nail.spawn_offset, 0)
|
||||
# spawn_item.set_position(spawn_pos)
|
||||
nail.apply_central_impulse(facing_vector)
|
||||
print("GET TREE: ", get_tree())
|
||||
await get_tree().create_timer(nail.cleanup_time).timeout
|
||||
nail.queue_free()
|
||||
|
||||
|
||||
func _on_nail_gun_area_body_entered(body):
|
||||
if body.is_in_group("player"):
|
||||
current_player = body
|
||||
is_reachable = true
|
||||
current_player.set_context_label.rpc_id(current_player.get_multiplayer_authority(), "Pickup " + item_info.item_name + "?")
|
||||
|
||||
|
||||
func _on_nail_gun_area_body_exited(body):
|
||||
if body.is_in_group("player"):
|
||||
current_player.set_context_label("")
|
||||
current_player = null
|
||||
is_reachable = false
|
||||
|
29
PickupableObjects/NailGun/NailGun.tscn
Normal file
29
PickupableObjects/NailGun/NailGun.tscn
Normal file
@@ -0,0 +1,29 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://d1w6rui20nu63"]
|
||||
|
||||
[ext_resource type="Script" path="res://PickupableObjects/NailGun/NailGun.gd" id="1_nb5m2"]
|
||||
[ext_resource type="Texture2D" uid="uid://ci13ka3m3nfmw" path="res://PickupableObjects/NailGun/nail_gun.png" id="2_w7jwi"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_38nhd"]
|
||||
size = Vector2(20, 31)
|
||||
|
||||
[node name="NailGun" type="Node2D"]
|
||||
script = ExtResource("1_nb5m2")
|
||||
item_name = "Nail Gun"
|
||||
item_description = "Shoot at Enemies to slow them down!"
|
||||
item_type = 0
|
||||
item_clip_size = 6
|
||||
item_ammo = 5
|
||||
item_cooldown = 2.0
|
||||
item_texture = ExtResource("2_w7jwi")
|
||||
|
||||
[node name="NailGunArea" type="Area2D" parent="."]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="NailGunArea"]
|
||||
texture = ExtResource("2_w7jwi")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="NailGunArea"]
|
||||
position = Vector2(0, 5.5)
|
||||
shape = SubResource("RectangleShape2D_38nhd")
|
||||
|
||||
[connection signal="body_entered" from="NailGunArea" to="." method="_on_nail_gun_area_body_entered"]
|
||||
[connection signal="body_exited" from="NailGunArea" to="." method="_on_nail_gun_area_body_exited"]
|
25
PickupableObjects/NailGun/NailShot.gd
Normal file
25
PickupableObjects/NailGun/NailShot.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
extends RigidBody2D
|
||||
|
||||
@export var hit_power:int = 10
|
||||
@export var nail_velocity:int = 200
|
||||
@export var spawn_offset:int = 25
|
||||
@export var cleanup_time:float = 2.0
|
||||
|
||||
@onready var collision_shape = get_node("CollisionShape2D")
|
||||
@onready var facing_vector = Vector2(0, 0)
|
||||
@onready var controlling_player:CharacterBody2D
|
||||
@onready var hit_player:CharacterBody2D = null
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.is_in_group("moveable"):
|
||||
collision_shape.set_deferred("disabled", true)
|
||||
body.apply_central_impulse(facing_vector)
|
||||
elif body.is_in_group("player"):
|
||||
body.player_hit.is_player_hit = true
|
||||
#body.player_hit.hit_velocity = last_velocity.normalized() * push_strength
|
||||
body.health_changed_func(-1)
|
||||
hit_player = body
|
21
PickupableObjects/NailGun/NailShot.tscn
Normal file
21
PickupableObjects/NailGun/NailShot.tscn
Normal file
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://brs78nmhyom78"]
|
||||
|
||||
[ext_resource type="Script" path="res://PickupableObjects/NailGun/NailShot.gd" id="1_ul31y"]
|
||||
[ext_resource type="Texture2D" uid="uid://cgtkkroa583fo" path="res://TileSets/Stuff.png" id="2_4fssh"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dsxgv"]
|
||||
size = Vector2(11, 15)
|
||||
|
||||
[node name="NailShot" type="RigidBody2D"]
|
||||
script = ExtResource("1_ul31y")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_4fssh")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(0, 98, 15, 15)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(0.5, -0.5)
|
||||
shape = SubResource("RectangleShape2D_dsxgv")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
BIN
PickupableObjects/NailGun/nail_gun.png
Normal file
BIN
PickupableObjects/NailGun/nail_gun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 281 B |
34
PickupableObjects/NailGun/nail_gun.png.import
Normal file
34
PickupableObjects/NailGun/nail_gun.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ci13ka3m3nfmw"
|
||||
path="res://.godot/imported/nail_gun.png-bd6d067424e08f8881295b50a9197858.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://PickupableObjects/NailGun/nail_gun.png"
|
||||
dest_files=["res://.godot/imported/nail_gun.png-bd6d067424e08f8881295b50a9197858.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
@@ -1,4 +1,4 @@
|
||||
extends Node
|
||||
extends Node2D
|
||||
|
||||
class_name PU_Item
|
||||
|
||||
@@ -6,7 +6,7 @@ enum ItemType {WEAPON, ITEM, OTHER, ELSE}
|
||||
|
||||
@export var item_name:String = ""
|
||||
@export_multiline var item_description:String = ""
|
||||
@export var item_type = ItemType
|
||||
@export var item_type: ItemType
|
||||
@export var item_clip_size:int = 0
|
||||
@export var item_ammo:int = 0
|
||||
@export var item_cooldown:float = 1.0
|
||||
|
@@ -5,13 +5,17 @@ extends Control
|
||||
@onready var ammo_label := $AmmoLabel
|
||||
@onready var image_slot := $ItemImage
|
||||
@onready var reload_bar := $ReloadBar
|
||||
@onready var item_selecter := $ItemSelector
|
||||
@onready var toolbar_slot := $ToolbarSlot
|
||||
|
||||
@rpc("call_local")
|
||||
func slot_selected():
|
||||
item_selecter.set_visible(true)
|
||||
toolbar_slot.set_modulate(Color("4f58d8"))
|
||||
slot_label.show()
|
||||
|
||||
@rpc("call_local")
|
||||
func slot_deselected():
|
||||
item_selecter.set_visible(false)
|
||||
toolbar_slot.set_modulate(Color("ffffff"))
|
||||
slot_label.hide()
|
||||
|
||||
func reload_item(cooldown: float):
|
||||
reload_bar.set_visible(true)
|
||||
@@ -24,24 +28,26 @@ func reload_item(cooldown: float):
|
||||
|
||||
func clear_slot():
|
||||
image_slot.set_texture(null)
|
||||
slot_label.set_text("")
|
||||
ammo_label.set_text("")
|
||||
ammo_label.set_visible(false)
|
||||
|
||||
func setup_slot(item_details: Dictionary):
|
||||
clear_slot()
|
||||
slot_label.set_text(item_details.item_name)
|
||||
var picNode = TextureRect.new()
|
||||
image_slot.add_child(picNode)
|
||||
picNode.set_mouse_filter(2)
|
||||
#picNode.set_mouse_filter(2)
|
||||
picNode.set_name("inv_texture")
|
||||
picNode.set_texture(item_details.item_texture)
|
||||
picNode.set_stretch_mode(TextureRect.STRETCH_KEEP)
|
||||
picNode.size = Vector2(16, 16)
|
||||
picNode.position = Vector2(-8, -8)
|
||||
picNode.set_anchors_preset(Control.PRESET_BOTTOM_WIDE)
|
||||
picNode.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
# picNode.set_stretch_mode(TextureRect.STRETCH_KEEP)
|
||||
picNode.size = Vector2(64, 64)
|
||||
picNode.position = Vector2(-32, -32)
|
||||
|
||||
if item_details.item_type == 0: # is weapon
|
||||
set_ammo_label(str(item_details.item_ammo))
|
||||
|
||||
func set_slot_label(slot_index: String):
|
||||
slot_label.set_text(slot_index)
|
||||
|
||||
|
||||
func set_ammo_label(ammo_value: String):
|
||||
ammo_label.set_visible(true)
|
||||
|
@@ -1,31 +1,10 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://defhc376y3h1d"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://defhc376y3h1d"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/Inventory/InventorySlot.gd" id="1_pltri"]
|
||||
[ext_resource type="FontFile" uid="uid://dj4pldmxeqmtt" path="res://UI/PressStart2P-Regular.ttf" id="1_wew62"]
|
||||
[ext_resource type="Texture2D" uid="uid://cgtkkroa583fo" path="res://TileSets/Stuff.png" id="2_mxhl7"]
|
||||
[ext_resource type="Texture2D" uid="uid://4txm3cwkoncp" path="res://UI/Inventory/circle_progress.png" id="3_5flhr"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_wthnv"]
|
||||
resource_name = "blink"
|
||||
loop_mode = 1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:self_modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_b5fyj"]
|
||||
_data = {
|
||||
"blink": SubResource("Animation_wthnv")
|
||||
}
|
||||
|
||||
[node name="InventorySlot" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 8
|
||||
@@ -48,34 +27,21 @@ theme_override_fonts/font = ExtResource("1_wew62")
|
||||
theme_override_font_sizes/font_size = 0
|
||||
text = "1"
|
||||
|
||||
[node name="ItemImage" type="Sprite2D" parent="."]
|
||||
|
||||
[node name="ToolbarSlot" type="Sprite2D" parent="."]
|
||||
scale = Vector2(4, 4)
|
||||
texture = ExtResource("2_mxhl7")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(80, 144, 16, 16)
|
||||
|
||||
[node name="ItemSelector" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
modulate = Color(0.054902, 0.290196, 0.258824, 1)
|
||||
self_modulate = Color(1, 1, 1, 0.822247)
|
||||
scale = Vector2(4, 4)
|
||||
texture = ExtResource("2_mxhl7")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(64, 144, 16, 16)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="ItemSelector"]
|
||||
autoplay = "blink"
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_b5fyj")
|
||||
}
|
||||
|
||||
[node name="SlotLabel" type="Label" parent="."]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_left = -51.0
|
||||
offset_top = -58.0
|
||||
offset_right = 61.0
|
||||
offset_bottom = -35.0
|
||||
offset_left = -53.0
|
||||
offset_top = -65.0
|
||||
offset_right = 75.0
|
||||
offset_bottom = -42.0
|
||||
theme_override_fonts/font = ExtResource("1_wew62")
|
||||
theme_override_font_sizes/font_size = 0
|
||||
text = "ItemName"
|
||||
@@ -92,5 +58,3 @@ texture_under = ExtResource("3_5flhr")
|
||||
texture_progress = ExtResource("3_5flhr")
|
||||
tint_under = Color(1, 1, 1, 0)
|
||||
tint_progress = Color(0.254902, 0.654902, 0.407843, 0.588235)
|
||||
|
||||
[node name="ItemImage" type="Sprite2D" parent="."]
|
||||
|
@@ -2,18 +2,87 @@ extends Control
|
||||
|
||||
|
||||
@export var items:Array = []
|
||||
@export var current_slot:int = 0
|
||||
|
||||
|
||||
@export var active_item:Dictionary = {}
|
||||
|
||||
@onready var old_slot:int = 0
|
||||
@onready var current_slot:int = 0
|
||||
@onready var slot_container = $Panel/HBoxContainer
|
||||
|
||||
signal active_item_changed(active_item)
|
||||
|
||||
func _process(_delta):
|
||||
if current_slot == 0:
|
||||
return
|
||||
if Input.is_action_just_pressed("drop_item"):
|
||||
if items[current_slot]:
|
||||
print("ITEM IN SLOT: ", items[current_slot])
|
||||
|
||||
drop_item()
|
||||
if Input.is_action_just_released("cycle_down"):
|
||||
var new_slot = current_slot + 1
|
||||
if new_slot == 6:
|
||||
new_slot = 1
|
||||
if new_slot > len(items):
|
||||
new_slot = 1
|
||||
set_active_slot(new_slot)
|
||||
if Input.is_action_just_released("cycle_up"):
|
||||
var new_slot = current_slot - 1
|
||||
if new_slot == 0:
|
||||
new_slot = len(items)
|
||||
set_active_slot(new_slot)
|
||||
|
||||
|
||||
func add_inventory_item(new_item: Dictionary):
|
||||
if len(items) == 6:
|
||||
drop_item(true)
|
||||
items.append(new_item)
|
||||
var slot = get_node("Panel/HBoxContainer/InventorySlot" + str(len(items)))
|
||||
slot.setup_slot(new_item)
|
||||
if len(items) == 1:
|
||||
set_active_slot(len(items))
|
||||
|
||||
|
||||
func drop_item(replace: bool = false):
|
||||
print("CURRENT SLOT: ", current_slot)
|
||||
var clear_slot = current_slot
|
||||
if items[clear_slot]:
|
||||
# TODO: Here we would spawn the item in
|
||||
items.remove_at(clear_slot)
|
||||
print("NEW ITEM ARRAY! ", items)
|
||||
if not replace:
|
||||
# old_slot = current_slot
|
||||
# current_slot = current_slot - 1
|
||||
# if current_slot > -1:
|
||||
# active_item = items[current_slot]
|
||||
# else:
|
||||
# active_item = {}
|
||||
var slot = get_node("$Panel/HBoxContainer/InventorySlot" + str(current_slot))
|
||||
slot.clear_slot()
|
||||
set_active_slot(clear_slot)
|
||||
|
||||
func set_active_slot(slot_index: int):
|
||||
print("CURRENT SLOT: ", current_slot, " SLOT INDEX: ", slot_index)
|
||||
if current_slot != slot_index and current_slot != 0:
|
||||
var old_slot = get_node("Panel/HBoxContainer/InventorySlot" + str(current_slot))
|
||||
old_slot.slot_deselected()
|
||||
#old_slot.slot_deselected.rpc_id(multiplayer.get_unique_id())
|
||||
if len(items) == 0:
|
||||
active_item = {}
|
||||
current_slot = 0
|
||||
else:
|
||||
var slot = get_node("Panel/HBoxContainer/InventorySlot" + str(slot_index))
|
||||
slot.slot_selected()
|
||||
#slot.slot_selected.rpc_id(multiplayer.get_unique_id())
|
||||
current_slot = slot_index
|
||||
active_item = items[current_slot - 1]
|
||||
emit_signal("active_item_changed", active_item)
|
||||
|
||||
|
||||
|
||||
#func set_active_slot():
|
||||
# if current_slot == -1:
|
||||
# return
|
||||
# var old_slot = get_node("Panel/HBoxContainer/InventorySlot" + str(old_slot))
|
||||
# old_slot.slot_deselected.rpc_id(get_multiplayer_authority())
|
||||
# var slot = get_node("Panel/HBoxContainer/InventorySlot" + str(current_slot))
|
||||
# slot.slot_selected.rpc_id(get_multiplayer_authority())
|
||||
|
||||
|
@@ -44,7 +44,6 @@ theme_override_constants/separation = 70
|
||||
|
||||
[node name="InventorySlot1" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="InventorySlot2" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
|
||||
@@ -65,4 +64,5 @@ size_flags_vertical = 4
|
||||
|
||||
[node name="InventorySlot6" parent="Panel/HBoxContainer" instance=ExtResource("1_a71mm")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
@@ -15,6 +15,10 @@ run/main_scene="res://Game Manager/game_manager.tscn"
|
||||
config/features=PackedStringArray("4.0", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
ItemDatabase="*res://ItemDatabase/ItemDatabase.gd"
|
||||
|
||||
[display]
|
||||
|
||||
window/stretch/mode="viewport"
|
||||
@@ -86,6 +90,16 @@ drop_item={
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
interact={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
use_item={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(101, 18),"global_position":Vector2(105, 63),"factor":1.0,"button_index":1,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
|
Reference in New Issue
Block a user