forked from DUCKSOO/ToonHeroes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTowerManager.cpp
64 lines (55 loc) · 1.38 KB
/
TowerManager.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
#include "TowerManager.h"
#include "Core.h"
void TowerManager::init() // 원점 초기화 함수
{
memset(m_pTowerList, NULL, sizeof(m_pTowerList));
}
void TowerManager::setScene(Layer* _curScene) //이미지 설정 , 기준점 변경, 좌표 설정, 레이어에 add
{
this->init();
for (int i = 0; i < MAX_TOWER; i++)
{
m_pTowerList[i] = new Object_Tower;
if (i == 0)
{
m_pTowerList[i]->init(P_TOWER);
m_pTowerList[i]->setPosition(Point(155, 100));
}
else if (i == 1)
{
m_pTowerList[i]->init(E_TOWER);
m_pTowerList[i]->setPosition(Point(1900, 100));
}
m_pTowerList[i]->setScale(0.7f);
_curScene->addChild(m_pTowerList[i]);
}
}
void TowerManager::dealloc() // 동적 할당 풀기 ( 종료 시 or 스테이지 이동 시 시행 )
{
for (int i = 0; i < MAX_TOWER; i++)
{
delete(m_pTowerList[i]);
}
}
Object_Tower* TowerManager::CollisionCheckAboutTower(Object_Alliance* _alliance)
{
for (int i = 0; i < MAX_TOWER; i++)
{
if (m_pTowerList[i] == NULL) continue;
if (m_pTowerList[i]->getLiveFlag() == false) continue;
if (m_pTowerList[i]->getTag() == E_TOWER)
{
if (_alliance->m_iObjTag == PLAYER)
{
float x = m_pTowerList[i]->getPosition().x;
float x2 = _alliance->getPosition().x;
if (m_pTowerList[i]->getPosition().x - _alliance->allianceSprite->getPosition().x < 50.0f)
{
_alliance->m_iState = ATTACK;
return m_pTowerList[i];
}
}
}
}
return NULL;
}