本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例9: execute
import com.artemis.EntityEdit; //导入依赖的package包/类
@Override
public void execute () {
EntityEdit editor = entity.edit();
if (add)
editor.add(component);
else
editor.remove(component);
}
示例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));
}
示例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);
}
示例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));
}