-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameBaseSystem.cpp
109 lines (96 loc) · 3.05 KB
/
GameBaseSystem.cpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "pch.h"
#include "GameBaseSystem.h"
#include "VisPredComponents.h"
GameBaseSystem::GameBaseSystem(std::shared_ptr<SceneManager> sceneManager):System(sceneManager)
{
}
void GameBaseSystem::Initialize()
{
}
void GameBaseSystem::Start(uint32_t gameObjectId)
{
auto entity = GetSceneManager()->GetEntity(gameObjectId);
if (!entity || !entity->HasComponent<GameBaseComponent>())
return;
auto comp =entity->GetComponent<GameBaseComponent>();
auto player = GetSceneManager()->GetEntityByIdentityName(comp->PlayerName);
if (!player)
return;
if (!player->HasComponent<PlayerComponent>())
return;
auto sencitiveUI = GetSceneManager()->GetEntityByIdentityName(comp->SencitiveUI);
if (comp->MouseSencitive < 0)
comp->MouseSencitive = 1;
if (sencitiveUI)
{
comp->SencitiveEntity = sencitiveUI;
auto text = sencitiveUI->GetComponent<TextComponent>();
text->Color.w = 0;
text->Text = L"¸¶¿ì½º °¨µµ : " + std::to_wstring(comp->MouseSencitive);
}
comp->Player = player;
auto playercomp = comp->Player.lock()->GetComponent<PlayerComponent>();
playercomp->MaxHP = comp->MaxHP;
playercomp->HP = comp->MaxHP;
playercomp->Sencitive = (static_cast<float>(comp->MouseSencitive) / 2.f / 100.f);
}
void GameBaseSystem::Finish(uint32_t gameObjectId)
{
}
void GameBaseSystem::Finalize()
{
}
void GameBaseSystem::Update(float deltaTime)
{
COMPLOOP(GameBaseComponent, comp)
{
if (!comp.Player.lock())
continue;
if (INPUTKEYDOWN(KEYBOARDKEY::RBRACKET))
{
comp.MouseSencitive++;
comp.Player.lock()->GetComponent<PlayerComponent>()->Sencitive = (static_cast<float>(comp.MouseSencitive) / 2.f / 100.f);;
GetSceneManager()->SerializePrefab(comp.GetEntityID(), true);
comp.ShowSencitiveUI = true;
comp.ShowProgress = 0.00f;
}
if (INPUTKEYDOWN(KEYBOARDKEY::LBRACKET))
{
comp.MouseSencitive--;
if (comp.MouseSencitive<=0)
comp.MouseSencitive = 1;
comp.Player.lock()->GetComponent<PlayerComponent>()->Sencitive = (static_cast<float>(comp.MouseSencitive) / 2.f / 100.f);;
GetSceneManager()->SerializePrefab(comp.GetEntityID(), true);
comp.ShowSencitiveUI = true;
comp.ShowProgress = 0.00f;
}
if (INPUTKEYDOWN(KEYBOARDKEY::BACKSLASH))
{
comp.MouseSencitive = 20;
comp.Player.lock()->GetComponent<PlayerComponent>()->Sencitive = (static_cast<float>(comp.MouseSencitive)/2.f / 100.f);;
GetSceneManager()->SerializePrefab(comp.GetEntityID(), true);
comp.ShowSencitiveUI = true;
comp.ShowProgress = 0.00f;
}
if (comp.ShowSencitiveUI && comp.SencitiveEntity.lock())
{
auto text = comp.SencitiveEntity.lock()->GetComponent<TextComponent>();
if (comp.ShowProgress <= 0.01f)
{
text->Color.w = 1;
text->Text = L"¸¶¿ì½º °¨µµ : " + std::to_wstring(comp.MouseSencitive);
if (text->HasComponent<TextBounceComponent>())
text->GetComponent<TextBounceComponent>()->AddedBounce = true;
}
comp.ShowProgress += deltaTime;
if (comp.ShowProgress > comp.ShowDuration)
{
text->Color.w = 0;
comp.ShowProgress = 0.00f;
comp.ShowSencitiveUI = false;
}
}
else
comp.ShowSencitiveUI = false;
}
}