added animation

but not full in ADeditor
This commit is contained in:
2010-09-05 16:25:23 +04:00
parent c898f978da
commit 8fa6b8e2a6
24 changed files with 924 additions and 725 deletions

View File

@@ -15,7 +15,8 @@ SOURCES += main.cpp \
../player.cpp \
../game_data.cpp \
triggermodel.cpp \
mapmodel.cpp
mapmodel.cpp \
animationmodel.cpp
HEADERS += mainwindow.h \
../loader.h \
alienmodel.h \
@@ -26,7 +27,8 @@ HEADERS += mainwindow.h \
../player.h \
../game_data.h \
triggermodel.h \
mapmodel.h
mapmodel.h \
animationmodel.h
FORMS += mainwindow.ui
TRANSLATIONS += adeditor_ru.ts
RESOURCES += ADeditor.qrc

View File

@@ -6,18 +6,18 @@
class AlienModel : public QAbstractListModel
{
Q_OBJECT
Q_OBJECT
public:
explicit AlienModel(QList<tbAlien> aliens, QObject *parent = 0);
explicit AlienModel(QList<tbAlien> aliens, QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
void refresh(QList<tbAlien> aliens);
void refresh(QList<tbAlien> aliens);
signals:
public slots:
private:
QList<tbAlien> aliens;
QList<tbAlien> aliens;
};
#endif // ALIENMODEL_H

View File

@@ -0,0 +1,35 @@
#include "animationmodel.h"
AnimationModel::AnimationModel(QList <tbAnimation> manims, QObject *parent) :
QAbstractListModel(parent)
{
anims = manims;
}
void AnimationModel::refresh(QList<tbAnimation>manims)
{
anims = manims;
}
int AnimationModel::rowCount(const QModelIndex &) const
{
return anims.count();
}
QVariant AnimationModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= anims.size())
return QVariant();
if (role == Qt::DisplayRole)
{
return anims.at(index.row()).id;
}
return QVariant();
}

24
ADeditor/animationmodel.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef ANIMATIONMODEL_H
#define ANIMATIONMODEL_H
#include <QAbstractListModel>
#include "../loader.h"
class AnimationModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit AnimationModel(QList <tbAnimation> anims, QObject *parent = 0);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
void refresh(QList <tbAnimation> anims);
signals:
public slots:
private:
QList <tbAnimation> anims;
};
#endif // ANIMATIONMODEL_H

View File

