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


Java Entity.getComponent方法代码示例

本文整理汇总了Java中com.artemis.Entity.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getComponent方法的具体用法?Java Entity.getComponent怎么用?Java Entity.getComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.artemis.Entity的用法示例。


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

示例1: initialize

import com.artemis.Entity; //导入方法依赖的package包/类
@Override
protected void initialize() {
    super.initialize();

    addBackground();
    addLogo();

    final Entity featureEntity = tagManager.getEntity(OdbFeatureDetectionSystem.FEATURES_TAG);
    final OdbFeatureComponent featureComponent = featureEntity.getComponent(OdbFeatureComponent.class);

    addFeatureIcon(featureComponent.isHotspotOptimization, "feature-hotspot");
    addFeatureIcon(featureComponent.isPacked, "feature-packed");
    addFeatureIcon(featureComponent.isPooled, "feature-pooled");
    addFeatureIcon(featureComponent.isFactory, "feature-factory");

    scheduleTransitionToGameScreen();
}
 
开发者ID:DaanVanYperen,项目名称:odb-artax,代码行数:18,代码来源:FeatureScreenSetupSystem.java

示例2: initialize

import com.artemis.Entity; //导入方法依赖的package包/类
@Override
protected void initialize() {
	super.initialize();

	addBackground();
	addLogo();

	final Entity featureEntity = tagManager.getEntity(OdbFeatureDetectionSystem.FEATURES_TAG);
	final OdbFeatureComponent featureComponent = featureEntity.getComponent(OdbFeatureComponent.class);

	addFeatureIcon(featureComponent.isHotspotOptimization, "feature-hotspot");
	addFeatureIcon(featureComponent.isPacked, "feature-packed");
	addFeatureIcon(featureComponent.isPooled, "feature-pooled");
	addFeatureIcon(featureComponent.isFactory, "feature-factory");

	scheduleTransitionToGameScreen();
}
 
开发者ID:DaanVanYperen,项目名称:odb-dynasty,代码行数:18,代码来源:FeatureScreenSetupSystem.java

示例3: respawnPlayer

import com.artemis.Entity; //导入方法依赖的package包/类
public void respawnPlayer() {
	
	float spawnX = 1222;
	spawnX = 722;
	float spawnY = getLevelSizeY() - 17682;
	
	Entity ent = getPlayerEntity();
	if (ent != null) {
		Health health = ent.getComponent(Health.class);
		health.reset();
		
		Position pos = ent.getComponent(Position.class);
		pos.setPos(spawnX, spawnY);
	} else {
		//setPlayer(EntityFactory.createPlayer(100, 100).getId());
		SpawnableBase base = EntityFactory.getEntity(SpawnableTypes.SPRITE_PLAYER);
		setPlayer(base.prepareFromData(levelID, spawnX, spawnY, EntityData.TEAM_PLAYER).getId());
		//setPlayer(EntityFactory.createEntity_Player(getLevelID(), spawnX, spawnY).getId());
	}
	
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:22,代码来源:Level.java

示例4: checkCanKickBomb

import com.artemis.Entity; //导入方法依赖的package包/类
protected boolean checkCanKickBomb(Body body, Vector2 fromV, Vector2 toV) {
    World b2dWorld = body.getWorld();
    kickingBomb = null;
    kicking = false;

    RayCastCallback rayCastCallback = new RayCastCallback() {

        @Override
        public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
            if (fixture.getFilterData().categoryBits == GameManager.BOMB_BIT) {
                Entity bombEntity = (Entity) fixture.getBody().getUserData();
                kickingBomb = bombEntity.getComponent(Bomb.class);
                return 0;
            }
            return 0;
        }
    };

    b2dWorld.rayCast(rayCastCallback, fromV, toV);
    if (kickingBomb != null) {
        kicking = true;
    }
    return kicking;
}
 
开发者ID:yichen0831,项目名称:Bomberman_libGdx,代码行数:25,代码来源:PlayerSystem.java

示例5: checkCanExplodeThrough

