add loader
add schema new loader model using xml separated work and load data validation using schema map data in xml new core model... proecting
This commit is contained in:
37
towers.cpp
37
towers.cpp
@@ -4,7 +4,6 @@ Towers::Towers(Game_Data *gd, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
gameData = gd;
|
||||
nextId = 0;
|
||||
Tower tw;
|
||||
for (int i=0; i<gameData->players.size(); i++)
|
||||
gameData->players[i]->srcTowers.push_back(tw);
|
||||
@@ -12,42 +11,36 @@ Towers::Towers(Game_Data *gd, QObject *parent) :
|
||||
|
||||
bool Towers::AddTower(int playerId, int srcId, QPoint pos)
|
||||
{
|
||||
if (playerId < 0 || playerId >= gameData->players.size()) qDebug("ERROR out of players range"),exit(-1);
|
||||
if (srcId < 0 || srcId >= gameData->players.at(playerId)->srcTowers.size()) qDebug("ERROR out of towers range"),exit(-1);
|
||||
//QByteArray ar;
|
||||
//ar << pos;
|
||||
if (playerId < 0 || playerId >= gameData->players.size())
|
||||
{
|
||||
qCritical("ERROR out of players range");
|
||||
return false;
|
||||
}
|
||||
if (srcId < 0 || srcId >= gameData->players.at(playerId)->srcTowers.size())
|
||||
{
|
||||
qCritical("ERROR out of towers range");
|
||||
return false;
|
||||
}
|
||||
Tower tw = gameData->players.at(playerId)->srcTowers.at(srcId);
|
||||
tw.Id = nextId;
|
||||
if (gameData->map->addTowerOnMap(playerId,pos))
|
||||
{
|
||||
tw.pos = pos;
|
||||
gameData->map->printMap();
|
||||
nextId++;
|
||||
gameData->curTowers.push_back(tw);
|
||||
gameData->curTowers.insert(tw.pos,tw);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Towers::DelTower(int index)
|
||||
void Towers::DelTower(QPoint pos)
|
||||
{
|
||||
gameData->curTowers.remove(index);
|
||||
gameData->curTowers.remove(pos);
|
||||
}
|
||||
|
||||
|
||||
void Towers::DelTowerById(int Id)
|
||||
{
|
||||
DelTower(TowerIndex(Id));
|
||||
}
|
||||
|
||||
|
||||
int Towers::TowerIndex(int towerId)
|
||||
{
|
||||
int i=-1;
|
||||
for (i=0; i<gameData->curTowers.size(); i++)
|
||||
if (gameData->curTowers.at(i).Id==towerId) return i;
|
||||
return i;
|
||||
}
|
||||
|
||||
void Towers::update()
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user