@@ -2,7 +2,7 @@
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QFileDialog>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@@ -26,6 +26,11 @@ MainWindow::MainWindow(QWidget *parent) :
adloader = new Loader(this);
adloader->load("data2.xml");
animModel = new AnimationModel(adloader->animations.values());
ui->lvAnimations->setModel((QAbstractItemModel * )animModel);
connect(ui->lvAnimations->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(lvAnimations_select(QModelIndex, QModelIndex)));
ui->lvAnimations->selectionModel()->setCurrentIndex(ui->lvAnimations->model()->index(0,0),QItemSelectionModel::ClearAndSelect);
mapScene = new QGraphicsScene();
ui->gvMap->setScene(mapScene);
ui->gvMap->scale(10,10);
@@ -105,159 +110,185 @@ void MainWindow::on_cbAlRegeneration_toggled(bool checked)
}
void MainWindow::lvAnimations_select(QModelIndex index, QModelIndex)
{
if (index.isValid())
{
ui->lwImages->clear();
refresh_lwImages(adloader->animations.values().at(index.row()).pathes);
}
}
void MainWindow::lvAliens_select(QModelIndex index, QModelIndex)
{
tbAlien al = adloader->aliens.values().at(index.row());
ui->leAlName->setText(al.name);
ui->sbAlHealth->setValue(al.health);
ui->sbAlArmor->setValue(al.armor);
if (al.armor > 0) ui->cbAlArmor->setChecked(true);
else ui->cbAlArmor->setChecked(false);
ui->sbAlSpeed->setValue(al.speed);
ui->sbAlPrise->setValue(al.prise);
ui->sbAlregeneration->setValue(al.regeneration);
if (al.regeneration > 0) ui->cbAlRegeneration->setChecked(true);
else ui->cbAlRegeneration->setChecked(false);
ui->sbAlScore->setValue(al.score);
ui->cbAlIsFly->setChecked(al.isFlying);
if (index.isValid())
{
tbAlien al = adloader->aliens.values().at(index.row());
ui->leAlName->setText(al.name);
ui->sbAlHealth->setValue(al.health);
ui->sbAlArmor->setValue(al.armor);
if (al.armor > 0) ui->cbAlArmor->setChecked(true);
else ui->cbAlArmor->setChecked(false);
ui->sbAlSpeed->setValue(al.speed);
ui->sbAlPrise->setValue(al.prise);
ui->sbAlregeneration->setValue(al.regeneration);
if (al.regeneration > 0) ui->cbAlRegeneration->setChecked(true);
else ui->cbAlRegeneration->setChecked(false);
ui->sbAlScore->setValue(al.score);
ui->cbAlIsFly->setChecked(al.isFlying);
}
}
void MainWindow::lvMaps_select(QModelIndex index, QModelIndex)
{
tbMap map = adloader->maps.values().at(index.row());
ui->leMapName->setText(map.name);
ui->sbMapHei->setValue(map.size.height());
ui->sbMapWid->setValue(map.size.width());
ui->sbMapPlayers->setValue(map.maxPlayers);
Map m(map.data,map.size,map.name,map.maxPlayers,map.imgType);
QPixmap pix(map.size);
QPainter p(&pix);
p.fillRect(m.rect(),Qt::white);
for (int i=0; i<m.cells().size(); i++) {
for (int j=0; j<m.cells().at(i).size(); j++) {
QPen pen;
pen.setColor(Qt::white);
int cel = m.cells().at(i).at(j);
if (cel == Map::Wall)
pen.setColor(Qt::black);
if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,200));
p.setPen(pen);
p.drawPoint(i,j);
if (index.isValid())
{
tbMap map = adloader->maps.values().at(index.row());
ui->leMapName->setText(map.name);
ui->sbMapHei->setValue(map.size.height());
ui->sbMapWid->setValue(map.size.width());
ui->sbMapPlayers->setValue(map.maxPlayers);
Map m(map.data,map.size,map.name,map.maxPlayers,map.imgType);
QPixmap pix(map.size);
QPainter p(&pix);
p.fillRect(m.rect(),Qt::white);
for (int i=0; i<m.cells().size(); i++) {
for (int j=0; j<m.cells().at(i).size(); j++) {
QPen pen;
pen.setColor(Qt::white);
int cel = m.cells().at(i).at(j);
if (cel == Map::Wall)
pen.setColor(Qt::black);
if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,200));
p.setPen(pen);
p.drawPoint(i,j);
}
}
p.end();
mapScene->clear();
mapScene->addPixmap(pix);
ui->gvMap->centerOn(0,0);
//ui->gvMap->resetCachedContent();
ui->pbMapEdit->setIcon(QIcon(pix));
}
p.end();
mapScene->clear();
mapScene->addPixmap(pix);
ui->gvMap->centerOn(0,0);
//ui->gvMap->resetCachedContent();
ui->pbMapEdit->setIcon(QIcon(pix));
}
void MainWindow::lvTowers_select(QModelIndex index, QModelIndex)
{
tbTower tw = adloader->towers.values().at(index.row());
ui->sbTwBuildTime->setValue(tw.buildTime);
ui->sbTwCost->setValue(tw.cost);
ui->sbTwExpByDam->setValue(tw.expByDamage);
if (tw.expByDamage > 0)
ui->cbTwExpByDam->setChecked(true);
else
ui->cbTwExpByDam->setChecked(false);
ui->sbTwExpByKill->setValue(tw.expByKill);
if (tw.expByKill > 0)
ui->cbTwExpByKill->setChecked(true);
else
ui->cbTwExpByKill->setChecked(false);
ui->sbTwExpByShot->setValue(tw.expByShot);
if (tw.expByShot > 0)
ui->cbTwExpByShot->setChecked(true);
else
ui->cbTwExpByShot->setChecked(false);
ui->leTwName->setText(tw.name);
ui->sbTwRadius->setValue(tw.radius);
ui->sbTwReload->setValue(tw.reload);
ui->cbTwSplash->setCurrentIndex(adloader->splashes.keys().indexOf(tw.splashId));
if (index.isValid())
{
tbTower tw = adloader->towers.values().at(index.row());
ui->sbTwBuildTime->setValue(tw.buildTime);
ui->sbTwCost->setValue(tw.cost);
ui->sbTwExpByDam->setValue(tw.expByDamage);
if (tw.expByDamage > 0)
ui->cbTwExpByDam->setChecked(true);
else
ui->cbTwExpByDam->setChecked(false);
ui->sbTwExpByKill->setValue(tw.expByKill);
if (tw.expByKill > 0)
ui->cbTwExpByKill->setChecked(true);
else
ui->cbTwExpByKill->setChecked(false);
ui->sbTwExpByShot->setValue(tw.expByShot);
if (tw.expByShot > 0)
ui->cbTwExpByShot->setChecked(true);
else
ui->cbTwExpByShot->setChecked(false);
ui->leTwName->setText(tw.name);
ui->sbTwRadius->setValue(tw.radius);
ui->sbTwReload->setValue(tw.reload);
ui->cbTwSplash->setCurrentIndex(adloader->splashes.keys().indexOf(tw.splashId));
}
}
void MainWindow::lvSplashes_select(QModelIndex index, QModelIndex)
{
tbSplash spl = adloader->splashes.values().at(index.row());
ui->sbSplLifeTime->setValue(spl.lifetime);
ui->sbSplSpeed->setValue(spl.speed);
ui->cbSplAutoControl->setChecked(spl.autoControl);
ui->leSplName->setText(spl.name);
if (index.isValid())
{
tbSplash spl = adloader->splashes.values().at(index.row());
ui->sbSplLifeTime->setValue(spl.lifetime);
ui->sbSplSpeed->setValue(spl.speed);
ui->cbSplAutoControl->setChecked(spl.autoControl);
ui->leSplName->setText(spl.name);
}
}
void MainWindow::lvTriggers_select(QModelIndex index, QModelIndex)
{
tbTrigger trig = adloader->triggers.values().at(index.row());
ui->sbTrigCount->setValue(trig.count);
if (trig.count > 0)
ui->cbTrigCount->setChecked(true);
else
ui->cbTrigCount->setChecked(false);
ui->sbTrigDamage->setValue(trig.damage);
if (trig.damage > 0)
ui->cbTrigDamage->setChecked(true);
else
ui->cbTrigDamage->setChecked(false);
ui->sbTrigDamRadius->setValue(trig.radius);
if (trig.radius > 0)
ui->cbTrigDamRad->setChecked(true);
else
ui->cbTrigDamRad->setChecked(false);
ui->sbTrigChance->setValue(trig.chance);
if (trig.chance == 100)
ui->cbTrigChance->setChecked(false);
else
ui->cbTrigChance->setChecked(true);
ui->sbTrigRandomRadius->setValue(trig.randomPosRadius);
if (trig.randomPosRadius > 0)
ui->cbTrigRandRadius->setChecked(true);
else
ui->cbTrigRandRadius->setChecked(false);
ui->sbTrigTimer->setValue(trig.timer);
switch (trig.type)
if (index.isValid())
{
case srcTriggerType::onDestination :
ui->cbTrigType->setCurrentIndex(0);
break;
case srcTriggerType::onAlienInRadius :
ui->cbTrigType->setCurrentIndex(1);
break;
case srcTriggerType::onTimer :
ui->cbTrigType->setCurrentIndex(2);
break;
tbTrigger trig = adloader->triggers.values().at(index.row());
ui->sbTrigCount->setValue(trig.count);
if (trig.count > 0)
ui->cbTrigCount->setChecked(true);
else
ui->cbTrigCount->setChecked(false);
ui->sbTrigDamage->setValue(trig.damage);
if (trig.damage > 0)
ui->cbTrigDamage->setChecked(true);
else
ui->cbTrigDamage->setChecked(false);
ui->sbTrigDamRadius->setValue(trig.radius);
if (trig.radius > 0)
ui->cbTrigDamRad->setChecked(true);
else
ui->cbTrigDamRad->setChecked(false);
ui->sbTrigChance->setValue(trig.chance);
if (trig.chance == 100)
ui->cbTrigChance->setChecked(false);
else
ui->cbTrigChance->setChecked(true);
ui->sbTrigRandomRadius->setValue(trig.randomPosRadius);
if (trig.randomPosRadius > 0)
ui->cbTrigRandRadius->setChecked(true);
else
ui->cbTrigRandRadius->setChecked(false);
ui->sbTrigTimer->setValue(trig.timer);
switch (trig.type)
{
case srcTriggerType::onDestination :
ui->cbTrigType->setCurrentIndex(0);
break;
case srcTriggerType::onAlienInRadius :
ui->cbTrigType->setCurrentIndex(1);
break;
case srcTriggerType::onTimer :
ui->cbTrigType->setCurrentIndex(2);
break;
}
if (trig.type != srcTriggerType::onTimer)
{
ui->lbTrigTimer->setVisible(false);
ui->sbTrigTimer->setVisible(false);
} else {
ui->lbTrigTimer->setVisible(true);
ui->sbTrigTimer->setVisible(true);
}
switch (trig.childAim)
{
case srcTriggerType::noAim :
ui->cbTrigChildAim->setCurrentIndex(0);
break;
case srcTriggerType::allSide :
ui->cbTrigChildAim->setCurrentIndex(1);
break;
case srcTriggerType::parentAim :
ui->cbTrigChildAim->setCurrentIndex(2);
break;
case srcTriggerType::nearlestAlien :
ui->cbTrigChildAim->setCurrentIndex(3);
break;
}
ui->leTrigName->setText(trig.name);
}
if (trig.type != srcTriggerType::onTimer)
{
ui->lbTrigTimer->setVisible(false);
ui->sbTrigTimer->setVisible(false);
} else {
ui->lbTrigTimer->setVisible(true);
ui->sbTrigTimer->setVisible(true);
}
switch (trig.childAim)
{
case srcTriggerType::noAim :
ui->cbTrigChildAim->setCurrentIndex(0);
break;
case srcTriggerType::allSide :
ui->cbTrigChildAim->setCurrentIndex(1);
break;
case srcTriggerType::parentAim :
ui->cbTrigChildAim->setCurrentIndex(2);
break;
case srcTriggerType::nearlestAlien :
ui->cbTrigChildAim->setCurrentIndex(3);
break;
}
ui->leTrigName->setText(trig.name);
}
@@ -906,6 +937,7 @@ void MainWindow::on_cbTrigType_currentIndexChanged(int index)
} else {
ui->lbTrigTimer->setVisible(true);
ui->sbTrigTimer->setVisible(true);
ui->sbTrigTimer->setValue(adloader->triggers[id].timer);
}
isSaved = false;
}
@@ -917,3 +949,37 @@ void MainWindow::on_cbTrigChildAim_currentIndexChanged(int index)
adloader->triggers[id].childAim = (srcTriggerType::aimType)ui->cbTrigChildAim->itemData(index).toInt();
isSaved = false;
}
void MainWindow::on_pbImgAdd_clicked()
{
int id = adloader->animations.values().at(ui->lvAnimations->currentIndex().row()).id;
QFileDialog fd;
fd.setNameFilter(tr("Images (*.png)"));
fd.setFileMode(QFileDialog::ExistingFiles);
if (fd.exec())
{
adloader->animations[id].pathes.append(fd.selectedFiles());
refresh_lwImages(adloader->animations.value(id).pathes);
isSaved = false;
}
}
void MainWindow::refresh_lwImages(QStringList pathes)
{
ui->lwImages->clear();
for (int i=0; i<pathes.size(); ++i)
{
ui->lwImages->addItem(new QListWidgetItem(QIcon(pathes.at(i)),pathes.at(i)));
}
}
void MainWindow::on_pbImgDel_clicked()
{
int id = adloader->animations.values().at(ui->lvAnimations->currentIndex().row()).id;
for (int i=0; i<ui->lwImages->selectedItems().size(); ++i)
adloader->animations[id].pathes.removeOne(ui->lwImages->selectedItems().at(i)->text());
refresh_lwImages(adloader->animations.value(id).pathes);
}

