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/SectionController.cc

    r10729 r10731  
    3939        this->setFormationMode(WALL);
    4040
    41         bIsDivisionLeader_ = false;
    4241        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
    4342        this->myWingman_ = 0;
    4443        this->myDivisionLeader_ = 0;
     44        this->rank_ = SECTIONLEADER;
    4545
    4646        orxout(internal_error) << this << "Was created" << endl;
     
    5252       
    5353    }
     54
     55    void SectionController::tick(float dt)
     56    {
     57        if (!this->isActive())
     58            return;
     59       
     60        if (this->bHasTargetPosition_)
     61        {
     62            this->moveToTargetPosition();
     63        }
     64
     65       
     66        SUPER(SectionController, tick, dt);
     67    }
     68
     69    void SectionController::action()
     70    {
     71        //this->target_ = this->sectionTarget_;       
     72        if (!myDivisionLeader_)
     73        {
     74            LeaderController* newDivisionLeader = findNewDivisionLeader();
     75            this->myDivisionLeader_ = newDivisionLeader;
     76            if (newDivisionLeader)
     77                orxout(internal_error) << "new DivisionLeader set" << endl;
     78
     79        }
     80        setTargetPositionOfWingman();
     81
     82    }
     83   
    5484    void SectionController::setTargetPositionOfWingman()
    5585    {
     
    85115       
    86116    }
    87 
    88117    LeaderController* SectionController::findNewDivisionLeader()
    89118    {
     
    98127        {
    99128            //0ptr or not DivisionController?
    100             if (!(it) || !(it)->bIsDivisionLeader_ || !(it->getControllableEntity()))
     129            if (!(it) || !((it)->getRank() == DIVISIONLEADER) || !(it->getControllableEntity()))
    101130                continue;
    102131            //same team?
     
    126155
    127156    }
     157    bool SectionController::setWingman(CommonController* cwingman)
     158    {
     159        WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
    128160
    129     void SectionController::action()
    130     {
    131         //this->target_ = this->sectionTarget_;       
    132         if (!myDivisionLeader_)
     161        if (!this->myWingman_)
    133162        {
    134             LeaderController* newDivisionLeader = findNewDivisionLeader();
    135             this->myDivisionLeader_ = newDivisionLeader;
    136             if (newDivisionLeader)
    137                 orxout(internal_error) << "new DivisionLeader set" << endl;
    138 
     163            this->myWingman_ = wingman;
     164            return true;
    139165        }
    140         setTargetPositionOfWingman();
    141 
    142     }
    143     /*
    144     Wingmen and Leaders attack target_, which is a member variable of their classes.
    145     Wingmen's target_ is set to sectionTarget_, which is a member variable of SectionController class, unless
    146     Wingman covers Leader's rear.
    147     Leader's target_ must always equal sectionTarget_.
    148     if section has a target, its Leader shoots at it, but doesn't follow.
    149     Every section is a part of division. Division consisting of one Section is still a division.
    150     Division's leader's target_ must always equal divisionTarget_, which is a member variable of DivisionController.
    151     Division leader ONLY can follow target_ while in formation flight.
    152     If Division doesn't have a target, Division Leader stays in place, unless it has a waypoint.
    153     Division Leader's sectionTarget_ must equal divisionTarget_,
    154     but the other section, that is not a leading section, can attack any target that is near divisonTarget_
    155 
    156     */
    157    
    158     void SectionController::tick(float dt)
    159     {
    160         if (!this->isActive())
    161             return;
    162        
    163         if (this->bHasTargetPosition_)
     166        else
    164167        {
    165             this->moveToTargetPosition();
     168            return false;
    166169        }
    167 
    168        
    169         SUPER(SectionController, tick, dt);
    170170    }
    171171   
     172    bool SectionController::hasWingman()
     173    {
     174        if (this->myWingman_)
     175            return true;
     176        else
     177            return false;
     178    }
    172179
    173180    void SectionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Note: See TracChangeset for help on using the changeset viewer.