Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11169


Ignore:
Timestamp:
Apr 17, 2016, 8:40:05 PM (9 years ago)
Author:
fvultier
Message:

Fixed errors with pickups.

Location:
code/branches/tgidronFS16
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tgidronFS16/data/levels/Hover.oxw

    r11168 r11169  
    2525?>
    2626
    27 <?lua
    28     include("templates/pickupRepresentationTemplates.oxt")
    29     include("includes/pickups.oxi")
    30  ?>
    31 
    3227<Template name=destroyhoverpickupRepresentation>
    3328    <PickupRepresentation>
     
    4641</Template>
    4742
    48 <Template name=destroymetapickup baseclass=MetaPickup>
    49   <MetaPickup representation="destroy" metaType="destroy" />
     43<Template name=destroyhoverpickup baseclass=MetaPickup>
     44  <MetaPickup representation="destroyhover" metaType="destroy" />
    5045</Template>
    51 
    52 <PickupRepresentation
    53     name = "destroyhover"
    54     pickupName = "Destroy Carrier Pickup"
    55     pickupDescription = "destroys you."
    56     spawnerTemplate = "destroyhoverpickupRepresentation"
    57     inventoryRepresentation = "destroyCarrierPickup"
    58 />
    59 
    6046
    6147<Level
     
    6652    <Template link=lodtemplate_default />
    6753  </templates>
     54
    6855  <?lua include("includes/notifications.oxi") ?>
    6956
     
    7764  >
    7865
     66    <PickupRepresentation
     67      name = "destroyhover"
     68      pickupName = "Destroy Hover Pickup"
     69      pickupDescription = "destroys you."
     70      spawnerTemplate = "destroyhoverpickupRepresentation"
     71      inventoryRepresentation = "destroyHoverPickup"
     72    />
     73
    7974    <StaticEntity position="0,0,0" collisionType="static">
    8075      <attached>
     
    8378          cellSize="<?lua print(MAZE_CELL_SIZE)?>"
    8479          cellHeight="<?lua print(MAZE_CELL_HEIGHT)?>"
    85           pickuptemplate=destroyhoverpickupRepresentation
    86           pickupbase=destroymetapickup
     80          pickuptemplate=destroyhoverpickup
     81          pickuprepresentationtemplate=destroyhoverpickupRepresentation
    8782        />
    8883        <Model
  • code/branches/tgidronFS16/data/overlays/HoverHUD.oxo

    r11168 r11169  
    7676     showpoints     = true
    7777    />
    78 
    79    
    8078  </OverlayGroup>
    81 
    82  </OverlayGroup>
    83 
    8479
    8580</Template>
  • code/branches/tgidronFS16/src/modules/hover/Hover.cc

    r11168 r11169  
    9898            for(int y=0; y<numCells; y++){
    9999                for(int x=0; x<numCells; x++){
    100                     switch(levelcode[ y * numCells + x ]){
     100                    switch(levelcode[ y * numCells + x ])
     101                    {
    101102                        case 1: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
    102                                 break;
     103                            break;
    103104                        case 3: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
    104105                        case 2: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 0);
    105                         default: break;
     106                        default:
     107                            break;
    106108                    }
    107                 }   
     109                }
    108110            }
    109111
     
    120122            for (int i = 0; i<5; i++)
    121123            {
    122                 PickupSpawner* pickup = new PickupSpawner(origin_->getContext());
    123                 pickup->setPosition(rand()%numCells, rand()%numCells, cellSize);
    124                 //pickup->setPickupTemplateName(origin_->getPickupMeta());
    125                 //pickup->setPickupTemplateName("destroymetapickup");
    126                 pickup->setMaxSpawnedItems(5);
    127                 pickup->setRespawnTime(30);
    128                 pickup->setTriggerDistance(5);
    129                 //pickup->createDroppedPickup(this->getContext(), pickup , this, 5);
    130                 pickups_.push_back(pickup);
    131             }
    132 
    133 
     124                PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
     125
     126                pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
     127                pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate());
     128                pickupSpawner->setMaxSpawnedItems(5);
     129                pickupSpawner->setRespawnTime(30);
     130                pickupSpawner->setTriggerDistance(5);
     131                // Add pickup spawner to the pickup spawner list
     132                pickupSpawners_.push_back(pickupSpawner);
     133            }
     134
     135            orxout() << this->origin_->getPickupTemplate() << endl;
     136            orxout() << this->origin_->getPickupRepresentationTemplate() << endl;
    134137        }
    135138    }
    136139
    137140
    138 
    139     void Hover::startLevel(){
     141    // Rename/delete this function.
     142    void Hover::startLevel()
     143    {
    140144        //Generate 5 flags randomly (test only 1 flag)
    141145            for ( int i = 0; i < 5; i++ )
     
    152156                //PickupSpawner->setPosition(rand()%numCells, rand()%numCells, cellSize);
    153157                //pickup->createDroppedPickup(this->getContext(), pickup , this, 5);
    154                 pickups_.push_back(pickup);
    155             }
    156 
     158                pickupSpawners_.push_back(pickup);
     159            }
     160
     161           
    157162    }
    158163
     
    163168
    164169        // Check if ship collided with one of the flags
    165         for ( unsigned int i = 0; i < flags_.size(); i++ ){
    166             if(flags_[i]->getCollided()){
     170        for ( unsigned int i = 0; i < flags_.size(); i++ )
     171        {
     172            if(flags_[i]->getCollided())
     173            {
    167174                flags_[i]->destroyLater();
    168175                flags_.erase (flags_.begin()+i);
     
    186193
    187194    }
     195
     196    Vector3 Hover::get3dCoordinates(int x, int y, float heightOffset)
     197    {
     198        return Vector3(x*cellSize*1.0f + cellSize/2, heightOffset, y*cellSize*1.0f + cellSize/2);
     199    }
    188200}
  • code/branches/tgidronFS16/src/modules/hover/Hover.h

    r11168 r11169  
    6161            void endLevel();
    6262
    63 
    64 
    6563            inline int getNumberOfFlags() const
    6664                { return this->numberOfFlags_; }
     65
     66            virtual Vector3 get3dCoordinates(int x, int y, float heightOffset);
    6767
    6868        private:
     
    8181            int totFlags;
    8282
    83             std::vector<PickupSpawner*> pickups_;
     83            std::vector<PickupSpawner*> pickupSpawners_;
    8484    };
    8585}
  • code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc

    r11168 r11169  
    4545        RegisterObject(HoverOrigin);
    4646        checkGametype();
     47
     48        pickupTemplate_ = "";
     49        pickupRepresentationTemplate_ = "";
    4750    }
    4851
     
    5457        XMLPortParam(HoverOrigin, "cellSize", setCellSize, getCellSize, xmlelement, mode);
    5558        XMLPortParam(HoverOrigin, "cellHeight", setCellHeight, getCellHeight, xmlelement, mode);
    56         XMLPortParam(HoverOrigin, "pickuptemplate", setPickup, getPickup, xmlelement, mode);
    57         XMLPortParam(HoverOrigin, "pickupbase", setPickupMeta, getPickupMeta, xmlelement, mode);
     59        XMLPortParam(HoverOrigin, "pickuptemplate", setPickupTemplate, getPickupTemplate, xmlelement, mode);
     60        XMLPortParam(HoverOrigin, "pickuprepresentationtemplate", setPickupRepresentationTemplate, getPickupRepresentationTemplate, xmlelement, mode);
    5861    }
    5962
  • code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h

    r11168 r11169  
    6666                { return this->cellHeight_; }
    6767
    68             inline void setPickup(std::string pickuptemplate)
    69                 { this->pickupTemplate_ = pickuptemplate; }
    70             inline std::string getPickup() const
     68            inline void setPickupTemplate(std::string pickupTemplate)
     69                { this->pickupTemplate_ = pickupTemplate; }
     70            inline std::string getPickupTemplate() const
    7171                { return this->pickupTemplate_; }
    7272
    73             inline void setPickupMeta(std::string pickupbase)
    74                 { this->pickupMeta_ = pickupbase; }
    75             inline std::string getPickupMeta() const
    76                 { return this->pickupMeta_; }
     73            inline void setPickupRepresentationTemplate(std::string pickupRepresenationaTemplate)
     74                { this->pickupRepresentationTemplate_ = pickupRepresenationaTemplate; }
     75            inline std::string getPickupRepresentationTemplate() const
     76                { return this->pickupRepresentationTemplate_; }
    7777
    7878        private:
     
    8282            int cellSize_;
    8383            int cellHeight_;
     84
     85            // Tempaltes for the destroy hover pickup
    8486            std::string pickupTemplate_;
    85             std::string pickupMeta_;
     87            std::string pickupRepresentationTemplate_;
    8688    };
    8789}
Note: See TracChangeset for help on using the changeset viewer.