forked from scarsty/kys-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTitleScene.cpp
More file actions
107 lines (101 loc) · 3.09 KB
/
Copy pathTitleScene.cpp
File metadata and controls
107 lines (101 loc) · 3.09 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
#include "TitleScene.h"
#include "Audio.h"
#include "BattleScene.h"
#include "Button.h"
#include "Event.h"
#include "Font.h"
#include "GameUtil.h"
#include "INIReader.h"
#include "InputBox.h"
#include "MainScene.h"
#include "Menu.h"
#include "Random.h"
#include "RandomRole.h"
#include "Script.h"
#include "SubScene.h"
#include "TeamMenu.h"
#include "UISave.h"
#include "UIShop.h"
#include "../others/Hanz2Piny.h"
#include "PotConv.h"
#include "TextBoxRoll.h"
#include "ZipFile.h"
TitleScene::TitleScene()
{
full_window_ = 1;
menu_ = std::make_shared<Menu>();
menu_->setPosition(400, 250);
menu_->addChild<Button>(20, 0)->setTexture("title", 3, 23, 23);
menu_->addChild<Button>(20, 50)->setTexture("title", 4, 24, 24);
menu_->addChild<Button>(20, 100)->setTexture("title", 6, 26, 26);
menu_load_ = std::make_shared<UISave>();
menu_load_->setPosition(500, 300);
render_message_ = 1;
}
TitleScene::~TitleScene()
{
}
void TitleScene::draw()
{
int count = count_ / 20;
TextureManager::getInstance()->renderTexture("title", 0, 0, 0);
int alpha = 255 - abs(255 - count_ % 510);
count_++;
if (alpha == 0)
{
RandomDouble r;
head_id_ = r.rand_int(115);
head_x_ = r.rand_int(1024 - 150);
head_y_ = r.rand_int(640 - 150);
}
TextureManager::getInstance()->renderTexture("head", head_id_, head_x_, head_y_, { 255, 255, 255, 255 }, alpha);
Font::getInstance()->draw(GameUtil::VERSION(), 28, 0, 0);
}
void TitleScene::dealEvent(BP_Event& e)
{
int r = menu_->run();
if (r == 0)
{
Save::getInstance()->load(0);
//Script::getInstance()->runScript("../game/script/0.lua");
std::string name = "";
auto input = std::make_shared<InputBox>("請輸入姓名:", 30);
input->setInputPosition(350, 300);
input->run();
if (input->getResult() >= 0)
{
name = input->getText();
}
if (!name.empty())
{
auto random_role = std::make_shared<RandomRole>();
random_role->setRole(Save::getInstance()->getRole(0));
random_role->setRoleName(name);
if (random_role->runAtPosition(300, 0) == 0)
{
MainScene::getInstance()->setManPosition(Save::getInstance()->MainMapX, Save::getInstance()->MainMapY);
MainScene::getInstance()->setTowards(1);
MainScene::getInstance()->forceEnterSubScene(GameUtil::getInstance()->getInt("constant", "begin_scene", 70), 19, 20, GameUtil::getInstance()->getInt("constant", "begin_event", -1));
MainScene::getInstance()->run();
}
}
}
if (r == 1)
{
if (menu_load_->run() >= 0)
{
//Save::getInstance()->getRole(0)->MagicLevel[0] = 900; //测试用
//Script::getInstance()->runScript("../game/script/0.lua");
MainScene::getInstance()->run();
}
}
if (r == 2)
{
setExit(true);
}
}
void TitleScene::onEntrance()
{
Engine::getInstance()->playVideo("../game/movie/1.mp4");
Audio::getInstance()->playMusic(16);
}