本文整理汇总了Java中com.badlogic.gdx.utils.XmlReader.Element.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getChild方法的具体用法?Java Element.getChild怎么用?Java Element.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.XmlReader.Element
的用法示例。
在下文中一共展示了Element.getChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXML(Element root) throws IOException {
super.loadFromXML(root);
story = new Array<QuestState>();
storyTimes = new Array<GameCalendarDate>();
if (isFinished()) {
finishedQuests.add(this);
} else if (isStarted()) {
activeQuests.add(this);
}
variables = new Variables();
variables.loadFromXML(root);
Element storyElement = root.getChildByName(XML_STORY);
if (storyElement != null) {
for (int i = 0; i < storyElement.getChildCount(); ++i) {
Element storyStateElement = storyElement.getChild(i);
story.add(getStateForId(storyStateElement.getAttribute(XMLUtil.XML_ATTRIBUTE_ID)));
GameCalendarDate date = new GameCalendarDate(GameState.getCurrentGameDate().getCalendar());
date.readFromXML(storyStateElement.getChildByName(XML_TIME));
storyTimes.add(date);
}
}
}
示例2: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXML(Element root) throws IOException {
ObjectMap<String, Crime<?>> savedCrimes = new ObjectMap<String, Crime<?>>();
Element crimesElement = root.getChildByName(XML_CRIMES);
for (int i = 0; i < crimesElement.getChildCount(); ++i) {
Crime<?> crime = Crime.readCrime(crimesElement.getChild(i));
savedCrimes.put(crime.getId(), crime);
}
Element factionsElement = root.getChildByName(XML_FACTIONS);
for (int i = 0; i < factionsElement.getChildCount(); ++i) {
Element factionElement = factionsElement.getChild(i);
Faction faction = Faction.getFaction(factionElement.getName());
for (int j = 0; j < factionElement.getChildCount(); ++j) {
addCrime(savedCrimes.get(factionElement.getChild(j).getText()), faction);
}
}
}
示例3: SurvivalHazardConfig
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private SurvivalHazardConfig(Element element) {
for (int i = 0; i < element.getChildCount(); ++i) {
Element stageElement = element.getChild(i);
String name = stageElement.get(XMLUtil.XML_ATTRIBUTE_NAME, "");
String timesString = stageElement.get(XML_TIMES, null);
Integer times = timesString != null ? Integer.valueOf(timesString) : null;
SurvivalHazardStage stage = new SurvivalHazardStage(name);
XMLUtil.readModifiers(stage, stageElement);
if (times == null) {
defaultStage = stage;
} else {
this.stages.put(times, stage);
}
}
}
示例4: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXML(Element root) throws IOException {
Element formationElement = root.getChildByName(XML_FORMATION);
if (formationElement == null) {
return;
}
orientation = Orientation.valueOf(formationElement.getAttribute(XML_FORMATION_ORIENTATION, "UP"));
for (int i = 0; i <formationElement.getChildCount(); ++i) {
Element memberElement = formationElement.getChild(i);
Integer index = Integer.valueOf(memberElement.getAttribute(XML_ATTRIBUTE_INDEX));
int xOffset = Integer.parseInt(memberElement.getAttribute(XML_ATTRIBUTE_XOFFSET, "0"));
int yOffset = Integer.parseInt(memberElement.getAttribute(XML_ATTRIBUTE_YOFFSET, "0"));
formation.put(index, new Tile(xOffset,yOffset));
}
recalculateOrthoFormation();
recalculateIsoFormation();
}
示例5: readActions
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
/**
* Read the actions from the suppled XML element and loads them into the
* supplied ActionsContainer.
*
* The XML element should contain children in the following format:
*
* <pre>
* <actionClassName parameter1Name="parameter1Value" parameter2Name="parameter2Value" ... />
* </pre>
*
* @param ac
* @param actionsElement
*/
@SuppressWarnings({ "unchecked" })
public static void readActions(ActionsContainer ac, Element actionsElement) {
if (actionsElement != null) {
for (int i = 0; i < actionsElement.getChildCount(); ++i) {
Element actionElement = actionsElement.getChild(i);
String implementationClassName = actionElement.getName();
implementationClassName = Action.class.getPackage().getName() + "."
+ StringUtil.capitalizeFirstLetter(implementationClassName);
try {
Class<? extends Action> actionClass = (Class<? extends Action>) ClassReflection
.forName(implementationClassName);
Action newAction = ac.addAction(actionClass);
if (newAction != null) {
newAction.loadFromXML(actionElement);
}
} catch (ReflectionException e) {
throw new GdxRuntimeException(e);
}
}
}
}
示例6: readAllGameObjectsFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private void readAllGameObjectsFromXML(Element root) {
Array<Element> gosElements = root.getChildrenByName(GameSaver.XML_GAME_OBJECTS);
for (Element gosElement : gosElements) {
String mapId = gosElement.getAttribute(GameSaver.XML_MAP, null);
GameMap map = mapId == null ? null : mapsById.get(mapId);
Array<GameObject> gosForMap = new Array<GameObject>();
if (map != null) {
gosToMaps.put(map, gosForMap);
}
for (int i = 0; i < gosElement.getChildCount(); ++i) {
Element goElement = gosElement.getChild(i);
GameObject go = (GameObject) createFromXML(gameState, goElement);
gosForMap.add(go);
}
}
}
示例7: addChildrens
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private void addChildrens(Element element, Table table) {
int childCount = element.getChildCount();
for (int x = 0; x < childCount; x++) {
Element child = element.getChild(x);
if (child.getName().equalsIgnoreCase("button")) {
addButton(table, child);
} else if (child.getName().equalsIgnoreCase("row")) {
addRow(table);
} else if (child.getName().equalsIgnoreCase("list")) {
addList(table, child);
} else if (child.getName().equalsIgnoreCase("scroll-panel")) {
addScrollPanel(table, child);
} else if (child.getName().equalsIgnoreCase("image")) {
addImage(table, child);
} else if (child.getName().equalsIgnoreCase("label")) {
addLabel(table, child);
} else if (child.getName().equalsIgnoreCase("text-area")) {
addTextArea(table, child);
} else if (child.getName().equalsIgnoreCase("table")) {
addTable(table, child);
} else if (child.getName().equalsIgnoreCase("text-field")) {
addTextField(table, child);
} else if (child.getName().equalsIgnoreCase("window")) {
addWindow(table, child);
} else if (child.getName().equalsIgnoreCase("vertical-group")) {
addVerticalGroup(table, child);
} else if (child.getName().equalsIgnoreCase("horizontal-group")) {
addHorizontalGroup(table, child);
}
}
}
示例8: readAllLocationsFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private void readAllLocationsFromXML(Element root) throws IOException {
Array<Element> locationsElements = root.getChildrenByName(GameSaver.XML_LOCATIONS);
for (Element locationsElement : locationsElements) {
String mapId = locationsElement.getAttribute(GameSaver.XML_MAP, null);
if (mapId == null) {
continue;
}
GameMap map = null;
for (int i = 0; i < locationsElement.getChildCount(); ++i) {
Element locElement = locationsElement.getChild(i);
GameLocation loc = (GameLocation) createFromXML(gameState, locElement);
// the first location is the map itself, the others are those that belong to it
// its okay if this dies on a class cast, since if this is not true, then everything is terrible
if (i == 0) {
map = (GameMap) loc;
} else {
loc.setMap(map);
// load any "master data" from the xml file
loc.loadFromXML(Gdx.files.internal(Configuration
.getFolderLocations() + loc.getType() + ".xml"));
// and then reload it from the savegame to override any changes
// TODO this currently means the savegame element is read twice, this should be optimized
loc.loadFromXML(locElement);
}
gameState.addLocation(loc);
}
}
}
示例9: readTargetType
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
/**
* Reads the target type from the supplied element.
*
* @param ttc
* @param targetElement
*/
public static void readTargetType(TargetTypeContainer ttc, Element targetElement) {
if (targetElement == null) {
return;
}
targetElement = targetElement.getChild(0);
if (targetElement != null) {
ttc.setTargetType(StringUtil.capitalizeFirstLetter(targetElement.getName()),
readScript("targetType_" + ttc.getId(), targetElement));
}
}
示例10: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXML(Element root) {
s_canBeCast = true;
super.loadFromXML(root);
foci = new ObjectMap<String, Boolean>();
Element fociElement = root.getChildByName(XML_FOCI);
if (fociElement != null) {
for (int i = 0; i < fociElement.getChildCount(); ++i) {
Element focusElement = fociElement.getChild(i);
String itemID = focusElement.getAttribute(XMLUtil.XML_ATTRIBUTE_ID);
boolean consumed = focusElement.getBooleanAttribute(XML_ATTRIBUTE_CONSUMED, false);
foci.put(itemID, consumed);
}
}
}
示例11: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public void loadFromXML(Element root) throws IOException {
super.loadFromXML(root);
if (s_model != null) {
try {
animations = new CharacterAnimationMap(s_model, s_audioProfile, getSpeed());
} catch (IOException e) {
throw new GdxRuntimeException("Problem loading animation for character "+getInternalId(),e);
}
}
characterCircle.setColor(ColorUtil.WHITE_FIFTY);
destinationIndicator.setColor(ColorUtil.WHITE_FIFTY);
brain.loadFromXML(root);
getFaction().addMember(this);
Element tempHostilityElement = root.getChildByName(XML_TEMPORARY_HOSTILITY);
if (tempHostilityElement != null) {
for(int i = 0; i < tempHostilityElement.getChildCount(); ++i) {
Element hostilityElement = tempHostilityElement.getChild(i);
Integer duration = Integer.parseInt(hostilityElement.get(XML_DURATION));
GameCalendarDate start = new GameCalendarDate(gameState.getCalendar());
start.readFromXML(hostilityElement.getChildByName(XML_START));
temporaryHostility.put(Faction.getFaction(hostilityElement.getName()), new Pair<GameCalendarDate, Integer>(start, duration));
}
}
resetCharacterCircleColor();
Element visited = root.getChildByName(XML_VISITED);
if (visited != null) {
String visitedLocations = visited.getText();
String[] locations = visitedLocations.split(",");
for (String location : locations) {
this.visitedLocations.add(location.trim());
}
}
}
示例12: loadFromXMLNoInit
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXMLNoInit(FileHandle file) throws IOException {
XmlReader xmlReader = new XmlReader();
Element root = xmlReader.parse(file);
XMLUtil.handleImports(this, file, root);
XMLUtil.readPrimitiveMembers(this, root);
Element indicatorElement = root.getChildByName(XML_INDICATOR);
if (indicatorElement != null) {
indicator = new ParticleEffectDescriptor(indicatorElement);
indicatorNoDelay = new ParticleEffectDescriptor(indicator.getEffectId(), 0, indicator.getXOffset(), indicator.getYOffset());
}
onHitScript = XMLUtil.readScript(id, root.getChildByName(XML_ON_HIT), onHitScript);
durationScript = XMLUtil.readScript(id, root.getChildByName(XML_DURATION), durationScript);
onEndScript = XMLUtil.readScript(id, root.getChildByName(XML_ON_END), onEndScript);
persistentScript = XMLUtil.readScript(id, root.getChildByName(XML_PERSISTENT), persistentScript);
conditionScript = XMLUtil.readScript(id, root.getChildByName(XML_CONDITION), conditionScript);
Element descriptionElement = root.getChildByName(XML_DESCRIPTION);
if (descriptionElement != null) {
descriptionParamsScript = XMLUtil.readScript(id, descriptionElement.getChildByName(XML_EXTRA_PARAMETERS), descriptionParamsScript);
}
Element parametersElement = root.getChildByName(XMLUtil.XML_PARAMETERS);
if (parametersElement != null) {
for (int i = 0; i < parametersElement.getChildCount(); ++i) {
Element parameterElement = parametersElement.getChild(i);
parameters.add(EffectParameterDefinition.readFromXML(parameterElement));
}
}
Element typesElement = root.getChildByName(XML_TYPE);
if (typesElement != null && !typesElement.getText().isEmpty()) {
String[] types = typesElement.getText().split(",");
for (String type : types) {
this.types.add(type.trim().toUpperCase(Locale.ENGLISH));
}
}
}
示例13: validateAndLoadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void validateAndLoadFromXML(Element actionElement) {
if (actionElement.getChildCount() < 1) {
throw new GdxRuntimeException("AddAction must have at least one child element!");
}
this.actionElement = actionElement.getChild(0);
}
示例14: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public void loadFromXML(Element root) throws IOException {
XMLUtil.readPrimitiveMembers(this, root.getChildByName(XMLUtil.XML_PROPERTIES));
variables.loadFromXML(root);
position.loadFromXML(root);
XMLUtil.readActions(this, root.getChildByName(XMLUtil.XML_ACTIONS));
Element forbiddenActionsElement = root.getChildByName(XML_FORBIDDEN_ACTIONS);
if (forbiddenActionsElement != null) {
for (int i = 0; i < forbiddenActionsElement.getChildCount(); ++i) {
Element forbiddenByElement = forbiddenActionsElement.getChild(i);
String forbiddenBy = forbiddenByElement.getAttribute(XMLUtil.XML_ATTRIBUTE_ID);
Array<String> forbidden = new Array<String>();
for (int j = 0; j < forbiddenByElement.getChildCount(); ++j) {
forbidden.add(StringUtil.capitalizeFirstLetter(forbiddenByElement.getChild(j).getName()));
}
forbiddenActions.put(forbiddenBy, forbidden);
}
}
if (isGlobal()) {
gameState.addGameObject(this);
}
if (map == null) {
gameState.addUnassignedGameObject(this);
}
}
示例15: readQuestsFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private static void readQuestsFromXML(Element root) throws IOException {
Element questsElement = root.getChildByName(GameSaver.XML_QUESTS);
for (int i = 0; i < questsElement.getChildCount(); ++i) {
Element questElement = questsElement.getChild(i);
Quest quest = Quest.getQuest(questElement.getName());
quest.loadFromXML(questElement);
}
}