-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUWorld.cpp
More file actions
76 lines (68 loc) · 1.56 KB
/
UWorld.cpp
File metadata and controls
76 lines (68 loc) · 1.56 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
#include "UWorld.h"
#include <iostream>
#include "engine/Utility.h"
using namespace std;
void UWorld::render()
{
if (GameMap != nullptr) {
GameMap->render();
}
}
void UWorld::update()
{
if (nextGameMap != "") {
GameMap->destroy();
TalkManager->clear();
makeScene(nextGameMap);
nextGameMap = "";
}
MessageManager->Tip.appendLine("输入 h + 指令名字 可获取帮助");
MessageManager->Tip.appendLine("输入 iexit 退出游戏");
MessageManager->Tip.appendLine("输入 itrans + 空格 + 地图英文名 切换地图");
MessageManager->Title.appendLine(gameTitle);
MessageManager->Title.appendLine(gameMapName);
if (GameMap != nullptr) {
GameMap->update();
}
if (TalkManager != nullptr) {
TalkManager->update();
}
}
void UWorld::run()
{
Running = true;
while (Running) {
system("cls");
if (preEnd)Running = false;
MessageManager->show();
render();
string cmd;getline(cin , cmd);
EventDispatcher->executeInput(uiName , cmd);
update();
}
}
void UWorld::init()
{
EventDispatcher->bindEvent("i", this, &UWorld::iexit);
EventDispatcher->bindEvent("i", this, &UWorld::ijump);
EventDispatcher->bindEvent("h", this, &UWorld::htrans);
}
void UWorld::htrans(string key, string cmd)
{
if (compareCmd(cmd, "trans")) {
MessageManager->Info.appendLine(levels);
}
}
void UWorld::iexit(string key ,string cmd)
{
if ( compareCmd(cmd , "exit"))
preEnd = true;
}
void UWorld::ijump(string key, string cmd)
{
auto vs = split(cmd, ' ');
if (vs->size() == 2 && compareCmd((*vs)[0] , "trans") ) {
makeScene((*vs)[1]);
}
}
UWorld * world =new UWorld();