Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 24, 2015, 11:54:47 AM (9 years ago)
Author:
gania
Message:

I hope that you don't code today, that version is not compilable just yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc

    r10843 r10847  
    6060        this->action_ = Action::FLY;
    6161        this->stopLookingAtTarget();
    62        
     62        this->attackRange_ = 2500;
    6363        RegisterObject( CommonController );
    6464    }
     
    6969        //orxout(internal_error) << "I died, my Rank is " << rank_ << endl;
    7070    }
    71    
     71    void CommonController::backupAction()
     72    {
     73        this->actionpoints_.push_back (this->currentActionpoint_);
     74    }
     75    void CommonController::restoreAction()
     76    {
     77        this->currentActionpoint_ = this->actionpoints_.back();
     78        this->actionpoints_.pop_back();
     79    }
     80    void CommonController::popAction()
     81    {
     82        this->currentActionpoint_ = actionpoints_.back();
     83        actionpoints_.pop_back();
     84    }
     85
    7286    void CommonController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
    7387    {
    7488        SUPER( CommonController, XMLPort, xmlelement, mode );
    7589        XMLPortParam( CommonController, "formationMode", setFormationModeXML, getFormationModeXML,  xmlelement, mode );
    76         XMLPortParam( CommonController, "action", setActionXML, getActionXML,  xmlelement, mode );
    77         XMLPortParam ( CommonController, "protect", setProtectXML, getProtectXML,  xmlelement, mode );
     90        //XMLPortParam( CommonController, "action", setActionXML, getActionXML,  xmlelement, mode );
     91        //XMLPortParam ( CommonController, "protect", setProtectXML, getProtectXML,  xmlelement, mode );
    7892        //XMLPortParam ( CommonController, "enemy", setEnemyXML, getEnemyXML,  xmlelement, mode );
     93        XMLPortObject(CommonController, WorldEntity, "actionpoints", addActionpoint, getActionpoint,  xmlelement, mode);
     94
    7995    }
    8096    void CommonController::setProtectXML( std::string val )
     
    104120        if (!this->getProtect())
    105121            return "noProtectWasSet";
    106         return this->getProtect()->getName();
    107     }
    108 
     122        return CommonController::getName (this->getProtect());
     123    }
     124    std::string CommonController::getName(ControllableEntity* entity)
     125    {
     126        std::string name = entity->getName();
     127        if (name == "")
     128        {
     129            const void * address = static_cast<const void*>(entity);
     130            std::stringstream ss;
     131            ss << address; 
     132            name = ss.str();           
     133        }
     134        return name;
     135
     136    }
    109137    void CommonController::setProtect (ControllableEntity* protect)
    110138    {
     
    126154        else if ( valUpper == "PROTECT" )
    127155            value = Action::PROTECT;
     156        else if ( valUpper == "NONE" )
     157            value = Action::NONE;
     158        else if ( valUpper == "FIGHTALL" )
     159            value = Action::FIGHTALL;
     160        else if ( valUpper == "ATTACK" )
     161            value = Action::ATTACK;
    128162        else
    129163            ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ val + "'." );
     
    149183                break;
    150184            }
     185            case Action::NONE:
     186            {
     187                return "NONE";
     188                break;
     189            }
     190            case Action::FIGHTALL:
     191            {
     192                return "FIGHTALL";
     193                break;
     194            }
     195            case Action::ATTACK:
     196            {
     197                return "ATTACK";
     198                break;
     199            }
    151200            default:
    152                 return "FIGHT";
     201                return "NONE";
    153202                break;
    154203        }
     
    237286       
    238287    }
     288    void CommonController::addActionpoint(WorldEntity* actionpoint)
     289    {
     290        std::string actionName;
     291        Vector3 position;
     292        std::string targetName;
     293        this->actionpoints_.push_back(actionpoint);
     294        if (static_cast<Actionpoint*> (actionpoint))
     295        {
     296            Actionpoint* ap = static_cast<Actionpoint*> (actionpoint);
     297            actionName = ap->getActionXML();
     298            targetName = ap->get
     299            Action::Value value;
     300           
     301            if ( valUpper == "FIGHT" )
     302            {
     303                value = Action::FIGHT;
     304
     305            }
     306            else if ( valUpper == "FLY" )
     307            {
     308                value = Action::FLY;
     309
     310            }
     311            else if ( valUpper == "PROTECT" )
     312            {
     313                value = Action::PROTECT;
     314
     315            }
     316            else if ( valUpper == "NONE" )
     317            {
     318                value = Action::NONE;
     319
     320            }
     321            else if ( valUpper == "FIGHTALL" )
     322            {
     323                value = Action::FIGHTALL;
     324
     325            }
     326            else if ( valUpper == "ATTACK" )
     327            {
     328                value = Action::ATTACK;
     329
     330            }
     331            else
     332                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ val + "'." );
     333            this->setAction( value );
     334        }
     335        else
     336        {
     337            actionName = "FLY";
     338        }
     339       
     340    }
     341
     342    WorldEntity* CommonController::getActionpoint(unsigned int index) const
     343    {
     344        if (index < this->actionpoints_.size())
     345            return this->actionpoints_[index];
     346        else
     347            return 0;
     348    }
    239349    void CommonController::setClosestTarget()
    240350    {
     351        this->setTarget (closestTarget());
     352    }
     353    ControllableEntity* CommonController::closestTarget()
     354    {
    241355        if (!this->getControllableEntity())
    242             return;
     356            return 0;
    243357
    244358        Pawn* closestTarget = 0;
     
    259373        if (closestTarget)
    260374        {
    261            (this)->setTarget(static_cast<ControllableEntity*>(closestTarget));
    262         }   
     375           return static_cast<ControllableEntity*>(closestTarget);
     376        }
     377        return 0; 
    263378    }
    264379    void CommonController::maneuver()
Note: See TracChangeset for help on using the changeset viewer.