2021-06-07 20:19:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "note.h"
|
|
|
|
#include "precisionevaluator.h"
|
2021-06-24 00:43:13 +02:00
|
|
|
#include "classicactions.h"
|
2021-06-07 20:19:58 +02:00
|
|
|
|
2021-06-09 20:08:58 +02:00
|
|
|
#include <memory>
|
2021-06-21 21:10:50 +02:00
|
|
|
#include <array>
|
2021-06-09 20:08:58 +02:00
|
|
|
|
|
|
|
class ClassicSprite;
|
2021-06-24 00:43:13 +02:00
|
|
|
class ClassicGraphicsManager;
|
|
|
|
class ClassicAnimationScenario;
|
2021-06-09 20:08:58 +02:00
|
|
|
|
2021-06-07 20:19:58 +02:00
|
|
|
class ClassicNote : public Note
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2021-06-11 18:58:44 +02:00
|
|
|
enum class Grade
|
2021-06-07 20:19:58 +02:00
|
|
|
{
|
|
|
|
PERFECT,
|
|
|
|
GOOD,
|
|
|
|
BAD
|
|
|
|
};
|
|
|
|
|
2021-06-24 00:43:13 +02:00
|
|
|
enum State
|
|
|
|
{
|
|
|
|
NONE,
|
|
|
|
|
|
|
|
FLYING,
|
2021-06-24 20:04:09 +02:00
|
|
|
ACTIVE,
|
|
|
|
DYING,
|
|
|
|
DEAD
|
2021-06-24 00:43:13 +02:00
|
|
|
};
|
|
|
|
|
2021-07-15 04:45:52 +02:00
|
|
|
struct ClassicNoteInitializer
|
|
|
|
{
|
|
|
|
std::vector<microsec> intervals;
|
|
|
|
microsec perfect_offset;
|
|
|
|
|
|
|
|
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::unique_ptr<ClassicGraphicsManager>& manager);
|
2021-06-07 20:19:58 +02:00
|
|
|
virtual ~ClassicNote() = default;
|
2021-06-09 20:08:58 +02:00
|
|
|
|
2021-06-24 20:04:09 +02:00
|
|
|
virtual bool isActive() const override;
|
2021-06-11 18:58:44 +02:00
|
|
|
virtual void update(const microsec &music_offset) override;
|
2021-06-23 21:18:33 +02:00
|
|
|
virtual void input(PlayerInput&& inputdata) override;
|
2021-06-22 20:20:08 +02:00
|
|
|
virtual void putToGame(const microsec &music_offset) override;
|
2021-06-24 20:04:09 +02:00
|
|
|
virtual bool isInGame() const override;
|
2021-06-21 21:10:50 +02:00
|
|
|
virtual bool isExpired() const override;
|
2021-06-23 21:18:33 +02:00
|
|
|
virtual void draw() const override;
|
2021-06-21 21:10:50 +02:00
|
|
|
|
2021-06-07 20:19:58 +02:00
|
|
|
private:
|
2021-06-09 20:08:58 +02:00
|
|
|
|
2021-07-14 17:24:47 +02:00
|
|
|
struct NoteElement
|
|
|
|
{
|
2021-07-15 04:45:52 +02:00
|
|
|
std::shared_ptr<ClassicSprite> sprite;
|
|
|
|
std::array<std::shared_ptr<ClassicAnimationScenario>, 5> animations;
|
2021-06-21 21:10:50 +02:00
|
|
|
|
2021-07-15 04:45:52 +02:00
|
|
|
std::array<sf::Keyboard::Key, 2> keys;
|
|
|
|
Coordinates coordinates;
|
|
|
|
Type type;
|
2021-07-14 17:24:47 +02:00
|
|
|
|
|
|
|
bool pressed = false;
|
|
|
|
sf::Keyboard::Key pressed_as;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<NoteElement> _elements;
|
|
|
|
|
|
|
|
const PrecisionEvaluator<Grade> _evaluator;
|
|
|
|
const std::unique_ptr<ClassicGraphicsManager>& _graphics_manager;
|
2021-06-24 00:43:13 +02:00
|
|
|
|
|
|
|
State _state;
|
2021-06-07 20:19:58 +02:00
|
|
|
};
|