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


Java Family类代码示例

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


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

示例1: applyEffect

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@Override
protected void
applyEffect(PooledEngine engine, Entity entity, EffectComponent effectComponent) {
    damageComponent = damageMapper.get(entity);
    if (damageComponent != null) {
        damageComponent.ignoredEntities = null;
    } else {
        damageComponent = engine.createComponent(DamageComponent.class);
        entity.add(damageComponent);
    }
    healthComponent = healthMapper.get(entity);
    if (healthComponent == null) {
        healthComponent = engine.createComponent(HealthComponent.class);
        entity.add(healthComponent);
    }
    oldHealthIgnore = healthComponent.ignoredEntities;
    healthComponent.ignoredEntities = Family.one(ObstacleClass.class, BulletClass.class).get();
}
 
开发者ID:ezet,项目名称:penguins-in-space,代码行数:19,代码来源:InvulnerabilityEffect.java

示例2: PathFindingSystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public PathFindingSystem(int mapHeight, int mapWidth, TiledMap tiledMap) {
    super(Family.all(PathComponent.class, TransformComponent.class).get());

    this.mapHeight = mapHeight;
    this.mapWidth = mapWidth;

    map = new TileType[mapWidth][mapHeight];

    TiledMapTileLayer path = (TiledMapTileLayer) tiledMap.getLayers().get("Path");
    TiledMapTileLayer rocks = (TiledMapTileLayer) tiledMap.getLayers().get("Rocks");
    TiledMapTileLayer bushes = (TiledMapTileLayer) tiledMap.getLayers().get("Bushes");

    for (int x = 0; x < map.length; x++) {
        for (int y = 0; y < map[x].length; y++) {
            if (path.getCell(x, y) != null) {
                map[x][y] = TileType.FLOOR;
            } else if (rocks.getCell(x, y) != null || bushes.getCell(x, y) != null) {
                map[x][y] = TileType.WALL;
            } else {
                map[x][y] = TileType.EMPTY;
            }
        }
    }
}
 
开发者ID:MiniDigger,项目名称:projecttd,代码行数:25,代码来源:PathFindingSystem.java

示例3: intervalSystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@Test
public void intervalSystem () {
	Engine engine = new Engine();
	IntervalIteratingSystemSpy intervalSystemSpy = new IntervalIteratingSystemSpy();
	ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(IntervalComponentSpy.class).get());
	ComponentMapper<IntervalComponentSpy> im = ComponentMapper.getFor(IntervalComponentSpy.class);

	engine.addSystem(intervalSystemSpy);

	for (int i = 0; i < 10; ++i) {
		Entity entity = new Entity();
		entity.add(new IntervalComponentSpy());
		engine.addEntity(entity);
	}

	for (int i = 1; i <= 10; ++i) {
		engine.update(deltaTime);

		for (int j = 0; j < entities.size(); ++j) {
			assertEquals(i / 2, im.get(entities.get(j)).numUpdates);
		}
	}
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:24,代码来源:IntervalIteratingTest.java

