mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 05:45:33 +00:00
Checkpoints
This commit is contained in:
parent
8b689acf3d
commit
1cb26de091
12 changed files with 320 additions and 7 deletions
2
Cirno.sln.DotSettings
Normal file
2
Cirno.sln.DotSettings
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeEditing/SuppressNullableWarningFix/Enabled/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
BIN
ExternalMaterial/Fridge/Fridge.pxc
Normal file
BIN
ExternalMaterial/Fridge/Fridge.pxc
Normal file
Binary file not shown.
BIN
ExternalMaterial/Fridge/Fridge.pxc1
Normal file
BIN
ExternalMaterial/Fridge/Fridge.pxc1
Normal file
Binary file not shown.
BIN
SFX/JFXR/Checkpoint.wav
(Stored with Git LFS)
Normal file
BIN
SFX/JFXR/Checkpoint.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
24
SFX/JFXR/Checkpoint.wav.import
Normal file
24
SFX/JFXR/Checkpoint.wav.import
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://dg00h7f284kex"
|
||||
path="res://.godot/imported/Checkpoint.wav-68e4d4f70b8a62fb23ae8a2aac635d2a.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://SFX/JFXR/Checkpoint.wav"
|
||||
dest_files=["res://.godot/imported/Checkpoint.wav-68e4d4f70b8a62fb23ae8a2aac635d2a.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
|
||||
106
Scenes/Props/Fridge.tscn
Normal file
106
Scenes/Props/Fridge.tscn
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
[gd_scene load_steps=16 format=3 uid="uid://r70dfwgv51tw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://duhodrhcnoslh" path="res://Scripts/Interactables/Switch.cs" id="1_powf3"]
|
||||
[ext_resource type="Texture2D" uid="uid://bs6gll1muttjt" path="res://Sprites/Props/Fridge.png" id="1_w2v7h"]
|
||||
[ext_resource type="Script" uid="uid://d0a0o50j82eo6" path="res://Scripts/Activables/ScriptableBase.cs" id="3_wn4pw"]
|
||||
[ext_resource type="Script" uid="uid://b5fesrd4lv8t1" path="res://Scripts/Resources/Events/EventResource.cs" id="4_12pos"]
|
||||
[ext_resource type="Script" uid="uid://bwg12macnb0ll" path="res://Scripts/Resources/Events/UpdateCheckPointEvent.cs" id="5_k5rjk"]
|
||||
[ext_resource type="FontFile" uid="uid://coek1e2q257pq" path="res://fonts/at01.ttf" id="6_k5rjk"]
|
||||
[ext_resource type="Script" uid="uid://da3uje4601m8b" path="res://Scripts/Misc/CheckpointAnimation.cs" id="7_6hd6h"]
|
||||
[ext_resource type="AudioStream" uid="uid://dg00h7f284kex" path="res://SFX/JFXR/Checkpoint.wav" id="8_3t7ov"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_w2v7h"]
|
||||
atlas = ExtResource("1_w2v7h")
|
||||
region = Rect2(0, 0, 16, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_powf3"]
|
||||
atlas = ExtResource("1_w2v7h")
|
||||
region = Rect2(16, 0, 16, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_wn4pw"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_w2v7h")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"Closed",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_powf3")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"Open",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_wn4pw"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wtdkd"]
|
||||
size = Vector2(13.5, 19)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6hd6h"]
|
||||
script = ExtResource("5_k5rjk")
|
||||
Target = NodePath("../Marker2D")
|
||||
WaitForCompletion = true
|
||||
metadata/_custom_type_script = "uid://bwg12macnb0ll"
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_6hd6h"]
|
||||
line_spacing = 1.0
|
||||
font = ExtResource("6_k5rjk")
|
||||
font_color = Color(0.28, 0.724, 1, 1)
|
||||
outline_size = 4
|
||||
outline_color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="Fridge" type="Area2D" node_paths=PackedStringArray("Target", "Targets") groups=["Interactable"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
script = ExtResource("1_powf3")
|
||||
Target = NodePath("Script")
|
||||
Targets = [NodePath("Script"), NodePath("CheckpointAnimation")]
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(1.495, 0)
|
||||
sprite_frames = SubResource("SpriteFrames_wn4pw")
|
||||
animation = &"Closed"
|
||||
autoplay = "Closed"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_wn4pw")
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||
position = Vector2(1.8, 0)
|
||||
collision_layer = 64
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
||||
position = Vector2(-1.75, 0.5)
|
||||
shape = SubResource("RectangleShape2D_wtdkd")
|
||||
|
||||
[node name="Script" type="Node2D" parent="."]
|
||||
script = ExtResource("3_wn4pw")
|
||||
Events = Array[ExtResource("4_12pos")]([SubResource("Resource_6hd6h")])
|
||||
|
||||
[node name="Marker2D" type="Marker2D" parent="."]
|
||||
position = Vector2(0, 20)
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
offset_left = -23.0
|
||||
offset_top = -23.0
|
||||
offset_right = 23.0
|
||||
text = "Checkpoint"
|
||||
label_settings = SubResource("LabelSettings_6hd6h")
|
||||
|
||||
[node name="CheckpointAnimation" type="Node2D" parent="." node_paths=PackedStringArray("Sprite", "Label", "Sound")]
|
||||
script = ExtResource("7_6hd6h")
|
||||
Sprite = NodePath("../AnimatedSprite2D")
|
||||
Label = NodePath("../Label")
|
||||
Sound = NodePath("../AudioStreamPlayer2D")
|
||||
LabelStartPosition = Vector2(-23, -16)
|
||||
LabelEndPosition = Vector2(-23, -28)
|
||||
LabelAnimationTime = 0.2
|
||||
|
||||
[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."]
|
||||
stream = ExtResource("8_3t7ov")
|
||||
File diff suppressed because one or more lines are too long
102
Scripts/Misc/CheckpointAnimation.cs
Normal file
102
Scripts/Misc/CheckpointAnimation.cs
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts;
|
||||
using GTweens.Builders;
|
||||
using GTweens.Easings;
|
||||
using GTweens.Extensions;
|
||||
using GTweens.Tweens;
|
||||
using GTweensGodot.Extensions;
|
||||
|
||||
public partial class CheckpointAnimation : Node2D, IActivable
|
||||
{
|
||||
[Export] public AnimatedSprite2D Sprite { get; private set; }
|
||||
[Export] public Label Label { get; private set; }
|
||||
|
||||
[Export] public AudioStreamPlayer2D Sound { get; private set; }
|
||||
|
||||
[Export] public StringName ClosedAnimationName { get; private set; } = "Closed";
|
||||
[Export] public StringName OpenAnimationName { get; private set; } = "Open";
|
||||
|
||||
[Export] public Vector2 LabelStartPosition { get; private set; } = new Vector2(0, 0);
|
||||
[Export] public Vector2 LabelEndPosition { get; private set; } = new Vector2(0, 16);
|
||||
|
||||
[Export] public float LabelAnimationTime { get; private set; } = 0.5f;
|
||||
|
||||
[Export] public float DoorCloseTime { get; private set; } = 1.5f;
|
||||
|
||||
private GTween _tween;
|
||||
|
||||
private CancellationTokenSource _cts;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Sprite.Play(ClosedAnimationName);
|
||||
Label.Hide();
|
||||
}
|
||||
|
||||
public bool Activate(ActivationType activationType = ActivationType.Toggle)
|
||||
{
|
||||
// Cancel previous token
|
||||
_cts?.Cancel();
|
||||
_cts?.Dispose();
|
||||
|
||||
// Create new token source
|
||||
_cts = new CancellationTokenSource();
|
||||
|
||||
// Start new animation with the new token
|
||||
_ = AnimateAsync(_cts.Token);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task AnimateAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
//_tween?.Complete();
|
||||
if (_tween != null)
|
||||
{
|
||||
await _tween.AwaitCompleteOrKill(cancellationToken);
|
||||
}
|
||||
|
||||
Sound.Play();
|
||||
|
||||
Label.Show();
|
||||
Label.SetPosition(LabelStartPosition);
|
||||
Sprite.Play(OpenAnimationName);
|
||||
|
||||
//Sprite.Play(ClosedAnimationName);
|
||||
_tween = GTweenSequenceBuilder.New()
|
||||
// .AppendCallback(() =>
|
||||
// {
|
||||
// Sprite.Play(OpenAnimationName);
|
||||
// Label.SetPosition(LabelStartPosition);
|
||||
// Label.Show();
|
||||
// })
|
||||
// .AppendCallback(() => Sprite.Play(OpenAnimationName))
|
||||
// .AppendCallback(() => Label.SetPosition(LabelStartPosition))
|
||||
// .AppendCallback(() => Label.Show())
|
||||
.Append(Label.TweenPositionY(LabelEndPosition.Y, LabelAnimationTime))
|
||||
.AppendTime(DoorCloseTime)
|
||||
.AppendCallback(() => Label.Hide())
|
||||
.AppendCallback(() => Sprite.Play(ClosedAnimationName))
|
||||
.Build();
|
||||
|
||||
_tween.SetEasing(Easing.OutBounce);
|
||||
|
||||
await _tween.PlayAsync(cancellationToken);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
GD.Print("Animation was cancelled.");
|
||||
// Optional cleanup here
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GD.PrintErr($"Unexpected error during animation: {e}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Scripts/Misc/CheckpointAnimation.cs.uid
Normal file
1
Scripts/Misc/CheckpointAnimation.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://da3uje4601m8b
|
||||
BIN
Sprites/Props/Fridge.aseprite
(Stored with Git LFS)
Normal file
BIN
Sprites/Props/Fridge.aseprite
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Sprites/Props/Fridge.png
(Stored with Git LFS)
Normal file
BIN
Sprites/Props/Fridge.png
(Stored with Git LFS)
Normal file
Binary file not shown.
34
Sprites/Props/Fridge.png.import
Normal file
34
Sprites/Props/Fridge.png.import
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bs6gll1muttjt"
|
||||
path="res://.godot/imported/Fridge.png-d04c10e0dabe9cc5555b0293a47531b0.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Sprites/Props/Fridge.png"
|
||||
dest_files=["res://.godot/imported/Fridge.png-d04c10e0dabe9cc5555b0293a47531b0.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
|
||||
Loading…
Add table
Add a link
Reference in a new issue