fix bugs in wavetracewhen building towers

fix some bugs in ADeditor
This commit is contained in:
2010-09-01 21:50:30 +04:00
parent 3316f3f48f
commit 7752f7be12
12 changed files with 605 additions and 296 deletions

Binary file not shown.

View File

@@ -1,111 +1,241 @@
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<qtcreator> <qtcreator>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>RunConfiguration0-BaseEnvironmentBase</variable>
<value type="int">2</value>
</data>
<data>
<variable>RunConfiguration0-CommandLineArguments</variable>
<valuelist type="QVariantList"/>
</data>
<data>
<variable>RunConfiguration0-ProFile</variable>
<value type="QString">ADeditor.pro</value>
</data>
<data>
<variable>RunConfiguration0-RunConfiguration.name</variable>
<value type="QString">ADeditor</value>
</data>
<data>
<variable>RunConfiguration0-UseDyldImageSuffix</variable>
<value type="bool">false</value>
</data>
<data>
<variable>RunConfiguration0-UseTerminal</variable>
<value type="bool">false</value>
</data>
<data>
<variable>RunConfiguration0-UserEnvironmentChanges</variable>
<valuelist type="QVariantList"/>
</data>
<data>
<variable>RunConfiguration0-UserSetName</variable>
<value type="bool">false</value>
</data>
<data>
<variable>RunConfiguration0-UserSetWorkingDirectory</variable>
<value type="bool">true</value>
</data>
<data>
<variable>RunConfiguration0-UserWorkingDirectory</variable>
<value type="QString">/home/andrey/AD/aliendefender</value>
</data>
<data>
<variable>RunConfiguration0-type</variable>
<value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
</data>
<data>
<variable>activeRunConfiguration</variable>
<value type="int">0</value> <value type="int">0</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.EditorSettings</variable> <variable>activebuildconfiguration</variable>
<value type="QString">Debug</value>
</data>
<data>
<variable>buildConfiguration-Debug</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value key="EditorConfiguration.Codec" type="QByteArray">System</value> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<value key="QtVersionId" type="int">0</value>
<value key="ToolChain" type="int">0</value>
<value key="buildConfiguration" type="int">2</value>
</valuemap> </valuemap>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.Target.0</variable> <variable>buildConfiguration-Release</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Настольный компьютер</value> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value> <value key="QtVersionId" type="int">0</value>
<value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">1</value> <value key="buildConfiguration" type="int">0</value>
<value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
<valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
<valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
</valuemap>
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
<value type="QString">clean</value>
</valuelist>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/build-ADeditor</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">9</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
</valuemap>
<valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
<valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
</valuemap>
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
<valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
<value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
<valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
<value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
</valuemap>
<value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
<value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
<valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Release</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Users/Andrey/Desktop/build-AD</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">9</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
</valuemap>
<value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
<valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">ADeditor</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
<value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">ADeditor.pro</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">true</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString">C:\Users\Andrey\Desktop\aliendefender</value>
</valuemap>
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
</valuemap> </valuemap>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.TargetCount</variable> <variable>buildconfiguration-Debug-buildstep0</variable>
<value type="int">1</value> <valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=gnome</value>
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/andrey</value>
<value type="QString">LANG=ru_RU.UTF-8</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
<value type="QString">LOGNAME=andrey</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/andrey</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=6561</value>
<value type="QString">SSH_AGENT_PID=1239</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh</value>
<value type="QString">USER=andrey</value>
<value type="QString">USERNAME=andrey</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279</value>
</valuelist>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">/home/andrey/AD/aliendefender/ADeditor/ADeditor.pro</value>
<value type="QString">-spec</value>
<value type="QString">linux-g++</value>
<value type="QString">-r</value>
<value type="QString">CONFIG+=debug</value>
</valuelist>
<value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value>
<value key="abstractProcess.enabled" type="bool">false</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender/ADeditor</value>
</valuemap>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable> <variable>buildconfiguration-Debug-buildstep1</variable>
<value type="int">4</value> <valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wExeabp7q4,guid=18815993df3603fdc64a3f6d4c7b5822</value>
<value type="QString">DEFAULTS_PATH=/usr/share/gconf/gnome.default.path</value>
<value type="QString">DESKTOP_SESSION=gnome</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">GDMSESSION=gnome</value>
<value type="QString">GDM_KEYBOARD_LAYOUT=us</value>
<value type="QString">GDM_LANG=ru_RU.UTF-8</value>
<value type="QString">GNOME_DESKTOP_SESSION_ID=this-is-deprecated</value>
<value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-4vN5uf</value>
<value type="QString">GTK_MODULES=canberra-gtk-module</value>
<value type="QString">HOME=/home/andrey</value>
<value type="QString">LANG=ru_RU.UTF-8</value>
<value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator:</value>
<value type="QString">LOGNAME=andrey</value>
<value type="QString">MANDATORY_PATH=/usr/share/gconf/gnome.mandatory.path</value>
<value type="QString">ORBIT_SOCKETDIR=/tmp/orbit-andrey</value>
<value type="QString">PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games</value>
<value type="QString">PWD=/home/andrey</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">SESSION_MANAGER=local/buull-eeePC:@/tmp/.ICE-unix/1205,unix/buull-eeePC:/tmp/.ICE-unix/1205</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SPEECHD_PORT=6561</value>
<value type="QString">SSH_AGENT_PID=1239</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/keyring-4vN5uf/ssh</value>
<value type="QString">USER=andrey</value>
<value type="QString">USERNAME=andrey</value>
<value type="QString">XAUTHORITY=/var/run/gdm/auth-for-andrey-x9URui/database</value>
<value type="QString">XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg</value>
<value type="QString">XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/</value>
<value type="QString">XDG_SESSION_COOKIE=f0649decca52f2beb55c9ea74ad1d028-1283151906.338331-318132279</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<value type="QString">-w</value>
</valuelist>
<value key="abstractProcess.command" type="QString">/usr/bin/make</value>
<value key="abstractProcess.enabled" type="bool">true</value>
<value key="abstractProcess.workingDirectory" type="QString">/home/andrey/AD/aliendefender/ADeditor</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Debug-cleanstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<value key="cleanConfig" type="bool">true</value>
<valuelist key="makeargs" type="QVariantList">
<value type="QString">clean</value>
</valuelist>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-buildstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-buildstep1</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
</valuemap>
</data>
<data>
<variable>buildconfiguration-Release-cleanstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
</valuemap>
</data>
<data>
<variable>buildconfigurations</variable>
<valuelist type="QVariantList">
<value type="QString">Debug</value>
<value type="QString">Release</value>
</valuelist>
</data>
<data>
<variable>buildstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
<value key="mkspec" type="QString"></value>
</valuemap>
</data>
<data>
<variable>buildstep1</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
</valuemap>
</data>
<data>
<variable>buildsteps</variable>
<valuelist type="QVariantList">
<value type="QString">trolltech.qt4projectmanager.qmake</value>
<value type="QString">trolltech.qt4projectmanager.make</value>
</valuelist>
</data>
<data>
<variable>cleanstep0</variable>
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value>
<value key="clean" type="bool">true</value>
</valuemap>
</data>
<data>
<variable>cleansteps</variable>
<valuelist type="QVariantList">
<value type="QString">trolltech.qt4projectmanager.make</value>
</valuelist>
</data>
<data>
<variable>defaultFileEncoding</variable>
<value type="QByteArray">System</value>
</data>
<data>
<variable>project</variable>
<valuemap type="QVariantMap"/>
</data> </data>
</qtcreator> </qtcreator>

View File

@@ -218,6 +218,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
switch (ret) switch (ret)
{ {
case QMessageBox::Save : case QMessageBox::Save :
adloader->save("data2.xml");
adloader->load("data2.xml");
adloader->save("data2.xml"); adloader->save("data2.xml");
event->accept(); event->accept();
break; break;
@@ -364,6 +366,17 @@ void MainWindow::on_pbAlDel_clicked()
if (adloader->aliens.size() < 2) return; if (adloader->aliens.size() < 2) return;
QMessageBox msgBox; QMessageBox msgBox;
int id = adloader->aliens.keys().at(ui->lvAliens->currentIndex().row()); int id = adloader->aliens.keys().at(ui->lvAliens->currentIndex().row());
for (int i=0; i<adloader->waveParts.size(); i++)
{
if (adloader->waveParts.values().at(i).alienId == id)
{
msgBox.setText(tr("You can not delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id));
msgBox.setInformativeText(tr("It used in wawe %1").arg(adloader->waveParts.values().at(i).waveId));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
return;
}
}
msgBox.setText(tr("Delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id)); msgBox.setText(tr("Delete alien %1 id=%2").arg(adloader->aliens.value(id).name).arg(id));
msgBox.setInformativeText(tr("Are you sure?")); msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
@@ -514,6 +527,17 @@ void MainWindow::on_pbTwDel_clicked()
if (adloader->towers.size() < 2) return; if (adloader->towers.size() < 2) return;
QMessageBox msgBox; QMessageBox msgBox;
int id = adloader->towers.keys().at(ui->lvTowers->currentIndex().row()); int id = adloader->towers.keys().at(ui->lvTowers->currentIndex().row());
for (int i=0; i<adloader->levTowers.size(); i++)
{
if (adloader->levTowers.values().at(i).towerId == id)
{
msgBox.setText(tr("You can not delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id));
msgBox.setInformativeText(tr("It used in level %1").arg(adloader->levTowers.values().at(i).levelId));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
return;
}
}
msgBox.setText(tr("Delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id)); msgBox.setText(tr("Delete tower %1 id=%2").arg(adloader->towers.value(id).name).arg(id));
msgBox.setInformativeText(tr("Are you sure?")); msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
@@ -585,6 +609,7 @@ void MainWindow::on_pbSplAdd_clicked()
} }
void MainWindow::on_pbSlpDel_clicked() void MainWindow::on_pbSlpDel_clicked()
{ {
if (adloader->splashes.size() < 2) return; if (adloader->splashes.size() < 2) return;
@@ -595,7 +620,19 @@ void MainWindow::on_pbSlpDel_clicked()
if (adloader->towers.values().at(i).splashId == id) if (adloader->towers.values().at(i).splashId == id)
{ {
msgBox.setText(tr("You can not delete splash %1 id=%2").arg(adloader->splashes.value(id).name).arg(id)); msgBox.setText(tr("You can not delete splash %1 id=%2").arg(adloader->splashes.value(id).name).arg(id));
msgBox.setInformativeText(tr("It used by tower %1").arg(adloader->towers.values().at(i).name)); msgBox.setInformativeText(tr("It used by tower %1 id=%2").arg(adloader->towers.values().at(i).name).arg(adloader->towers.values().at(i).id));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
return;
}
}
for (int i=0; i<adloader->chains.size(); i++)
{
if (adloader->chains.values().at(i).childSplashId == id
|| adloader->chains.values().at(i).parentSplashId == id)
{
msgBox.setText(tr("You can not delete splash %1 id=%2").arg(adloader->splashes.value(id).name).arg(id));
msgBox.setInformativeText(tr("It used by chain in tower %1 id=%2").arg(adloader->towers.value(adloader->chains.values().at(i).towerId).name).arg(adloader->chains.values().at(i).towerId));
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec(); msgBox.exec();
return; return;
@@ -774,6 +811,17 @@ void MainWindow::on_pbTrigDel_clicked()
if (adloader->triggers.size() < 2) return; if (adloader->triggers.size() < 2) return;
QMessageBox msgBox; QMessageBox msgBox;
int id = adloader->triggers.keys().at(ui->lvTriggers->currentIndex().row()); int id = adloader->triggers.keys().at(ui->lvTriggers->currentIndex().row());
for (int i=0; i<adloader->chains.size(); i++)
{
if (adloader->chains.values().at(i).triggerId == id)
{
msgBox.setText(tr("You can not delete trigger %1 id=%2").arg(adloader->triggers.value(id).name).arg(id));
msgBox.setInformativeText(tr("It used by chain in tower %1 id=%2").arg(adloader->towers.value(adloader->chains.values().at(i).towerId).name).arg(adloader->chains.values().at(i).towerId));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
return;
}
}
msgBox.setText(tr("Delete trigger %1 id=%2").arg(adloader->triggers.value(id).name).arg(id)); msgBox.setText(tr("Delete trigger %1 id=%2").arg(adloader->triggers.value(id).name).arg(id));
msgBox.setInformativeText(tr("Are you sure?")); msgBox.setInformativeText(tr("Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);

View File

@@ -24,10 +24,24 @@
<property name="spacing"> <property name="spacing">
<number>2</number> <number>2</number>
</property> </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">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>4</number>
</property> </property>
<widget class="QWidget" name="tabAliens"> <widget class="QWidget" name="tabAliens">
<attribute name="title"> <attribute name="title">
@@ -709,7 +723,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_33" stretch="10,4,0,1"> <layout class="QHBoxLayout" name="horizontalLayout_33" stretch="10,1,0">
<item> <item>
<widget class="QLabel" name="label_25"> <widget class="QLabel" name="label_25">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -726,35 +740,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QGraphicsView" name="TwImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="pushButton_5"> <widget class="QPushButton" name="pushButton_5">
<property name="enabled"> <property name="enabled">
@@ -777,6 +762,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_6">
<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> </layout>
</item> </item>
<item> <item>
@@ -915,6 +913,9 @@
</item> </item>
<item> <item>
<widget class="QDoubleSpinBox" name="sbSplSpeed"> <widget class="QDoubleSpinBox" name="sbSplSpeed">
<property name="accelerated">
<bool>true</bool>
</property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
</property> </property>
@@ -1001,7 +1002,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_46" stretch="10,4,0,1"> <layout class="QHBoxLayout" name="horizontalLayout_46" stretch="10,1,0">
<item> <item>
<widget class="QLabel" name="label_41"> <widget class="QLabel" name="label_41">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -1018,35 +1019,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QGraphicsView" name="SplImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="pushButton_7"> <widget class="QPushButton" name="pushButton_7">
<property name="enabled"> <property name="enabled">
@@ -1069,6 +1041,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_8">
<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> </layout>
</item> </item>
<item> <item>
@@ -1342,6 +1327,9 @@
</item> </item>
<item> <item>
<widget class="QSpinBox" name="sbTrigTimer"> <widget class="QSpinBox" name="sbTrigTimer">
<property name="accelerated">
<bool>true</bool>
</property>
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
</property> </property>
@@ -1466,20 +1454,192 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> <widget class="QWidget" name="tabMaps">
</item> <attribute name="title">
<item row="5" column="0"> <string>Maps</string>
<widget class="QPushButton" name="pbSave"> </attribute>
<property name="text"> <layout class="QGridLayout" name="gridLayout_6" columnstretch="1,2">
<string>Save</string> <item row="0" column="0">
</property> <widget class="QListView" name="lvMaps"/>
</widget> </item>
</item> <item row="0" column="1" rowspan="2">
<item row="4" column="0"> <widget class="QFrame" name="frame_4">
<widget class="QPushButton" name="pbReload"> <property name="frameShape">
<property name="text"> <enum>QFrame::StyledPanel</enum>
<string>Cancel</string> </property>
</property> <property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGraphicsView" name="gvMap">
<property name="backgroundBrush">
<brush brushstyle="Dense6Pattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="dragMode">
<enum>QGraphicsView::ScrollHandDrag</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leMapName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbMapWid">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbMapHei">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>MaxPlayers</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbMapPlayers">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pbMapEdit">
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_17" stretch="2,1">
<property name="spacing">
<number>20</number>
</property>
<item>
<widget class="QPushButton" name="pbTrigAdd_2">
<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="pbTrigDel_2">
<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> </widget>
</item> </item>
</layout> </layout>
@@ -1489,4 +1649,3 @@
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@@ -39,10 +39,10 @@ AD_Graphics::AD_Graphics(AD_Core *adcore, QWidget *parent) : QGraphicsView(paren
// pen.setColor(Qt::yellow); // pen.setColor(Qt::yellow);
// brush.setColor(Qt::yellow); // brush.setColor(Qt::yellow);
// } // }
if (cel >= Map::Player || (cel <= Map::PlayerTower && cel !=Map::Wall)) if (cel >= Map::Free || (cel <= Map::PlayerTower && cel !=Map::Wall))
{ {
pen.setColor(QColor(qAbs(cel)*345%255,(qAbs(cel)*721)%255,(qAbs(cel)*75)%255,50)); pen.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
brush.setColor(QColor(qAbs(cel)*345%255,(qAbs(cel)*721)%255,(qAbs(cel)*75)%255,50)); brush.setColor(QColor(qAbs(cel+2)*345%255,(qAbs(cel+2)*721)%255,(qAbs(cel+2)*75)%255,50));
} }
p.setPen(pen); p.setPen(pen);
p.setBrush(brush); p.setBrush(brush);
@@ -89,6 +89,38 @@ void AD_Graphics::timerEvent(QTimerEvent * )
void AD_Graphics::drawBackground(QPainter * p, const QRectF & ) void AD_Graphics::drawBackground(QPainter * p, const QRectF & )
{ {
p->drawImage(0,0,*mapimg); p->drawImage(0,0,*mapimg);
// for (int i=0; i<data->map->cells().size(); i++) {
// for (int j=0; j<data->map->cells().at(i).size(); j++) {
// QPen pen;
// QBrush brush;
// pen.setColor(Qt::white);
// brush.setColor(Qt::white);
// brush.setStyle(Qt::SolidPattern);
// int cel = data->map->cells().at(i).at(j);
// if (cel == Map::Wall)
// {
// pen.setColor(Qt::black);
// brush.setColor(Qt::black);
// }
// // if (cel <= Map::PlayerTower && cel !=Map::Wall) {
// // pen.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
// // brush.setColor(QColor(cel%255,(cel*100)%255,(cel+100)%255));
// // }
// // if (cel >= Map::PlayerAlien) {
// // pen.setColor(Qt::yellow);
// // brush.setColor(Qt::yellow);
// // }
// 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));
// }
// p->setPen(pen);
// p->setBrush(brush);
// p->drawRect(i*cellSize,j*cellSize,cellSize,cellSize);
// }
// }
//qDebug() << "t:" << data->curTowers.size(); //qDebug() << "t:" << data->curTowers.size();
for (QHash<QPoint, TowerType>::iterator i = data->curTowers.begin(); i != data->curTowers.end(); ++i) for (QHash<QPoint, TowerType>::iterator i = data->curTowers.begin(); i != data->curTowers.end(); ++i)
{ {

View File

@@ -24,7 +24,7 @@ AD_Core::AD_Core(QObject *parent) :
// adaliens->addAlien(0); // adaliens->addAlien(0);
// adaliens->AddAlien(0); // adaliens->AddAlien(0);
// adaliens->AddAlien(0); // adaliens->AddAlien(0);
adtowers->addTower(0,2,QPoint(15,1)); //adtowers->addTower(0,2,QPoint(15,1));
for (int i=0; i<20;i++) for (int i=0; i<20;i++)
// adtowers->addTower(0,1,QPoint(8,20-i)); // adtowers->addTower(0,1,QPoint(8,20-i));
// for (int i=0; i<20; i++) // for (int i=0; i<20; i++)

View File

@@ -58,6 +58,7 @@
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<value key="QtVersionId" type="int">0</value> <value key="QtVersionId" type="int">0</value>
<value key="ToolChain" type="int">0</value> <value key="ToolChain" type="int">0</value>
<value key="addQDumper" type=""></value>
<value key="buildConfiguration" type="int">2</value> <value key="buildConfiguration" type="int">2</value>
</valuemap> </valuemap>
</data> </data>
@@ -66,6 +67,7 @@
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value>
<value key="QtVersionId" type="int">0</value> <value key="QtVersionId" type="int">0</value>
<value key="addQDumper" type=""></value>
<value key="buildConfiguration" type="int">0</value> <value key="buildConfiguration" type="int">0</value>
</valuemap> </valuemap>
</data> </data>

View File

@@ -5,7 +5,8 @@
<alien speed="0.05" imageType="-1078580008" prise="1" id="4" score="10" name="test" health="100"/> <alien speed="0.05" imageType="-1078580008" 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 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 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="MONSTR" health="888"/> </aliens> <alien speed="0.05" imageType="1" prise="10" id="33" score="99" name="Mega Alien" health="888"/>
</aliens>
<maps> <maps>
<map width="16" imageType="1" height="16" id="1" data="AAAERHicY2BgEGAA4v///0hQgmFmAGlGcjCxZuCTHzUDuxkMDOr85JrBwKC0A8kMJlwYagYOeYgZ+NXgNwMtPEbNINIMIsynOO8DAG0r1Q0=" name="My Map" maxPlayers="2"/> <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="30" imageType="2" height="20" id="2" data="AAAJ3HicY2BgkGNgYBD5//+PBDGYgUGdnzh1EDOBNCM1MKlmEqNu1MxRM0fNHNxmgsobapnJwKC0Yyj5fdTMUTNHzRzaZpJgLwltMKUdxKgDADpycNA=" name="map2" maxPlayers="1"/>
@@ -24,7 +25,7 @@
<wave prise="220" timeout="5" id="11"/> <wave prise="220" timeout="5" id="11"/>
</waves> </waves>
<levels> <levels>
<level map="2" id="1" score="258217400" name="First Level"/> <level map="2" id="1" score="170015360" name="First Level"/>
</levels> </levels>
<waveParts> <waveParts>
<wavePart alien="10" count="10" wave="1"/> <wavePart alien="10" count="10" wave="1"/>
@@ -66,9 +67,10 @@
<splashes> <splashes>
<splash speed="0.2" imageType="0" lifetime="9999" id="1" name="rocket"/> <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.2" imageType="0" lifetime="9999" autoControl="true" id="2" name="smart rocket"/>
<splash speed="1" imageType="1" lifetime="9999" autoControl="true" id="3" name="bullet"/> <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="3" lifetime="5" id="4" name="bum"/>
<splash speed="0" imageType="2" lifetime="3" id="5" name="smoke"/> <splash speed="0" imageType="2" lifetime="3" id="5" name="smoke"/>
<splash speed="0.1" imageType="-1074795776" lifetime="50" autoControl="true" id="6" name="Снаряд"/>
</splashes> </splashes>
<towers> <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="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"/>

View File

@@ -91,10 +91,10 @@ void Map::delTowerOnMap(int playerId, QPoint pos)
bool Map::isReachable(int playerId, QPoint pos) bool Map::isReachable(int playerId, QPoint pos)
{ {
Cells[pos.x()][pos.y()]=PlayerTower-playerId; Cells[pos.x()][pos.y()]=PlayerTower-Player-playerId;
Cells[pos.x()+1][pos.y()]=PlayerTower-playerId; Cells[pos.x()+1][pos.y()]=PlayerTower-Player-playerId;
Cells[pos.x()][pos.y()+1]=PlayerTower-playerId; Cells[pos.x()][pos.y()+1]=PlayerTower-Player-playerId;
Cells[pos.x()+1][pos.y()+1]=PlayerTower-playerId; Cells[pos.x()+1][pos.y()+1]=PlayerTower-Player-playerId;
for (int i=0; i<Starts.size(); i++) { for (int i=0; i<Starts.size(); i++) {
for (int j=0; j<Finishs.size(); j++) { for (int j=0; j<Finishs.size(); j++) {
if (waveTrace(Starts.at(i),Finishs.at(j))<0) { if (waveTrace(Starts.at(i),Finishs.at(j))<0) {

6
map.h
View File

@@ -12,9 +12,9 @@ public:
enum CellType enum CellType
{ {
Free = 0, Free = 0,
Player = 1, Player = 1, // use Player + playerId for multiplayer
AlienPath = 1000, AlienPath = 1000, // use AlienPath + Player and + playerId
PlayerTower = -1, PlayerTower = -1, // use PlayerTower - Player - playerId
Wall = -1000, Wall = -1000,
Start = 9999, Start = 9999,
Finish = 8888 Finish = 8888

View File

@@ -17,23 +17,18 @@ void Splashes::addSplash(int player, int srcTower, int srcId, QPointF pos, QPoin
spl.TowerId = curTower; spl.TowerId = curTower;
spl.srcTower = srcTower; spl.srcTower = srcTower;
spl.PlayerId = player; spl.PlayerId = player;
spl.AlienId = aim;
spl.pos = pos;
spl.destination = dest;
if (src.autoControl) if (src.autoControl)
{ {
spl.AlienId = aim;
if (gameData->curAliens.contains(aim)) if (gameData->curAliens.contains(aim))
spl.destination = gameData->curAliens.value(aim).pos+QPointF(0.5,0.5); spl.destination = gameData->curAliens.value(aim).pos+QPointF(0.5,0.5);
else
spl.destination = dest;
} else {
spl.AlienId = -1;
spl.destination = dest;
} }
spl.pos = pos;
spl.angle = 180.0f*(- std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()))/M_PI; 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.imgType = src.imgType;
spl.life = 0; spl.life = 0;
spl.src = srcId; spl.src = srcId;
//TriggerType trig;
srcTriggerType trig; srcTriggerType trig;
for(int i=0; i<src.triggerIndexes.size(); i++) for(int i=0; i<src.triggerIndexes.size(); i++)
{ {
@@ -59,7 +54,6 @@ void Splashes::addSplash(int player, int srcTower, int srcId, QPointF pos, QPoin
} }
} }
//qDebug() << "t=" << src.triggerIndexes.size() << "d=" << spl.trigsOnDest.size();
gameData->curSplashes.insert(spl.id,spl); gameData->curSplashes.insert(spl.id,spl);
nextId++; nextId++;
} }
@@ -72,55 +66,6 @@ void Splashes::addSplash(QPoint curTowerId)
TowerType tw = gameData->curTowers.value(curTowerId); TowerType tw = gameData->curTowers.value(curTowerId);
addSplash(tw.PlayerId,tw.src,0,QPointF(tw.pos+QPoint(1,1)),gameData->curAliens.value(tw.aim).pos+QPointF(0.5,0.5),tw.aim,tw.pos); addSplash(tw.PlayerId,tw.src,0,QPointF(tw.pos+QPoint(1,1)),gameData->curAliens.value(tw.aim).pos+QPointF(0.5,0.5),tw.aim,tw.pos);
} }
// TowerType tw = gameData->curTowers.value(curTowerId);
// srcSplashType src = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src).splashes.at(0);
// SplashType spl;
// spl.id = nextId;
// spl.TowerId = curTowerId;
// spl.srcTower = tw.src;
// spl.PlayerId = tw.PlayerId;
// if (!gameData->curAliens.contains(tw.aim))
// qFatal("Error finding splash aim! Tower has nvalid aim!");
// spl.destination = gameData->curAliens.value(tw.aim).pos;
// if (src.autoControl)
// spl.AlienId = tw.aim;
// else
// spl.AlienId = -1;
// spl.pos = tw.pos+QPointF(0.5,0.5); // FIXME: splash do not create in center or left-angle of tower, it must be in tower's side
// 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.life = 0;
// spl.src = 0;
// //TriggerType trig;
// for(int i=0; i<src.triggerIndexes.size(); i++)
// {
// srcTriggerType trig;
// TriggerOnDest tod;
// TriggerOnAlien toa;
// TriggerOnTimer tot;
// trig = gameData->players.at(tw.PlayerId)->srcTowers.at(tw.src).triggers.at(src.triggerIndexes.at(i));
// switch (trig.type)
// {
// case srcTriggerType::onDestination :
// tod.src = src.triggerIndexes.at(i);
// spl.trigsOnDest.append(tod);
// break;
// case srcTriggerType::onAlienInRadius :
// toa.src = src.triggerIndexes.at(i);
// spl.trigsOnAlien.append(toa);
// break;
// case srcTriggerType::onTimer :
// tot.src = src.triggerIndexes.at(i);
// tot.timer = trig.timer;
// spl.trigsOnTimer.append(tot);
// break;
// }
// }
// //qDebug() << "t=" << src.triggerIndexes.size() << "d=" << spl.trigsOnDest.size();
// gameData->curSplashes.insert(spl.id,spl);
// nextId++;
// }
} }
@@ -131,16 +76,12 @@ void Splashes::update()
{ {
float arctg,angl; float arctg,angl;
SplashType spl = gameData->curSplashes.values().at(i); SplashType spl = gameData->curSplashes.values().at(i);
//bool isTowerSplash = false;
srcSplashType src; srcSplashType src;
// FIXME : if splash is not tower's splash, will be some trouble // FIXME : if splash is not tower's splash, will be some trouble
src = gameData->players.at(spl.PlayerId)->srcTowers.at(spl.srcTower).splashes.at(spl.src); src = gameData->players.at(spl.PlayerId)->srcTowers.at(spl.srcTower).splashes.at(spl.src);
spl.life++; spl.life++;
if (spl.life > src.lifetime) if (spl.life > src.lifetime)
deadIndexes.append(spl.id); deadIndexes.append(spl.id);
//isTowerSplash = true;
//if (!isTowerSplash)
// src = gameData->srcSplashes.at(spl.src);
if (src.autoControl) if (src.autoControl)
{ {
bool badAl = false; bool badAl = false;
@@ -153,35 +94,9 @@ void Splashes::update()
if (badAl) if (badAl)
deadIndexes.push_back(spl.id); deadIndexes.push_back(spl.id);
spl.pos = spl.destination; spl.pos = spl.destination;
for (int k=0; k<spl.trigsOnDest.size(); k++) doTriggerOnDest(spl,&deadIndexes,badAl);
{
// TODO: activate trigger
srcTriggerType strig = gameData->players.at(spl.PlayerId)->srcTowers.at(spl.srcTower).triggers.at(spl.trigsOnDest.at(k).src);
if (strig.delParent) deadIndexes.push_back(spl.id);
if (strig.count > 0 && strig.childId > 0)
{
//qDebug("bvgbjdklbvfjldsk");
addSplash(spl.PlayerId,spl.srcTower,strig.childId,spl.pos,spl.destination,-1,spl.TowerId);
}
if (strig.damage > 0)
{
if (!(strig.radius > 0))
{
if (!badAl)
{
float hh = gameData->curAliens[spl.AlienId].health -= strig.damage;
if (hh < 0)
gameData->curAliens.remove(spl.AlienId);
//qDebug() << "health=" << hh;
}
} else {
processTrigger(strig,spl.pos);
}
}
}
} }
arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y()); arctg = std::atan2(spl.pos.x() - spl.destination.x(),spl.pos.y() - spl.destination.y());
//if (tmpdy < 0) arctg=arctg+M_PI;
angl = 180.0f*(-arctg)/M_PI; angl = 180.0f*(-arctg)/M_PI;
spl.angle = angl; spl.angle = angl;
spl.pos.setX(spl.pos.x() spl.pos.setX(spl.pos.x()
@@ -196,17 +111,7 @@ void Splashes::update()
if (distance2(spl.pos, spl.destination) < src.speed*src.speed) if (distance2(spl.pos, spl.destination) < src.speed*src.speed)
{ {
spl.pos = spl.destination; spl.pos = spl.destination;
for (int k=0; k<spl.trigsOnDest.size(); k++) doTriggerOnDest(spl,&deadIndexes,true);
{
srcTriggerType strig = gameData->players.at(spl.PlayerId)->srcTowers.at(spl.srcTower).triggers.at(spl.trigsOnDest.at(k).src);
if (strig.delParent) deadIndexes.push_back(spl.id);
processTrigger(strig,spl.pos);
if (strig.count > 0 && strig.childId > 0)
{
//qDebug("bvgbjdklbvfjldsk");
addSplash(spl.PlayerId,spl.srcTower,strig.childId,spl.pos,spl.destination,-1,spl.TowerId);
}
}
} }
} }
spl.pos.setX(spl.pos.x() spl.pos.setX(spl.pos.x()
@@ -215,7 +120,6 @@ void Splashes::update()
-src.speed*std::cos(-spl.angle*M_PI/180.f)); -src.speed*std::cos(-spl.angle*M_PI/180.f));
} }
// TODO: smooth splash rotate // TODO: smooth splash rotate
// TODO: activate trigger and more...
gameData->curSplashes.insert(spl.id,spl); gameData->curSplashes.insert(spl.id,spl);
} }
for (int j=0; j<deadIndexes.size(); j++) for (int j=0; j<deadIndexes.size(); j++)
@@ -229,19 +133,51 @@ void Splashes::delSplash(int Id)
} }
void Splashes::processTrigger(srcTriggerType srctrig, QPointF pos) void Splashes::doTriggerOnDest(const SplashType &spl, QList<int> *deadIndexes,
bool badAl)
{ {
//qDebug("trig proc"); for (int k=0; k<spl.trigsOnDest.size(); k++)
QList <int> dead;
for (QHash<int, AlienType>::iterator i = gameData->curAliens.begin(); i != gameData->curAliens.end(); ++i)
{ {
if (distance2(pos, (*i).pos) < srctrig.radius*srctrig.radius) // TODO: aims for childs
srcTriggerType strig = gameData->players.
at(spl.PlayerId)->srcTowers.
at(spl.srcTower).triggers.
at(spl.trigsOnDest.at(k).src);
if (strig.delParent) deadIndexes->append(spl.id);
if (strig.count > 0 && strig.childId > 0)
{ {
(*i).health -= srctrig.damage; for (int j=0; j<strig.count; ++j)
//qDebug() << "health=" << hh; {
if ((*i).health < 0) dead.append((*i).id); // TODO: randomRadiusPos
addSplash(spl.PlayerId,spl.srcTower,strig.childId,
spl.pos,spl.destination,-1,spl.TowerId);
}
}
if (strig.damage > 0)
{
if (!(strig.radius > 0))
{
if (!badAl)
{
float hh = gameData->curAliens[spl.AlienId].health -= strig.damage;
if (hh < 0)
gameData->curAliens.remove(spl.AlienId);
}
} else {
QList <int> dead;
for (QHash<int, AlienType>::iterator
i = gameData->curAliens.begin();
i != gameData->curAliens.end(); ++i)
{
if (distance2(spl.pos, (*i).pos) < strig.radius*strig.radius)
{
(*i).health -= strig.damage;
if ((*i).health < 0) dead.append((*i).id);
}
}
for (int i=0; i<dead.size(); ++i)
gameData->curAliens.remove(dead.at(i));
}
} }
} }
for (int i=0; i<dead.size(); ++i)
gameData->curAliens.remove(dead.at(i));
} }

View File

@@ -20,7 +20,7 @@ private:
Game_Data *gameData; Game_Data *gameData;
int nextId; int nextId;
void processTrigger(srcTriggerType srctrig,QPointF pos); void doTriggerOnDest(const SplashType &spl, QList <int> * deadIndexes, bool badAl);
}; };
#endif // SPLASHES_H #endif // SPLASHES_H