GameEntitiesContainer EntityFactory::AddWall(int numCols, int numRows, D3DXVECTOR3 position, GameEntitiesContainer gc, bool xWall, string texturepath) { int color; if( xWall ) color = 1; else color = 2; GameEntity* wall = new GameEntity(this->_game); GameMap2GraphicsComponent* graphics; wall->setPosition( D3DXVECTOR3(position.x*20, position.y*20, position.z*20)); if( xWall ) { graphics = new GameMap2GraphicsComponent(numCols, numRows, this->_game, wall, color, D3DXVECTOR3(1, 0, 0), texturepath); wall->AddGraphicsComponent(graphics); WallPointXCollisionComponent* wallCollision = new WallPointXCollisionComponent(this->_game, wall); wall->AddCollisionComponent(wallCollision); wall->setRotation(D3DXVECTOR3(0, 90, 0)); } else { graphics = new GameMap2GraphicsComponent(numCols, numRows, this->_game, wall, color, D3DXVECTOR3(0, 0, 1), texturepath); wall->AddGraphicsComponent(graphics); WallPointCollisionComponent* wallCollision = new WallPointCollisionComponent(this->_game, wall); wall->AddCollisionComponent(wallCollision); } gc.Entities.push_back(wall); gc.Walls.push_back(wall); return gc; }
GameEntitiesContainer EntityFactory::AddFloor(int numRows, int numCols, D3DXVECTOR3 position, GameEntitiesContainer gc) { GameEntity* floor = new GameEntity(this->_game); GameMap1GraphicsComponent* graphics6 = new GameMap1GraphicsComponent(numRows, numCols, this->_game, floor); floor->AddGraphicsComponent(graphics6); floor->setPosition( D3DXVECTOR3(position.x*20, position.y*20, position.z*20)); FloorPointCollisionComponent* floorCollision = new FloorPointCollisionComponent(this->_game, floor); floor->AddCollisionComponent(floorCollision); gc.Entities.push_back(floor); gc.Floors.push_back(floor); return gc; }
GameEntitiesContainer EntityFactory::AddTrapDoor( int numRows, int numCols,GameEntitiesContainer container, D3DXVECTOR3 position, PlayerComponent* player) { D3DXVECTOR3 newPos = D3DXVECTOR3(position.x * 20, position.y * 20, position.z * 20); GameEntity *trapEntity = new GameEntity(this->_game); trapEntity->setPosition(newPos); TrapDoorComponent* trapDoor = new TrapDoorComponent(this->_game, trapEntity); GameMap1GraphicsComponent* graphics6 = new GameMap1GraphicsComponent(numRows, numCols, this->_game, trapEntity); trapEntity->AddGraphicsComponent(graphics6); TrapDoorGraphicsComponent *trapDoorGraphics = new TrapDoorGraphicsComponent(numRows, numCols, trapDoor, this->_game, trapEntity); TrapDoorCollisionComponent *trapDoorCollisions = new TrapDoorCollisionComponent(this->_game, trapEntity, player, trapDoor); trapEntity->AddComponent(trapDoor); trapEntity->AddGraphicsComponent(trapDoorGraphics); trapEntity->AddCollisionComponent(trapDoorCollisions); container.Floors.push_back(trapEntity); container.Entities.push_back(trapEntity); return container; }