-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTargetScene.cpp
More file actions
94 lines (71 loc) · 1.58 KB
/
Copy pathTargetScene.cpp
File metadata and controls
94 lines (71 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "TargetScene.h"
#include <iostream>
#include <utility>
TargetScene::TargetScene(std::vector<TargetSceneDef::TargetPtr> Targets)
{
Characters=std::move(Targets);
TargetInputHandler_ = std::make_unique<InputHandler>();
TargetInputHandler_->Subscribe(this);
}
TargetScene::TargetScene(const TargetScene& Target)
: Scene(Target)
{
Characters=Target.Characters;
TargetInputHandler_ = std::make_unique<InputHandler>();
TargetInputHandler_->Subscribe(this);
PreviousScene_=Target.PreviousScene_;
CurrentTarget_=Target.CurrentTarget_;
}
void TargetScene::Update(const sf::Keyboard::Key Key)
{
const auto TargetIndex = ChooseTarget(Key);
if (TargetIndex == -1) {
return;
}
std::cout << "Target Name:" << Characters.at(TargetIndex)->Name << std::endl;
Unload();
}
void TargetScene::UpdateScene()
{
TargetInputHandler_->HandleInput();
}
void TargetScene::Redraw()
{
PreviousScene_->Redraw();
}
void TargetScene::Load(const std::string& FileName)
{
PreviousScene_=Game::CurrentScene;
Game::CurrentScene=std::make_shared<TargetScene>(*this);
}
void TargetScene::Unload()
{
static auto Next= PreviousScene_;
Game::CurrentScene=Next;
//Next=Game::CurrentScene;
std::cout<<"Hm"<<std::endl;
}
unsigned int TargetScene::ChooseTarget(const sf::Keyboard::Key Key)
{
if (Key == sf::Keyboard::Left)
{
if (CurrentTarget_ > 0)
{
CurrentTarget_--;
}
return -1;
}
if (Key == sf::Keyboard::Right)
{
if (CurrentTarget_ < Characters.size() - 1)
{
CurrentTarget_++;
}
return -1;
}
if (Key == sf::Keyboard::Enter)
{
return CurrentTarget_;
}
return -1;
}