-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainTopicSystem.cpp
More file actions
138 lines (117 loc) · 3.03 KB
/
MainTopicSystem.cpp
File metadata and controls
138 lines (117 loc) · 3.03 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "pch.h"
#include "MainTopicSystem.h"
#include "EventManager.h"
#include "VisPredComponents.h"
MainTopicSystem::MainTopicSystem(std::shared_ptr<SceneManager> scenemanager):System(scenemanager)
{
EventManager::GetInstance().Subscribe("OnChangeTopic", CreateSubscriber(&MainTopicSystem::OnChangeTopic));
}
#include <array>
#include <string>
enum class TopicType
{
FINDBELL,
KILLALL,
NONE,
// 다른 TopicType 추가
END // END는 마지막으로 사용하여 배열의 크기를 결정합니다.
};
void MainTopicSystem::OnChangeTopic(std::any mode)
{
VisPred::Game::TopicType Mode = std::any_cast<VisPred::Game::TopicType>(mode);
if (!m_MainTopicEntity.lock())
return;
auto topic = m_MainTopicEntity.lock()->GetComponent<MainTopicComponent>();
auto image = m_MainTopicEntity.lock()->GetComponent<ImageComponent>();
auto text = m_MainTopicEntity.lock()->GetComponent<TextComponent>();
if (topic->Mode == Mode)
return;
if (topic->HasComponent<TextBounceComponent>())
{
topic->GetComponent<TextBounceComponent>()->AddedBounce = true;
}
if (topic->HasComponent<ImageBounceComponent>())
{
topic->GetComponent<ImageBounceComponent>()->AddedBounce = true;
}
topic->Mode = Mode;
switch (Mode)
{
case VisPred::Game::TopicType::FINDBELL:
{
text->Text = topic->Ment[(int)VisPred::Game::TopicType::FINDBELL];
text->Color = topic->MentColor;
image->Color = topic->BackGroundColor;
topic->IsReset = true;
}
break;
case VisPred::Game::TopicType::KILLALL:
{
text->Text = topic->Ment[(int)VisPred::Game::TopicType::KILLALL];
text->Color = topic->MentColor;
image->Color = topic->BackGroundColor;
topic->IsReset = true;
}
break;
case VisPred::Game::TopicType::NONE:
{
text->Text = topic->Ment[(int)VisPred::Game::TopicType::NONE];
text->Color.w = 0;
image->Color.w = 0;
}
break;
case VisPred::Game::TopicType::END:
break;
default:
break;
}
}
void MainTopicSystem::Initialize()
{
COMPLOOP(MainTopicComponent, comp)
{
Start(comp.GetEntityID());
if (m_MainTopicEntity.lock())
{
break;
}
}
}
void MainTopicSystem::Start(uint32_t gameObjectId)
{
auto entity = GetSceneManager()->GetEntity(gameObjectId);
if (!entity || !entity->HasComponent<MainTopicComponent>() || !entity->HasComponent<ImageComponent>()|| !entity->HasComponent<TextComponent>())
return;
if (m_MainTopicEntity.lock())
return;
m_MainTopicEntity = entity;
auto topiccomp = m_MainTopicEntity.lock()->GetComponent<MainTopicComponent>();
OnChangeTopic(VisPred::Game::TopicType::NONE);
}
void MainTopicSystem::Finish(uint32_t gameObjectId)
{
}
void MainTopicSystem::Finalize()
{
}
void MainTopicSystem::FixedUpdate(float deltaTime)
{
if (!m_MainTopicEntity.lock())
return;
auto comp = m_MainTopicEntity.lock()->GetComponent<MainTopicComponent>();
if (comp->IsReset)
{
comp->IsReset = false;
comp->IsShowing = true;
}
if (comp->IsShowing)
{
comp->Progress += deltaTime;
if (comp->Progress > comp->Duration)
{
comp->Progress = 0;
comp->IsShowing = false;
OnChangeTopic(VisPred::Game::TopicType::NONE);
}
}
}