View File

@@ -12,6 +12,7 @@
#include "splashmodel.h"
#include "triggermodel.h"
#include "mapmodel.h"
#include "animationmodel.h"
namespace Ui {
class MainWindow;
@@ -34,13 +35,17 @@ private:
SplashModel * splModel;
TriggerModel* trigModel;
MapModel * mapModel;
AnimationModel * animModel;
QGraphicsScene * mapScene;
bool isSaved;
void refresh_lwImages(QStringList pathes);
void closeEvent(QCloseEvent *);
private slots:
void on_cbTrigChildAim_currentIndexChanged(int index);
void on_pbImgDel_clicked();
void on_pbImgAdd_clicked();
void on_cbTrigChildAim_currentIndexChanged(int index);
void on_cbTrigType_currentIndexChanged(int index);
void on_cbTrigCount_toggled(bool checked);
void on_leTrigName_editingFinished();
@@ -91,6 +96,7 @@ private slots:
void on_sbAlHealth_valueChanged(double );
void on_pbSave_clicked();
void lvAliens_select(QModelIndex, QModelIndex);
void lvAnimations_select(QModelIndex, QModelIndex);
void lvTowers_select(QModelIndex, QModelIndex);
void lvSplashes_select(QModelIndex, QModelIndex);
void lvTriggers_select(QModelIndex, QModelIndex);

View File

@@ -24,13 +24,6 @@
<property name="spacing">
<number>2</number>
</property>
<item row="5" column="0">
<widget class="QPushButton" name="pbSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pbReload">
<property name="text">
@@ -38,380 +31,396 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="pbSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>4</number>
<number>5</number>
</property>
<widget class="QWidget" name="tabAliens">
<attribute name="title">
<string>Aliens</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,2">
<item row="0" column="0">
<widget class="QListView" name="lvAliens">
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QListView" name="lvAliens">
<property name="editTriggers">
<set>QAbstractItemView::AllEditTriggers</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="2,1">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QPushButton" name="pbAlAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbAlDel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leAlName"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Health</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlHealth">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>99.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="cbAlArmor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Armor</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlArmor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="cbAlRegeneration">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Regeneration</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlregeneration">
<property name="enabled">
<bool>false</bool>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep">
<double>5.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Speed</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlSpeed">
<property name="suffix">
<string/>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="minimum">
<double>0.000010000000000</double>
</property>
<property name="maximum">
<double>99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>0.010000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Prize</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbAlPrise">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Score</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbAlScore">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QCheckBox" name="cbAlIsFly">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Is Flying</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9" stretch="10,0,0">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="1" rowspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leAlName"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Health</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlHealth">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>99.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="cbAlArmor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Armor</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlArmor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="cbAlRegeneration">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Regeneration</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlregeneration">
<property name="enabled">
<bool>false</bool>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
<property name="singleStep">
<double>5.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Speed</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="sbAlSpeed">
<property name="suffix">
<string/>
</property>
<property name="decimals">
<number>5</number>
</property>
<property name="minimum">
<double>0.000010000000000</double>
</property>
<property name="maximum">
<double>99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>0.010000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Prize</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbAlPrise">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Score</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbAlScore">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QCheckBox" name="cbAlIsFly">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Is Flying</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9" stretch="10,0,0">
<item>
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="2,1">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QPushButton" name="pbAlAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbAlDel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTowers">
@@ -1637,6 +1646,107 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tabAnimation">
<attribute name="title">
<string>Animations</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QListView" name="lvAnimations"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_22" stretch="2,1">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QPushButton" name="pbAnimAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbAnimDel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QListWidget" name="lwImages">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_23" stretch="2,1">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QPushButton" name="pbImgAdd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbImgDel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@@ -4,7 +4,6 @@
AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(parent)
{
loadImages();
data = adcore->addata;
core = adcore;
//scale(cellSize, cellSize);
@@ -41,8 +40,8 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
// }
if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
{
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,150));
brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,80));
}
p.setPen(pen);
p.setBrush(brush);
@@ -50,7 +49,7 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
}
}
startTimer(25);
startTimer(50);
show();
}
@@ -143,7 +142,7 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
p->setBrush(brush);
p->drawRect(-20,-20,40,40);
} else {
p->drawImage(QRect(-20,-20,40,40), images[itTowers][(*i).imgType]->at(0));
p->drawImage(QRect(-20,-20,40,40), *data->curAnimations.at((*i).imgType).images.at((*i).animIndex));
}
p->resetTransform();
}
@@ -158,7 +157,10 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
//p->translate(-rec.height()/2, -rec.width()/2);
p->translate((*i).pos * cellSize+QPointF(10,10));
p->rotate((*i).angle);
p->drawImage(QRect(-20,-20,40,40), images[itAliens][0]->at(0));
p->drawImage(QRect(-20,-20,40,40), *data->curAnimations.at((*i).imgType).images.at((*i).animIndex));
(*i).animIndex++;
if ((*i).animIndex >= data->curAnimations.at((*i).imgType).images.size())
(*i).animIndex = 0;
p->resetTransform();
}
//qDebug() << "s:" << data->curSplashes.size();
@@ -178,7 +180,12 @@ void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
//p->setBrush(brush);
//p->setPen(QColor(0,0,0,0));
//p->drawEllipse(QPoint(),5,5);
p->drawImage(QPoint(-(images[itSplashes][(*i).imgType]->at(0).size().width()/2),-(images[itSplashes][(*i).imgType]->at(0).size().height()/2)), images[itSplashes][(*i).imgType]->at(0));
QImage img;
img = *data->curAnimations.at((*i).imgType).images.at((*i).animIndex);
p->drawImage(QPoint(-(img.size().width()/2),-(img.size().height()/2)), img);
(*i).animIndex++;
if ((*i).animIndex >= data->curAnimations.at((*i).imgType).images.size())
(*i).animIndex = 0;
p->resetTransform();
}
}
@@ -190,25 +197,3 @@ void AD_Graphics::draw()
//resetCachedContent();
//repaint();
}
void AD_Graphics::loadImages()
{
images.resize(3);
for (int i = 0; i < images.size(); i++) {
switch ((imagesType)i) {
case itAliens:
images[i].push_back(new Animation(":/images/images/Aliens/Al_00_0.png"));
break;
case itTowers:
images[i].push_back(new Animation(":/images/images/Towers/01_6.png"));
images[i].push_back(new Animation(":/images/images/Towers/00_0.png"));
case itSplashes:
images[i].push_back(new Animation(":/images/images/Splashes/Rocket.png"));
images[i].push_back(new Animation(":/images/images/Splashes/Shot_0.png"));
images[i].push_back(new Animation(":/images/images/Splashes/Smoke_01.png"));
images[i].push_back(new Animation(":/images/images/Splashes/expl.png"));
default: break;
}
}
}

