本文整理汇总了Java中com.badlogic.ashley.utils.ImmutableArray.get方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableArray.get方法的具体用法?Java ImmutableArray.get怎么用?Java ImmutableArray.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.ashley.utils.ImmutableArray
的用法示例。
在下文中一共展示了ImmutableArray.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
/**
* Updates all the systems in this Engine.
* @param deltaTime The time passed since the last frame.
*/
public void update(float deltaTime){
if (updating) {
throw new IllegalStateException("Cannot call update() on an Engine that is already updating.");
}
updating = true;
ImmutableArray<EntitySystem> systems = systemManager.getSystems();
for (int i = 0; i < systems.size(); ++i) {
EntitySystem system = systems.get(i);
if (system.checkProcessing()) {
system.update(deltaTime);
}
componentOperationHandler.processOperations();
entityManager.processPendingOperations();
}
updating = false;
}
示例2: update
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
/**
* Updates all the systems in this Engine.
* @param deltaTime The time passed since the last frame.
*/
public void update(float deltaTime){
if (updating) {
throw new IllegalStateException("Cannot call update() on an Engine that is already updating.");
}
updating = true;
ImmutableArray<EntitySystem> systems = systemManager.getSystems();
try {
for (int i = 0; i < systems.size(); ++i) {
EntitySystem system = systems.get(i);
if (system.checkProcessing()) {
system.update(deltaTime);
}
while(componentOperationHandler.hasOperationsToProcess() || entityManager.hasPendingOperations()) {
componentOperationHandler.processOperations();
entityManager.processPendingOperations();
}
}
}
finally {
updating = false;
}
}
示例3: addFishflock
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
private static void addFishflock(Engine engine, int nrX, int nrY, int nrZ, float margin){
Boid protoypeBoid = new Boid();
protoypeBoid.influence = 0.3f;
Maker maker = new Maker().setMesh("assets/models/zierfisch.obj")
.setShader("assets/shaders/cc/fish.vert.glsl", "assets/shaders/cc/fish.frag.glsl")
.setTexture(0, "assets/textures/fish-diffuse.png")
.setTexture(1, "assets/textures/fish-emission.png")
.setTexture(4, "assets/textures/fog-gradient-03.png")
.setScale(0.5f)
.add(protoypeBoid);
Vector3f center = new Vector3f(0,0,-5);
for(int x = 0; x < nrX; x++){
for(int y = 0; y < nrY; y++){
for(int z = 0; z < nrZ; z++){
Entity fish = maker.setPosition(
x*margin - (nrX-1)*margin/2 + center.x,
y*margin - (nrY-1)*margin/2 + center.y,
z*margin - (nrZ-1)*margin/2 + center.z
).build();
engine.addEntity(fish);
}
}
}
ImmutableArray<Entity> allEnts = engine.getEntities();
Entity randomEnt1 = allEnts.get(allEnts.size() - 1);
Light light1 = new Light();
light1.color.set(.3f, 0.9f, 1f);
light1.intensity = 0.7f;
randomEnt1.add(light1);
/*Entity startLight = new Entity();
startLight.add(new Light());
startLight.add(new Pose());
startLight.getComponent(Light.class).color.set(1.0f, 0.7f, 0.94f);
startLight.getComponent(Light.class).intensity = 0.01f;
startLight.getComponent(Pose.class).position.y = 1.0f;
engine.addEntity(startLight);*/
/*
Entity randomEnt2 = allEnts.get((int) (Math.random() * allEnts.size()));
Light light2 = new Light();
light2.color.set(.6f, 1f, 1f);
light2.intensity = 1.0f;
randomEnt2.add(light2);
Entity randomEnt3 = allEnts.get((int) (Math.random() * allEnts.size()));
Light light3 = new Light();
light3.color.set(.7f, 1f, 1f);
light3.intensity = 10.0f;
randomEnt3.add(light3);*/
}
示例4: show
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
@Override
public void show() {
Objects.camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Objects.world = new World(new Vector2(0,0), false);
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1f);
entityEngine = new Engine();
entityEngine.addEntity(EntityUtils.createPlayer());
entityEngine.addSystem(new RemoveEntityTimerSystem());
entityEngine.addSystem(new PlayerSystem());
entityEngine.addSystem(new AStarSystem());
entityEngine.addSystem(new Box2DToSpritePositionSystem());
entityEngine.addSystem(new LightFollowPlayerSystem());
entityEngine.addSystem(new MapControllerSystem(game));
entityEngine.addSystem(new RendererSystem());
entityEngine.addSystem(new Box2DLightsSystem());
//entityEngine.addSystem(new Box2DDebugRendererSystem());
entityEngine.addSystem(new DrawInfoSystem());
entityEngine.addSystem(new DrawPossibleFloorPlacementsSystem());
entityEngine.addSystem(new RemoveFloorSystem());
ImmutableArray<EntitySystem> systems = entityEngine.getSystems();
for(int i = 0; i < systems.size(); i++){ // It must have a Initializable
Initializable init = (Initializable) systems.get(i);
init.init();
}
for(int i = 0; i < systems.size(); i++){ // It must not have a Createable
if(systems.get(i) instanceof Createable){
Createable create = (Createable) systems.get(i);
create.create();
}
}
Objects.camera.zoom = Values.CAMERA_ZOOM;
Objects.camera.translate(new Vector2(CameraSize.getWidth() / 2, CameraSize.getHeight() / 2));;
}
示例5: update
import com.badlogic.ashley.utils.ImmutableArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void update(float deltaTime) {
//Get all collidable entities
ImmutableArray<Entity> entities = engine.getEntitiesFor(
Family.all(Position.class, Bound.class).get());
//Construct the circles to represent the bounds
final List<Circle> bounds = new ArrayList<Circle>();
for(Entity entity : entities) {
final Vector2 position = Util.unprojectVector(Mappers.positionMapper.get(entity).getPosition());
final Bound bound = Mappers.boundMapper.get(entity);
bounds.add(new Circle(position.x, position.y, bound.radius)); //FIXME might have to consider unprojected coordinates.
}
checkA: for(int i = 0; i < bounds.size(); i++) {
Entity entityA = entities.get(i);
Circle circleA = bounds.get(i);
checkB : for(int j = 0; j < bounds.size(); j++) {
Entity entityB = entities.get(j);
Circle circleB = bounds.get(j);
if(circleA.overlaps(circleB)) {
//System.out.println("#CollisionSystem# COLLISION!!!!");
if(Mappers.projectileMapper.has(entityA) && Mappers.killableMapper.has(entityB)) {
//System.out.println("#CollisionSystem# Projectile collided with killable!!!!");
Projectile projectile = Mappers.projectileMapper.get(entityA);
Killable killable = Mappers.killableMapper.get(entityB);
if(projectile.friendly && Mappers.enemyMapper.has(entityB) ||
!projectile.friendly && Mappers.turretMapper.has(entityB)) {
AudioManager.play(AudioName.HIT_IMPACT);
switch (projectile.type) {
case SINGLE: {
engine.addEntity(EntityFactory.explosion(Mappers.positionMapper.get(entityA).getPosition(), 1f));
killable.removeHealth(projectile.damage);
//Decrement the hopcount and only remove if 0;
projectile.hopCount -= 1;
if(projectile.hopCount <= 0) engine.removeEntity(entityA);
break;
}
}
}
}
}
}
}
}