import com.artemis.Entity; //导入方法依赖的package包/类
private boolean checkCanExplodeThrough(Vector2 fromV, Vector2 toV) {
    canExplodeThrough = true;
    RayCastCallback rayCastCallback = new RayCastCallback() {

        @Override
        public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) {
            if (fixture.getFilterData().categoryBits == GameManager.INDESTRUCTIIBLE_BIT) {
                canExplodeThrough = false;
                return 0;
            }

            if (fixture.getFilterData().categoryBits == GameManager.BREAKABLE_BIT) {
                canExplodeThrough = false;
                Entity e = (Entity) fixture.getBody().getUserData();
                Breakable breakable = e.getComponent(Breakable.class);
                breakable.state = Breakable.State.EXPLODING;
                return 0;
            }
            return 0;
        }
    };

    b2dWorld.rayCast(rayCastCallback, fromV, toV);
    return canExplodeThrough;
}
 
开发者ID:yichen0831,项目名称:Bomberman_libGdx,代码行数:26,代码来源:ActorBuilder.java

示例6: added

import com.artemis.Entity; //导入方法依赖的package包/类
@Override
public void added(Entity e) {
    EnablableComponent c = e.getComponent(EnablableComponent.class);
    if (c != null) {
        c.setEnabled(true);
        if (c instanceof ScriptableComponent) ((ScriptableComponent)c).awake();
    }
}
 
开发者ID:AlexMog,项目名称:SurvivalMMO,代码行数:9,代码来源:EnableManager.java

示例7: createBoss

import com.artemis.Entity; //导入方法依赖的package包/类
public static Entity createBoss(int x, int y, int level) {
    Entity boss = createMonster(x, y, level);
    boss.addComponent(new Named("The Jailer"));
    boss.addComponent(new Reward(Score.POINTS_KILL_JAILER));
    boss.getComponent(Animation.class).id = "boss";
    Color color = boss.getComponent(Animation.class).color;
    Tox.world.getManager(TagManager.class).register(BOSS_TAG, boss);
    return boss;
}
 
开发者ID:DaanVanYperen,项目名称:tox,代码行数:10,代码来源:EntityFactory.java

示例8: cloneLegacyPlayer

import com.artemis.Entity; //导入方法依赖的package包/类
/**
 * Quick hack to transfer player state to the next level.
 *
 * Kinda funky stuff here. Be weary!
 *
 * @param x
 * @param y
 * @param legacyPlayer
 * @return
 */
public static Entity cloneLegacyPlayer(int x, int y, Entity legacyPlayer) {

    Entity player = copyEntityFromOldWorld(legacyPlayer);

    player.getComponent(Toxication.class).toxication = 0.5f;
    player.getComponent(Health.class).damage = 0;

    Position position = player.getComponent(Position.class);
    position.x = x; position.y = y;

    // copy over the old inventory.
    Inventory oldInventory = legacyPlayer.getComponent(Inventory.class);


    Inventory inventory = player.getComponent(Inventory.class);
    {
        for ( int i =0; i<3;i++)
        {
            if ( oldInventory.carried[i] != null )
            {
                inventory.carried[i] = copyEntityFromOldWorld(oldInventory.carried[i]);
                inventory.carried[i].addToWorld();
            }
        }

    }

    Tox.world.getManager(TagManager.class).register(EntityFactory.PLAYER_TAG, player);

    return player;
}
 
开发者ID:DaanVanYperen,项目名称:tox,代码行数:42,代码来源:EntityUtils.java

示例9: addMovingStarParticle

import com.artemis.Entity; //导入方法依赖的package包/类
public Entity addMovingStarParticle(int cx, int cy) {
    Entity starParticle = addStarParticle(cx, cy);
    Animation anim = starParticle.getComponent(Animation.class);
    anim.layer = Animation.Layer.SCREEN_PARTICLE2;
    anim.scale = MathUtils.random(0.25f,0.75f);
    Physics physics = new Physics();
    physics.velocityX = MathUtils.random(-50f,50f) * 5f;
    physics.velocityY = MathUtils.random(25f,75f) * 5f;
    physics.gravity = 9.8f * 0.5f;
    starParticle.addComponent(physics);
    return starParticle;
}
 
开发者ID:DaanVanYperen,项目名称:tox,代码行数:13,代码来源:ParticleSystem.java

示例10: tick