View File

@@ -6,7 +6,6 @@
#include <QMouseEvent>
#include "adcore.h"
#include "animation.h"
const float cellSize = 20.f;
@@ -18,11 +17,8 @@ public:
~AD_Graphics();
private:
enum imagesType {itAliens, itTowers, itSplashes};
void draw();
void drawBackground(QPainter * p, const QRectF &);
void loadImages();
void mouseDoubleClickEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *event);
@@ -30,7 +26,6 @@ private:
Game_Data * data;
AD_Core * core;
QImage * mapimg;
QVector<QVector<Animation * > > images;
//QGraphicsWidget * gsw;
protected:

View File

@@ -7,9 +7,7 @@ HEADERS += base_types.h \
adcore.h \
player.h \
loader.h \
animation.h \
ad_graphics.h \
graphicsalien.h
ad_graphics.h
SOURCES += map.cpp \
game_data.cpp \
aliens.cpp \
@@ -19,12 +17,9 @@ SOURCES += map.cpp \
adcore.cpp \
player.cpp \
loader.cpp \
animation.cpp \
ad_graphics.cpp \
graphicsalien.cpp
ad_graphics.cpp
RESOURCES += images.qrc
OTHER_FILES += data.xml \
schema.xml \
OTHER_FILES += schema.xml \
data2.xml
QT += core \
gui \

View File

