mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:45:33 +00:00
Prisms and hit buttons
This commit is contained in:
parent
1a898cb7b8
commit
dbca78c0b7
8 changed files with 141 additions and 6 deletions
17
Scenes/Actors/prism.tscn
Normal file
17
Scenes/Actors/prism.tscn
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://pvpt2af54s1a"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://yf367y2o5oyh" path="res://Scripts/Actors/Prism.cs" id="1_gnsdu"]
|
||||
[ext_resource type="Texture2D" uid="uid://tm14o2xkomjb" path="res://Sprites/Icon.png" id="2_3vm23"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_3vm23"]
|
||||
|
||||
[node name="Prism" type="Area2D"]
|
||||
collision_layer = 16
|
||||
collision_mask = 136
|
||||
script = ExtResource("1_gnsdu")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_3vm23")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_3vm23")
|
||||
45
Scenes/Interactable/Hit_Button.tscn
Normal file
45
Scenes/Interactable/Hit_Button.tscn
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://d11toudt5y03k"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cfi441fv227kj" path="res://Scripts/Interactables/HitButton.cs" id="1_nd3ct"]
|
||||
[ext_resource type="Texture2D" uid="uid://d24g1qb40t72l" path="res://Sprites/Button_Small.png" id="2_1w5nf"]
|
||||
[ext_resource type="AudioStream" uid="uid://bjvklk7qmlivd" path="res://SFX/288963__littlerobotsoundfactory__click_electronic_14.wav" id="3_7xhc3"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_vvpve"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rie4n"]
|
||||
atlas = ExtResource("2_1w5nf")
|
||||
region = Rect2(0, 0, 8, 8)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_sgwyd"]
|
||||
atlas = ExtResource("2_1w5nf")
|
||||
region = Rect2(8, 0, 8, 8)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_b2dxw"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_rie4n")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_sgwyd")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="HitButton" type="Area2D" groups=["Interactable"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 138
|
||||
script = ExtResource("1_nd3ct")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_vvpve")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_b2dxw")
|
||||
autoplay = "default"
|
||||
frame_progress = 0.061742
|
||||
|
||||
[node name="ActivationSound" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource("3_7xhc3")
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -301,7 +301,7 @@ ActivationType = 0
|
|||
Targets = Array[NodePath]([NodePath("../Rumia")])
|
||||
WaitForCompletion = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jm0wb"]
|
||||
[sub_resource type="Resource" id="Resource_w8skm"]
|
||||
resource_local_to_scene = true
|
||||
script = ExtResource("49_0si7g")
|
||||
Target = NodePath(".")
|
||||
|
|
@ -1260,7 +1260,7 @@ Events = Array[ExtResource("62_w8skm")]([SubResource("Resource_068l7"), SubResou
|
|||
|
||||
[node name="BossBattleStartScript" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("43_kf3qc")]
|
||||
position = Vector2(-1487, -396)
|
||||
Events = Array[ExtResource("62_w8skm")]([SubResource("Resource_4f4id"), SubResource("Resource_s2o7m"), SubResource("Resource_b1dht"), SubResource("Resource_xrgpy"), SubResource("Resource_jm0wb")])
|
||||
Events = Array[ExtResource("62_w8skm")]([SubResource("Resource_4f4id"), SubResource("Resource_s2o7m"), SubResource("Resource_b1dht"), SubResource("Resource_xrgpy"), SubResource("Resource_w8skm")])
|
||||
|
||||
[node name="Enemy13" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("47_u1ve6")]
|
||||
position = Vector2(-1657, -788)
|
||||
|
|
|
|||
23
Scripts/Actors/Prism.cs
Normal file
23
Scripts/Actors/Prism.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
public partial class Prism : Area2D
|
||||
{
|
||||
[Export] public float ReflectionAngle { get; set; } = 90f;
|
||||
[Export] public float RotationAngle { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
this.AreaEntered += OnCollision;
|
||||
}
|
||||
|
||||
private void OnCollision(Area2D other)
|
||||
{
|
||||
if (other is not Bullet bullet) return;
|
||||
|
||||
bullet.RotateBullet(ReflectionAngle);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
1
Scripts/Actors/Prism.cs.uid
Normal file
1
Scripts/Actors/Prism.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://yf367y2o5oyh
|
||||
21
Scripts/Interactables/HitButton.cs
Normal file
21
Scripts/Interactables/HitButton.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Interactables;
|
||||
|
||||
public partial class HitButton : Switch
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
this.AreaEntered += OnAreaEntered;
|
||||
}
|
||||
|
||||
private void OnAreaEntered(Area2D area)
|
||||
{
|
||||
if (area is not Bullet bullet) return;
|
||||
|
||||
this.Activate(this.ActivationType);
|
||||
|
||||
bullet.RequestCollisionDestruction();
|
||||
}
|
||||
}
|
||||
1
Scripts/Interactables/HitButton.cs.uid
Normal file
1
Scripts/Interactables/HitButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cfi441fv227kj
|
||||
Loading…
Add table
Add a link
Reference in a new issue