RTS2D
include/object/Unit.h
00001 #ifndef UNIT_H
00002 #include <cmath>
00003 #include <vector>
00004 #include <string>
00005 #include <cmath>
00006 #include "Entity.h"
00007 #include "Mymath.h"
00008 #include "UnitProperty.h"
00009 #include "BuildingProperty.h"
00010 #include "Define.h"
00011 #include <allegro5/allegro_primitives.h>
00012 #define UNIT_H
00013 
00017 class Unit : public Entity {
00018 public:
00019     Unit(float px, float py, int type, int team);
00020     virtual ~Unit();
00021 
00022     float getTx();
00023     float getTy();
00024     std::pair<float,float> getT();
00025     int getSignal();
00026     bool isHold();
00027     bool isAgressive();
00028     float getCooldown();
00029     float getGroupRadius();
00030     Entity* getTarget();
00031     Entity* getFocus();
00032     Entity* getFollow();
00033     std::pair<float,float> getLastMove();
00034     std::vector<std::pair<float,float>> getCollisionPath();
00035     int getBuild();
00036     Entity* getGoldMine();
00037 
00038     void setTx(float tx);
00039     void setTy(float ty);
00040     void setT(float tx, float ty);
00041     void setSignal(int signal);
00042     void setHold(bool hold);
00043     void setAgressive(bool agressive);
00044     void setCooldown(float cooldown);
00045     void setGroupRadius(float groupRadius);
00046     void setTarget(Entity* target);
00047     void setFocus(Entity* focus);
00048     void setFollow(Entity* follow);
00049     void setLastMove(std::pair<float,float> lastMove);
00050     void setCollisionPath(std::vector<std::pair<float,float>> collisionPath);
00051     void setBuild(int build);
00052     void setGoldMine(Entity* goldMine);
00053 
00054     float getSpeed();
00055     float getRadius();
00056     float getRange();
00057     float getDamage();
00058     float getAttackSpeed();
00059     float getMaxHp();
00060     int getCost();
00061     int getProjectile();
00062     int getCount();
00063     float getAggroRadius();
00064     std::vector<ALLEGRO_BITMAP*> getBitmap();
00065     std::vector<std::string> getAction();
00066     std::string getName();
00067     float getTime();
00068 
00069     bool isMoving();
00070     bool inCollision();
00071     bool isAttackReady();
00072 
00073     void stop();
00074     void wait();
00075     void move(std::pair<float,float> d);
00076     void updateCooldown();
00077     void updateMove();
00078     void updateSpriteConfig();
00079     void update();
00080     //void setPath(std::vector<std::pair<int,int>> path);
00081     //std::vector<std::pair<int,int>> getPath();
00082     std::pair<float,float> getNextMovement();
00083     float getPixelPathDistance();
00084     void checkPath();
00085     int getNearestPath();
00086     void deleteFarPath();
00087     bool isUnit();
00088     void render();
00089     void actionSprite();
00090 
00091     int getXFollow();
00092     int getYFollow();
00093     void setXFollow(int x);
00094     void setYFollow(int y);
00095     void resetFollow();
00096     bool isRepath();
00097     void setRepath(bool repath);
00098     void resetCollision();
00099     Entity* collide;
00100     float dist;
00101     int ncollide;
00102 
00103     /* Auxilia o bot, usado somente para que a IA nao execute o mesmo comando de movimentacao todo frame
00104        Essa variavel e' modificada apenas no metodo unitMove da classe Game */
00105     std::pair<float,float> movePosition;
00106 
00107 protected:
00108 private:
00109     float tx_; /* Coordenada X do target da unidade */
00110     float ty_; /* Coordenada Y do target da unidade */
00111     float groupRadius_; /* Raio do grupo, serve para parar a movimentacao mais longe quanto maior o tamanho grupo */
00112     int signal_; /* Serve apenas para direcionar o sentido da colisao em hold */
00113     bool wait_; /* Espera na movimentacao se for true */
00114     bool pushed_; /* Se foi empurrada */
00115     bool agressive_; /* Se a unidade estiver no modo agressivo, ela ataca outras entidades inimigas que estao no seu alcance */
00116     float cooldown_; /* Cooldown do ataque */
00117     bool hold_; /* Se for true, ninguem pode empurrar */
00118     float movingTime_; /* Usado pra ver qual sprite de movimentacao renderizar */
00119     float actionTime_; /* Usado pra ver qual sprite de acao renderizar */
00120     bool renderAct_;
00121     Entity* target_;
00122     Entity* focus_;
00123     Entity* follow_;
00124     Entity* goldMine_;
00125     int xfollow;
00126     int yfollow;
00127     int build_;
00128     float angle_;
00129     std::pair<float,float> lastMove_;
00130     //std::vector<std::pair<int,int>> path_;
00131     std::vector<std::pair<float,float>> collisionPath_;
00132     bool repath_;
00133 
00134 };
00135 
00136 #endif // UNIT_H
 Todos Classes Funções