示例4: RenderingSystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public RenderingSystem(SpriteBatch batch) {
    super(Family.all(TransformComponent.class, TextureComponent.class).get());

    textureM = ComponentMapper.getFor(TextureComponent.class);
    transformM = ComponentMapper.getFor(TransformComponent.class);


    renderQueue = new Array<Entity>();

    comparator = new Comparator<Entity>() {
        @Override
        public int compare(Entity entityA, Entity entityB) {
            return (int) Math.signum(transformM.get(entityB).pos.z -
                    transformM.get(entityA).pos.z);
        }
    };

    this.batch = batch;

    cam = new OrthographicCamera(FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
    cam.position.set(FRUSTUM_WIDTH / 2, FRUSTUM_HEIGHT / 2, 0);
}
 
开发者ID:DevelopersGuild,项目名称:rebel-invader,代码行数:23,代码来源:RenderingSystem.java

示例5: AttackSystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public AttackSystem(World world,
					Categories categories,
					CollisionHandler handler) {
	super(Family.all(
		AttackComponent.class,
		SpineComponent.class
	).get());
	
	logger.info("initialize");
	this.world = world;
	this.categories = categories;
	this.handler = handler;
	
	AssetManager manager = Env.getGame().getAssetManager();
	laserSfx = manager.get(Env.SFX_FOLDER + "/laser.ogg", Sound.class);
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:17,代码来源:AttackSystem.java

示例6: SensorSystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public SensorSystem(PhysicsSystem physicsSystem)
{
	super(Family.all(PhysicsComponent.class, SensorComponent.class).get());
	
	this.physicsSystem = physicsSystem;
	
	Categories categories = physicsSystem.getCategories();
	
	physicsSystem.getHandler().add(
		categories.getBits("sensor"),
		categories.getBits("player"),
		new SensorPlayerContactListener()
	);
	
	physicsSystem.getHandler().add(
		categories.getBits("sensor"),
		categories.getBits("box"),
		new SensorBoxContactListener()
	);
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:21,代码来源:SensorSystem.java

示例7: CCTvSystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public CCTvSystem(VisionSystem visionSystem, Tags tags) {
	super(Family.all(
		CCTvComponent.class,
		TransformComponent.class,
		AnimationControlComponent.class
	).get());
	
	logger.info("initialize");
	this.visionSystem = visionSystem;
	this.tags = tags;
	this.cctvTags = new CCTVTags();
	
	AssetManager manager = Env.getGame().getAssetManager();
	foundSfx = manager.get(Env.SFX_FOLDER + "/found.ogg");
	alarmSfx = manager.get(Env.SFX_FOLDER + "/alarm.ogg");
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:17,代码来源:CCTvSystem.java

示例8: clearTarget

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public static void clearTarget (Entity target) {
	ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(TargetComponent.class).get());
	
	for (Entity entity : entities) {
		TargetComponent targetComp = Components.TARGET.get(entity);
		if (targetComp.getTarget() == target) {
			targetComp.setTarget(null);

			//Dispatch a message to the entites FSM that there target was removed from the engine
			if (Components.FSM.has(entity)) {
				FSMComponent fsm = Components.FSM.get(entity);
				MessageManager.getInstance().dispatchMessage(null, fsm, TelegramMessage.TARGET_REMOVED.ordinal(), target);
			}
		}

	}
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:18,代码来源:EntityUtils.java

示例9: EntityRenderSystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public EntityRenderSystem () {
	super(Family.one(SpriteComponent.class, SquadComponent.class).get(), new Comparator<Entity>() {

		@Override
		public int compare (Entity e1, Entity e2) {
			if (Components.PARALAX.has(e1) && Components.PARALAX.has(e2)) {
				ParalaxComponent p1 = Components.PARALAX.get(e1);
				ParalaxComponent p2 = Components.PARALAX.get(e2);
				return p1.layer < p2.layer ? 1 : 0;
			} else if (Components.PARALAX.has(e1) || Components.PARALAX.has(e2)) {
				return Components.PARALAX.has(e1) ? -1 : 1;
			} else {
				return 0;
			}

		}
	});

	batch = new SpriteBatch();
	shapeRenderer = new ShapeRenderer();
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:22,代码来源:EntityRenderSystem.java

示例10: clearTarget

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public void clearTarget (Entity target) {
	ImmutableArray<Entity> entities = engine.getEntitiesFor(Family.all(TargetComponent.class, SquadComponent.class).get());
	
	for (Entity squad : entities) {
		SquadComponent squadComp = Components.SQUAD.get(squad);
		squadComp.untrack(squad, target);	//The squad no longer will track the target
		
		TargetComponent targetComp = Components.TARGET.get(squad);
		//If we were targeting that squad we remove it from our target
		if (targetComp.getTarget() == target) {
			targetComp.setTarget(null);

			//Dispatch a message to the entites FSM that there target was removed from the engine
			if (Components.FSM.has(squad)) {
				FSMComponent fsm = Components.FSM.get(squad);
				MessageManager.getInstance().dispatchMessage(null, fsm, TelegramMessage.TARGET_REMOVED.ordinal(), target);
			}
		}

	}
}
 
开发者ID:libgdx-jam,项目名称:GDXJam,代码行数:22,代码来源:SquadEntityListener.java

示例11: printUserData

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public void printUserData() {
    Family market = Family.all(MarketItemComponent.class, PriceComponent.class, NameComponent.class, PriceHistoryComponent.class).get();
    ImmutableArray<Entity> marketItemEntities = entityEngine.getEntitiesFor(market);

    Family players = Family.all(WalletComponent.class, NameComponent.class, InventoryComponent.class).get();
    for (Entity player : entityEngine.getEntitiesFor(players)) {
        NameComponent nc = player.getComponent(NameComponent.class);
        WalletComponent wc = player.getComponent(WalletComponent.class);
        InventoryComponent ic = player.getComponent(InventoryComponent.class);
        System.out.println("Name: " + nc.name);
        ic.printInventory(marketItemEntities);
        long value = ic.getInventoryValue(marketItemEntities);
        System.out.println("Inventory Value: $" + value);
        System.out.println(" Wallet Balance: $" + wc.balance);
        System.out.println("    Total Value: $" + (value + wc.balance));
    }
}
 
开发者ID:ahammer,项目名称:StockSimulator,代码行数:18,代码来源:GameState.java

示例12: printMarketHistory

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public void printMarketHistory() {
    Family market = Family.all(MarketItemComponent.class, PriceComponent.class, NameComponent.class, PriceHistoryComponent.class).get();
    ImmutableArray<Entity> entities = entityEngine.getEntitiesFor(market);

    System.out.println("Current Prices: ");
    for (Entity e : entities) {
        PriceComponent p = e.getComponent(PriceComponent.class);
        NameComponent n = e.getComponent(NameComponent.class);
        PriceHistoryComponent history = e.getComponent(PriceHistoryComponent.class);

        Iterator itr;

        System.out.print(n.name + " Resolution 1 \n");
        itr = history.getPriceHistory().iterator();
        while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");
        System.out.print(n.name + " Resolution 5\n");
        itr = history.getPriceHistorySkipFive().iterator();
        while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");

        System.out.print(n.name + " Resolution 15\n");
        itr = history.getPriceHistorySkipFifteen().iterator();
        while (itr.hasNext()) System.out.print((Integer) itr.next() + "\n");

    }

}
 
开发者ID:ahammer,项目名称:StockSimulator,代码行数:27,代码来源:GameState.java

示例13: DebugUISystem

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
public DebugUISystem(OrthographicCamera camera, SpriteBatch spriteBatch, ShapeRenderer shapeRenderer) {
	super(Family.all(TransformComponent.class).get());
	
	cam = camera;
	batch = spriteBatch;
	shape = shapeRenderer;
	fontSmall = FontFactory.createFont(FontFactory.fontBitstreamVM, 10);
	fontLarge = FontFactory.createFont(FontFactory.fontBitstreamVMBold, 20);
	objects = new Array<Entity>();
	
	
	boolean showInfo = false;
	if (showInfo) {
		System.out.println("\n------- sys info -------");
		System.getProperties().list(System.out);
		System.out.println("-------------------------\n");
		
		/*
		System.out.println(String.format("%s %s", Gdx.graphics.getPpiX(), Gdx.graphics.getPpiY()));
		for (DisplayMode mode : Gdx.graphics.getDisplayModes()) {
			System.out.println(String.format("%s %s %s %s", mode.width, mode.height, mode.bitsPerPixel, mode.refreshRate));
		}
		System.out.println("-------------------------\n");
		*/
	}
}
 
开发者ID:0XDE57,项目名称:SpaceProject,代码行数:27,代码来源:DebugUISystem.java

示例14: update

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void update(float deltaTime) {
	GameEngine engine = App.engine;
	ComponentMappers maps = engine.mappers;
	
	for (DropOffPoint point : points){
		for (Entity e : engine.getEntitiesFor(Family.all(Collector.class).get())){
			Collector c = maps.collector.get(e);
			PhysicsComponent phys = maps.physics.get(e);
			
			if (phys.getPosition().dst(point.position) < point.range){
				totalCivsReturned += c.civilians;
				c.civilians = 0;
			}
			
		}
	}

}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:21,代码来源:CivilianDropOffSystem.java

示例15: processEntity

import com.badlogic.ashley.core.Family; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void processEntity(Entity entity, float deltaTime) {
	ComponentMappers maps =App.engine.mappers;
	PhysicsComponent physics = maps.physics.get(entity);
	Collector collector = maps.collector.get(entity);
	
	for (Entity e : App.engine.getEntitiesFor(Family.all(Collectable.class).get())){
		Collectable c = maps.collectable.get(e);
		PhysicsComponent p = maps.physics.get(e);
		if (c!= null && p != null){
			if (p.getPosition().sub(physics.getPosition()).len() < c.pickupRange){
				if (c.type == Collectable.ItemType.Civilian && collector.civilians < collector.maxCivilians) {
					collector.civilians += 1;
					App.engine.removeEntity(p.ownerEntity);
				}
			}
		}
	}
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:21,代码来源:CollectableSystem.java


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