@@ -24,7 +24,7 @@ void Aliens::addAlien(int srcId)
al.path = gameData->map->createPath(al.pos.toPoint(),al.finish);
al.pathIndex = 1;
al.angle = 180.0f*(- std::atan2( al.pos.x() - al.path.at(al.pathIndex).x(),al.pos.y() - al.path.at(al.pathIndex).y()))/M_PI;
al.animIndex = 0.f;
al.animIndex = 0;
if (al.path.isEmpty())
{
qCritical("ERROR create path");

View File

@@ -1,27 +0,0 @@
#include "animation.h"
#include <QFile>
#include <QDebug>
Animation::Animation(const QString & path)
{
// int i = 0;
// QString s = path + QString::number(i) + ".png";
// //qDebug() << "check " << s;
// while (QFile::exists(s)) {
// images.push_back(new QImage(s));
// s = path + QString::number(++i) + ".png";
// }
// qDebug() << "found " << images.size() << " images";
if (QFile::exists(path))
{
images.push_back(new QImage(path));
}
}
Animation::~Animation()
{
}

View File

@@ -1,19 +0,0 @@
#ifndef ANIMATION_H
#define ANIMATION_H
#include <QString>
#include <QImage>
class Animation
{
public:
explicit Animation(const QString & path);
~Animation();
QImage & at(int index) const {return *(images[index]);};
private:
QVector<QImage * > images;
};
#endif // ANIMATION_H

View File

@@ -13,6 +13,8 @@
#include <QSize>
#include <QRect>
#include <QRectF>
#include <QImage>
#include <QStringList>
struct srcAlienType
@@ -41,7 +43,7 @@ struct AlienType
QVector <QPointF> path;
int pathIndex;
int imgType;
float animIndex;
int animIndex;
};
@@ -108,6 +110,7 @@ struct SplashType
{
int id;
int imgType;
int animIndex;
int src;
QPoint TowerId; // parent tower (-1;-1) for null parent
int srcTower;
@@ -147,6 +150,7 @@ struct TowerType
int oldAim;
int PlayerId; // tower's owner
int imgType;
int animIndex;
QPoint pos; // not QPointF because tower fixed on grid
float angle; // -180 .. 180
unsigned int reload; // time for reload in ticks
@@ -155,6 +159,12 @@ struct TowerType
};
struct AnimationType
{
QList<QImage * > images;
};
struct WaveType
{
QList <int> types; // some types of aliens (e.g. 2 fly and 3 grount in one wave)

View File

@@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE data>
<ADdata>
<aliens>
<alien speed="0.01" score="50" imageType="1" prise="1" id="1" name="al fly" health="40" flying="true"/>
<alien speed="0.012" score="100" imageType="1" prise="0" id="10" name="my alien" health="100"/>
<alien speed="0.0099" score="350" imageType="1" prise="1" id="12" name="MONSTR" health="200" armor="1.5" regeneration="3"/>
</aliens>
<maps>
<map imageType="1" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" width="16" height="16" maxPlayers="2"/>
</maps>
<waves>
<wave id="1" timeout="20000" prise="100"/>
<wave id="2" timeout="20000" prise="200"/>
<wave id="3" timeout="20000" prise="220"/>
</waves>
<levels>
<level id="1" map="1" name="First Level"/>
</levels>
<waveParts>
<wavePart wave="1" alien="10" count="4"/>
<wavePart wave="1" alien="12" count="5"/>
<wavePart wave="1" alien="10" count="10"/>
<wavePart wave="2" alien="10" count="9"/>
<wavePart wave="3" alien="10" count="1"/>
<wavePart wave="3" alien="10" count="2"/>
<wavePart wave="3" alien="12" count="3"/>
<wavePart wave="3" alien="12" count="4"/>
</waveParts>
<wavesOnLevels>
<waveOnLevel level="1" wave="1"/>
<waveOnLevel level="1" wave="2"/>
<waveOnLevel level="1" wave="3"/>
</wavesOnLevels>
<splashes>
<splash speed="0.2" imageType="1" id="1" name="rocket" lifetime="9999"/>
<splash speed="0.2" imageType="1" id="2" name="smart rocket" lifetime="9999" autoControl="true"/>
<splash speed="100" imageType="2" id="3" name="bullet" lifetime="100" autoControl="true"/>
<splash speed="1" imageType="3" id="4" name="bum" lifetime="10"/>
<splash speed="0" imageType="4" id="5" name="smoke" lifetime="10"/>
</splashes>
<towers>
<tower id="1" imageType="1" name="rocket launcher" cost="30" buildTime="50" reload="20" splash="1" radius="3" expByDamage="0.04" expByKill="0.1" expByShot="0.15"/>
<tower id="3" imageType="1" name="rocket launcher 2" cost="30" buildTime="50" reload="20" splash="1" radius="3" expByDamage="0.04" expByKill="0.1" expByShot="0.15"/>
<tower id="2" imageType="2" name="gun" cost="10" buildTime="25" reload="5" splash="3" radius="1.5" expByDamage="0.1" expByShot="0.1" expByKill="0.2"/>
</towers>
<triggers>
<trigger id="2" name="shot" type="onDestination" delParent="true" damage="5"/>
<trigger id="3" name="explosion" type="onDestination" count="1" delParent="true" damage="5" radius="1.5"/>
<trigger id="4" name="smoke" type="onTimer" timer="2" count="1"/>
</triggers>
<chains>
<chain tower="1" parent="1" trigger="3" child="4"/>
<chain tower="1" parent="1" trigger="4" child="5"/>
<chain tower="3" parent="2" trigger="3" child="4"/>
<chain tower="3" parent="2" trigger="4" child="5"/>
<chain tower="2" parent="3" trigger="2"/>
</chains>
<towersOnLevels>
<towerOnLevel level="1" tower="1"/>
<towerOnLevel level="1" tower="2"/>
<towerOnLevel level="1" tower="3"/>
</towersOnLevels>
</ADdata>

View File

@@ -1,15 +1,15 @@
<!DOCTYPE data>
<ADdata>
<aliens>
<alien speed="0.08" imageType="31" prise="15" id="2" score="12" name="Monstr" health="33"/>
<alien speed="0.05" imageType="-1078580008" prise="1" id="4" score="10" name="test" health="100"/>
<alien speed="0.08" imageType="1" prise="15" id="2" score="12" name="Monstr" health="33"/>
<alien speed="0.05" imageType="1" prise="1" id="4" score="10" name="test" health="100"/>
<alien speed="0.03" imageType="1" prise="4" id="10" score="99" name="first" health="50"/>
<alien regeneration="3" speed="0.01" imageType="1" prise="10" armor="1.5" id="12" score="99" name="MONSTR" health="200"/>
<alien speed="0.05" imageType="1" prise="10" id="33" score="99" name="Mega Alien" health="888"/>
</aliens>
<maps>
<map width="16" imageType="1" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/>
<map width="30" imageType="2" height="20" id="2" data="AAAJ3HicY2BgkGNgYBD5//+PBDGYgUGdnzh1EDOBNCM1MKlmEqNu1MxRM0fNHNxmgsobapnJwKC0Yyj5fdTMUTNHzRzaZpJgLwltMKUdxKgDADpycNA=" name="map2" maxPlayers="1"/>
<map width="16" imageType="10" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/>
<map width="30" imageType="20" height="20" id="2" data="AAAJ3HicY2BgkGNgYBD5//+PBDGYgUGdnzh1EDOBNCM1MKlmEqNu1MxRM0fNHNxmgsobapnJwKC0Yyj5fdTMUTNHzRzaZpJgLwltMKUdxKgDADpycNA=" name="map2" maxPlayers="1"/>
</maps>
<waves>
<wave prise="100" timeout="10" id="1"/>
@@ -25,17 +25,25 @@
<wave prise="220" timeout="5" id="11"/>
</waves>
<levels>
<level map="2" id="1" score="170015360" name="First Level"/>
<level map="2" id="1" score="150660272" name="First Level"/>
</levels>
<waveParts>
<wavePart alien="10" count="10" wave="1"/>
<wavePart alien="12" count="5" wave="2"/>
<wavePart alien="10" count="5" wave="2"/>
<wavePart alien="10" count="1" wave="3"/>
<wavePart alien="10" count="2" wave="3"/>
<wavePart alien="12" count="3" wave="3"/>
<wavePart alien="12" count="4" wave="3"/>
<wavePart alien="2" count="20" wave="4"/>
<wavePart alien="4" count="60" wave="4"/>
<wavePart alien="4" count="6" wave="5"/>
<wavePart alien="12" count="16" wave="5"/>
<wavePart alien="10" count="16" wave="5"/>
<wavePart alien="4" count="16" wave="5"/>
<wavePart alien="12" count="26" wave="5"/>
<wavePart alien="10" count="26" wave="5"/>
<wavePart alien="4" count="26" wave="5"/>
<wavePart alien="4" count="1" wave="6"/>
<wavePart alien="10" count="1" wave="6"/>
<wavePart alien="4" count="1" wave="6"/>
@@ -65,22 +73,22 @@
<waveOnLevel wave="8" level="1"/>
</wavesOnLevels>
<splashes>
<splash speed="0.2" imageType="0" lifetime="9999" id="1" name="rocket"/>
<splash speed="0.2" imageType="0" lifetime="9999" autoControl="true" id="2" name="smart rocket"/>
<splash speed="0.1" imageType="1" lifetime="9999" autoControl="true" id="3" name="bullet"/>
<splash speed="0" imageType="3" lifetime="5" id="4" name="bum"/>
<splash speed="0" imageType="2" lifetime="8" id="5" name="smoke"/>
<splash speed="0.1" imageType="-1074795776" lifetime="50" autoControl="true" id="6" name="Снаряд"/>
<splash speed="0.2" imageType="5" lifetime="9999" id="1" name="rocket"/>
<splash speed="0.2" imageType="5" lifetime="9999" autoControl="true" id="2" name="smart rocket"/>
<splash speed="1" imageType="7" lifetime="9999" autoControl="true" id="3" name="bullet"/>
<splash speed="0" imageType="4" lifetime="16" id="4" name="bum"/>
<splash speed="0" imageType="6" lifetime="10" id="5" name="smoke"/>
<splash speed="0.1" imageType="5" lifetime="50" autoControl="true" id="6" name="Снаряд"/>
</splashes>
<towers>
<tower imageType="0" radius="12" expByKill="0.1" expByShot="0.15" buildTime="150" splash="2" reload="15" id="1" name="rocket launcher 2" cost="50" expByDamage="0.04"/>
<tower imageType="1" radius="5" expByKill="0.2" expByShot="0.1" buildTime="100" splash="3" reload="20" id="2" name="gun" cost="10" expByDamage="0.1"/>
<tower imageType="0" radius="4" expByKill="0.1" expByShot="0.15" buildTime="200" splash="1" reload="50" id="3" name="rocket launcher" cost="30" expByDamage="0.04"/>
<tower imageType="3" radius="12" expByKill="0.1" expByShot="0.15" buildTime="150" splash="2" reload="15" id="1" name="rocket launcher 2" cost="50" expByDamage="0.04"/>
<tower imageType="2" radius="3" expByKill="0.2" expByShot="0.1" buildTime="100" splash="3" reload="5" id="2" name="gun" cost="10" expByDamage="0.1"/>
<tower imageType="3" radius="5" expByKill="0.1" expByShot="0.15" buildTime="200" splash="1" reload="50" id="3" name="rocket launcher" cost="30" expByDamage="0.04"/>
</towers>
<triggers>
<trigger damage="5" childAim="noAim" delParent="true" type="onDestination" id="2" name="shot"/>
<trigger damage="21" childAim="noAim" radius="2.5" delParent="true" count="1" type="onDestination" id="3" name="explosion"/>
<trigger childAim="noAim" count="1" type="onTimer" timer="2" id="4" name="smoke"/>
<trigger childAim="noAim" count="1" type="onTimer" id="4" name="smoke" timer="2"/>
</triggers>
<chains>
<chain tower="1" trigger="3" child="4" parent="2"/>
@@ -94,4 +102,13 @@
<towerOnLevel tower="2" level="1"/>
<towerOnLevel tower="3" level="1"/>
</towersOnLevels>
<animations>
<animation pathes="/home/andrey/AD/aliendefender/images/Aliens/Al_00_0.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_1.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_2.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_3.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_4.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_5.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_6.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_7.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_8.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_9.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_10.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_11.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_12.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_13.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_14.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_15.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_16.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_17.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_18.png;/home/andrey/AD/aliendefender/images/Aliens/Al_00_19.png" id="1"/>
<animation pathes="/home/andrey/AD/aliendefender/images/Towers/00_0.png" id="2"/>
<animation pathes="/home/andrey/AD/aliendefender/images/Towers/01_6.png" id="3"/>
<animation pathes="/home/andrey/AD/aliendefender/images/Splashes/expl_00.png;/home/andrey/AD/aliendefender/images/Splashes/expl_01.png;/home/andrey/AD/aliendefender/images/Splashes/expl_02.png;/home/andrey/AD/aliendefender/images/Splashes/expl_03.png;/home/andrey/AD/aliendefender/images/Splashes/expl_04.png;/home/andrey/AD/aliendefender/images/Splashes/expl_05.png;/home/andrey/AD/aliendefender/images/Splashes/expl_06.png;/home/andrey/AD/aliendefender/images/Splashes/expl_07.png;/home/andrey/AD/aliendefender/images/Splashes/expl_08.png;/home/andrey/AD/aliendefender/images/Splashes/expl_09.png;/home/andrey/AD/aliendefender/images/Splashes/expl_10.png;/home/andrey/AD/aliendefender/images/Splashes/expl_11.png;/home/andrey/AD/aliendefender/images/Splashes/expl_12.png;/home/andrey/AD/aliendefender/images/Splashes/expl_13.png;/home/andrey/AD/aliendefender/images/Splashes/expl_14.png;/home/andrey/AD/aliendefender/images/Splashes/expl_15.png;/home/andrey/AD/aliendefender/images/Splashes/expl_16.png" id="4"/>
<animation pathes="/home/andrey/AD/aliendefender/images/Splashes/Rocket.png" id="5"/>
<animation pathes="/home/andrey/AD/aliendefender/images/Splashes/Smoke_00.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_01.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_02.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_03.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_04.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_05.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_06.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_07.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_08.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_09.png;/home/andrey/AD/aliendefender/images/Splashes/Smoke_10.png" id="6"/>
<animation pathes="/home/andrey/AD/aliendefender/images/Splashes/Shot_0.png;/home/andrey/AD/aliendefender/images/Splashes/Shot_1.png;/home/andrey/AD/aliendefender/images/Splashes/Shot_2.png;/home/andrey/AD/aliendefender/images/Splashes/Shot_3.png" id="7"/>
</animations>
</ADdata>

View File

@@ -18,6 +18,7 @@ public:
QHash <QPoint,TowerType> curTowers;
QList <WaveType> waves;
QList <Player *> players;
QList <AnimationType> curAnimations;
Map * map;
int curWave;
int missingAliens;

View File

@@ -1,18 +0,0 @@
#include "graphicsalien.h"
GraphicsAlien::GraphicsAlien(QGraphicsItem *grItem) : QGraphicsItem(grItem)
{
}
QRectF GraphicsAlien::boundingRect()
{
return QRectF(0,0,10,10);
}
void GraphicsAlien::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
}

