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.
This commit is contained in:
parent
55ba919f7e
commit
a5de8e733e
@ -11,15 +11,29 @@
|
||||
<idBlue>5</idBlue>
|
||||
<typeID>20</typeID>
|
||||
<trigger>
|
||||
<name>deleteRandomObject</name>
|
||||
<name>deleteRandomObjectToTheRight</name>
|
||||
<xPosition>10.0</xPosition>
|
||||
<yPosition>14.0</yPosition>
|
||||
<zPosition>5.0</zPosition>
|
||||
<targetIdGreen>-</targetIdGreen>
|
||||
<targetIdBlue>-</targetIdBlue>
|
||||
<distance>3.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>0</objectNum>
|
||||
<functionPointer>0</functionPointer>
|
||||
</trigger>
|
||||
<trigger>
|
||||
<name>deleteRandomObjectAtTorch</name>
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<targetIdGreen>1</targetIdGreen>
|
||||
<targetIdBlue>3</targetIdBlue>
|
||||
<distance>2.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>0</objectNum>
|
||||
<functionPointer>0</functionPointer>
|
||||
</trigger>
|
||||
</composition>
|
||||
|
||||
<composition>
|
||||
@ -39,6 +53,8 @@
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<targetIdGreen>-</targetIdGreen>
|
||||
<targetIdBlue>-</targetIdBlue>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>0</objectNum>
|
||||
@ -63,6 +79,8 @@
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<targetIdGreen>-</targetIdGreen>
|
||||
<targetIdBlue>-</targetIdBlue>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>0</objectNum>
|
||||
@ -87,6 +105,8 @@
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<targetIdGreen>-</targetIdGreen>
|
||||
<targetIdBlue>-</targetIdBlue>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>0</objectNum>
|
||||
@ -111,6 +131,8 @@
|
||||
<xPosition>0.0</xPosition>
|
||||
<yPosition>0.0</yPosition>
|
||||
<zPosition>0.0</zPosition>
|
||||
<targetIdGreen>-</targetIdGreen>
|
||||
<targetIdBlue>-</targetIdBlue>
|
||||
<distance>1.0</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>0</objectNum>
|
||||
|
@ -163,32 +163,35 @@ std::vector<int> 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<int> ret = nextID;
|
||||
nextID[1] += 1;
|
||||
if (nextID[1] == 255){
|
||||
|
29
level.cc
29
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));
|
||||
|
Loading…
Reference in New Issue
Block a user