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:
|
||||
@@ -237,6 +254,17 @@ func move_player(c_velocity: Vector2):
|
||||
# var normal = collision.get_normal()
|
||||
# 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
|
||||
|
Reference in New Issue
Block a user