init
This commit is contained in:
23
items/apple.tres
Normal file
23
items/apple.tres
Normal file
@@ -0,0 +1,23 @@
|
||||
[gd_resource type="Resource" script_class="ItemData" format=3 uid="uid://wif1wqrr83k0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccj66fmxndpv" path="res://items/item_effects/item_effect.gd" id="1_dumep"]
|
||||
[ext_resource type="AudioStream" uid="uid://unkdyg28yfhq" path="res://items/item_effects/hp-up.wav" id="2_rj1s8"]
|
||||
[ext_resource type="Script" uid="uid://rgpcvn78hiod" path="res://items/scripts/item_data.gd" id="2_xmv7l"]
|
||||
[ext_resource type="Script" uid="uid://cbwvdfpoms6fb" path="res://items/item_effects/item_effect_heal.gd" id="3_ia5ia"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxf00vjmse6ab" path="res://items/sprites/items.png" id="5_hbuy5"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qgymf"]
|
||||
script = ExtResource("3_ia5ia")
|
||||
audio = ExtResource("2_rj1s8")
|
||||
metadata/_custom_type_script = "uid://cbwvdfpoms6fb"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_26tcx"]
|
||||
atlas = ExtResource("5_hbuy5")
|
||||
region = Rect2(192, 0, 32, 32)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_xmv7l")
|
||||
name = "A delicious red apple"
|
||||
texture = SubResource("AtlasTexture_26tcx")
|
||||
effects = Array[ExtResource("1_dumep")]([SubResource("Resource_qgymf")])
|
||||
metadata/_custom_type_script = "uid://rgpcvn78hiod"
|
||||
16
items/gem.tres
Normal file
16
items/gem.tres
Normal file
@@ -0,0 +1,16 @@
|
||||
[gd_resource type="Resource" script_class="ItemData" format=3 uid="uid://bc4mt6ldpoq18"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccj66fmxndpv" path="res://items/item_effects/item_effect.gd" id="1_gbvxt"]
|
||||
[ext_resource type="Script" uid="uid://rgpcvn78hiod" path="res://items/scripts/item_data.gd" id="1_m7x72"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxf00vjmse6ab" path="res://items/sprites/items.png" id="2_o2n4o"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gbvxt"]
|
||||
atlas = ExtResource("2_o2n4o")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_m7x72")
|
||||
name = "Gem"
|
||||
description = "A valuable gem"
|
||||
texture = SubResource("AtlasTexture_gbvxt")
|
||||
metadata/_custom_type_script = "uid://rgpcvn78hiod"
|
||||
BIN
items/item_effects/hp-up.wav
Normal file
BIN
items/item_effects/hp-up.wav
Normal file
Binary file not shown.
24
items/item_effects/hp-up.wav.import
Normal file
24
items/item_effects/hp-up.wav.import
Normal file
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://unkdyg28yfhq"
|
||||
path="res://.godot/imported/hp-up.wav-2660d0c83d6b7930d0bf14b33024a9e0.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://items/item_effects/hp-up.wav"
|
||||
dest_files=["res://.godot/imported/hp-up.wav-2660d0c83d6b7930d0bf14b33024a9e0.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
6
items/item_effects/item_effect.gd
Normal file
6
items/item_effects/item_effect.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
class_name ItemEffect extends Resource
|
||||
|
||||
@export var use_description := ""
|
||||
|
||||
func use() -> void:
|
||||
pass
|
||||
1
items/item_effects/item_effect.gd.uid
Normal file
1
items/item_effects/item_effect.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ccj66fmxndpv
|
||||
8
items/item_effects/item_effect_heal.gd
Normal file
8
items/item_effects/item_effect_heal.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
class_name ItemEffectHeal extends ItemEffect
|
||||
|
||||
@export var heal_amount := 1
|
||||
@export var audio: AudioStream
|
||||
|
||||
func use() -> void:
|
||||
PlayerManager.player.update_hp(heal_amount)
|
||||
PauseMenu.play_audio(audio)
|
||||
1
items/item_effects/item_effect_heal.gd.uid
Normal file
1
items/item_effects/item_effect_heal.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cbwvdfpoms6fb
|
||||
46
items/item_pickup/item_pickup.gd
Normal file
46
items/item_pickup/item_pickup.gd
Normal file
@@ -0,0 +1,46 @@
|
||||
@tool
|
||||
class_name ItemPickup extends CharacterBody2D
|
||||
|
||||
signal picked_up
|
||||
|
||||
@export var item_data: ItemData :
|
||||
set = set_item_data
|
||||
|
||||
@onready var area: Area2D = $Area2D
|
||||
@onready var sprite: Sprite2D = $Sprite2D
|
||||
@onready var audio_player: AudioStreamPlayer2D = $AudioStreamPlayer2D
|
||||
|
||||
func _ready() -> void:
|
||||
update_texture()
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
area.body_entered.connect(on_body_enter)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var collision_info := move_and_collide(velocity * delta)
|
||||
if collision_info:
|
||||
velocity = velocity.bounce(collision_info.get_normal())
|
||||
velocity -= velocity * delta * 4
|
||||
|
||||
func on_body_enter(body: Node2D) -> void:
|
||||
if !item_data or body is not Player:
|
||||
return
|
||||
if PlayerManager.INVENTORY_DATA.add_item(item_data):
|
||||
item_picked_up()
|
||||
|
||||
func item_picked_up() -> void:
|
||||
area.body_entered.disconnect(on_body_enter)
|
||||
audio_player.play()
|
||||
visible = false
|
||||
picked_up.emit()
|
||||
await audio_player.finished
|
||||
queue_free()
|
||||
|
||||
func update_texture() -> void:
|
||||
if !item_data or !sprite:
|
||||
return
|
||||
sprite.texture = item_data.texture
|
||||
|
||||
func set_item_data(new_item_data: ItemData) -> void:
|
||||
item_data = new_item_data
|
||||
update_texture()
|
||||
1
items/item_pickup/item_pickup.gd.uid
Normal file
1
items/item_pickup/item_pickup.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dtuirhoxa1fkj
|
||||
107
items/item_pickup/item_pickup.tscn
Normal file
107
items/item_pickup/item_pickup.tscn
Normal file
@@ -0,0 +1,107 @@
|
||||
[gd_scene format=3 uid="uid://bd3uiuggwfq2v"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dtuirhoxa1fkj" path="res://items/item_pickup/item_pickup.gd" id="1_0g51u"]
|
||||
[ext_resource type="AudioStream" uid="uid://borbldx5nrrjp" path="res://items/item_pickup/item_pickup.wav" id="2_0rscd"]
|
||||
[ext_resource type="Texture2D" uid="uid://bxqdnnk4dqnu5" path="res://player/sprites/Shadow.png" id="2_jl14n"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxf00vjmse6ab" path="res://items/sprites/items.png" id="2_tc5ok"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_0rscd"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7rq5k"]
|
||||
atlas = ExtResource("2_tc5ok")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jl14n"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_puw1c"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("ShadowSprite:scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.5, 0.5)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_bjvna"]
|
||||
resource_name = "bounce"
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8),
|
||||
"transitions": PackedFloat32Array(-2, -2, -2, -2, -2),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, -6), Vector2(0, 0), Vector2(0, -2), Vector2(0, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("ShadowSprite:scale")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.4, 0.6, 0.8),
|
||||
"transitions": PackedFloat32Array(-2, -2, -2, -2, -2),
|
||||
"update": 0,
|
||||
"values": [Vector2(0.5, 0.5), Vector2(0.2, 0.2), Vector2(0.5, 0.5), Vector2(0.4, 0.4), Vector2(0.5, 0.5)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_o0c3x"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_puw1c"),
|
||||
&"bounce": SubResource("Animation_bjvna")
|
||||
}
|
||||
|
||||
[node name="ItemPickup" type="CharacterBody2D" unique_id=320551238]
|
||||
collision_layer = 0
|
||||
collision_mask = 16
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_0g51u")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="." unique_id=1719100885]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=82383132]
|
||||
shape = SubResource("CircleShape2D_0rscd")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1485596032]
|
||||
texture = SubResource("AtlasTexture_7rq5k")
|
||||
|
||||
[node name="ShadowSprite" type="Sprite2D" parent="." unique_id=772537575]
|
||||
modulate = Color(0, 0, 0, 0.34901962)
|
||||
position = Vector2(0, 8)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = ExtResource("2_jl14n")
|
||||
|
||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="." unique_id=60991160]
|
||||
stream = ExtResource("2_0rscd")
|
||||
max_polyphony = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=721385119]
|
||||
shape = SubResource("CircleShape2D_jl14n")
|
||||
debug_color = Color(0.24937189, 0.6105543, 0.506212, 0.41960785)
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1968131721]
|
||||
libraries/ = SubResource("AnimationLibrary_o0c3x")
|
||||
autoplay = &"bounce"
|
||||
BIN
items/item_pickup/item_pickup.wav
Normal file
BIN
items/item_pickup/item_pickup.wav
Normal file
Binary file not shown.
24
items/item_pickup/item_pickup.wav.import
Normal file
24
items/item_pickup/item_pickup.wav.import
Normal file
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://borbldx5nrrjp"
|
||||
path="res://.godot/imported/item_pickup.wav-cb95f6a75b96e4fc19c3e7765c534824.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://items/item_pickup/item_pickup.wav"
|
||||
dest_files=["res://.godot/imported/item_pickup.wav-cb95f6a75b96e4fc19c3e7765c534824.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=0
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
16
items/key_dungeon.tres
Normal file
16
items/key_dungeon.tres
Normal file
@@ -0,0 +1,16 @@
|
||||
[gd_resource type="Resource" script_class="ItemData" format=3 uid="uid://q18yuwmxakt8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ccj66fmxndpv" path="res://items/item_effects/item_effect.gd" id="1_gyq0a"]
|
||||
[ext_resource type="Script" uid="uid://rgpcvn78hiod" path="res://items/scripts/item_data.gd" id="2_5w3bm"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxf00vjmse6ab" path="res://items/sprites/items.png" id="3_5w3bm"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_p582r"]
|
||||
atlas = ExtResource("3_5w3bm")
|
||||
region = Rect2(224, 0, 32, 32)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_5w3bm")
|
||||
name = "Dungeon Key"
|
||||
description = "Looks a standard key. Who knows what kind of doors it will unlock?"
|
||||
texture = SubResource("AtlasTexture_p582r")
|
||||
metadata/_custom_type_script = "uid://rgpcvn78hiod"
|
||||
25
items/potion.tres
Normal file
25
items/potion.tres
Normal file
@@ -0,0 +1,25 @@
|
||||
[gd_resource type="Resource" script_class="ItemData" format=3 uid="uid://cysttu2nlwmpp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rgpcvn78hiod" path="res://items/scripts/item_data.gd" id="1_70df6"]
|
||||
[ext_resource type="Script" uid="uid://ccj66fmxndpv" path="res://items/item_effects/item_effect.gd" id="1_hxf14"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxf00vjmse6ab" path="res://items/sprites/items.png" id="2_8h85v"]
|
||||
[ext_resource type="Script" uid="uid://cbwvdfpoms6fb" path="res://items/item_effects/item_effect_heal.gd" id="2_u0y06"]
|
||||
[ext_resource type="AudioStream" uid="uid://unkdyg28yfhq" path="res://items/item_effects/hp-up.wav" id="3_ncbnu"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_q7uc3"]
|
||||
script = ExtResource("2_u0y06")
|
||||
heal_amount = 2
|
||||
audio = ExtResource("3_ncbnu")
|
||||
metadata/_custom_type_script = "uid://cbwvdfpoms6fb"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2nysy"]
|
||||
atlas = ExtResource("2_8h85v")
|
||||
region = Rect2(32, 0, 32, 32)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_70df6")
|
||||
name = "Potion"
|
||||
description = "A potion to health your wounds"
|
||||
texture = SubResource("AtlasTexture_2nysy")
|
||||
effects = Array[ExtResource("1_hxf14")]([SubResource("Resource_q7uc3")])
|
||||
metadata/_custom_type_script = "uid://rgpcvn78hiod"
|
||||
15
items/scripts/item_data.gd
Normal file
15
items/scripts/item_data.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
class_name ItemData extends Resource
|
||||
|
||||
@export var name := ""
|
||||
@export_multiline var description := ""
|
||||
@export var texture: Texture2D
|
||||
@export_category("Item user effects")
|
||||
@export var effects: Array[ItemEffect]
|
||||
|
||||
func use() -> bool:
|
||||
if effects.is_empty():
|
||||
return false
|
||||
for effect in effects:
|
||||
if effect:
|
||||
effect.use()
|
||||
return true
|
||||
1
items/scripts/item_data.gd.uid
Normal file
1
items/scripts/item_data.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://rgpcvn78hiod
|
||||
BIN
items/sprites/items.png
Normal file
BIN
items/sprites/items.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
40
items/sprites/items.png.import
Normal file
40
items/sprites/items.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dxf00vjmse6ab"
|
||||
path="res://.godot/imported/items.png-c112ec8c06134d386ecee7bdec880e50.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://items/sprites/items.png"
|
||||
dest_files=["res://.godot/imported/items.png-c112ec8c06134d386ecee7bdec880e50.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
|
||||
16
items/stone.tres
Normal file
16
items/stone.tres
Normal file
@@ -0,0 +1,16 @@
|
||||
[gd_resource type="Resource" script_class="ItemData" format=3 uid="uid://mcj3rqawtwa5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rgpcvn78hiod" path="res://items/scripts/item_data.gd" id="1_becff"]
|
||||
[ext_resource type="Script" uid="uid://ccj66fmxndpv" path="res://items/item_effects/item_effect.gd" id="1_uj5p3"]
|
||||
[ext_resource type="Texture2D" uid="uid://dxf00vjmse6ab" path="res://items/sprites/items.png" id="2_mwerj"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uj5p3"]
|
||||
atlas = ExtResource("2_mwerj")
|
||||
region = Rect2(64, 0, 32, 32)
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_becff")
|
||||
name = "Stone"
|
||||
description = "A simple stone"
|
||||
texture = SubResource("AtlasTexture_uj5p3")
|
||||
metadata/_custom_type_script = "uid://rgpcvn78hiod"
|
||||
Reference in New Issue
Block a user