Пример #1
0
void GameCore::initializeTeleporters()
{
    MapReader* mapReader = mazeBuilder->getMapReader();
    Entity4Position_t* pos;
    int teleporterId = 0;
    Teleporter* teleporter;
    Ogre::Vector3 inPos;
    Ogre::Vector3 outPos;
    float scaleFactor = mapReader->getScaleFactor();
    while ((pos = mapReader->getTeleportEntity()) != NULL)
    {
        inPos = Ogre::Vector3(-pos->startX, 0, pos->startZ) * scaleFactor;
        outPos = Ogre::Vector3(-pos->endX, 0, pos->endZ) * scaleFactor;
        teleporter = new Teleporter(teleporterId, inPos, outPos);
        teleporter->createVisual(sceneManager);
        teleporter->createPhysics(dynamics);
        teleporterMap[teleporterId++] = teleporter;
    }
}
Пример #2
0
void GameCore::initializeItems()
{
    if(mapMode)
    {
        MapReader* mapReader = mazeBuilder->getMapReader();
        int itemId = 0;
        if (mapReader != NULL)
        {
            float scaleFactor = mapReader->getScaleFactor();
            MapEntity2_t* ent;
            std::string meshName="LaserRifle.mesh";
            std::string materialName="LaserRifleItem";
            Ogre::Vector3 meshScale(2,2,2);
            while ((ent = mapReader->getItem()) != NULL)
            {
                if (ent->type == ItemType::LASER_MACHINE_GUN)
                {
                    meshName = "LaserRifle.mesh";
                    materialName = "LaserRifleItem";
                    meshScale=Ogre::Vector3(2,2,2);
                }
                else if(ent->type==ItemType::LASER_PISTOL)
                {
                    meshName="cube.mesh";
                    materialName="LaserPistolItem";
                    meshScale=Ogre::Vector3(.05,.05,.05);
                }
                else if(ent->type==ItemType::EAGLE_EYE)
                {
                    meshName="EagleEye.mesh";
                    materialName="NULL";
                    meshScale=Ogre::Vector3(4,4,4);
                }
                else if(ent->type==ItemType::EXTRA_HEALTH)
                {
                    meshName="Medkit.mesh";
                    materialName="NULL";
                    meshScale=Ogre::Vector3(12,12,12);
                }
				else if(ent->type==ItemType::IMMORTALITY)
				{
					meshName="Immortality.mesh";
					materialName="NULL";
					meshScale=Ogre::Vector3(10,10,10);
				}
				else if(ent->type==ItemType::ONE_SHOT)
				{
					meshName="OneShot.mesh";
					materialName="NULL";
					meshScale=Ogre::Vector3(15,15,15);
				}
                else
                {
                    Logger::getSingleton()->addLine("GameCore: unidentified item read", true);
                    continue;
                }
				Ogre::Vector3 itemPos(-ent->entityPosition.startX*scaleFactor,0,ent->entityPosition.startZ*scaleFactor);
				Ogre::Vector3 startPos=itemPos;
				Ogre::Vector3 endPos=itemPos;
				startPos.y=mazeBuilder->getWallHeight()-10;
				endPos.y=-100;
				btCollisionObject object;
				Ogre::Vector3 hitPos;
				if(PhysicsHandler::performRaycastTest(startPos,endPos,dynamics,&object,&hitPos))
				{
					CollisionObjectInfo* info=(CollisionObjectInfo*)object.getUserPointer();
					std::cout<<"type: "<<info->getObjectType()<<std::endl;
					if(info->getObjectType()==CollisionObjectTypes::GROUND || info->getObjectType()==CollisionObjectTypes::STATIC_OBJECT)
						itemPos.y=hitPos.y;
					else if(info->getObjectType()==CollisionObjectTypes::WALL)
					{
						Logger::getSingleton()->addLine("GameCoreInitializer: item-wall collision detected; item removed",true);
						continue;
					}
				}
				itemPos.y+=10;
                createItem(itemId++, (ItemType::ItemTypes)ent->type, meshName, materialName, meshScale, itemPos);
            }
        }
    }
}