import com.artemis.Entity; //导入方法依赖的package包/类
public void tick() {
	//testing contrib graph use of commits and merged branches
	
	//System.out.println("AI tick!");
	
	Entity ent = Game_AI_TestBed.instance().getLevel(levelID).getWorld().getEntity(entID);
	Position pos = ent.getComponent(Position.class);
	
	int pathFollowAccuracy = 4;
	
	//pathfollow
	if (blackboard.hasPath()) {
		IntPair pointTile = blackboard.getPathPoint();
		Vector2f pointCoord = new Vector2f((pointTile.x * Cst.TILESIZE) + (Cst.TILESIZE / 2), (pointTile.y * Cst.TILESIZE) + (Cst.TILESIZE / 2));
		
		float dist = VecUtil.getDist(pointCoord, pos.toVec());
		
		//was moveTo
		blackboard.setPosTarget(pointCoord);
		
		if (dist < pathFollowAccuracy) {
			//System.out.println("inc point!");
			blackboard.incPathPoint();
		} else {
			//System.out.println("pathnav to " + dist);
			
		}
	} else {
		//System.out.println("no path");
	}
	
	//test
	behavior.tick();
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:35,代码来源:Agent.java

示例11: prepareFromData

import com.artemis.Entity; //导入方法依赖的package包/类
@Override
public Entity prepareFromData(int levelID, Object... objects) {
	Entity ent = EntityFactory.createEntity_NPC(levelID, (Float)objects[0], (Float)objects[1]);
	EntityData data = ent.getComponent(EntityData.class);
	data.setTeam((int) objects[2]);
	data.initAI(levelID, ent.getId());
	return ent;
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:9,代码来源:SpawnableBaseNPC.java

示例12: prepareFromData

import com.artemis.Entity; //导入方法依赖的package包/类
@Override
public Entity prepareFromData(int levelID, Object... objects) {
	Entity ent = super.prepareFromData(levelID, objects);
	
	ent.getComponent(RenderData.class).renderType = RenderData.TYPE_LINE;
	ent.getComponent(ProjectileData.class).prjDamage = 5;
	
	return ent;
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:10,代码来源:SpawnablePrjBullet.java

示例13: prepareFromData

import com.artemis.Entity; //导入方法依赖的package包/类
@Override
public Entity prepareFromData(int levelID, Object... objects) {
	Entity ent = EntityFactory.createEntity_Projectile(levelID, (Float)objects[0], (Float)objects[1]);
	ent.getComponent(EntityData.class).setTeam((int) objects[2]);
	
	ProjectileData data = ent.getComponent(ProjectileData.class);
	
	ent.getComponent(Velocity.class).set((Float)objects[3] * data.speed, (Float)objects[4] * data.speed);
	return ent;
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:11,代码来源:SpawnableBaseProjectile.java

示例14: addToLookup

import com.artemis.Entity; //导入方法依赖的package包/类
public void addToLookup(int id, int idHit) {
	// TODO: WE ARE ASSUMING LEVEL 0 HERE, FIX!!!
	Level level = Game_AI_TestBed.instance().getLevel(0);
	Entity entA = level.getWorld().getEntity(id);
	Entity entB = level.getWorld().getEntity(idHit);
	
	if (entA != null && entB != null) {
		PhysicsData dataA = entA.getComponent(PhysicsData.class);
		PhysicsData dataB = entB.getComponent(PhysicsData.class);
		
		if (dataA != null) dataA.addCollision(idHit);
		if (dataB != null) dataB.addCollision(id);
	}
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:15,代码来源:SpriteSim.java

示例15: removeFromLookup

import com.artemis.Entity; //导入方法依赖的package包/类
public void removeFromLookup(int id, int idHit) {
	// TODO: WE ARE ASSUMING LEVEL 0 HERE, FIX!!!
	Level level = Game_AI_TestBed.instance().getLevel(0);
	Entity entA = level.getWorld().getEntity(id);
	Entity entB = level.getWorld().getEntity(idHit);
	
	if (entA != null && entB != null) {
		PhysicsData dataA = entA.getComponent(PhysicsData.class);
		PhysicsData dataB = entB.getComponent(PhysicsData.class);
		
		if (dataA != null) dataA.removeCollision(idHit);
		if (dataB != null) dataB.removeCollision(id);
	}
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:15,代码来源:SpriteSim.java


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