TankGroup.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006 
00007 /*
00008  * TankGroup.h
00009  * MetalWarriors
00010  * $Revision: 1.9 $
00011  *
00012  * Created by Daniel Aarno on Sun Oct 12 2003.
00013  * Copyright (c) 2003 Daniel Aarno and Erik Ytterberg - All rights reserved.
00014  *
00015  *     This program is free software; you can redistribute it and/or modify
00016  *     it under the terms of the GNU General Public License as published by
00017  *     the Free Software Foundation; either version 2 of the License, or
00018  *     (at your option) any later version.
00019  *
00020  *     This program is distributed in the hope that it will be useful,
00021  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *     GNU General Public License for more details.
00024  *
00025  *     You should have received a copy of the GNU General Public License
00026  *     along with this program; if not, write to the Free Software
00027  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00028  */
00029 
00030 #ifndef TANKGROUP_H
00031 #define TANKGROUP_H
00032 
00033 #include <vector>
00034 #include "VehicleSprite.h"
00035 #include "Driver.h"
00036 #include "Target.h"
00037 
00038 typedef enum
00039   {
00040     SINGLE,
00041     SIMON_SAYS,
00042     FORMATION,
00043     FOLLOW_ME
00044   }FollowMode;
00045 
00046 typedef enum
00047   {
00048     TARGET_ACCEPT_NO,
00049     TARGET_ACCEPT_MAYBE,
00050     TARGET_ACCEPT_YES,
00051   }TargetAccept;
00052 
00053 typedef struct{
00054   VehicleSprite *sprite;
00055   AutoDriver *driver;
00056   AutoGunner* gunner;
00057   float rel_pos[3];
00058   float rel_rot_pos[3];
00059   waypoint_t static_wp;
00060 }group_member_t;
00061 
00062 
00063 class VehicleGroup : public KeyDriver
00064 {
00065 
00066  protected:
00067   group_member_t *active_member;
00068   group_member_t *leader;
00069   std::vector<group_member_t*> members;
00070   FollowMode follow_mode;
00071   float group_update_timer;
00072 
00073   
00074  protected:
00075   void recalcRelPos(void);
00076   void calcRelPos(group_member_t *tank);
00077   void updateStaticWaypoints(void);
00078 
00079  public:
00080   VehicleGroup(): KeyDriver(), active_member(NULL), leader(NULL), follow_mode(SINGLE), group_update_timer(0.0) {}
00081   virtual ~VehicleGroup() {}
00082   void addMember(VehicleSprite* new_member);
00083   int delMember(VehicleSprite *del_member);
00084   int setActiveMember(VehicleSprite* active);
00085   VehicleSprite *getMember(int index);
00086   
00087   int setLeader(VehicleSprite *new_leader);
00088   VehicleSprite *getLeader(void);
00089   void setFollow(FollowMode mode);
00090   std::vector<group_member_t*> getMembers(void);
00091   void handleEvent(int key, int x, int y, bool special, bool down, unsigned int modifiers);
00092   void updateDrivers(void);
00093   void stopAll(void);
00094   TargetAccept willAcceptTarget(TargetType, void *originator);
00095   void injectTarget(Target *target);
00096   
00097   void setAccelerate(bool b) {};
00098   void setSlowDown(bool b) {};
00099   void setTurnLeft(bool b) {};
00100   void setTurnRight(bool b) {};
00101 };
00102 
00103 
00104 #endif /*TANKGROUP_H*/

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7