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


Java EntityEdit类代码示例

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


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

示例1: process

import com.artemis.EntityEdit; //导入依赖的package包/类
@Override
protected void process(final int entityId)
{
    final Position p    = mPos.get(entityId);
    final Size     size = mSize.get(entityId);
    final Name     name = mName.get(entityId);

    // remove dead creature from the world
    map.obstacles.del(p.x, p.y);
    world.delete(entityId);

    final Point p2 = map.getFirstTotallyFree(p.x, p.y, -1);

    // add corpse item
    final int        corpseId = world.create();
    final EntityEdit edit     = world.edit(corpseId);

    edit.create(Position.class).set(p2.x, p2.y);
    edit.create(Sprite.class).set('$', Color.RED.darker().darker(), false);
    edit.create(Corpse.class);
    edit.create(Health.class).set(size.value + 3);
    edit.add(new Name(name.name + "'s corpse", "corpse"));

    map.items.set(corpseId, p2.x, p2.y);
}
 
开发者ID:fabio-t,项目名称:alone-rl,代码行数:26,代码来源:DeadSystem.java

示例2: makeDerivative

import com.artemis.EntityEdit; //导入依赖的package包/类
public void makeDerivative(final int id)
{
    final Strength str     = mStr.get(id);
    final Agility agi      = mAgi.get(id);
    final Constitution con = mCon.get(id);

    final EntityEdit edit = world.edit(id);

    // Secondary Attributes
    final int size = Math.round((con.value - agi.value) / 2f);
    edit.create(Size.class).set(size);
    edit.create(Stamina.class).set((5 + str.value + con.value) * 100); // FIXME for debug, reduce/tweak later
    edit.create(Speed.class).set((con.value - str.value - agi.value + 6) / 12f);
    edit.create(Health.class).set((con.value + 3) * 10);

    // Tertiary Attributes

    // a fish does not need to eat, for now
    if (mHerbivore.has(id) || mCarnivore.has(id))
        edit.create(Hunger.class).set(0f, (size / 2f) + 2f);
}
 
开发者ID:fabio-t,项目名称:alone-rl,代码行数:22,代码来源:BootstrapSystem.java

示例3: createArmy

import com.artemis.EntityEdit; //导入依赖的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

示例4: createFadingTileLabel

import com.artemis.EntityEdit; //导入依赖的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

示例5: createFadingTileIcon

import com.artemis.EntityEdit; //导入依赖的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

示例6: makeItem

import com.artemis.EntityEdit; //导入依赖的package包/类
public int makeItem(final String tag)
{
    final ItemTemplate template = templates.get(tag);

    if (template == null)
    {
        log.warn("Item named {} doesn't exist", tag);
        return -1;
    }

    final int id = world.create();

    final EntityEdit edit = world.edit(id);

    edit.add(new Name(template.name, tag));

    // TODO find a way to do this dynamically. Right now I cannot figure out a way
    // of deserialising an array of Components, because it's an abstract class that I cannot annotate.
    if (template.wearable != null)
        edit.add(template.wearable);
    if (template.weapon != null)
        edit.add(template.weapon);
    if (template.sprite != null)
        edit.add(template.sprite);
    if (template.obstacle != null)
        edit.add(template.obstacle);
    if (template.crushable != null)
        edit.add(template.crushable);
    if (template.cuttable != null)
        edit.add(template.cuttable);

    return id;
}
 
开发者ID:fabio-t,项目名称:alone-rl,代码行数:34,代码来源:ItemSystem.java

示例7: createClick

import com.artemis.EntityEdit; //导入依赖的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

示例8: createEmpire

import com.artemis.EntityEdit; //导入依赖的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

示例9: execute

import com.artemis.EntityEdit; //导入依赖的package包/类
@Override
public void execute () {
	EntityEdit editor = entity.edit();
	if (add)
		editor.add(component);
	else
		editor.remove(component);
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:9,代码来源:VisComponentManipulator.java

示例10: createExpansionOption

import com.artemis.EntityEdit; //导入依赖的package包/类
private EntityEdit createExpansionOption(int cx, int cy, String animId, CastleBlock.Type type) {
    return world.createEntity()
      .edit()
            .add(new Pos(cx, cy))
            .add(new Bounds(17, 13))
            .add(new Clickable())
            .add(new Focusable())
            .add(new ExpansionOption(type))
            .add(new Anim(animId, 13));
}
 
开发者ID:DaanVanYperen,项目名称:underkeep,代码行数:11,代码来源:EntityFactorySystem.java

示例11: loadBody

import com.artemis.EntityEdit; //导入依赖的package包/类
public void loadBody(final String filename, final EntityEdit edit) throws IOException
{
    // final InputStream fileStream = loader.getResourceAsStream(filename);
    final InputStream fileStream = new FileInputStream(filename);

    final YAMLFactory factory = new YAMLFactory();
    final YAMLParser  parser  = factory.createParser(fileStream);

    int     str       = 0, agi = 0, con = 0, skin = 0, sight = 0;
    boolean herbivore = false, carnivore = false;

    parser.nextToken(); // START_OBJECT

    while (parser.nextToken() != null)
    {
        final String name = parser.getCurrentName();

        if (name == null)
            break;

        parser.nextToken(); // get value for this "name"

        switch (name)
        {
            case "strength":
                str = parser.getIntValue();
                edit.create(Strength.class).value = Util.clamp(str, -2, 2);
                break;
            case "agility":
                agi = parser.getIntValue();
                edit.create(Agility.class).value = Util.clamp(agi, -2, 2);
                break;
            case "constitution":
                con = parser.getIntValue();
                edit.create(Constitution.class).value = Util.clamp(con, -2, 2);
                break;
            case "skin":
                skin = parser.getIntValue();
                edit.create(Skin.class).value = Util.clamp(skin, -2, 2);
                break;
            case "sight":
                sight = parser.getIntValue();
                edit.create(Sight.class).value = Util.clamp(sight, 1, 18);
                break;
            case "herbivore":
                herbivore = parser.getBooleanValue();

                if (herbivore)
                    edit.create(Herbivore.class);
                break;
            case "carnivore":
                carnivore = parser.getBooleanValue();

                if (carnivore)
                    edit.create(Carnivore.class);
                break;
            case "underwater":
                edit.create(Underwater.class);
                break;
        }
    }

    // Secondary Attributes
    final int size = Math.round((con - agi) / 2f);
    edit.create(Size.class).set(size);
    edit.create(Stamina.class).set((5 + str + con) * 100); // FIXME for debug, reduce/tweak later
    edit.create(Speed.class).set((con - str - agi + 6) / 12f);
    edit.create(Health.class).set((con + 3) * 10);

    // Tertiary Attributes

    // a fish does not need to eat, for now
    if (herbivore || carnivore)
        edit.create(Hunger.class).set(0f, (size / 2f) + 2f);
}
 
开发者ID:fabio-t,项目名称:alone-rl,代码行数:76,代码来源:BootstrapSystem.java

示例12: newPositioned

import com.artemis.EntityEdit; //导入依赖的package包/类
private static EntityEdit newPositioned(final World world, final float x, final float y) {
    return world.createEntity()
      .edit()
            .add(new Pos(x, y));
}
 
开发者ID:DaanVanYperen,项目名称:naturally-selected-2d,代码行数:6,代码来源:EntityFactory.java


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