Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2019, 4:53:45 PM (6 years ago)
Author:
cwaupoti
Message:

Zombie can now approach, tried to add waves

Location:
code/branches/Boxhead_FS19/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Boxhead_FS19/src/modules/hover/Hover.cc

    r12374 r12390  
    3939#include "MazeGenerator.h"
    4040#include "core/CoreIncludes.h"
     41#include "worldentities/pawns/Pawn.h"
     42#include "worldentities/pawns/ScriptableControllerDrone.h"
     43#include "worldentities/pawns/SpaceShip.h"
     44
     45#include "tools/Timer.h"
     46#include "infos/Bot.h"
     47#include "worldentities/pawns/ModularSpaceShip.h"
     48#include "graphics/Model.h"
     49
    4150
    4251
     
    5564        this->setHUDTemplate("HoverHUD");
    5665    }
     66    // void Hover::spawnZombie(std::string id)
     67    // {
     68    //     Identifier *identifier = ClassByString("SpaceShip");
     69
     70    //       if(!identifier)
     71    //     {
     72    //         orxout(user_error) << "Script tried to spawn unknown object" << std::endl;
     73    //         return;
     74    //     }
     75
     76    //     if(!identifier->isLoadable())
     77    //     {
     78    //         orxout(user_error) << "Script tried to spawn unloadable object" << std::endl;
     79    //         return;
     80    //     }
     81       
     82   
     83    //     WorldEntity *entity;
     84    //     Identifiable *obj = identifier->fabricate(this->controller_->getWorldEntityByID("Player")->getContext());
     85
     86
     87
     88    //     orxout(user_status) << "First hit!" << std::endl;
     89
     90    //    if(obj->isA(ClassIdentifier<WorldEntity>::getIdentifier()))
     91    //     {
     92    //         orxout(user_status) << "Is WorldEntity!" << std::endl;
     93    //         entity = orxonox_cast<WorldEntity*>(obj);
     94    //     }
     95    //     else if(obj->isA(ClassIdentifier<PlayerInfo>::getIdentifier()))
     96    //     {
     97    //         // TODO This does not work yet because somehow the controllable entity is not set
     98    //         // yet at this stage.
     99    // //        entity = orxonox_cast<PlayerInfo*>(obj)->getControllableEntity();
     100
     101    //         orxout(user_status) << "Is PlayerInfo!" << std::endl;
     102
     103    //         //use TEMPLATES in the map to define objects that are not present on the map yet
     104    //         return;
     105    //     }
     106    //     else
     107    //     {
     108    //         orxout(user_warning) << "Script tried to spawn an object that is neither a WorldEntity, nor a PlayerInfo" << std::endl;
     109           
     110    //         return;
     111    //     }
     112       
     113    //     if(entity->isA(ClassIdentifier<MobileEntity>::getIdentifier())) {
     114    //         orxout(user_status) << "Is MobileEntity!" << std::endl;
     115    //         this->controller_->registerMobileEntity(id, orxonox_cast<MobileEntity*>(entity));
     116    //     }
     117
     118       
     119
     120    //     if(entity->isA(ClassIdentifier<Pawn>::getIdentifier())) {
     121    //         orxout(user_status) << "Is Pawn!" << std::endl;
     122    //         this->controller_->registerPawn(id, orxonox_cast<Pawn*>(entity));
     123    //     }
     124       
     125    //     this->controller_->registerWorldEntity(id, orxonox_cast<WorldEntity*>(entity));
     126
     127
     128    //     ///////////////GOLD!!!!!!!!!!!!!!!////////////////////////
     129    //     Pawn* pawn = this->controller_->getPawnByID(id);
     130
     131    //     //Attach to pawn
     132    //     SpaceShip* drone = new SpaceShip(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
     133       
     134    //     drone->addTemplate("spaceshipzombie"); //ScriptableControllerDroneTemplate spaceshipescort
     135
     136    //     Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(500,20,500);
     137    //     drone->setPosition(spawnPosition);
     138    // }
    57139
    58140    void Hover::tick(float dt)
     
    95177            // }
    96178
     179           
     180
    97181
    98182
     
    117201        // }
    118202        // numberOfFlags_ = flags_.size();
     203
     204        //Spawn Zombies
     205        //spawnZombie(z1);
     206
     207
    119208    }
    120209}
  • code/branches/Boxhead_FS19/src/modules/hover/Hover.h

    r12273 r12390  
    4545namespace orxonox
    4646{
     47
     48
     49   
     50
    4751    class _HoverExport Hover : public Gametype
    4852    {
     
    5862                { return this->numberOfFlags_; }
    5963
     64             void spawnZombie(std::string id);
     65
     66            /**
     67             * @brief Set the position of an object
     68             * @param id The ID of the object
     69             * @param x The position on the x-axis
     70             * @param y The position on the y-axis
     71             * @param z The position on the z-axis
     72             */
     73
    6074        private:
    6175            WeakPtr<HoverOrigin> origin_;
     
    6680}
    6781
     82
    6883#endif /* _Hover_H__ */
  • code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.cc

    r12006 r12390  
    1010#include "graphics/Model.h"
    1111#include "worldentities/pawns/ScriptableControllerDrone.h"
     12#include "worldentities/pawns/SpaceShip.h"
     13
    1214
    1315
     
    4244
    4345        LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawnTest)>::registerFunction<&ScriptableControllerAPI::spawnTest>(this, lua, "spawnTest");
    44 
     46        LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawnZombie)>::registerFunction<&ScriptableControllerAPI::spawnZombie>(this, lua, "spawnZombie");
    4547
    4648
     
    289291    }
    290292
    291 
    292 
     293    void ScriptableControllerAPI::spawnZombie(std::string id)
     294    {
     295        Identifier *identifier = ClassByString("SpaceShip");
     296
     297          if(!identifier)
     298        {
     299            orxout(user_error) << "Script tried to spawn unknown object" << std::endl;
     300            return;
     301        }
     302
     303        if(!identifier->isLoadable())
     304        {
     305            orxout(user_error) << "Script tried to spawn unloadable object" << std::endl;
     306            return;
     307        }
     308       
     309   
     310        WorldEntity *entity;
     311        Identifiable *obj = identifier->fabricate(this->controller_->getWorldEntityByID("Player")->getContext());
     312
     313
     314
     315        orxout(user_status) << "First hit!" << std::endl;
     316
     317       if(obj->isA(ClassIdentifier<WorldEntity>::getIdentifier()))
     318        {
     319            orxout(user_status) << "Is WorldEntity!" << std::endl;
     320            entity = orxonox_cast<WorldEntity*>(obj);
     321        }
     322        else if(obj->isA(ClassIdentifier<PlayerInfo>::getIdentifier()))
     323        {
     324            // TODO This does not work yet because somehow the controllable entity is not set
     325            // yet at this stage.
     326    //        entity = orxonox_cast<PlayerInfo*>(obj)->getControllableEntity();
     327
     328            orxout(user_status) << "Is PlayerInfo!" << std::endl;
     329
     330            //use TEMPLATES in the map to define objects that are not present on the map yet
     331            return;
     332        }
     333        else
     334        {
     335            orxout(user_warning) << "Script tried to spawn an object that is neither a WorldEntity, nor a PlayerInfo" << std::endl;
     336           
     337            return;
     338        }
     339       
     340        if(entity->isA(ClassIdentifier<MobileEntity>::getIdentifier())) {
     341            orxout(user_status) << "Is MobileEntity!" << std::endl;
     342            this->controller_->registerMobileEntity(id, orxonox_cast<MobileEntity*>(entity));
     343        }
     344
     345       
     346
     347        if(entity->isA(ClassIdentifier<Pawn>::getIdentifier())) {
     348            orxout(user_status) << "Is Pawn!" << std::endl;
     349            this->controller_->registerPawn(id, orxonox_cast<Pawn*>(entity));
     350        }
     351       
     352        this->controller_->registerWorldEntity(id, orxonox_cast<WorldEntity*>(entity));
     353
     354
     355        ///////////////GOLD!!!!!!!!!!!!!!!////////////////////////
     356        Pawn* pawn = this->controller_->getPawnByID(id);
     357
     358        //Attach to pawn
     359        SpaceShip* drone = new SpaceShip(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
     360       
     361        drone->addTemplate("spaceshipzombie"); //ScriptableControllerDroneTemplate spaceshipescort
     362
     363        Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(500,20,500);
     364        drone->setPosition(spawnPosition);
     365    }
    293366
    294367
  • code/branches/Boxhead_FS19/src/orxonox/scriptablecontroller/scriptable_controller_api.h

    r11974 r12390  
    161161     * @param z The position on the z-axis
    162162     */
     163
     164    void spawnZombie(std::string id);
     165
     166    /**
     167     * @brief Set the position of an object
     168     * @param id The ID of the object
     169     * @param x The position on the x-axis
     170     * @param y The position on the y-axis
     171     * @param z The position on the z-axis
     172     */
     173
     174
    163175    void setPosition(std::string id, double x, double y, double z);
    164176
Note: See TracChangeset for help on using the changeset viewer.