View File

@@ -1,14 +0,0 @@
#ifndef GRAPHICSALIEN_H
#define GRAPHICSALIEN_H
#include <QGraphicsItem>
class GraphicsAlien : public QGraphicsItem
{
public:
GraphicsAlien(QGraphicsItem * grItem= 0);
QRectF boundingRect();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
};
#endif // GRAPHICSALIEN_H

View File

@@ -21,6 +21,7 @@ void Loader::load(QString filename)
file->close();
qFatal("Error parsing data.xml");
}
readAnimations();
readAliens();
readMaps();
readLevels();
@@ -206,6 +207,7 @@ void Loader::save(QString filename)
{
case srcTriggerType::onTimer :
elem.setAttribute("type","onTimer");
elem.setAttribute("timer",trig.timer);
break;
case srcTriggerType::onDestination :
elem.setAttribute("type","onDestination");
@@ -238,6 +240,16 @@ void Loader::save(QString filename)
elem.setAttribute("level",tol.levelId);
elem.setAttribute("tower",tol.towerId);
}
child = data.createElement("animations");
root.appendChild(child);
for (int i=0; i<animations.size(); i++)
{
tbAnimation ta = animations.values().at(i);
elem = data.createElement("animation");
child.appendChild(elem);
elem.setAttribute("id",ta.id);
elem.setAttribute("pathes",ta.pathes.join(";"));
}
cfile.write(data.toByteArray());
cfile.close();
//qDebug() << data.toByteArray();
@@ -268,6 +280,7 @@ Game_Data * Loader::loadlevel(int id)
tbWavePart tbwpt;
QList <tbWavePart> wplist;
QList <int> alienIds;
QList <int> animIds;
for (int i=0; i<wollist.size(); ++i)
{
WaveType wt;
@@ -304,7 +317,9 @@ Game_Data * Loader::loadlevel(int id)
tbAlien tbal = aliens.value(alienIds.at(i));
salt.armor = tbal.armor;
salt.health = tbal.health;
salt.imgType = tbal.imgType;
if (!animIds.contains(tbal.imgType))
animIds.append(tbal.imgType);
salt.imgType = animIds.indexOf(tbal.imgType);
salt.isFlying = tbal.isFlying;
salt.name = tbal.name;
salt.prise = tbal.prise;
@@ -325,7 +340,9 @@ Game_Data * Loader::loadlevel(int id)
stt.expByDamage = tbt.expByDamage;
stt.expByKill = tbt.expByKill;
stt.expByShot = tbt.expByShot;
stt.imgType = tbt.imgType;
if (!animIds.contains(tbt.imgType))
animIds.append(tbt.imgType);
stt.imgType = animIds.indexOf(tbt.imgType);
stt.name = tbt.name;
stt.radius = tbt.radius;
stt.reload = tbt.reload;
@@ -334,22 +351,35 @@ Game_Data * Loader::loadlevel(int id)
tbSplash tbs = splashes.value(tbt.splashId);
srcSplashType sst;
sst.autoControl = tbs.autoControl;
sst.imgType = tbs.imgType;
if (!animIds.contains(tbs.imgType))
animIds.append(tbs.imgType);
sst.imgType = animIds.indexOf(tbs.imgType);
sst.lifetime = tbs.lifetime;
sst.name = tbs.name;
sst.speed = tbs.speed;
stt.splashes.append(sst);
int recursiveCheck = 1;
fillTowerChains(&chlist,&trigIds,&stt,tbt.splashId,0,&recursiveCheck);
fillTowerChains(&animIds,&chlist,&trigIds,&stt,
tbt.splashId,0,&recursiveCheck);
for (int k=0; k<map->maxPlayers(); ++k)
gd->players[k]->srcTowers.append(stt);
qDebug() << tr("Tower %1 trig=%2 splash=%3").arg(stt.name).arg(stt.triggers.size()).arg(stt.splashes.size()) << tr("chain lenght %1").arg(recursiveCheck);
}
for (int i=0; i<animIds.size(); i++)
{
AnimationType anim;
for (int k=0; k<animations.value(animIds.at(i)).pathes.size(); k++)
anim.images.append(new QImage(animations.value(animIds.at(i))
.pathes.at(k)));
gd->curAnimations.append(anim);
}
return gd;
}
void Loader::fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, srcTowerType * stt, int parId, int parIndex, int * recursiveCheck)
void Loader::fillTowerChains(QList <int> * animIds, QList <tbChain> * chlist,
QList <int> * trigIds, srcTowerType * stt,
int parId, int parIndex, int * recursiveCheck)
{
if (*recursiveCheck > 100)
{
@@ -385,14 +415,16 @@ void Loader::fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, sr
tbSplash tbs = splashes.value(chlist->at(i).childSplashId);
srcSplashType sst;
sst.autoControl = tbs.autoControl;
sst.imgType = tbs.imgType;
if (!animIds->contains(tbs.imgType))
animIds->append(tbs.imgType);
sst.imgType = animIds->indexOf(tbs.imgType);
sst.lifetime = tbs.lifetime;
sst.name = tbs.name;
sst.speed = tbs.speed;
stt->splashes.append(sst);
stt->triggers[stt->splashes.at(parIndex).triggerIndexes.size()-1].childId = stt->splashes.size() - 1;
*recursiveCheck += 1;
fillTowerChains(chlist,trigIds,stt,chlist->at(i).childSplashId, stt->splashes.size()-1,recursiveCheck);
fillTowerChains(animIds,chlist,trigIds,stt,chlist->at(i).childSplashId, stt->splashes.size()-1,recursiveCheck);
}
}
}
@@ -441,21 +473,30 @@ void Loader::readAliens()
QDomNodeList alelems = doc->elementsByTagName("alien");
for (int i=0; i<alelems.size(); i++)
{
bool OK = true;
tbAlien al;
QDomNamedNodeMap nm = alelems.at(i).attributes();
al.id = nm.namedItem("id").nodeValue().toInt();
if (aliens.contains(al.id)) qCritical("Same alien ID dedected, replacing...");
if (aliens.contains(al.id)) qCritical("Same alien ID detected, replacing...");
al.name = nm.namedItem("name").nodeValue();
al.speed = nm.namedItem("speed").nodeValue().toFloat();
al.health = nm.namedItem("health").nodeValue().toFloat();
al.prise = nm.namedItem("prise").nodeValue().toInt();
al.armor = nm.namedItem("armor").nodeValue().toFloat();
al.imgType = nm.namedItem("imageType").nodeValue().toInt();
if (!animations.contains(al.imgType))
{
qCritical("Invalid animation Id");
OK = false;
}
al.regeneration = nm.namedItem("regeneration").nodeValue().toFloat();
al.score = nm.namedItem("score").nodeValue().toInt();
al.isFlying = (nm.namedItem("flying").nodeValue() == "true");
aliens.insert(al.id,al);
//qDebug() << tr("Alien %1 id=%2 health=%3 speed=%4 prise=%5 imgType=%6 armor=%7 regeneration=%8 score=%10").arg(al.name).arg(al.id).arg(al.health).arg(al.speed).arg(al.prise).arg(al.imgType).arg(al.armor).arg(al.regeneration).arg(al.score);
if (OK)
{
aliens.insert(al.id,al);
//qDebug() << tr("Alien %1 id=%2 health=%3 speed=%4 prise=%5 imgType=%6 armor=%7 regeneration=%8 score=%10").arg(al.name).arg(al.id).arg(al.health).arg(al.speed).arg(al.prise).arg(al.imgType).arg(al.armor).arg(al.regeneration).arg(al.score);
}
}
//qDebug("================");
qDebug() << tr("Found %1 aliens").arg(aliens.size());
@@ -472,7 +513,7 @@ void Loader::readWaves()
tbWave w;
QDomNamedNodeMap nm = welems.at(i).attributes();
w.id = nm.namedItem("id").nodeValue().toInt();
if (waves.contains(w.id)) qCritical("Same wave ID dedected, replacing...");
if (waves.contains(w.id)) qCritical("Same wave ID detected, replacing...");
w.prise = nm.namedItem("prise").nodeValue().toInt();
w.timeout = nm.namedItem("timeout").nodeValue().toInt();
waves.insert(w.id,w);
@@ -643,7 +684,7 @@ void Loader::readLevels()
QDomNamedNodeMap nm = lelems.at(i).attributes();
l.id = nm.namedItem("id").nodeValue().toInt();
l.name = nm.namedItem("name").nodeValue();
if (levels.contains(l.id)) qCritical("Same wave ID dedected, replacing...");
if (levels.contains(l.id)) qCritical("Same wave ID detected, replacing...");
l.mapId = nm.namedItem("map").nodeValue().toInt();
if (!maps.contains(l.mapId))
{
@@ -672,7 +713,7 @@ void Loader::readTriggers()
tbTrigger trig;
QDomNamedNodeMap nm = trelems.at(i).attributes();
trig.id = nm.namedItem("id").nodeValue().toInt();
if (triggers.contains(trig.id)) qCritical("Same splash ID dedected, replacing...");
if (triggers.contains(trig.id)) qCritical("Same splash ID detected, replacing...");
trig.name = nm.namedItem("name").nodeValue();
trig.damage = nm.namedItem("damage").nodeValue().toFloat();
trig.radius = nm.namedItem("radius").nodeValue().toFloat();
@@ -715,18 +756,27 @@ void Loader::readSplashes()
QDomNodeList selems = doc->elementsByTagName("splash");
for (int i=0; i<selems.size(); i++)
{
bool OK = true;
tbSplash s;
QDomNamedNodeMap nm = selems.at(i).attributes();
s.id = nm.namedItem("id").nodeValue().toInt();
if (splashes.contains(s.id)) qCritical("Same splash ID dedected, replacing...");
if (splashes.contains(s.id)) qCritical("Same splash ID detected, replacing...");
s.name = nm.namedItem("name").nodeValue();
s.speed = nm.namedItem("speed").nodeValue().toFloat();
s.lifetime = nm.namedItem("lifetime").nodeValue().toInt();
s.imgType = nm.namedItem("imageType").nodeValue().toInt();
if (!animations.contains(s.imgType))
{
qCritical("Invalid animation ID");
OK = false;
}
str = nm.namedItem("autoControl").nodeValue();
s.autoControl = (str == "true");
splashes.insert(s.id,s);
//qDebug() << tr("Splash %1 id=%2 speed=%3 imgType=%4 autoControl=%5 lifetime=%6").arg(s.name).arg(s.id).arg(s.speed).arg(s.imgType).arg(s.autoControl).arg(s.lifetime);
if (OK)
{
splashes.insert(s.id,s);
//qDebug() << tr("Splash %1 id=%2 speed=%3 imgType=%4 autoControl=%5 lifetime=%6").arg(s.name).arg(s.id).arg(s.speed).arg(s.imgType).arg(s.autoControl).arg(s.lifetime);
}
}
//qDebug("================");
qDebug() << tr("Found %1 splashes").arg(splashes.size());
@@ -734,6 +784,24 @@ void Loader::readSplashes()
}
void Loader::readAnimations()
{
animations.clear();
QDomNodeList animelems = doc->elementsByTagName("animation");
for (int i=0; i<animelems.size(); i++)
{
tbAnimation anim;
QDomNamedNodeMap nm = animelems.at(i).attributes();
anim.id = nm.namedItem("id").nodeValue().toInt();
if (animations.contains(anim.id)) qCritical("Same animation ID detected, replacing...");
anim.pathes = nm.namedItem("pathes").nodeValue().split(";");
animations.insert(anim.id,anim);
qDebug() << tr("animation id=%1 pathes=%2").arg(anim.id).arg(anim.pathes.join(";"));
}
qDebug() << tr("Found %1 animations").arg(animations.size());
}
void Loader::readTowers()
{
towers.clear();
@@ -744,13 +812,18 @@ void Loader::readTowers()
tbTower tw;
QDomNamedNodeMap nm = twelems.at(i).attributes();
tw.id = nm.namedItem("id").nodeValue().toInt();
if (towers.contains(tw.id)) qCritical("Same tower ID dedected, replacing...");
if (towers.contains(tw.id)) qCritical("Same tower ID detected, replacing...");
tw.name = nm.namedItem("name").nodeValue();
tw.radius = nm.namedItem("radius").nodeValue().toFloat();
tw.expByDamage = nm.namedItem("expByDamage").nodeValue().toFloat();
tw.expByKill = nm.namedItem("expByKill").nodeValue().toFloat();
tw.expByShot = nm.namedItem("expByShot").nodeValue().toFloat();
tw.imgType = nm.namedItem("imageType").nodeValue().toInt();
if (!animations.contains(tw.imgType))
{
qCritical("Invalid animation ID");
OK = false;
}
tw.reload = nm.namedItem("reload").nodeValue().toInt();
tw.cost = nm.namedItem("cost").nodeValue().toInt();
tw.buildTime = nm.namedItem("buildTime").nodeValue().toInt();
@@ -782,7 +855,7 @@ void Loader::readMaps()
tbMap m;
QDomNamedNodeMap mn = melems.at(i).attributes();
m.id = mn.namedItem("id").nodeValue().toInt();
if (maps.contains(m.id)) qCritical("Same map ID dedected, replacing...");
if (maps.contains(m.id)) qCritical("Same map ID detected, replacing...");
m.name = mn.namedItem("name").nodeValue();
m.imgType = mn.namedItem("imageType").nodeValue().toInt();
m.maxPlayers = mn.namedItem("maxPlayers").nodeValue().toInt();

View File

@@ -130,6 +130,12 @@ struct tbLevel : tbHeader
unsigned int score;
};
struct tbAnimation
{
int id;
QStringList pathes;
};
class Loader : public QObject
{
@@ -148,6 +154,7 @@ public:
QHash <int,tbTower> towers;
QHash <int,tbTrigger> triggers;
QHash <int,tbWave> waves;
QHash <int,tbAnimation> animations;
QMultiHash <int,tbWaveOnLevel> levWaves;
QMultiHash <int,tbWavePart> waveParts;
QMultiHash <int,tbChain> chains;
@@ -176,8 +183,9 @@ private:
void readLevWaves();
void readWaveParts();
void readUpgrades();
void readAnimations();
void fillTowerChains(QList <tbChain> * chlist, QList <int> * trigIds, srcTowerType * stt, int parId, int parIndex, int * recursiveCheck);
void fillTowerChains(QList <int> * animIds, QList <tbChain> * chlist, QList <int> * trigIds, srcTowerType * stt, int parId, int parIndex, int * recursiveCheck);
void validate(QString filename);
QString createMapExample();
};

View File

@@ -81,6 +81,13 @@
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="animations">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="animation" type="animationType" maxOccurs="unbounded" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
@@ -217,5 +224,10 @@
<xsd:attribute name="score" type="xsd:positiveInteger" use="required"/>
</xsd:complexType>
<xsd:complexType name="animationType">
<xsd:attribute name="id" type="xsd:positiveInteger" use="required"/>
<xsd:attribute name="pathes" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:schema>

View File

@@ -27,6 +27,7 @@ void Splashes::addSplash(int player, int srcTower, int srcId, QPointF pos, QPoin
}
spl.angle = 180.0f*(- std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()))/M_PI;
spl.imgType = src.imgType;
spl.animIndex = 0;
spl.life = 0;
spl.src = srcId;
srcTriggerType trig;

View File

@@ -28,6 +28,7 @@ bool Towers::addTower(int playerId, int srcId, QPoint pos)
TowerType tw;
tw.src = srcId;
tw.imgType = gameData->players.at(playerId)->srcTowers.at(srcId).imgType;
tw.animIndex = 0;
tw.PlayerId = playerId;
tw.angle = 0;
tw.build = 0;