[Orxonox-commit 6527] r11169 - in code/branches/tgidronFS16: data/levels data/overlays src/modules/hover
fvultier at orxonox.net
fvultier at orxonox.net
Sun Apr 17 20:40:05 CEST 2016
Author: fvultier
Date: 2016-04-17 20:40:05 +0200 (Sun, 17 Apr 2016)
New Revision: 11169
Modified:
code/branches/tgidronFS16/data/levels/Hover.oxw
code/branches/tgidronFS16/data/overlays/HoverHUD.oxo
code/branches/tgidronFS16/src/modules/hover/Hover.cc
code/branches/tgidronFS16/src/modules/hover/Hover.h
code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc
code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h
Log:
Fixed errors with pickups.
Modified: code/branches/tgidronFS16/data/levels/Hover.oxw
===================================================================
--- code/branches/tgidronFS16/data/levels/Hover.oxw 2016-04-14 14:05:48 UTC (rev 11168)
+++ code/branches/tgidronFS16/data/levels/Hover.oxw 2016-04-17 18:40:05 UTC (rev 11169)
@@ -24,11 +24,6 @@
MAZE_SIZE = MAZE_NUM_CELLS*MAZE_CELL_SIZE
?>
-<?lua
- include("templates/pickupRepresentationTemplates.oxt")
- include("includes/pickups.oxi")
- ?>
-
<Template name=destroyhoverpickupRepresentation>
<PickupRepresentation>
<spawner-representation>
@@ -45,19 +40,10 @@
</PickupRepresentation>
</Template>
-<Template name=destroymetapickup baseclass=MetaPickup>
- <MetaPickup representation="destroy" metaType="destroy" />
+<Template name=destroyhoverpickup baseclass=MetaPickup>
+ <MetaPickup representation="destroyhover" metaType="destroy" />
</Template>
-<PickupRepresentation
- name = "destroyhover"
- pickupName = "Destroy Carrier Pickup"
- pickupDescription = "destroys you."
- spawnerTemplate = "destroyhoverpickupRepresentation"
- inventoryRepresentation = "destroyCarrierPickup"
-/>
-
-
<Level
plugins = hover
gametype = Hover
@@ -65,6 +51,7 @@
<templates>
<Template link=lodtemplate_default />
</templates>
+
<?lua include("includes/notifications.oxi") ?>
@@ -76,14 +63,22 @@
gravity = "0, -200, 0"
>
+ <PickupRepresentation
+ name = "destroyhover"
+ pickupName = "Destroy Hover Pickup"
+ pickupDescription = "destroys you."
+ spawnerTemplate = "destroyhoverpickupRepresentation"
+ inventoryRepresentation = "destroyHoverPickup"
+ />
+
<StaticEntity position="0,0,0" collisionType="static">
<attached>
<HoverOrigin
numCells="<?lua print(MAZE_NUM_CELLS)?>"
cellSize="<?lua print(MAZE_CELL_SIZE)?>"
cellHeight="<?lua print(MAZE_CELL_HEIGHT)?>"
- pickuptemplate=destroyhoverpickupRepresentation
- pickupbase=destroymetapickup
+ pickuptemplate=destroyhoverpickup
+ pickuprepresentationtemplate=destroyhoverpickupRepresentation
/>
<Model
position="<?lua print(MAZE_SIZE/2)?>,-16,<?lua print(MAZE_SIZE/2)?>"
Modified: code/branches/tgidronFS16/data/overlays/HoverHUD.oxo
===================================================================
--- code/branches/tgidronFS16/data/overlays/HoverHUD.oxo 2016-04-14 14:05:48 UTC (rev 11168)
+++ code/branches/tgidronFS16/data/overlays/HoverHUD.oxo 2016-04-17 18:40:05 UTC (rev 11169)
@@ -75,13 +75,8 @@
showpoints = true
/>
-
-
</OverlayGroup>
- </OverlayGroup>
-
-
</Template>
Modified: code/branches/tgidronFS16/src/modules/hover/Hover.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/Hover.cc 2016-04-14 14:05:48 UTC (rev 11168)
+++ code/branches/tgidronFS16/src/modules/hover/Hover.cc 2016-04-17 18:40:05 UTC (rev 11169)
@@ -97,14 +97,16 @@
//Generate inner Walls according to levelcode
for(int y=0; y<numCells; y++){
for(int x=0; x<numCells; x++){
- switch(levelcode[ y * numCells + x ]){
+ switch(levelcode[ y * numCells + x ])
+ {
case 1: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
- break;
+ break;
case 3: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 1);
case 2: (new HoverWall(origin_->getContext()))->init(x+1, numCells-y, cellSize, cellHeight, 0);
- default: break;
+ default:
+ break;
}
- }
+ }
}
//Generate 5 flags randomly (test only 1 flag)
@@ -119,24 +121,26 @@
//Generate 5 PickupSpawners randomly
for (int i = 0; i<5; i++)
{
- PickupSpawner* pickup = new PickupSpawner(origin_->getContext());
- pickup->setPosition(rand()%numCells, rand()%numCells, cellSize);
- //pickup->setPickupTemplateName(origin_->getPickupMeta());
- //pickup->setPickupTemplateName("destroymetapickup");
- pickup->setMaxSpawnedItems(5);
- pickup->setRespawnTime(30);
- pickup->setTriggerDistance(5);
- //pickup->createDroppedPickup(this->getContext(), pickup , this, 5);
- pickups_.push_back(pickup);
+ PickupSpawner* pickupSpawner = new PickupSpawner(origin_->getContext());
+
+ pickupSpawner->setPosition(get3dCoordinates(rand()%numCells, rand()%numCells, 10.0f));
+ pickupSpawner->setPickupTemplateName(origin_->getPickupTemplate());
+ pickupSpawner->setMaxSpawnedItems(5);
+ pickupSpawner->setRespawnTime(30);
+ pickupSpawner->setTriggerDistance(5);
+ // Add pickup spawner to the pickup spawner list
+ pickupSpawners_.push_back(pickupSpawner);
}
-
+ orxout() << this->origin_->getPickupTemplate() << endl;
+ orxout() << this->origin_->getPickupRepresentationTemplate() << endl;
}
}
-
- void Hover::startLevel(){
+ // Rename/delete this function.
+ void Hover::startLevel()
+ {
//Generate 5 flags randomly (test only 1 flag)
for ( int i = 0; i < 5; i++ )
{
@@ -151,9 +155,10 @@
PickupSpawner* pickup = new PickupSpawner(origin_->getContext());
//PickupSpawner->setPosition(rand()%numCells, rand()%numCells, cellSize);
//pickup->createDroppedPickup(this->getContext(), pickup , this, 5);
- pickups_.push_back(pickup);
+ pickupSpawners_.push_back(pickup);
}
+
}
void Hover::tick(float dt)
@@ -162,8 +167,10 @@
// Check if ship collided with one of the flags
- for ( unsigned int i = 0; i < flags_.size(); i++ ){
- if(flags_[i]->getCollided()){
+ for ( unsigned int i = 0; i < flags_.size(); i++ )
+ {
+ if(flags_[i]->getCollided())
+ {
flags_[i]->destroyLater();
flags_.erase (flags_.begin()+i);
totFlags++;
@@ -185,4 +192,9 @@
startLevel();
}
+
+ Vector3 Hover::get3dCoordinates(int x, int y, float heightOffset)
+ {
+ return Vector3(x*cellSize*1.0f + cellSize/2, heightOffset, y*cellSize*1.0f + cellSize/2);
+ }
}
Modified: code/branches/tgidronFS16/src/modules/hover/Hover.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/Hover.h 2016-04-14 14:05:48 UTC (rev 11168)
+++ code/branches/tgidronFS16/src/modules/hover/Hover.h 2016-04-17 18:40:05 UTC (rev 11169)
@@ -60,11 +60,11 @@
void levelUp();
void endLevel();
-
-
inline int getNumberOfFlags() const
{ return this->numberOfFlags_; }
+ virtual Vector3 get3dCoordinates(int x, int y, float heightOffset);
+
private:
WeakPtr<HoverOrigin> origin_;
std::vector<HoverFlag*> flags_;
@@ -80,7 +80,7 @@
int totFlags;
- std::vector<PickupSpawner*> pickups_;
+ std::vector<PickupSpawner*> pickupSpawners_;
};
}
Modified: code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc 2016-04-14 14:05:48 UTC (rev 11168)
+++ code/branches/tgidronFS16/src/modules/hover/HoverOrigin.cc 2016-04-17 18:40:05 UTC (rev 11169)
@@ -44,6 +44,9 @@
{
RegisterObject(HoverOrigin);
checkGametype();
+
+ pickupTemplate_ = "";
+ pickupRepresentationTemplate_ = "";
}
void HoverOrigin::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -53,8 +56,8 @@
XMLPortParam(HoverOrigin, "numCells", setNumCells, getNumCells, xmlelement, mode);
XMLPortParam(HoverOrigin, "cellSize", setCellSize, getCellSize, xmlelement, mode);
XMLPortParam(HoverOrigin, "cellHeight", setCellHeight, getCellHeight, xmlelement, mode);
- XMLPortParam(HoverOrigin, "pickuptemplate", setPickup, getPickup, xmlelement, mode);
- XMLPortParam(HoverOrigin, "pickupbase", setPickupMeta, getPickupMeta, xmlelement, mode);
+ XMLPortParam(HoverOrigin, "pickuptemplate", setPickupTemplate, getPickupTemplate, xmlelement, mode);
+ XMLPortParam(HoverOrigin, "pickuprepresentationtemplate", setPickupRepresentationTemplate, getPickupRepresentationTemplate, xmlelement, mode);
}
void HoverOrigin::checkGametype()
Modified: code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h
===================================================================
--- code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h 2016-04-14 14:05:48 UTC (rev 11168)
+++ code/branches/tgidronFS16/src/modules/hover/HoverOrigin.h 2016-04-17 18:40:05 UTC (rev 11169)
@@ -65,15 +65,15 @@
inline int getCellHeight() const
{ return this->cellHeight_; }
- inline void setPickup(std::string pickuptemplate)
- { this->pickupTemplate_ = pickuptemplate; }
- inline std::string getPickup() const
+ inline void setPickupTemplate(std::string pickupTemplate)
+ { this->pickupTemplate_ = pickupTemplate; }
+ inline std::string getPickupTemplate() const
{ return this->pickupTemplate_; }
- inline void setPickupMeta(std::string pickupbase)
- { this->pickupMeta_ = pickupbase; }
- inline std::string getPickupMeta() const
- { return this->pickupMeta_; }
+ inline void setPickupRepresentationTemplate(std::string pickupRepresenationaTemplate)
+ { this->pickupRepresentationTemplate_ = pickupRepresenationaTemplate; }
+ inline std::string getPickupRepresentationTemplate() const
+ { return this->pickupRepresentationTemplate_; }
private:
void checkGametype();
@@ -81,8 +81,10 @@
int numCells_;
int cellSize_;
int cellHeight_;
+
+ // Tempaltes for the destroy hover pickup
std::string pickupTemplate_;
- std::string pickupMeta_;
+ std::string pickupRepresentationTemplate_;
};
}
More information about the Orxonox-commit
mailing list