feat: add a chest node; add logic for random scroll in the chest; add a timer t hide the scroll after;
This commit is contained in:
@@ -15,4 +15,3 @@ even commercial ones. Attribution is not required but appreciated.
|
|||||||
Patreon: https://www.patreon.com/pixelarchipel
|
Patreon: https://www.patreon.com/pixelarchipel
|
||||||
Itchio Page: https://pixel-boy.itch.io/
|
Itchio Page: https://pixel-boy.itch.io/
|
||||||
Pack Page: https://pixel-boy.itch.io/ninja-adventure-asset-pack
|
Pack Page: https://pixel-boy.itch.io/ninja-adventure-asset-pack
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://decx4kt8ftrb5" path="res://Scenes/LockedDoor/locked_door.gd" id="7_nr542"]
|
[ext_resource type="Script" uid="uid://decx4kt8ftrb5" path="res://Scenes/LockedDoor/locked_door.gd" id="7_nr542"]
|
||||||
[ext_resource type="PackedScene" uid="uid://onpen57mc6i8" path="res://Scenes/PuzzleButton/puzzle_button.tscn" id="7_ohrk8"]
|
[ext_resource type="PackedScene" uid="uid://onpen57mc6i8" path="res://Scenes/PuzzleButton/puzzle_button.tscn" id="7_ohrk8"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bdu180bpjrn5h" path="res://Scenes/Switch/switch.tscn" id="8_njm7v"]
|
[ext_resource type="PackedScene" uid="uid://bdu180bpjrn5h" path="res://Scenes/Switch/switch.tscn" id="8_njm7v"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bqcsg2t581j7b" path="res://Scenes/TreasureChest/treasure_chest.tscn" id="9_bkvnf"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dsb83tlcapw8l" path="res://Scenes/NPC/npc.tscn" id="10_g3lhp"]
|
[ext_resource type="PackedScene" uid="uid://dsb83tlcapw8l" path="res://Scenes/NPC/npc.tscn" id="10_g3lhp"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_04h35"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_04h35"]
|
||||||
@@ -831,6 +832,15 @@ text = "Green Ninja"
|
|||||||
[node name="Switch" parent="ObstacleLayer" unique_id=78052327 instance=ExtResource("8_njm7v")]
|
[node name="Switch" parent="ObstacleLayer" unique_id=78052327 instance=ExtResource("8_njm7v")]
|
||||||
position = Vector2(-8, -26)
|
position = Vector2(-8, -26)
|
||||||
|
|
||||||
|
[node name="TreasureChest" parent="ObstacleLayer" unique_id=2069908436 instance=ExtResource("9_bkvnf")]
|
||||||
|
position = Vector2(-41, -19)
|
||||||
|
|
||||||
|
[node name="TreasureChest2" parent="ObstacleLayer" unique_id=1691247799 instance=ExtResource("9_bkvnf")]
|
||||||
|
position = Vector2(15, -19)
|
||||||
|
|
||||||
|
[node name="TreasureChest3" parent="ObstacleLayer" unique_id=267919049 instance=ExtResource("9_bkvnf")]
|
||||||
|
position = Vector2(-79, -19)
|
||||||
|
|
||||||
[node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("5_oi8ly")]
|
[node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("5_oi8ly")]
|
||||||
position = Vector2(137, -107)
|
position = Vector2(137, -107)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
extends StaticBody2D
|
||||||
|
|
||||||
|
var can_interact: bool = false
|
||||||
|
var is_open: bool = false
|
||||||
|
@export var scrolls: Array[Sprite2D]
|
||||||
|
var scroll_number = 0
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
scroll_number = randi_range(1, 4)
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if Input.is_action_just_pressed("Interact") and can_interact:
|
||||||
|
if !is_open:
|
||||||
|
$AudioStreamPlayer.play()
|
||||||
|
$AnimatedSprite2D.play("open")
|
||||||
|
scrolls[scroll_number].visible = true
|
||||||
|
$Timer.start()
|
||||||
|
is_open = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout(scroll_number: int) -> void:
|
||||||
|
scrolls[scroll_number].visible = false
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://h2y2p3dcj4ne
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bqcsg2t581j7b"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://h2y2p3dcj4ne" path="res://Scenes/TreasureChest/treasure_chest.gd" id="1_2tkyh"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://crewi6wldd7od" path="res://Ninja Adventure - Asset Pack/Items/Treasure/BigTreasureChest.png" id="1_v1qrq"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://ug5n4ca2cc77" path="res://Ninja Adventure - Asset Pack/Sounds/Game/Success3.wav" id="3_sdjdt"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://fybqrl1dbdao" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollIce.png" id="4_vnph0"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c1coi2k1hgv5b" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollFire.png" id="5_2b3qj"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d1his3w8n84aa" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollPlant.png" id="6_n2as5"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d1vovcdepn1w5" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollRock.png" id="7_lh1s0"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://6dmy1j0t5mqy" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollEmpty.png" id="8_lh1s0"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2tkyh"]
|
||||||
|
atlas = ExtResource("1_v1qrq")
|
||||||
|
region = Rect2(0, 0, 16, 14)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_sdjdt"]
|
||||||
|
atlas = ExtResource("1_v1qrq")
|
||||||
|
region = Rect2(16, 0, 16, 14)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_chgu2"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_2tkyh")
|
||||||
|
}],
|
||||||
|
"loop": 1,
|
||||||
|
"name": &"closed",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_sdjdt")
|
||||||
|
}],
|
||||||
|
"loop": 1,
|
||||||
|
"name": &"open",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_chgu2"]
|
||||||
|
size = Vector2(16, 12)
|
||||||
|
|
||||||
|
[node name="TreasureChest" type="StaticBody2D" unique_id=2069908436 node_paths=PackedStringArray("scrolls") groups=["interactable"]]
|
||||||
|
script = ExtResource("1_2tkyh")
|
||||||
|
scrolls = [NodePath("EmptyScroll"), NodePath("IceScroll"), NodePath("FireScroll"), NodePath("PlantScroll"), NodePath("RockScroll")]
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=990575183]
|
||||||
|
sprite_frames = SubResource("SpriteFrames_chgu2")
|
||||||
|
animation = &"open"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=104658718]
|
||||||
|
position = Vector2(0, 1)
|
||||||
|
shape = SubResource("RectangleShape2D_chgu2")
|
||||||
|
|
||||||
|
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="." unique_id=1922945704]
|
||||||
|
stream = ExtResource("3_sdjdt")
|
||||||
|
|
||||||
|
[node name="IceScroll" type="Sprite2D" parent="." unique_id=1614825692]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(0, -13)
|
||||||
|
texture = ExtResource("4_vnph0")
|
||||||
|
|
||||||
|
[node name="FireScroll" type="Sprite2D" parent="." unique_id=55522702]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(0, -13)
|
||||||
|
texture = ExtResource("5_2b3qj")
|
||||||
|
|
||||||
|
[node name="PlantScroll" type="Sprite2D" parent="." unique_id=1806015749]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(0, -13)
|
||||||
|
texture = ExtResource("6_n2as5")
|
||||||
|
|
||||||
|
[node name="RockScroll" type="Sprite2D" parent="." unique_id=1276385957]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(0, -13)
|
||||||
|
texture = ExtResource("7_lh1s0")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="." unique_id=647285700]
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="EmptyScroll" type="Sprite2D" parent="." unique_id=699932407]
|
||||||
|
visible = false
|
||||||
|
position = Vector2(0, -13)
|
||||||
|
texture = ExtResource("8_lh1s0")
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
||||||
Reference in New Issue
Block a user