-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemSlot.cpp
171 lines (148 loc) · 5.25 KB
/
ItemSlot.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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include "stdafx.h"
ItemSlot::ItemSlot()
{
}
ItemSlot::~ItemSlot()
{
}
void ItemSlot::Init()
{
m_Sprite.LoadTextureFromFile("Texture/ItemSlot.png");
m_pButton[0] = new Button;
m_pButton[0]->m_bSizeUp = true;
m_pButton[0]->m_Sprite.LoadTextureFromFile("Texture/Arrow.png");
m_pButton[0]->m_Sprite.m_Position = Vector3(1505.f, 1056.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pButton[0]);
m_pButton[1] = new Button;
m_pButton[1]->m_bSizeUp = true;
m_pButton[1]->m_Sprite.LoadTextureFromFile("Texture/Item1Button.png");
m_pButton[1]->m_Sprite.m_Position = Vector3(1334.f, 1004.f + 177.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pButton[1]);
m_pButton[2] = new Button;
m_pButton[2]->m_bSizeUp = true;
m_pButton[2]->m_Sprite.LoadTextureFromFile("Texture/Item2Button.png");
m_pButton[2]->m_Sprite.m_Position = Vector3(1500.f, 1004.f + 177.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pButton[2]);
m_pButton[3] = new Button;
m_pButton[3]->m_bSizeUp = true;
m_pButton[3]->m_Sprite.LoadTextureFromFile("Texture/Item3Button.png");
m_pButton[3]->m_Sprite.m_Position = Vector3(1670.f, 1004.f + 177.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pButton[3]);
}
void ItemSlot::Render()
{
m_Sprite.OnRender();
m_pButton[1]->m_Sprite.OnRender();
m_pButton[2]->m_Sprite.OnRender();
m_pButton[3]->m_Sprite.OnRender();
}
void ItemSlot::Update(float deltatime)
{
if (KeyManager::GetInstance()->GetKeyState(VK_F1) == EKEY_DOWN)
{
m_pGameStart->m_iScore += 200;
m_pGameStart->m_iNextAtt = 3;
}
if (KeyManager::GetInstance()->GetKeyState(VK_F2) == EKEY_DOWN)
{
m_pGameStart->m_iScore -= 50;
}
if (m_pGameStart->m_iScore >= 200.f && m_pGameStart->m_bAiAtt == false && m_bControl[0] == false)
{
m_pButton[1]->m_Sprite.SetColor(255, 255, 255, 255);
if (m_pButton[1]->m_bIsDown == true)
{
ItemUseTexture * m_pItemUseTexture = new ItemUseTexture;
m_pItemUseTexture->m_Sprite.LoadTextureFromFile("Texture/Item1Button.png");
m_pItemUseTexture->Init();
m_pItemUseTexture->m_Sprite.m_Position = Vector3(1500.f, 1080.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pItemUseTexture);
m_bControl[0] = true;
m_pGameStart->m_bItem1 = true;
}
}
else
{
m_pButton[1]->m_Sprite.SetColor(25, 25, 25, 255);
}
if (m_pGameStart->m_iScore >= 350.f && m_pGameStart->m_bAiAtt == false && m_bControl[1] == false)
{
m_pButton[2]->m_Sprite.SetColor(255, 255, 255, 255);
if (m_pButton[2]->m_bIsDown == true)
{
ItemUseTexture * m_pItemUseTexture = new ItemUseTexture;
m_pItemUseTexture->m_Sprite.LoadTextureFromFile("Texture/Item2Button.png");
m_pItemUseTexture->Init();
m_pItemUseTexture->m_Sprite.m_Position = Vector3(1500.f, 1080.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pItemUseTexture);
Item2 * m_pItem2 = new Item2;
m_pItem2->m_pGameStart = m_pGameStart;
m_pItem2->Init();
m_pItem2->m_Sprite.m_Position = Vector3(1150.f, 1080.f + 202.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pItem2);
m_bControl[1] = true;
m_pGameStart->m_bItem2 = true;
}
}
else
{
m_pButton[2]->m_Sprite.SetColor(25, 25, 25, 255);
}
if (m_pGameStart->m_iNextAtt >= 3 && m_pGameStart->m_bAiAtt == false && m_bControl[2] == false)
{
m_pButton[3]->m_Sprite.SetColor(255, 255, 255, 255);
if (m_pButton[3]->m_bIsDown == true)
{
ItemUseTexture * m_pItemUseTexture = new ItemUseTexture;
m_pItemUseTexture->m_Sprite.LoadTextureFromFile("Texture/Item3Button.png");
m_pItemUseTexture->Init();
m_pItemUseTexture->m_Sprite.m_Position = Vector3(1500.f, 1080.f, 0.f);
SceneManager::GetInstance()->GetNowScene()->m_ObjectManager.AddObject(m_pItemUseTexture);
m_bControl[2] = true;
m_pGameStart->m_bItem3 = true;
}
}
else
{
m_pButton[3]->m_Sprite.SetColor(25, 25, 25, 255);
}
if (m_pButton[0]->m_bIsDown == true)
{
if (m_bIsDown == false)
m_bIsDown = true;
else
m_bIsDown = false;
}
if (m_bIsDown == true)
{
m_Sprite.m_Position.y -= deltatime * 300.f;
m_pButton[0]->m_Sprite.m_Position.y -= deltatime * 300.f;
m_pButton[1]->m_Sprite.m_Position.y -= deltatime * 300.f;
m_pButton[2]->m_Sprite.m_Position.y -= deltatime * 300.f;
m_pButton[3]->m_Sprite.m_Position.y -= deltatime * 300.f;
if (m_Sprite.m_Position.y < 1004.f)
{
m_Sprite.m_Position.y = 1004.f;
m_pButton[0]->m_Sprite.m_Position.y = 1004.f - 128.f;
m_pButton[1]->m_Sprite.m_Position.y = 1020.f;
m_pButton[2]->m_Sprite.m_Position.y = 1020.f;
m_pButton[3]->m_Sprite.m_Position.y = 1020.f;
}
}
if (m_bIsDown == false)
{
m_Sprite.m_Position.y += deltatime * 300.f;
m_pButton[0]->m_Sprite.m_Position.y += deltatime * 300.f;
m_pButton[1]->m_Sprite.m_Position.y += deltatime * 300.f;
m_pButton[2]->m_Sprite.m_Position.y += deltatime * 300.f;
m_pButton[3]->m_Sprite.m_Position.y += deltatime * 300.f;
if (m_Sprite.m_Position.y > 1004.f + 177.f)
{
m_Sprite.m_Position.y = 1004.f + 177.f;
m_pButton[0]->m_Sprite.m_Position.y = 1056.f;
m_pButton[1]->m_Sprite.m_Position.y = 1004.f + 177.f;
m_pButton[2]->m_Sprite.m_Position.y = 1004.f + 177.f;
m_pButton[3]->m_Sprite.m_Position.y = 1004.f + 177.f;
}
}
}