Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 31, 2015, 4:07:29 PM (9 years ago)
Author:
gania
Message:

added a little bit of firing functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc

    r10729 r10731  
    4040        this->setFormationMode(WALL);
    4141
    42         bIsDivisionLeader_ = true;
    4342        this->myFollower_ = 0;
    4443        this->myWingman_ = 0;
    4544        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
    46        
    47         /*Vector3* pos = new Vector3(500,500,-500);
    48         this->setTargetPosition(*pos);*/
     45        this->rank_ = DIVISIONLEADER;
     46
     47        Vector3* pos = new Vector3(500,500,-500);
     48        this->setTargetPosition(*pos);
    4949
    5050    }
     
    5454     
    5555    }
     56
     57   
    5658    void DivisionController::tick(float dt)
    5759    {
     60        if (this->target_)
     61        {
     62            this->aimAtTarget();
     63            this->doFire();
     64        }
     65     
    5866        if (this->bHasTargetPosition_)
    5967        {
     
    6876        setTargetPositionOfFollower();
    6977        setTargetPositionOfWingman();
    70     }
    71 
    72     bool DivisionController::setFollower(LeaderController* myFollower)
    73     {
    74          if (!this->myFollower_)
    75         {
    76             this->myFollower_ = myFollower;
    77             return true;
    78         }
    79         else
    80         {
    81             return false;
    82         }
    83     }
     78
     79        for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
     80        {
     81            if (this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam())
     82            {
     83                this->target_=it->getControllableEntity();
     84                this->setTargetPosition(this->target_->getWorldPosition());
     85                break;
     86            }
     87        }
     88           
     89     
     90    }
     91
     92   
    8493
    8594    void DivisionController::setTargetPositionOfWingman()
     
    149158       
    150159    }
     160
     161
     162    bool DivisionController::setWingman(CommonController* cwingman)
     163    {
     164
     165        WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
     166        if (!this->myWingman_)
     167        {
     168            this->myWingman_ = wingman;
     169            return true;
     170        }
     171        else
     172        {
     173            return false;
     174        }
     175   
     176    }
     177    bool DivisionController::setFollower(LeaderController* myFollower)
     178    {
     179         if (!this->myFollower_)
     180        {
     181            this->myFollower_ = myFollower;
     182            return true;
     183        }
     184        else
     185        {
     186            return false;
     187        }
     188    }
     189    bool DivisionController::hasWingman()
     190    {
     191        if (this->myWingman_)
     192            return true;
     193        else
     194            return false;
     195    }
     196    bool DivisionController::hasFollower()
     197    {
     198        if (this->myFollower_)
     199            return true;
     200        else
     201            return false;
     202    }
     203
     204
    151205    void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    152206    {
Note: See TracChangeset for help on using the changeset viewer.