diff --git a/ExternalMaterial/Prism/Prism.png b/ExternalMaterial/Prism/Prism.png new file mode 100644 index 00000000..e1e70681 --- /dev/null +++ b/ExternalMaterial/Prism/Prism.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:753a83794096ae16edc691f01ccb38acdc16ff7e455398abe7ad45ab6b579e56 +size 2134 diff --git a/ExternalMaterial/Prism/Prism.png.import b/ExternalMaterial/Prism/Prism.png.import new file mode 100644 index 00000000..7045e78a --- /dev/null +++ b/ExternalMaterial/Prism/Prism.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://kpiqfphw2d2q" +path="res://.godot/imported/Prism.png-4949829a99e4ae9ccbb82d10468e6a96.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ExternalMaterial/Prism/Prism.png" +dest_files=["res://.godot/imported/Prism.png-4949829a99e4ae9ccbb82d10468e6a96.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +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/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 diff --git a/ExternalMaterial/Prism/Prism.pxc b/ExternalMaterial/Prism/Prism.pxc new file mode 100644 index 00000000..9a256eff Binary files /dev/null and b/ExternalMaterial/Prism/Prism.pxc differ diff --git a/ExternalMaterial/Prism/Prism.pxc1 b/ExternalMaterial/Prism/Prism.pxc1 new file mode 100644 index 00000000..b061ec4d Binary files /dev/null and b/ExternalMaterial/Prism/Prism.pxc1 differ diff --git a/Scenes/Actors/prism.tscn b/Scenes/Actors/prism.tscn index d134d30d..b6c5d243 100644 --- a/Scenes/Actors/prism.tscn +++ b/Scenes/Actors/prism.tscn @@ -1,7 +1,7 @@ [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"] +[ext_resource type="Texture2D" uid="uid://kpiqfphw2d2q" path="res://ExternalMaterial/Prism/Prism.png" id="2_3vm23"] [sub_resource type="CircleShape2D" id="CircleShape2D_3vm23"] @@ -15,3 +15,4 @@ shape = SubResource("CircleShape2D_3vm23") [node name="Sprite2D" type="Sprite2D" parent="."] texture = ExtResource("2_3vm23") +hframes = 15 diff --git a/Scripts/Actors/Prism.cs b/Scripts/Actors/Prism.cs index 5620e98a..ddd992e9 100644 --- a/Scripts/Actors/Prism.cs +++ b/Scripts/Actors/Prism.cs @@ -4,12 +4,27 @@ namespace Cirno.Scripts.Actors; public partial class Prism : Area2D { - [Export] public float ReflectionAngle { get; set; } = 90f; + [Export] public float ReflectionAngle { get; private set; } = 90f; [Export] public float RotationAngle { get; set; } + private Sprite2D _sprite; + public override void _Ready() { this.AreaEntered += OnCollision; + _sprite = this.GetNode("Sprite2D"); + + SetReflectionAngle(ReflectionAngle); + + } + + public void SetReflectionAngle(float angle) + { + ReflectionAngle = angle; + var frames = _sprite.Hframes; + var frame = (int)(frames * angle / 360); + + _sprite.Frame = frame - 1; } private void OnCollision(Area2D other) @@ -17,7 +32,6 @@ public partial class Prism : Area2D if (other is not Bullet bullet) return; bullet.RotateBullet(ReflectionAngle); - } } \ No newline at end of file