mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:05:34 +00:00
Intro with new animator
This commit is contained in:
parent
d07fe420dd
commit
cd43b3361d
16 changed files with 788 additions and 19 deletions
|
|
@ -52,6 +52,7 @@ public partial class Boss : Enemy, IActivable
|
|||
_bossHud = BossHudPrefab.Instantiate<BossHud>();
|
||||
_gameManager.CallDeferred("add_child", _bossHud);
|
||||
|
||||
_bossHud.Name = $"{BossName}_BossHud";
|
||||
_bossHud.Visible = false;
|
||||
_bossHud.BossName = BossName;
|
||||
_bossHud.BossMaxHealth = this.Health;
|
||||
|
|
|
|||
60
Scripts/UI/AudioNameVisualizer.cs
Normal file
60
Scripts/UI/AudioNameVisualizer.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts;
|
||||
using GTweens.Builders;
|
||||
using GTweens.Easings;
|
||||
using GTweens.Tweens;
|
||||
using GTweensGodot.Extensions;
|
||||
|
||||
public partial class AudioNameVisualizer : AudioStreamPlayer2D
|
||||
{
|
||||
[Export]
|
||||
public string TrackName { get; private set; }
|
||||
|
||||
[Export]
|
||||
public string AuthorName { get; private set; }
|
||||
|
||||
[Export] public PackedScene CanvasTemplate;
|
||||
|
||||
private MusicVisualizerCanvas _canvasLayer;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Setup();
|
||||
|
||||
if (Autoplay)
|
||||
{
|
||||
ShowName();
|
||||
}
|
||||
}
|
||||
|
||||
private void Setup()
|
||||
{
|
||||
var existingCanvas = this.GetTree().Root.GetNodeOrNull<CanvasLayer>("AudioCanvas");
|
||||
|
||||
if (existingCanvas is null)
|
||||
{
|
||||
// _canvasLayer = new CanvasLayer();
|
||||
// _canvasLayer.Name = "AudioCanvas";
|
||||
_canvasLayer = CanvasTemplate.Instantiate<MusicVisualizerCanvas>();
|
||||
GetTree().Root.CallDeferred("add_child", _canvasLayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_canvasLayer = (MusicVisualizerCanvas)existingCanvas;
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayWithName()
|
||||
{
|
||||
ShowName();
|
||||
Play();
|
||||
}
|
||||
|
||||
public void ShowName()
|
||||
{
|
||||
GD.Print("show name");
|
||||
_canvasLayer.ShowName(TrackName, AuthorName);
|
||||
}
|
||||
}
|
||||
1
Scripts/UI/AudioNameVisualizer.cs.uid
Normal file
1
Scripts/UI/AudioNameVisualizer.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://sebnyy6skgsr
|
||||
|
|
@ -9,6 +9,8 @@ namespace Cirno.Scripts.UI;
|
|||
|
||||
public partial class IntroScenePlayer : CanvasLayer
|
||||
{
|
||||
[Export] public bool StartRunning { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Control PanelsHolder { get; private set; }
|
||||
|
||||
|
|
@ -21,6 +23,9 @@ public partial class IntroScenePlayer : CanvasLayer
|
|||
[Export]
|
||||
public string NextSceneName { get; set; }
|
||||
|
||||
[Export]
|
||||
public AnimationPlayer AnimationPlayer { get; private set; }
|
||||
|
||||
private int _currentPanelIndex;
|
||||
|
||||
private List<TextureRect> _panels = new ();
|
||||
|
|
@ -30,12 +35,20 @@ public partial class IntroScenePlayer : CanvasLayer
|
|||
private double _timer = 0f;
|
||||
|
||||
private bool _running = false;
|
||||
|
||||
private void DeferredStartAnimation()
|
||||
{
|
||||
AnimationPlayer.Play("intro");
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_timer = 0;
|
||||
_running = true;
|
||||
_running = StartRunning;
|
||||
|
||||
DeferredStartAnimation();
|
||||
|
||||
return;
|
||||
foreach (var image in Images)
|
||||
{
|
||||
var panel = new TextureRect();
|
||||
|
|
@ -49,11 +62,19 @@ public partial class IntroScenePlayer : CanvasLayer
|
|||
|
||||
_panels.Add(panel);
|
||||
}
|
||||
|
||||
if (StartRunning)
|
||||
{
|
||||
Run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
var first = _panels.First();
|
||||
first.Visible = true;
|
||||
first.SetModulate(new Color(first.Modulate.R, first.Modulate.G, first.Modulate.B, 1f));
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
|
|
@ -70,21 +91,26 @@ public partial class IntroScenePlayer : CanvasLayer
|
|||
if (_timer >= TransitionTime)
|
||||
{
|
||||
_timer = 0;
|
||||
_currentPanelIndex++;
|
||||
|
||||
if (_currentPanelIndex >= _panels.Count)
|
||||
{
|
||||
_running = false;
|
||||
Finished();
|
||||
return;
|
||||
}
|
||||
|
||||
_running = false;
|
||||
|
||||
_ = Transition();
|
||||
NextPanel();
|
||||
}
|
||||
}
|
||||
|
||||
public void NextPanel()
|
||||
{
|
||||
_currentPanelIndex++;
|
||||
|
||||
if (_currentPanelIndex >= _panels.Count)
|
||||
{
|
||||
_running = false;
|
||||
Finished();
|
||||
return;
|
||||
}
|
||||
|
||||
_running = false;
|
||||
|
||||
_ = Transition();
|
||||
}
|
||||
|
||||
private void Finished()
|
||||
{
|
||||
GlobalState.Instance.GotoScene(NextSceneName);
|
||||
|
|
|
|||
49
Scripts/UI/MusicVisualizerCanvas.cs
Normal file
49
Scripts/UI/MusicVisualizerCanvas.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using GTweens.Builders;
|
||||
using GTweens.Easings;
|
||||
using GTweens.Tweens;
|
||||
using GTweensGodot.Extensions;
|
||||
|
||||
public partial class MusicVisualizerCanvas : CanvasLayer
|
||||
{
|
||||
private Label _nameLabel;
|
||||
private GTween _tween;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_nameLabel = GetNode<Label>("Title");
|
||||
_nameLabel.Hide();
|
||||
}
|
||||
|
||||
private void ResetLabel(string trackName, string authorName)
|
||||
{
|
||||
_nameLabel.Text = $"{trackName} ({authorName})";
|
||||
_nameLabel.SetAnchorsAndOffsetsPreset(Control.LayoutPreset.BottomRight, margin: 0);
|
||||
_nameLabel.Modulate = Colors.White;
|
||||
_nameLabel.Hide();
|
||||
}
|
||||
|
||||
public void ShowName(string trackName, string authorName)
|
||||
{
|
||||
_tween?.Kill();
|
||||
//_tween?.Complete();
|
||||
ResetLabel(trackName, authorName);
|
||||
_nameLabel.Show();
|
||||
|
||||
_tween = GTweenSequenceBuilder.New()
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X + 32, 0f)) // Add offset
|
||||
.Join(_nameLabel.TweenModulateAlpha(0, 0f)) // Invisibilify
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X - 32, 1f)) // Animate back
|
||||
.Join(_nameLabel.TweenModulateAlpha(1, 0.5f))
|
||||
.AppendTime(3f) // Wait before hiding
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X + 32, 1f)) // Start moving and hiding
|
||||
.Join(_nameLabel.TweenModulateAlpha(0, 0.5f))
|
||||
.Append(_nameLabel.TweenPositionX(_nameLabel.Position.X - 32, 0f)) // Move back to default position
|
||||
.AppendCallback(() => _nameLabel.Hide())
|
||||
.Build();
|
||||
|
||||
_tween.SetEasing(Easing.OutCubic);
|
||||
_tween.Play();
|
||||
}
|
||||
}
|
||||
1
Scripts/UI/MusicVisualizerCanvas.cs.uid
Normal file
1
Scripts/UI/MusicVisualizerCanvas.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cifjmgf1f2iuk
|
||||
30
Scripts/UI/MusicVisualizerCanvas.tscn
Normal file
30
Scripts/UI/MusicVisualizerCanvas.tscn
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dfdagutgntio4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cifjmgf1f2iuk" path="res://Scripts/UI/MusicVisualizerCanvas.cs" id="1_2rpsr"]
|
||||
[ext_resource type="LabelSettings" uid="uid://buk3e7bbwmnv1" path="res://Resources/Styles/Hud_Text_Style.tres" id="1_11hsa"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpd4ldfmt3s51" path="res://Sprites/UI/Note.png" id="2_6xd7p"]
|
||||
|
||||
[node name="AudioCanvas" type="CanvasLayer"]
|
||||
script = ExtResource("1_2rpsr")
|
||||
|
||||
[node name="Title" type="Label" parent="."]
|
||||
anchors_preset = 3
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -63.0
|
||||
offset_top = -23.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
size_flags_horizontal = 4
|
||||
text = "Title Text (Author)"
|
||||
label_settings = ExtResource("1_11hsa")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Title"]
|
||||
layout_mode = 1
|
||||
offset_left = -16.0
|
||||
offset_top = -2.0
|
||||
offset_bottom = 14.0
|
||||
texture = ExtResource("2_6xd7p")
|
||||
stretch_mode = 2
|
||||
Loading…
Add table
Add a link
Reference in a new issue