本文整理匯總了Java中com.badlogic.gdx.utils.ObjectMap.containsKey方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMap.containsKey方法的具體用法?Java ObjectMap.containsKey怎麽用?Java ObjectMap.containsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.ObjectMap
的用法示例。
在下文中一共展示了ObjectMap.containsKey方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: spreadCrimeInfo
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
/**
* This will spread information about crimes known to fromFaction but
* unknown to toFaction from the one to the other.
*
* @param fromFaction
* @param toFaction
*/
public void spreadCrimeInfo(Faction fromFaction, Faction toFaction) {
Array<Crime<?>> crimesKnownToFromFaction = trackedCrimes.get(fromFaction);
if (crimesKnownToFromFaction == null) {
return;
}
ObjectMap<Faction, Integer> penalties = new ObjectMap<Faction, Integer>();
for (Crime<?> crime : crimesKnownToFromFaction) {
if (addCrime(crime, toFaction)) {
Faction perpFaction = crime.getPerpetrator().getFaction();
int penalty = crime.getDispositionPenalty()/2;
if (penalties.containsKey(perpFaction)) {
penalties.put(perpFaction, penalties.get(perpFaction)+penalty);
} else {
penalties.put(perpFaction, penalty);
}
}
}
for (Entry<Faction, Integer> entry : penalties.entries()) {
toFaction.modifyDisposition(entry.key, -entry.value);
}
}
示例2: addModifierToReturnValue
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
private void addModifierToReturnValue(ObjectMap<ModifiableStat, Array<Modifier>> returnValue, ModifiableStat stat, Modifier modifier) {
Array<Modifier> modifiers;
if (!returnValue.containsKey(stat)) {
modifiers = new Array<Modifier>();
returnValue.put(stat, modifiers);
} else {
modifiers = returnValue.get(stat);
}
modifiers.add(modifier);
}
示例3: load
import com.badlogic.gdx.utils.ObjectMap; //導入方法依賴的package包/類
/**
* Internal method.
*
* <p>Handles loading both music and sounds from
* directories.</p>
*/
private void load(File rootDirectory, Class<? extends Audio> audioClass) {
String resourceName = audioClass == Music.class ? "Music" : "Sound";
String resourceNamePlural = audioClass == Music.class ? "Music" : "Sound(s)";
log.info("Loading " + resourceNamePlural.toLowerCase() + " from directory "
+ rootDirectory.getAbsolutePath());
ObjectMap<String, File> files = FileUtil.loadWithIdentifiers(rootDirectory, file -> {
String fileName = file.getName();
return fileName.endsWith(".ogg") || fileName.endsWith(".wav")
|| fileName.endsWith(".mp3");
});
ObjectMap<String, Audio> targetMap;
if (audioClass == Music.class) {
targetMap = this.music;
} else {
targetMap = this.sounds;
}
for (String key : files.keys()) {
File audioFile = files.get(key);
try {
if (targetMap.containsKey(key)) {
log.warn(resourceName + " file " + audioFile.getAbsolutePath()
+ " is replacing a previous entry under the key " + key);
}
targetMap.put(key,
audioClass == Music.class ? new MusicFactory(key, this, audioFile)
: new SoundFactory(key, this, audioFile));
log.info("Loaded " + resourceName.toLowerCase() + " " + audioFile.getName()
+ " under key " + key);
} catch (UnsupportedAudioFileException e) {
log.error("Failed to load " + resourceName.toLowerCase() + " file "
+ audioFile.getAbsolutePath() + " (unsupported filetype, .ogg/.wav/.mp3 only)");
}
}
log.info(targetMap.size + " " + resourceNamePlural.toLowerCase()
+ (audioClass == Music.class ? " tracks(s)" : "") + " loaded.");
}