Fixed unique items not spawning outside of main menu
This commit is contained in:
parent
102fd4f34a
commit
bffe842d49
9 changed files with 81 additions and 10 deletions
|
|
@ -2,10 +2,7 @@ class_name ItemSpawn extends Node2D
|
||||||
|
|
||||||
@export var common_items : Array[PackedScene]
|
@export var common_items : Array[PackedScene]
|
||||||
@export var rare_items : Array[PackedScene]
|
@export var rare_items : Array[PackedScene]
|
||||||
static var unique_items : Array[PackedScene] = [
|
static var unique_items : Array[PackedScene] = []
|
||||||
load("res://items/permanent_items/backslash.tscn"),
|
|
||||||
load("res://items/permanent_items/high_jump.tscn")
|
|
||||||
]
|
|
||||||
|
|
||||||
@export var rarity_bonus = 0
|
@export var rarity_bonus = 0
|
||||||
@export var guarantee_rare : bool = false
|
@export var guarantee_rare : bool = false
|
||||||
|
|
@ -39,3 +36,9 @@ func _ready():
|
||||||
add_child.call_deferred(object)
|
add_child.call_deferred(object)
|
||||||
object.reparent.call_deferred(get_parent())
|
object.reparent.call_deferred(get_parent())
|
||||||
|
|
||||||
|
static func refill_unique_item_pool():
|
||||||
|
unique_items = [
|
||||||
|
load("res://items/permanent_items/backslash.tscn"),
|
||||||
|
load("res://items/permanent_items/high_jump.tscn"),
|
||||||
|
load("res://items/permanent_items/upslash.tscn")
|
||||||
|
]
|
||||||
|
|
|
||||||
5
items/permanent_items/upslash.gd
Normal file
5
items/permanent_items/upslash.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Item
|
||||||
|
|
||||||
|
func collect() -> bool:
|
||||||
|
player.can_upslash = true
|
||||||
|
return true
|
||||||
1
items/permanent_items/upslash.gd.uid
Normal file
1
items/permanent_items/upslash.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cyql6o6m4xrv3
|
||||||
41
items/permanent_items/upslash.tscn
Normal file
41
items/permanent_items/upslash.tscn
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
[gd_scene load_steps=8 format=3 uid="uid://bwtdls58ajair"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cyql6o6m4xrv3" path="res://items/permanent_items/upslash.gd" id="1_vv4qh"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="3_ayb0v"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d4mrbgfl7jpqq" path="res://items/ItemShine.png" id="4_35mg8"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c7mrm8uel7r36" path="res://items/permanent_items/backslash.png" id="5_f1n28"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dxcfkdhl4g24c" path="res://items/active_items/updash/updash.png" id="6_4gfq4"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://pdd0sy3p4y0d" path="res://sounds/750240__universfield__coin-drop.mp3" id="6_5tj4p"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_hvhjo"]
|
||||||
|
|
||||||
|
[node name="Upslash" type="Area2D"]
|
||||||
|
script = ExtResource("1_vv4qh")
|
||||||
|
|
||||||
|
[node name="EarthAligner" parent="." instance=ExtResource("3_ayb0v")]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
visible = false
|
||||||
|
scale = Vector2(7, 7)
|
||||||
|
shape = SubResource("CircleShape2D_hvhjo")
|
||||||
|
|
||||||
|
[node name="Sprite2D2" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.725757, 0.519822, 5.77569e-07, 1)
|
||||||
|
scale = Vector2(2.5, 2.5)
|
||||||
|
texture = ExtResource("4_35mg8")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(0, -13)
|
||||||
|
rotation = 0.7853982
|
||||||
|
scale = Vector2(1.2, 1.2)
|
||||||
|
texture = ExtResource("5_f1n28")
|
||||||
|
|
||||||
|
[node name="Sprite2D3" type="Sprite2D" parent="."]
|
||||||
|
z_index = -1
|
||||||
|
position = Vector2(2, -18)
|
||||||
|
scale = Vector2(1.4, 1.4)
|
||||||
|
texture = ExtResource("6_4gfq4")
|
||||||
|
|
||||||
|
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||||
|
stream = ExtResource("6_5tj4p")
|
||||||
|
volume_db = 2.0
|
||||||
|
|
@ -48,6 +48,8 @@ var damage_knockup = 500
|
||||||
# Attack Handling
|
# Attack Handling
|
||||||
var atk_cooldown = 0.5
|
var atk_cooldown = 0.5
|
||||||
var atk_timer = 0
|
var atk_timer = 0
|
||||||
|
var can_upslash = true
|
||||||
|
|
||||||
signal attack
|
signal attack
|
||||||
|
|
||||||
# Active Item
|
# Active Item
|
||||||
|
|
@ -86,7 +88,10 @@ func manage_attack(delta : float):
|
||||||
atk_timer = max(0, atk_timer-delta)
|
atk_timer = max(0, atk_timer-delta)
|
||||||
if handle_input:
|
if handle_input:
|
||||||
if(Input.is_action_just_pressed("attack") and atk_timer <= 0):
|
if(Input.is_action_just_pressed("attack") and atk_timer <= 0):
|
||||||
attack.emit()
|
if Input.is_action_pressed("up") and can_upslash:
|
||||||
|
attack.emit("up")
|
||||||
|
else:
|
||||||
|
attack.emit("horizontal")
|
||||||
$AnimatedSprite2D.play("attack")
|
$AnimatedSprite2D.play("attack")
|
||||||
$SwordSwingAudio.play()
|
$SwordSwingAudio.play()
|
||||||
atk_timer = atk_cooldown
|
atk_timer = atk_cooldown
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=20 format=3 uid="uid://cmaovvr15b3qk"]
|
[gd_scene load_steps=21 format=3 uid="uid://cmaovvr15b3qk"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ddidj1uau28ck" path="res://player/player.gd" id="1_4flbx"]
|
[ext_resource type="Script" uid="uid://ddidj1uau28ck" path="res://player/player.gd" id="1_4flbx"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c4xg25s8loxp0" path="res://player/Player_Walk/Walk 1.png" id="2_hg6s5"]
|
[ext_resource type="Texture2D" uid="uid://c4xg25s8loxp0" path="res://player/Player_Walk/Walk 1.png" id="2_hg6s5"]
|
||||||
|
|
@ -112,4 +112,5 @@ pitch_scale = 1.62
|
||||||
[node name="SwordSwingAudio" type="AudioStreamPlayer2D" parent="."]
|
[node name="SwordSwingAudio" type="AudioStreamPlayer2D" parent="."]
|
||||||
stream = ExtResource("17_tqiix")
|
stream = ExtResource("17_tqiix")
|
||||||
volume_db = -12.0
|
volume_db = -12.0
|
||||||
|
|
||||||
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_attack_end"]
|
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_attack_end"]
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,16 @@ func _ready() -> void:
|
||||||
anim_sprite = $AnimatedSprite2D
|
anim_sprite = $AnimatedSprite2D
|
||||||
get_parent().attack.connect(swing)
|
get_parent().attack.connect(swing)
|
||||||
|
|
||||||
func swing() -> void:
|
func swing(dir_str) -> void:
|
||||||
facing = - get_parent().facing * facing_mult
|
facing = - get_parent().facing * facing_mult
|
||||||
scale.x = abs(scale.x) * facing
|
if dir_str == "up":
|
||||||
|
scale.x = abs(scale.x)
|
||||||
|
scale.y = abs(scale.y) * facing
|
||||||
|
rotation = PI/2
|
||||||
|
else:
|
||||||
|
scale.x = abs(scale.x) * facing
|
||||||
|
scale.y = abs(scale.y)
|
||||||
|
rotation = 0
|
||||||
anim_sprite.visible = true
|
anim_sprite.visible = true
|
||||||
await get_tree().create_timer(0.01).timeout
|
await get_tree().create_timer(0.01).timeout
|
||||||
slash_timer = slash_duration
|
slash_timer = slash_duration
|
||||||
|
|
@ -23,6 +30,6 @@ func _physics_process(delta: float) -> void:
|
||||||
if(slash_timer == 0):
|
if(slash_timer == 0):
|
||||||
anim_sprite.visible = false
|
anim_sprite.visible = false
|
||||||
for area in get_overlapping_areas():
|
for area in get_overlapping_areas():
|
||||||
area.hurt(damage, -get_parent().earth_aligner.global_from_local(Vector2(-facing, 0)))
|
area.hurt(damage, -get_parent().earth_aligner.global_from_local(Vector2(-facing, 0)).rotated(facing*rotation))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,11 @@ 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":90,"key_label":0,"unicode":121,"location":0,"echo":false,"script":null)
|
"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":90,"key_label":0,"unicode":121,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
up={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"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":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
ItemSpawn.refill_unique_item_pool()
|
||||||
|
|
||||||
func get_grid() -> Grid:
|
func get_grid() -> Grid:
|
||||||
return $Grid
|
return $Grid
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue