1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: invader1.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_goodies.hxx"
34 #include <vcl/msgbox.hxx>
35 #include <tools/datetime.hxx>
37 #include "invader.hxx"
43 #include "strings.hrc"
46 void MyWindow::Kollision()
50 long nRockets
= pMunition
->Count();
55 for(i
=0; i
<pBombe
->Count(); i
++)
57 //Kollision Bombe->Mauer pr�fen
58 aRect
= pBombe
->GetKoll(i
);
59 if(pWall
->Kollision(aRect
,FALSE
))
61 //Kollision Bombe->Fighter pr�fen
62 if(pFighter
->Kollision(pBombe
->GetKoll(i
),pExplosion
))
69 for(i
=0; i
<pMunition
->Count(); i
++)
71 //Kollision Muniton->Gegner pr�fen
72 aRect
= pMunition
->GetKoll(i
);
73 nWert
= pGegner
->Kollision(aRect
,pExplosion
);
77 pMunition
->SetDelete(i
);
79 //Kollision Muniton->Mauer pr�fen
80 aRect
= pMunition
->GetKoll(i
);
81 if(pWall
->Kollision(aRect
,FALSE
))
82 pMunition
->SetDelete(i
);
84 //Kollision Munition->Bombe pr�fen
85 aRect
= pMunition
->GetKoll(i
);
86 if(pBombe
->Kollision(aRect
,pExplosion
))
87 pMunition
->SetDelete(i
);
90 for(i
=0; i
<pGegner
->Count();i
++)
93 //Kollision Gegner->Mauer pr�fen
94 aRect
= pGegner
->GetKoll(i
);
95 pWall
->Kollision(aRect
,TRUE
);
96 //Kollision Gegner->Fighter pr�fen
97 aRect
= pGegner
->GetKoll(i
);
98 if(pFighter
->Kollision(aRect
,pExplosion
))
107 pBombe
->RemoveBomben();
108 nWert
= pMunition
->RemoveMunition();
109 if( nWert
!= nRockets
)
110 pScoreWindow
->SetRockets(nWert
);
113 pScoreWindow
->SetScore(nScore
);
115 if(pGegner
->RemoveGegner())
119 pMunition
->ClearAll();
125 pMunition
->ClearAll();
129 if(pExplosion
->RemoveExpl() && (bEndLevel
|| bFightDest
))
132 aWaitDlgTimer
.Start();
137 aString = String(ResId(STR_GRAT1,GetResMgr()));
138 aString += String(nLevel);
139 aString += String(ResId(STR_GRAT2,GetResMgr()));
144 pBox = new MessBox(GetParent(),WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
146 SetBackground(Wallpaper( Color( COL_WHITE ) ) );
148 aWaitDlgTimer.Start();
162 pScoreWindow->SetLives(nFighter);
165 aString = String(ResId(STR_FIGHTDEST1,GetResMgr()));
166 aString += String(nFighter);
167 aString += String(ResId(STR_FIGHTDEST2,GetResMgr()));
171 aString = String(ResId(STR_GAMEOVER,GetResMgr()));
178 pBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
179 aDummyStatus = ProgStatus;
181 SetBackground(Wallpaper( Color( COL_WHITE ) ) );
183 aWaitDlgTimer.Start();
193 pGegner->SetRandWert(200);
194 pGegner->SetDown(10);
203 //ProgStatus=aDummyStatus;
211 if (nScore > nHighScore)
214 aString = String(ResId(STR_HIGHSCORE1,GetResMgr()));
215 aString += String(nScore);
216 aString += String(ResId(STR_HIGHSCORE2,GetResMgr()));
217 aString += String(nHighScore);
218 aString += String(ResId(STR_HIGHSCORE3,GetResMgr()));
222 pBox = new MessBox(this,WinBits(WB_OK),String(ResId(STR_APP_TITLE,GetResMgr())),aString);
223 Paint(Rectangle(Point(0,0),Point(640,480)));
224 SetBackground(Wallpaper( Color( COL_WHITE ) ) );
226 aWaitDlgTimer.Start();
243 void MyWindow::InitLevel()
248 aPaintTimer
.SetTimeout(1000);
251 pMunition
->ClearAll();
257 pGegner
->SetAuseMode(FALSE
);
259 pScoreWindow
->SetRockets(5);
260 pScoreWindow
->SetLives(nFighter
);
261 pScoreWindow
->SetScore(nScore
);
262 pScoreWindow
->SetLevel(nLevel
);
266 pGegner
->SetRandWert(pGegner
->GetRandWert()+10);
272 if(nLevel
== 10 || nLevel
== 20 || nLevel
== 30 || nLevel
>= 40)
274 pGegner
->SetDown(pGegner
->GetDown()+2);
275 if(pGegner
->GetDown() > 30)
276 pGegner
->SetDown(30);
280 while( nWert
> WAVES
)
288 pScoreWindow
->SetLives(nFighter
);
300 nGegner
= waves
[nWert
-1][0];
302 for(long i
=0; i
<nGegner
; i
++)
303 if ( nLevel
> 10 ) pGegner
->InsertGegner((USHORT
)waves
[nWert
-1][i
*3+1],
304 (USHORT
)waves
[nWert
-1][i
*3+2],
305 (USHORT
)waves
[nWert
-1][i
*3+3]);
306 else if ( waves
[nWert
-1][i
*3+1] < 4 ) pGegner
->InsertGegner((USHORT
)waves
[nWert
-1][i
*3+1],
307 (USHORT
)waves
[nWert
-1][i
*3+2],
308 (USHORT
)waves
[nWert
-1][i
*3+3]);
315 if(levelpuf
[0] != nLevel
)
319 for(long i
=0; i
<levelpuf
[1]; i
++)
320 pGegner
->InsertGegner(levelpuf
[i
*3+2],levelpuf
[i
*3+3],levelpuf
[i
*3+4]);
322 nGegner
= levelpuf
[1];
330 nMauer
= (BYTE
)waves
[nWert
-1][nGegner
*3+1];
335 aPoint
= Point(0,340);
336 pWall
->InsertWall(aPoint
);
340 aPoint
= Point(32,340);
341 pWall
->InsertWall(aPoint
);
345 aPoint
= Point(64,340);
346 pWall
->InsertWall(aPoint
);
350 aPoint
= Point(96,340);
351 pWall
->InsertWall(aPoint
);
355 aPoint
= Point(128,340);
356 pWall
->InsertWall(aPoint
);
360 aPoint
= Point(160,340);
361 pWall
->InsertWall(aPoint
);
365 aPoint
= Point(192,340);
366 pWall
->InsertWall(aPoint
);
370 aPoint
= Point(224,340);
371 pWall
->InsertWall(aPoint
);
374 nMauer
= (BYTE
)waves
[nWert
-1][nGegner
*3+2];
378 pWall
->InsertWall(Point(256,340));
380 pWall
->InsertWall(Point(288,340));
382 pWall
->InsertWall(Point(320,340));
384 pWall
->InsertWall(Point(352,340));
386 pWall
->InsertWall(Point(384,340));
388 pWall
->InsertWall(Point(416,340));
390 pWall
->InsertWall(Point(448,340));
392 pWall
->InsertWall(Point(480,340));
394 nMauer
= (BYTE
)waves
[nWert
-1][nGegner
*3+3];
398 pWall
->InsertWall(Point(512,340));
400 pWall
->InsertWall(Point(544,340));
402 pWall
->InsertWall(Point(576,340));
404 pWall
->InsertWall(Point(608,340));
410 void MyWindow::RandomLevel()
414 srand(aTime
.GetTime() % 1000);
416 long nPos
= ranpos
[0];
417 while(!pGegner
->Count())
419 for(long i
=0; i
<nPos
;i
++)
422 int nRan
= rand() % 40;
425 pGegner
->InsertGegner(GEGNER5
,ranpos
[i
*2+1],ranpos
[i
*2+2]);
426 if(nRan
> 2 && nRan
< 9)
427 pGegner
->InsertGegner(GEGNER4
,ranpos
[i
*2+1],ranpos
[i
*2+2]);
428 if(nRan
> 8 && nRan
< 16)
429 pGegner
->InsertGegner(GEGNER3
,ranpos
[i
*2+1],ranpos
[i
*2+2]);
430 if(nRan
> 15 && nRan
< 27)
431 pGegner
->InsertGegner(GEGNER2
,ranpos
[i
*2+1],ranpos
[i
*2+2]);
432 if(nRan
> 26 && nRan
< 41)
433 pGegner
->InsertGegner(GEGNER1
,ranpos
[i
*2+1],ranpos
[i
*2+2]);
437 levelpuf
[0] = nLevel
;
438 levelpuf
[1] = pGegner
->Count();
440 for(i
=0; i
<pGegner
->Count(); i
++)
442 levelpuf
[i
*3+2] = pGegner
->GegType(i
);
443 levelpuf
[i
*3+3] = pGegner
->GegnerX(i
);
444 levelpuf
[i
*3+4] = pGegner
->GegnerY(i
);