mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Event System
This commit is contained in:
parent
797e24d766
commit
f379eac5c3
10 changed files with 336 additions and 10 deletions
62
Scripts/Activables/ScriptableBase.cs
Normal file
62
Scripts/Activables/ScriptableBase.cs
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
using System;
|
||||
using Cirno.Scripts.Resources.Events;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
||||
public partial class ScriptableBase : Node2D
|
||||
{
|
||||
[Export] public Array<EventResource> Events;
|
||||
|
||||
private EventResource CurrentEvent => Events[_currentEventIndex];
|
||||
|
||||
private int _currentEventIndex = 0;
|
||||
|
||||
private bool _started = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_started = true;
|
||||
StartEvent(CurrentEvent);
|
||||
}
|
||||
|
||||
private void StartEvent(EventResource eventResource)
|
||||
{
|
||||
eventResource.Start(this);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (!_started) return;
|
||||
|
||||
CurrentEvent.UpdateEvent(delta);
|
||||
|
||||
if (!CurrentEvent.WaitForCompletion || CurrentEvent.IsComplete())
|
||||
{
|
||||
// This loops
|
||||
//_currentEventIndex = (_currentEventIndex + 1) % Events.Count;
|
||||
_currentEventIndex++;
|
||||
if (_currentEventIndex >= Events.Count)
|
||||
{
|
||||
// It's over
|
||||
_started = false;
|
||||
_currentEventIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentEvent.Start(this);
|
||||
}
|
||||
// if (_currentHealth <= CurrentPhase.Threshold && currentPhaseIndex + 1 < Phases.Count)
|
||||
// {
|
||||
// currentPhaseIndex++;
|
||||
// _bossHud.SpellCardName = CurrentPhase.PhaseName;
|
||||
// StartPhase(CurrentPhase);
|
||||
// }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue