1 /*************************************************************************** 2 alienBlaster 3 Copyright (C) 2004 4 Paul Grathwohl, Arne Hormann, Daniel Kuehn, Soenke Schwardt 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 ***************************************************************************/ 20 #ifndef FORMATION_H 21 #define FORMATION_H 22 23 #include <vector> 24 #include "global.h" 25 #include "geometry.h" 26 27 class Enemy; 28 29 class Formation { 30 private: 31 std::vector<Enemy *> involvedEnemys; 32 int nrInvolved; 33 34 FormationTypes formationType; 35 36 Vector2D formationCenter; 37 Vector2D formationSpeed; 38 39 bool enemyWasKilled; 40 41 bool formationFires; 42 int nextFirePrimary; 43 int nextFireSecondary; 44 45 bool changeOnKill, changeSpontaneous, changeOften, changeSeldom; 46 int nextFormationChange; 47 FormationShotPatterns shotPattern; 48 int actShootingEnemy; 49 50 void chooseNewFormationType(); 51 52 void handleSpontaneousFormationChange( int dT ); 53 void moveEnemyInFormation(); 54 void fillTargetPos( vector<Vector2D> &targetPos ); 55 void fillTargetPosFormationV( vector<Vector2D> &targetPos ); 56 void fillTargetPosFormationReverseV( vector<Vector2D> &targetPos ); 57 void fillTargetPosFormationBlock( vector<Vector2D> &targetPos ); 58 void fillTargetPosFormationLine( vector<Vector2D> &targetPos ); 59 void getBestMapping( vector<Vector2D> &targetPos, 60 vector<Vector2D> &relPosForFighters ); 61 62 void calcNextPerm( int *perm ); 63 float calcTestMapping( int *perm, vector<Vector2D> &targetPos, 64 vector<Vector2D> *mapping ); 65 int factorial( int n ); 66 67 void shoot( int dT ); 68 69 public: 70 Formation( FormationTypes whichFormation, Vector2D centerAtStart, 71 Vector2D startVel, int nrEnemys=66, 72 FormationEnemySets enemyTypes=FORMATION_ENEMY_SET_DEFAULT, 73 int flagsFormationChangePolicy=0, 74 FormationShotPatterns shotPattern=FORMATION_SP_NONE ); 75 ~Formation(); 76 getCenter()77 Vector2D getCenter() { return formationCenter; } 78 79 void enemyKilled( Enemy *killedEnemy ); 80 void update( int dT ); isExpired()81 bool isExpired() { return (nrInvolved == 0); } 82 }; 83 84 85 #endif 86