90 lines
2.3 KiB
C
90 lines
2.3 KiB
C
|
#pragma once
|
||
|
|
||
|
#include "core/note.h"
|
||
|
#include "core/precisionevaluator.h"
|
||
|
#include "classicactions.h"
|
||
|
|
||
|
#include <memory>
|
||
|
#include <array>
|
||
|
|
||
|
class ClassicSprite;
|
||
|
class ClassicGraphicsManager;
|
||
|
class ClassicAnimationScenario;
|
||
|
|
||
|
class ClassicNote : public Note
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
enum class Grade
|
||
|
{
|
||
|
PERFECT,
|
||
|
GOOD,
|
||
|
BAD
|
||
|
};
|
||
|
|
||
|
enum State
|
||
|
{
|
||
|
NONE,
|
||
|
|
||
|
FLYING,
|
||
|
ACTIVE,
|
||
|
DYING,
|
||
|
DEAD
|
||
|
};
|
||
|
|
||
|
struct ClassicNoteInitializer
|
||
|
{
|
||
|
std::vector<microsec> intervals;
|
||
|
microsec perfect_offset;
|
||
|
bool hold;
|
||
|
|
||
|
struct Element
|
||
|
{
|
||
|
Type type;
|
||
|
Coordinates coordinates;
|
||
|
std::vector<Coordinates> falling_curve_interpolation;
|
||
|
std::array<sf::Keyboard::Key, 2> keys;
|
||
|
};
|
||
|
|
||
|
std::vector<Element> elements;
|
||
|
};
|
||
|
|
||
|
explicit ClassicNote(ClassicNoteInitializer&& init, const std::shared_ptr<ClassicGraphicsManager>& manager);
|
||
|
virtual ~ClassicNote() = default;
|
||
|
|
||
|
virtual bool isActive() const override;
|
||
|
virtual void update(const microsec &music_offset) override;
|
||
|
virtual void input(PlayerInput&& inputdata) override;
|
||
|
virtual void putToGame(const microsec &music_offset) override;
|
||
|
virtual bool isInGame() const override;
|
||
|
virtual bool shouldRemove() const override;
|
||
|
virtual void draw() const override;
|
||
|
|
||
|
bool isHold() const;
|
||
|
bool allElementsPressed() const;
|
||
|
bool isPressedAs(sf::Keyboard::Key key) const;
|
||
|
|
||
|
private:
|
||
|
|
||
|
struct NoteElement
|
||
|
{
|
||
|
std::shared_ptr<ClassicSprite> sprite;
|
||
|
std::array<std::shared_ptr<ClassicAnimationScenario>, 5> animations;
|
||
|
|
||
|
std::array<sf::Keyboard::Key, 2> keys;
|
||
|
Coordinates coordinates; // Each note may consist of several buttons.
|
||
|
Type type; // For example, ↑ → or ↓ → ←
|
||
|
// Note Element represents this idea.
|
||
|
bool pressed = false; // Each ending button in such sequence
|
||
|
sf::Keyboard::Key pressed_as; // is an element.
|
||
|
};
|
||
|
|
||
|
std::vector<NoteElement> _elements;
|
||
|
|
||
|
const PrecisionEvaluator<Grade> _evaluator;
|
||
|
const std::shared_ptr<ClassicGraphicsManager> _graphics_manager;
|
||
|
|
||
|
State _state;
|
||
|
bool _isHold;
|
||
|
};
|