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


Java World.createEntity方法代码示例

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


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

示例1: createArmy

import com.artemis.World; //导入方法依赖的package包/类
public static Entity createArmy(World world, MapPosition pos, String name, Empire empire, Entity source,
    int militaryPower) {
  Entity e = world.createEntity();
  EntityEdit edit = e.edit();

  edit.add(new Counter(Colors.contrast(empire.color), empire.color, militaryPower));

  edit.add(pos).add(new Name(name)).add(new Description(name))
      .add(new Destination(source.getComponent(ArmyCommand.class).forbiddenTiles, 1))
      .add(new Army(source, militaryPower)).add(empire);

  if (empire.isComputerControlled())
    edit.add(new AIControlled());

  return e;
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:17,代码来源:EntityFactory.java

示例2: createFadingTileLabel

import com.artemis.World; //导入方法依赖的package包/类
public static Entity createFadingTileLabel(World world, String label, Color color, float x, float y, float duration) {
  Entity e = world.createEntity();
  EntityEdit edit = e.edit();

  MutableMapPosition position = edit.create(MutableMapPosition.class);
  position.x = x;
  position.y = y;

  FadingMessage fading = edit.create(FadingMessage.class);
  fading.label = label;
  fading.color = color;
  fading.duration = duration;
  fading.vx = 0f;
  fading.vy = 1.3f;

  return e;
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:18,代码来源:EntityFactory.java

示例3: createFadingTileIcon

import com.artemis.World; //导入方法依赖的package包/类
public static Entity createFadingTileIcon(World world, TextureRegion icon, Color color, float x, float y,
    float duration) {
  Entity e = world.createEntity();
  EntityEdit edit = e.edit();

  MutableMapPosition position = edit.create(MutableMapPosition.class);
  position.x = x;
  position.y = y;

  FadingMessage fading = edit.create(FadingMessage.class);
  fading.icon = icon;
  fading.color = color;
  fading.duration = duration;
  fading.vx = 0f;
  fading.vy = 1.3f;

  return e;
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:19,代码来源:EntityFactory.java

示例4: createBasicEntity

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createBasicEntity(World world, float x, float y,
		int width, int height, float vx, float vy, float vmax, int health) {
	Entity e = world.createEntity();

	// Location data
	SpatialComp sc = world.createComponent(SpatialComp.class);
	sc.setValues(x, y, width, height);
	e.addComponent(sc);

	// Velocity data
	VelocityComp vc = world.createComponent(VelocityComp.class);
	vc.setValues(vx, vy, vmax);
	e.addComponent(vc);

	// Health data
	HealthComp hc = world.createComponent(HealthComp.class);
	hc.health = health;
	hc.killable = health != NO_HEALTH;
	e.addComponent(hc);

	return e;
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:23,代码来源:EntityFactory.java

示例5: createPlayer

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createPlayer(final World world) {
	final Entity newEntity = world.createEntity(Archetypes.getInstance().player);
	newEntity.getComponent(FacingAnimationComponent.class).mapAnimation(EEntity.PLAYER);
	newEntity.getComponent(TurnComponent.class).setMovesOnTurn(ETurnType.PLAYER);
	setName(newEntity, EEntity.PLAYER);
	return newEntity;
}
 
开发者ID:davidbecker,项目名称:taloonerrl,代码行数:8,代码来源:EntityFactory.java

示例6: createMonster

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createMonster(final EEntity type, final World world, final int xPosition,
		final int yPosition) {
	final Entity newEntity = world.createEntity(Archetypes.getInstance().monster);
	newEntity.getComponent(AnimationComponent.class).mapAnimation(type);
	final PositionComponent posComponent = newEntity.getComponent(PositionComponent.class);
	posComponent.setX(xPosition);
	posComponent.setY(yPosition);
	setName(newEntity, type);
	setAI(newEntity, type);
	return newEntity;
}
 
开发者ID:davidbecker,项目名称:taloonerrl,代码行数:12,代码来源:EntityFactory.java

示例7: createCollectible

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createCollectible(final EEntity type, final World world, final int xPosition,
		final int yPosition) {
	final Entity newEntity = world.createEntity(Archetypes.getInstance().collectible);
	newEntity.getComponent(SpriteComponent.class).mapSprite(type);
	final PositionComponent posComponent = newEntity.getComponent(PositionComponent.class);
	posComponent.setX(xPosition);
	posComponent.setY(yPosition);
	return newEntity;
}
 
开发者ID:davidbecker,项目名称:taloonerrl,代码行数:10,代码来源:EntityFactory.java

示例8: createDecoration

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createDecoration(final EEntity type, final World world, final int xPosition,
		final int yPosition) {
	final Entity newEntity = world.createEntity(Archetypes.getInstance().decoration);
	newEntity.getComponent(AnimationComponent.class).mapAnimation(type);
	final PositionComponent posComponent = newEntity.getComponent(PositionComponent.class);
	posComponent.setX(xPosition);
	posComponent.setY(yPosition);
	return newEntity;
}
 
开发者ID:davidbecker,项目名称:taloonerrl,代码行数:10,代码来源:EntityFactory.java

示例9: spawnMan

import com.artemis.World; //导入方法依赖的package包/类
public static Entity spawnMan(World world, int x, int y, int z) {

        Entity e = world.createEntity();
        e.edit().create(Position.class).set(x, y, z);

        Gender gender = Gender.random();
        String firstName;

        if (gender == Gender.MALE)
            firstName = NameGen.randomMaleFirstName();
        else
            firstName = NameGen.randomFemaleFirstName();

        String lastName = NameGen.randomLastName();
//        e.edit().create(Citizen.class).set(firstName, lastName, gender);

        Citizen c = e.edit().create(Citizen.class);
        c.firstName = firstName;
        c.lastName = lastName;
        c.gender = gender;
        c.bodyShape = BodyShape.types.get(gender.name());
        c.hairStyle = (HairStyle) MatUtils.randVal(HairStyle.types.values().toArray());
        c.hairColor = (HairColor) MatUtils.randVal(HairColor.types.values().toArray());
        c.skinColor = (SkinColor) MatUtils.randVal(SkinColor.types.values().toArray());

        e.edit().create(Health.class).set(10, 10);

        if (MatUtils.getBoolean(0.8f))
            c.garment = (GarmentType) MatUtils.randVal(GarmentType.types.values().toArray());

        if (MatUtils.getBoolean())
            c.hat = (HatType) MatUtils.randVal(HatType.types.values().toArray());

//        e.edit().create(Appearance.class).set(AssetLoader.atlas.findRegion("character/parts/body/maleBody"));
        e.edit().create(Sentience.class);

        Gdx.app.log("Spawn", firstName + " " + lastName + " has entered the station.");
        return e;
    }
 
开发者ID:stewsters,项目名称:acceptableLosses,代码行数:40,代码来源:Spawner.java

示例10: createClick

import com.artemis.World; //导入方法依赖的package包/类
public static Entity createClick(World world, int x, int y, float startScale, float speed) {
  Entity e = world.createEntity();
  EntityEdit edit = e.edit();

  MutableMapPosition pos = edit.create(MutableMapPosition.class);
  pos.x = x;
  pos.y = y;

  Sprite sprite = new Sprite();
  sprite.name = "click";
  sprite.color = new Color(1f, 1f, 1f, 0.5f);
  sprite.rotation = 0f;
  sprite.scaleX = startScale;
  sprite.scaleY = startScale;
  edit.add(sprite);

  Expires expires = edit.create(Expires.class);
  expires.delay = 1f;

  ScaleAnimation scaleAnimation = edit.create(ScaleAnimation.class);
  scaleAnimation.speed = speed;

  ColorAnimation colorAnimation = edit.create(ColorAnimation.class);
  colorAnimation.alphaAnimate = true;
  colorAnimation.alphaSpeed = -1f;

  return e;
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:29,代码来源:EntityFactory.java

示例11: createEmpire

import com.artemis.World; //导入方法依赖的package包/类
public static Entity createEmpire(World world, int x, int y, String name, Empire empire) {
  Entity e = world.createEntity();

  EntityEdit edit = e.edit();

  ArmyCommand command = new ArmyCommand();
  edit.add(empire).add(new EventsCount()).add(new Discoveries()).add(new Policies()).add(new Diplomacy())
      .add(command).add(new Score());

  Sprite sprite = new Sprite();
  sprite.name = "cylinderwide";
  sprite.rotation = 0f;
  sprite.scaleX = 1f;
  sprite.scaleY = 1f;
  sprite.color = empire.color;
  edit.add(sprite);

  InfluenceSource source = new InfluenceSource();
  edit.add(new MapPosition(x, y)).add(source).add(new Destination(command.forbiddenTiles, 2));

  edit.add(new Name(name)).add(new Description("Tribe of " + name))
      .add(new TextBox(() -> name + ": " + source.power()));

  if (empire.isComputerControlled())
    edit.add(new AIControlled());

  return e;
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:29,代码来源:EntityFactory.java

示例12: setup

import com.artemis.World; //导入方法依赖的package包/类
@Before
public void setup() {
	World world = new World(new WorldConfigurationBuilder().dependsOn(ExtendedComponentMapperPlugin.class).build());
	entity = world.createEntity();
	component = new TweenableTestComponent(5);
	entity.edit().add(component);
	step= new TweenableTestOperation();
}
 
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:9,代码来源:TweenOperationTest.java

示例13: setup

import com.artemis.World; //导入方法依赖的package包/类
@Before
public void setup() {
	World world = new World(new WorldConfigurationBuilder().dependsOn(ExtendedComponentMapperPlugin.class).build());
	entity = world.createEntity();
	component = new TweenableTestComponent(5);
	entity.edit().add(component);
	step = new UnpooledTweenOperation();
}
 
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:9,代码来源:UnpooledTweenOperationTest.java

示例14: createBubble

import com.artemis.World; //导入方法依赖的package包/类
private static Entity createBubble(World world, float sourceX,
		float sourceY, int bubWidth, int bubHeight, String imgName,
		int health) {
	Entity e = world.createEntity();

	MoveWithPlayerComp mwpc = world
			.createComponent(MoveWithPlayerComp.class);
	mwpc.xDisplace = -(bubWidth - Constants.SHIP_WIDTH) / 2;
	mwpc.yDispace = -(bubHeight - Constants.SHIP_HEIGHT) / 2;
	e.addComponent(mwpc);

	SpatialComp sc = world.createComponent(SpatialComp.class);
	sc.setValues(sourceX + mwpc.xDisplace, sourceY + mwpc.yDispace,
			bubWidth, bubHeight);
	e.addComponent(sc);

	SingleSpriteComp ssc = world.createComponent(SingleSpriteComp.class);
	ssc.name = imgName;
	ssc.tint = Color.WHITE;
	e.addComponent(ssc);

	HealthComp hc = world.createComponent(HealthComp.class);
	hc.health = health;
	e.addComponent(hc);

	e.addComponent(world.createComponent(NonCullComp.class));
	world.getManager(GroupManager.class).add(e, Constants.Groups.PLAYER);
	return e;
}
 
开发者ID:bmaxwell921,项目名称:SwapShip,代码行数:30,代码来源:EntityFactory.java

示例15: prepareWorld

import com.artemis.World; //导入方法依赖的package包/类
private static World prepareWorld (int numEntities) {
	World world = new World();

	world.setSystem(new MovementSystem());
	world.setSystem(new StateSystem());
	world.setSystem(new CollisionSystem());
	world.setSystem(new RemovalSystem());

	world.initialize();

	for (int i = 0; i < numEntities; ++i) {
		Entity entity = world.createEntity();

		if (Constants.shouldHaveComponent(ComponentType.POSITION, i)) {
			PositionComponent pos = new PositionComponent();
			pos.pos.x = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
			pos.pos.y = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
			entity.addComponent(pos);
		}

		if (Constants.shouldHaveComponent(ComponentType.MOVEMENT, i)) {
			MovementComponent mov = new MovementComponent();
			mov.velocity.x = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
			mov.velocity.y = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
			mov.accel.x = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);
			mov.accel.y = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);

			entity.addComponent(mov);
		}

		if (Constants.shouldHaveComponent(ComponentType.RADIUS, i)) {
			RadiusComponent rad = new RadiusComponent();
			rad.radius = MathUtils.random(Constants.MIN_RADIUS, Constants.MAX_RADIUS);
			entity.addComponent(rad);
		}

		if (Constants.shouldHaveComponent(ComponentType.STATE, i)) {
			entity.addComponent(new StateComponent());
		}

		world.addEntity(entity);
	}

	return world;
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:46,代码来源:ArtemisBenchmark.java


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