当前位置: 首页>>代码示例>>Java>>正文


Java SparseArray类代码示例

本文整理汇总了Java中com.watabou.utils.SparseArray的典型用法代码示例。如果您正苦于以下问题:Java SparseArray类的具体用法?Java SparseArray怎么用?Java SparseArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SparseArray类属于com.watabou.utils包,在下文中一共展示了SparseArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TerrainFeaturesTilemap

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public TerrainFeaturesTilemap(SparseArray<Plant> plants, SparseArray<Trap> traps) {
	super(Assets.TERRAIN_FEATURES, new TextureFilm( Assets.TERRAIN_FEATURES, SIZE, SIZE ));

	this.plants = plants;
	this.traps = traps;

	Random.seed( Dungeon.seedCurDepth());
	tileVariance = new float[Dungeon.level.map.length];
	for (int i = 0; i < tileVariance.length; i++)
		tileVariance[i] = Random.Float();
	Random.seed();

	map( Dungeon.level.map, Dungeon.level.width() );

	instance = this;
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:17,代码来源:TerrainFeaturesTilemap.java

示例2: getTopLevelObject

import com.watabou.utils.SparseArray; //导入依赖的package包/类
@Nullable
public LevelObject getTopLevelObject(int pos) {
	LevelObject top = null;

	for (int i = 0; i < objects.size(); i++) {
		SparseArray<LevelObject> objectLayer = objects.valueAt(i);

		LevelObject candidate = objectLayer.get(pos);
		if (top == null) {
			top = candidate;
		} else {
			if (candidate != null && candidate.getLayer() > top.getLayer()) {
				top = candidate;
			}
		}
	}
	return top;
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:19,代码来源:Level.java

示例3: remove

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public boolean remove(LevelObject levelObject) {

		SparseArray<LevelObject> objectsLayer = objects.get(levelObject.getLayer());

		if (objectsLayer == null) {
			return false;
		}

		int index = objectsLayer.indexOfValue(levelObject);

		if (index >= 0) {
			objectsLayer.remove(objectsLayer.keyAt(index));
			return true;
		}
		return false;
	}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:17,代码来源:Level.java

示例4: markObjects

import com.watabou.utils.SparseArray; //导入依赖的package包/类
private static void markObjects() {
	for (int i = 0; i < level.objects.size(); i++) {
		SparseArray<LevelObject> objectLayer = level.objects.valueAt(i);
		for(int j = 0; j < objectLayer.size();j++) {
			LevelObject object = objectLayer.valueAt(j);
			if(object.nonPassable()) {
				passable[object.getPos()] = false;
			}
		}
	}
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:12,代码来源:Dungeon.java

示例5: getLevelObject

import com.watabou.utils.SparseArray; //导入依赖的package包/类
@Nullable
public LevelObject getLevelObject(int pos, int layer) {
	SparseArray<LevelObject> objectsLayer = objects.get(layer);
	if (objectsLayer == null) {
		return null;
	}
	return objectsLayer.get(pos);
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:9,代码来源:Level.java

示例6: putLevelObject

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public void putLevelObject(LevelObject levelObject) {
	SparseArray<LevelObject> objectsLayer = objects.get(levelObject.getLayer());
	if (objectsLayer == null) {
		objectsLayer = new SparseArray<>();
		objects.put(levelObject.getLayer(), objectsLayer);
	}

	objectsLayer.put(levelObject.getPos(), levelObject);
}
 
开发者ID:NYRDS,项目名称:pixel-dungeon-remix,代码行数:10,代码来源:Level.java

示例7: init

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public static void init() {

		challenges = ShatteredPixelDungeon.challenges();
		mapSize = ShatteredPixelDungeon.mapSize();

		Actor.clear();
		Actor.resetNextID();

		Scroll.initLabels();
		Potion.initColors();
		Ring.initGems();

		Statistics.reset();
		Journal.reset();

		quickslot.reset();
		QuickSlotButton.reset();

		depth = 0;
		gold = 0;

		droppedItems = new SparseArray<>();

		for (limitedDrops a : limitedDrops.values())
			a.count = 0;

		chapters = new HashSet<>();

		Ghost.Quest.reset();
		Wandmaker.Quest.reset();
		Blacksmith.Quest.reset();
		Imp.Quest.reset();

		SpecialRoom.initForRun();

		Generator.initArtifacts();

		hero = new Hero();
		hero.live();

		Badges.reset();

		StartScene.curClass.initHero(hero);

		playtest = false;
		sanchikarahtranscend = false;
		shadowyogkilled = false;
		crabkingkilled = false;
		banditkingkilled = false;
		tengukilled = false;
		tengudenkilled = false;
		skeletonkingkilled = false;
		petHasteLevel = 0;
		ratChests = 0;
		shellCharge = 20;
		sporkAvail = false;
		dewWater = false;

		pars = new int[100];

	}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:62,代码来源:Dungeon.java

示例8: restoreFromBundle

import com.watabou.utils.SparseArray; //导入依赖的package包/类
@Override
public void restoreFromBundle(Bundle bundle) {

	if (bundle.contains("width") && bundle.contains("height")) {
		setSize(bundle.getInt("width"), bundle.getInt("height"));
	} else
		setSize(32, 32);

	mobs = new HashSet<Mob>();
	heaps = new SparseArray<Heap>();
	blobs = new HashMap<Class<? extends Blob>, Blob>();
	plants = new SparseArray<Plant>();

	map = bundle.getIntArray(MAP);
	visited = bundle.getBooleanArray(VISITED);
	mapped = bundle.getBooleanArray(MAPPED);

	entrance = bundle.getInt(ENTRANCE);
	exit = bundle.getInt(EXIT);
	currentmoves = bundle.getInt(MOVES);

	locked = bundle.getBoolean(LOCKED);

	cleared = bundle.getBoolean(CLEARED);
	reset = bundle.getBoolean(RESET);
	forcedone = bundle.getBoolean(FORCEDONE);
	genpetnext = bundle.getBoolean(GENPETNEXT);
	sealedlevel = bundle.getBoolean(SEALEDLEVEL);
	viewDistance = bundle.getInt(VIEW);

	weakFloorCreated = false;

	Collection<Bundlable> collection = bundle.getCollection(HEAPS);
	for (Bundlable h : collection) {
		Heap heap = (Heap) h;
		if (!heap.isEmpty())
			heaps.put(heap.pos, heap);
	}

	collection = bundle.getCollection(PLANTS);
	for (Bundlable p : collection) {
		Plant plant = (Plant) p;
		plants.put(plant.pos, plant);
	}

	collection = bundle.getCollection(MOBS);
	for (Bundlable m : collection) {
		Mob mob = (Mob) m;
		if (mob != null) {
			mobs.add(mob);
		}
	}

	collection = bundle.getCollection(BLOBS);
	for (Bundlable b : collection) {
		Blob blob = (Blob) b;
		blobs.put(blob.getClass(), blob);
	}

	feeling = bundle.getEnum(FEELING, Feeling.class);
	if (feeling == Feeling.DARK)
		viewDistance = (int) Math.ceil(viewDistance / 3f);

	buildFlagMaps();
	cleanWalls();
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:67,代码来源:Level.java

示例9: convertTrapsFrom43

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public static int[] convertTrapsFrom43( int[] map, SparseArray<Trap> traps){
	for (int i = 0; i < map.length; i++){

		int c = map[i];

		//non-trap tiles getting their values shifted around
		if (c >= 24 && c <= 26) {
			c -= 4; //24-26 becomes 20-22
		} else if (c == 29) {
			c = 23; //29 becomes 23
		} else if ( c >= 34 && c <= 36) {
			c -= 10; //34-36 becomes 24-26
		} else if ( c >= 41 && c <= 46) {
			c -= 14; //41-46 becomes 27-32
		}

		//trap tiles, must be converted to general trap tiles and specific traps instantiated
		else if (c >= 17 && c <= 40){
			//this is going to be messy...
			Trap trap = null;
			switch(c){
				case 17: trap = new ToxicTrap().reveal(); break;
				case 18: trap = new ToxicTrap().hide(); break;

				case 19: trap = new FireTrap().reveal(); break;
				case 20: trap = new FireTrap().hide(); break;

				case 21: trap = new ParalyticTrap().reveal(); break;
				case 22: trap = new ParalyticTrap().hide(); break;

				case 23:
					c = INACTIVE_TRAP;
					trap = null;
					break;

				case 27: trap = new PoisonTrap().reveal(); break;
				case 28: trap = new PoisonTrap().hide(); break;

				case 30: trap = new AlarmTrap().reveal(); break;
				case 31: trap = new AlarmTrap().hide(); break;

				case 32: trap = new LightningTrap().reveal(); break;
				case 33: trap = new LightningTrap().hide(); break;

				case 37: trap = new GrippingTrap().reveal(); break;
				case 38: trap = new GrippingTrap().hide(); break;

				case 39: trap = new SummoningTrap().reveal(); break;
				case 40: trap = new SummoningTrap().hide(); break;
			}
			if (trap != null){
				trap.set( i );
				traps.put( trap.pos, trap );
				if (trap.visible)
					c = TRAP;
				else
					c = SECRET_TRAP;
				}
		}

		map[i] = c;
	}
	return map;
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:65,代码来源:Terrain.java

示例10: create

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public void create() {
	
	resizingNeeded = false;
	
	map = new int[LENGTH];
	visited = new boolean[LENGTH];
	Arrays.fill( visited, false );
	mapped = new boolean[LENGTH];
	Arrays.fill( mapped, false );
	
	mobs = new HashSet<Mob>();
	heaps = new SparseArray<Heap>();
	blobs = new HashMap<Class<? extends Blob>,Blob>();
	plants = new SparseArray<Plant>();
	
	if (!Dungeon.bossLevel()) {
		addItemToSpawn( Generator.random( Generator.Category.FOOD ) );
		if (Dungeon.posNeeded()) {
			addItemToSpawn( new PotionOfStrength() );
			Dungeon.potionOfStrength++;
		}
		if (Dungeon.souNeeded()) {
			addItemToSpawn( new ScrollOfUpgrade() );
			Dungeon.scrollsOfUpgrade++;
		}
		if (Dungeon.soeNeeded()) {
			addItemToSpawn( new ScrollOfEnchantment() );
			Dungeon.scrollsOfEnchantment++;
		}
		
		if (Dungeon.depth > 1) {
			switch (Random.Int( 10 )) {
			case 0:
				if (!Dungeon.bossLevel( Dungeon.depth + 1 )) {
					feeling = Feeling.CHASM;
				}
				break;
			case 1:
				feeling = Feeling.WATER;
				break;
			case 2:
				feeling = Feeling.GRASS;
				break;
			}
		}
	}
	
	boolean pitNeeded = Dungeon.depth > 1 && weakFloorCreated;
	
	do {
		Arrays.fill( map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL );
		
		pitRoomNeeded = pitNeeded;
		weakFloorCreated = false;
		
	} while (!build());
	decorate();
	
	buildFlagMaps();
	cleanWalls();
	
	createMobs();
	createItems();
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:65,代码来源:Level.java

示例11: restoreFromBundle

import com.watabou.utils.SparseArray; //导入依赖的package包/类
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	mobs = new HashSet<Mob>();
	heaps = new SparseArray<Heap>();
	blobs = new HashMap<Class<? extends Blob>, Blob>();
	plants = new SparseArray<Plant>();
	
	map		= bundle.getIntArray( MAP );
	visited	= bundle.getBooleanArray( VISITED );
	mapped	= bundle.getBooleanArray( MAPPED );
	
	entrance	= bundle.getInt( ENTRANCE );
	exit		= bundle.getInt( EXIT );
	
	weakFloorCreated = false;
	
	adjustMapSize();
	
	Collection<Bundlable> collection = bundle.getCollection( HEAPS );
	for (Bundlable h : collection) {
		Heap heap = (Heap)h;
		if (resizingNeeded) {
			heap.pos = adjustPos( heap.pos );
		}
		heaps.put( heap.pos, heap );
	}
	
	collection = bundle.getCollection( PLANTS );
	for (Bundlable p : collection) {
		Plant plant = (Plant)p;
		if (resizingNeeded) {
			plant.pos = adjustPos( plant.pos );
		}
		plants.put( plant.pos, plant );
	}
	
	collection = bundle.getCollection( MOBS );
	for (Bundlable m : collection) {
		Mob mob = (Mob)m;
		if (mob != null) {
			if (resizingNeeded) {
				mob.pos = adjustPos( mob.pos );
			}
			mobs.add( mob );
		}
	}
	
	collection = bundle.getCollection( BLOBS );
	for (Bundlable b : collection) {
		Blob blob = (Blob)b;
		blobs.put( blob.getClass(), blob );
	}
	
	buildFlagMaps();
	cleanWalls();
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:58,代码来源:Level.java

示例12: init

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public static void init() {

		challenges = YetAnotherPixelDungeon.challenges();
		
		Actor.clear();
		
		PathFinder.setMapSize( Level.WIDTH, Level.HEIGHT );
		
		Scroll.initLabels();
		Potion.initColors();
		Wand.initWoods();
		Ring.initGems();
		
		Statistics.reset();
		Journal.reset();
		
		depth = 0;
		gold = 0;
		
		droppedItems = new SparseArray<ArrayList<Item>>();
		
		potionOfStrength = 0;
		potionOfExperience = 0;
		scrollsOfUpgrade = 0;
		scrollsOfEnchantment = 0;
		ankhs = 0;
//		vials = 0;
		wands = 0;
		rings = 0;
		ammos = 0;
		torches = 0;
//		dewVial = true;
//		transmutation = Random.IntRange( 6, 14 );
		
		chapters = new HashSet<Integer>();
		
		Ghost.Quest.reset();
		Wandmaker.Quest.reset();
		Blacksmith.Quest.reset();
		AmbitiousImp.Quest.reset();
		
		Room.shuffleTypes();

        ShopPainter.initAssortment();

		QuickSlot.quickslotValue_1 = null;
		QuickSlot.quickslotValue_2 = null;
		QuickSlot.quickslotValue_3 = null;

		hero = new Hero();
		hero.live();
		hero.buff( Hunger.class ).satisfy( 0, true );

		Badges.reset();
		
		StartScene.curClass.initHero( hero );
	}
 
开发者ID:ConsideredHamster,项目名称:YetAnotherPixelDungeon,代码行数:58,代码来源:Dungeon.java

示例13: restoreFromBundle

import com.watabou.utils.SparseArray; //导入依赖的package包/类
@Override
public void restoreFromBundle( Bundle bundle ) {

	mobs = new HashSet<Mob>();
	heaps = new SparseArray<Heap>();
	blobs = new HashMap<Class<? extends Blob>, Blob>();
	plants = new SparseArray<Plant>();

	map		= bundle.getIntArray( MAP );
	visited	= bundle.getBooleanArray( VISITED );
	mapped	= bundle.getBooleanArray( MAPPED );

	mobsSpawned = bundle.getInt(MOBS_SPAWNED);

	entrance	= bundle.getInt( ENTRANCE );
	exit		= bundle.getInt( EXIT );

	weakFloorCreated = false;

	adjustMapSize();

	Collection<Bundlable> collection = bundle.getCollection( HEAPS );
	for (Bundlable h : collection) {
		Heap heap = (Heap)h;
		if (resizingNeeded) {
			heap.pos = adjustPos( heap.pos );
		}
		heaps.put( heap.pos, heap );
	}

	collection = bundle.getCollection( PLANTS );
	for (Bundlable p : collection) {
		Plant plant = (Plant)p;
		if (resizingNeeded) {
			plant.pos = adjustPos( plant.pos );
		}
		plants.put( plant.pos, plant );
	}

	collection = bundle.getCollection( MOBS );
	for (Bundlable m : collection) {
		Mob mob = (Mob)m;
		if (mob != null) {
			if (resizingNeeded) {
				mob.pos = adjustPos( mob.pos );
			}
			mobs.add( mob );
		}
	}

	collection = bundle.getCollection( BLOBS );
	for (Bundlable b : collection) {
		Blob blob = (Blob)b;
		blobs.put( blob.getClass(), blob );
	}

	buildFlagMaps();
	cleanWalls();
}
 
开发者ID:ConsideredHamster,项目名称:YetAnotherPixelDungeon,代码行数:60,代码来源:Level.java

示例14: restoreFromBundle

import com.watabou.utils.SparseArray; //导入依赖的package包/类
@Override
public void restoreFromBundle( Bundle bundle ) {
	
	mobs = new HashSet<Mob>();
	heaps = new SparseArray<Heap>();
	blobs = new HashMap<Class<? extends Blob>, Blob>();
	plants = new SparseArray<Plant>();
	
	map		= bundle.getIntArray( MAP );
	visited	= bundle.getBooleanArray( VISITED );
	mapped	= bundle.getBooleanArray( MAPPED );
	
	entrance	= bundle.getInt( ENTRANCE );
	exit		= bundle.getInt( EXIT );

       locked      = bundle.getBoolean( LOCKED );
	
	weakFloorCreated = false;
	
	adjustMapSize();
	
	Collection<Bundlable> collection = bundle.getCollection( HEAPS );
	for (Bundlable h : collection) {
		Heap heap = (Heap)h;
		if (resizingNeeded) {
			heap.pos = adjustPos( heap.pos );
		}
           if (!heap.isEmpty())
		    heaps.put( heap.pos, heap );
	}
	
	collection = bundle.getCollection( PLANTS );
	for (Bundlable p : collection) {
		Plant plant = (Plant)p;
		if (resizingNeeded) {
			plant.pos = adjustPos( plant.pos );
		}
		plants.put( plant.pos, plant );
	}
	
	collection = bundle.getCollection( MOBS );
	for (Bundlable m : collection) {
		Mob mob = (Mob)m;
		if (mob != null) {
			if (resizingNeeded) {
				mob.pos = adjustPos( mob.pos );
			}
			mobs.add( mob );
		}
	}
	
	collection = bundle.getCollection( BLOBS );
	for (Bundlable b : collection) {
		Blob blob = (Blob)b;
		blobs.put( blob.getClass(), blob );
	}

       fallingItems = (ArrayList)bundle.getCollection( FALLING );

	feeling = bundle.getEnum( FEELING, Feeling.class );
	if (feeling == Feeling.DARK)
		viewDistance = (int)Math.ceil(viewDistance/3f);
	
	buildFlagMaps();
	cleanWalls();
}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:67,代码来源:Level.java

示例15: create

import com.watabou.utils.SparseArray; //导入依赖的package包/类
public void create() {

		Random.seed( Dungeon.seedCurDepth() );
		
		if (!(Dungeon.bossLevel() || Dungeon.depth == 21) /*final shop floor*/) {
			addItemToSpawn( Generator.random( Generator.Category.FOOD ) );

			if (Dungeon.posNeeded()) {
				addItemToSpawn( new PotionOfStrength() );
				Dungeon.LimitedDrops.STRENGTH_POTIONS.count++;
			}
			if (Dungeon.souNeeded()) {
				addItemToSpawn( new ScrollOfUpgrade() );
				Dungeon.LimitedDrops.UPGRADE_SCROLLS.count++;
			}
			if (Dungeon.asNeeded()) {
				addItemToSpawn( new Stylus() );
				Dungeon.LimitedDrops.ARCANE_STYLI.count++;
			}

			DriedRose rose = Dungeon.hero.belongings.getItem( DriedRose.class );
			if (rose != null && rose.isIdentified() && !rose.cursed){
				//aim to drop 1 petal every 2 floors
				int petalsNeeded = (int) Math.ceil((float)((Dungeon.depth / 2) - rose.droppedPetals) / 3);

				for (int i=1; i <= petalsNeeded; i++) {
					//the player may miss a single petal and still max their rose.
					if (rose.droppedPetals < 11) {
						addItemToSpawn(new DriedRose.Petal());
						rose.droppedPetals++;
					}
				}
			}
			
			if (Dungeon.depth > 1) {
				switch (Random.Int( 10 )) {
				case 0:
					if (!Dungeon.bossLevel( Dungeon.depth + 1 )) {
						feeling = Feeling.CHASM;
					}
					break;
				case 1:
					feeling = Feeling.WATER;
					break;
				case 2:
					feeling = Feeling.GRASS;
					break;
				case 3:
					feeling = Feeling.DARK;
					addItemToSpawn(new Torch());
					viewDistance = Math.round(viewDistance/2f);
					break;
				}
			}
		}
		
		do {
			width = height = length = 0;

			mobs = new HashSet<>();
			heaps = new SparseArray<>();
			blobs = new HashMap<>();
			plants = new SparseArray<>();
			traps = new SparseArray<>();
			customTiles = new HashSet<>();
			customWalls = new HashSet<>();
			
		} while (!build());
		
		buildFlagMaps();
		cleanWalls();
		
		createMobs();
		createItems();

		Random.seed();
	}
 
开发者ID:00-Evan,项目名称:shattered-pixel-dungeon,代码行数:78,代码来源:Level.java


注:本文中的com.watabou.utils.SparseArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。