use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.
the class DestroyGame method parseMapXml.
private void parseMapXml() {
for (Element xml : this.getSettings().getChildren()) {
try {
// factory
DestroyableFactory factory = this.getFactory(xml.getName());
if (factory == null) {
continue;
}
// id
String id = xml.getAttributeValue("id");
if (id == null || id.trim().isEmpty()) {
continue;
}
// owner
String ownerId = xml.getAttributeValue("owner");
Participator owner = null;
if (ownerId != null && !ownerId.trim().isEmpty()) {
owner = this.getMatch().findWinnerById(ownerId.trim());
}
// name
String name = XMLParser.parseMessage(xml.getAttributeValue("name"));
// object
Destroyable destroyable = factory.newDestroyable(this, owner, id.trim(), name, xml);
if (destroyable == null) {
continue;
}
destroyable.setName(name);
this.addDestroyable(destroyable);
// register
if (destroyable.registerGoal()) {
for (MatchWinner winner : this.getMatch().getWinnerList()) {
if (destroyable.isCompletableBy(winner)) {
winner.addGoal(destroyable);
}
}
}
// register listeners
destroyable.registerEventListeners(this, true);
} catch (JDOMException ex) {
ex.printStackTrace();
}
}
}
use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.
the class LeakGame method parseMapXml.
private void parseMapXml() {
for (Element xml : this.getSettings().getChildren()) {
try {
// factory
LeakableFactory factory = this.getFactory(xml.getName());
if (factory == null) {
continue;
}
// id
String id = xml.getAttributeValue("id");
if (id == null || id.trim().isEmpty()) {
continue;
}
// owner
String ownerId = xml.getAttributeValue("owner");
Participator owner = null;
if (ownerId != null && !ownerId.trim().isEmpty()) {
owner = this.getMatch().findWinnerById(ownerId.trim());
}
// name
String name = XMLParser.parseMessage(xml.getAttributeValue("name"));
// object
Leakable leakable = factory.newLeakable(this, owner, id.trim(), name, xml);
if (leakable == null) {
continue;
}
leakable.setName(name);
this.addLeakable(leakable);
// register
if (leakable.registerGoal()) {
for (Participator completableBy : this.match.getWinnerList()) {
if (leakable.isCompletableBy(completableBy)) {
completableBy.addGoal(leakable);
}
}
}
// register listeners
leakable.registerEventListeners(this, true);
} catch (JDOMException ex) {
ex.printStackTrace();
}
}
}
use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.
the class Point method heartbeat.
public void heartbeat(long ticks) {
if (this.isPermanent() && this.isCompleted()) {
return;
}
Match match = this.game.getMatch();
Multimap<Participator, GamePlayer> competitors = ArrayListMultimap.create();
for (GamePlayer player : this.getPlayers()) {
if (this.canCapture(player) && this.canDominate(player)) {
Participator competitor = match.findWinnerByPlayer(player);
if (competitor != null && (competitor.equals(player) || this.canCapture(competitor))) {
competitors.put(competitor, player);
}
}
}
Multimap<Participator, GamePlayer> dominators = this.getDominatorStrategy().getDominators(competitors);
if (dominators == null) {
dominators = DominatorStrategy.EMPTY_DOMINATORS;
}
List<Participator> canCapture = new ArrayList<>();
for (Participator competitor : dominators.keySet()) {
if (this.canCapture(competitor)) {
canCapture.add(competitor);
}
}
// Heartbeat the current state.
Participator oldOwner = this.getOwner();
this.getState().heartbeat(ticks, match, competitors, dominators, canCapture, oldOwner);
Participator newOwner = this.getOwner();
double pointReward = this.getPointReward();
if (oldOwner != null && newOwner != null && oldOwner.equals(newOwner) && pointReward != Score.ZERO) {
// Give reward points for owning the point.
this.heartbeatReward(oldOwner, pointReward);
}
}
use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.
the class CaptureGame method parseMapXml.
private void parseMapXml() {
for (Element xml : this.getSettings().getChildren()) {
try {
// factory
CapturableFactory factory = this.getFactory(xml.getName());
if (factory == null) {
continue;
}
// id
String id = xml.getAttributeValue("id");
if (id == null || id.trim().isEmpty()) {
continue;
}
// owner
String ownerId = xml.getAttributeValue("owner");
Participator owner = null;
if (ownerId != null && !ownerId.trim().isEmpty()) {
owner = this.getMatch().findWinnerById(ownerId.trim());
}
// name
String name = XMLParser.parseMessage(xml.getAttributeValue("name"));
// object
Capturable capturable = factory.newCapturable(this, owner, id.trim(), name, xml);
if (capturable == null) {
continue;
}
capturable.setName(name);
this.addCapturable(capturable);
// register
if (capturable.registerGoal()) {
for (MatchWinner winner : this.getMatch().getWinnerList()) {
if (capturable.isCompletableBy(winner)) {
winner.addGoal(capturable);
}
}
}
// register listeners
capturable.registerEventListeners(this, true);
} catch (JDOMException ex) {
ex.printStackTrace();
}
}
}
use of pl.themolka.arcade.game.Participator in project Arcade2 by ShootGame.
the class PointRegionRender method renderPoint.
public void renderPoint(Point point) {
Participator owner = point.getOwner();
this.renderPoint(point, owner != null ? owner.getColor() : point.getNeutralColor());
}
Aggregations