From 36c42123b846d27a7bd940e801ca197dde5bada6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20F=C3=BCndgens?= Date: Fri, 19 Dec 2014 16:15:29 +0100 Subject: [PATCH] Added the option to give a trigger a target composition. The position the trigger activates at is the old manually set position + the position of the target composition. --- Levels/ObjectSetups/Level1.xml | 24 +++++++++++++++++++++++- converter/converter.cc | 21 ++++++++++++--------- level.cc | 29 +++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/Levels/ObjectSetups/Level1.xml b/Levels/ObjectSetups/Level1.xml index 49ad503..6df3c75 100644 --- a/Levels/ObjectSetups/Level1.xml +++ b/Levels/ObjectSetups/Level1.xml @@ -11,15 +11,29 @@ 5 20 - deleteRandomObject + deleteRandomObjectToTheRight 10.0 14.0 5.0 + - + - 3.0 false 0 0 + + deleteRandomObjectAtTorch + 0.0 + 0.0 + 0.0 + 1 + 3 + 2.0 + false + 0 + 0 + @@ -39,6 +53,8 @@ 0.0 0.0 0.0 + - + - 1.0 false 0 @@ -63,6 +79,8 @@ 0.0 0.0 0.0 + - + - 1.0 false 0 @@ -87,6 +105,8 @@ 0.0 0.0 0.0 + - + - 1.0 false 0 @@ -111,6 +131,8 @@ 0.0 0.0 0.0 + - + - 1.0 false 0 diff --git a/converter/converter.cc b/converter/converter.cc index 4470a10..8128a4f 100644 --- a/converter/converter.cc +++ b/converter/converter.cc @@ -163,32 +163,35 @@ std::vector Converter::newComposition(int type, float posX, float posZ){ XMLElement* xPosition = doc->NewElement("xPosition"); XMLElement* yPosition = doc->NewElement("yPosition"); XMLElement* zPosition = doc->NewElement("zPosition"); + XMLElement* targetIdGreen = doc->NewElement("targetIdGreen"); + XMLElement* targetIdBlue = doc->NewElement("targetIdBlue"); XMLElement* distance = doc->NewElement("distance"); XMLElement* isBiggerThan = doc->NewElement("isBiggerThan"); XMLElement* objectNum = doc->NewElement("objectNum"); XMLElement* functionPointer = doc->NewElement("functionPointer"); - //XMLElement* targetIdGreen = doc->NewElement("targetIdGreen"); - //XMLElement* targetIdBlue = doc->NewElement("targetIdBlue"); + name->SetText("-"); - xPosition->SetText("0.0"); - yPosition->SetText("0.0"); - zPosition->SetText("0.0"); + xPosition->SetText("0"); + yPosition->SetText("0"); + zPosition->SetText("0"); + targetIdGreen->SetText("-"); + targetIdBlue->SetText("-"); distance->SetText("1.0"); isBiggerThan->SetText("false"); objectNum->SetText("0"); functionPointer->SetText("-"); - //targetIdGreen->SetText("0"); - //targetIdBlue->SetText("0"); + trigger->InsertEndChild(name); trigger->InsertEndChild(xPosition); trigger->InsertEndChild(yPosition); trigger->InsertEndChild(zPosition); + trigger->InsertEndChild(targetIdGreen); + trigger->InsertEndChild(targetIdBlue); trigger->InsertEndChild(distance); trigger->InsertEndChild(isBiggerThan); trigger->InsertEndChild(objectNum); trigger->InsertEndChild(functionPointer); - //trigger->InsertEndChild(targetIdGreen); - //trigger->InsertEndChild(targetIdBlue); + std::vector ret = nextID; nextID[1] += 1; if (nextID[1] == 255){ diff --git a/level.cc b/level.cc index a787352..146222b 100644 --- a/level.cc +++ b/level.cc @@ -281,14 +281,39 @@ void Level::load() { std::string name = charName; if (name.compare("-") != 0){ float xPos, yPos, zPos, distance; - glm::vec3 position; bool isBigger; int idGreen, idBlue, objectNum, functionPointer_int; + errorCheck(xmlTrigger->FirstChildElement("xPosition")->QueryFloatText(&xPos)); errorCheck(xmlTrigger->FirstChildElement("yPosition")->QueryFloatText(&yPos)); errorCheck(xmlTrigger->FirstChildElement("zPosition")->QueryFloatText(&zPos)); + glm::vec3 position = glm::vec3(xPos, yPos, zPos); + const char* charTarget = xmlTrigger->FirstChildElement("targetIdGreen")->GetText(); + if(charTarget == NULL){ + printf("XMLError: No targetIdGreen found for a trigger.\n"); + } + std::string stringTarget = charTarget; + if (stringTarget.compare("-") != 0){ + int targetIdGreen = 0, targetIdBlue = 0; + errorCheck(xmlTrigger->FirstChildElement("targetIdGreen")->QueryIntText(&targetIdGreen)); + errorCheck(xmlTrigger->FirstChildElement("targetIdBlue")->QueryIntText(&targetIdBlue)); + XMLElement* thisComposition = doc->FirstChildElement("composition"); + for(; thisComposition; thisComposition=thisComposition->NextSiblingElement("composition")){ + int thisIdGreen, thisIdBlue; + errorCheck(thisComposition->FirstChildElement("idGreen")->QueryIntText(&thisIdGreen)); + errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&thisIdBlue)); + if (targetIdGreen == thisIdGreen && targetIdBlue == thisIdBlue){ + glm::vec3 targetPosition; + errorCheck(thisComposition->FirstChildElement("xPos")->QueryFloatText(&targetPosition[0])); + errorCheck(thisComposition->FirstChildElement("yOffset")->QueryFloatText(&targetPosition[1])); + errorCheck(thisComposition->FirstChildElement("zPos")->QueryFloatText(&targetPosition[2])); + targetPosition[1] += terrain.getHeightmap()[int(targetPosition[0]-0.5+0.5*terrain.getHeightmapHeight())] + [int(targetPosition[2]-0.5+0.5*terrain.getHeightmapWidth())]; + position += targetPosition; + } + } + } errorCheck(xmlTrigger->FirstChildElement("distance")->QueryFloatText(&distance)); - position = glm::vec3(xPos, yPos, zPos); errorCheck(xmlTrigger->FirstChildElement("isBiggerThan")->QueryBoolText(&isBigger)); errorCheck(composition->FirstChildElement("idGreen")->QueryIntText(&idGreen)); errorCheck(composition->FirstChildElement("idBlue")->QueryIntText(&idBlue));