use of com.janfic.games.computercombat.actors.ComputerActor in project computercombat by janfic.
the class CollectAnimation method animate.
@Override
public List<List<Action>> animate(String currentPlayerUID, String playerUID, MatchScreen screen, float animationSpeed) {
Map<String, ComputerActor> computerActors = screen.getComputerActors();
Map<String, List<SoftwareActor>> softwareActors = screen.getSoftwareActors();
Board board = screen.getBoard();
List<List<Action>> actions = new ArrayList<>();
List<Action> popAction = new ArrayList<>();
List<ComponentActor> componentActors = board.getComponents();
for (Component component : getAllComponents()) {
for (ComponentActor componentActor : componentActors) {
if (componentActor.getComponent().equals(component)) {
boolean isPlayerMove = currentPlayerUID.equals(playerUID);
Action a = Actions.sequence(Actions.fadeOut(0.35f * animationSpeed), Actions.delay(0.35f * animationSpeed), Actions.moveTo(isPlayerMove ? 0 : board.getWidth() - 7 - 24, (8 - (componentActor.getComponent().getY() + 1)) * 24 + 7, (isPlayerMove ? componentActor.getComponent().getX() : 7 - componentActor.getComponent().getX()) / 6f * animationSpeed));
a.setActor(componentActor);
componentActor.setZIndex(0);
Action b = Actions.sequence(Actions.fadeOut(0), Actions.visible(true), Actions.fadeIn(0.7f * animationSpeed), Actions.fadeOut((isPlayerMove ? componentActor.getComponent().getX() : 7 - componentActor.getComponent().getX()) / 6f * animationSpeed, Interpolation.fade));
b.setActor(componentActor.getCollectedRegion());
Image collectedComponent = new Image(board.getSkin(), "collected_component");
board.getStage().addActor(collectedComponent);
collectedComponent.setColor(board.getSkin().getColor(component.getTextureName().toUpperCase()).cpy().mul(1, 1, 1, 0));
collectedComponent.setZIndex(10);
int i = 4;
final ComputerActor computerActor = computerActors.get(currentPlayerUID);
SoftwareActor tempActor = null;
if (progress.containsKey(component.toString())) {
Card c = progress.get(component.toString());
for (int j = 0; j < softwareActors.get(currentPlayerUID).size(); j++) {
SoftwareActor softwareActor = softwareActors.get(currentPlayerUID).get(j);
if (c.equals(softwareActor.getSoftware())) {
tempActor = softwareActor;
i = j;
break;
}
}
}
final SoftwareActor progressActor = tempActor;
Vector2 start = new Vector2(isPlayerMove ? -5 : board.getWidth() + 3, (8 - (componentActor.getComponent().getY() + 1)) * 24 + 7 + 12 - 4);
start = board.localToStageCoordinates(start);
Vector2 end = board.localToStageCoordinates(new Vector2(isPlayerMove ? -5 : board.getWidth() + 3, gutterYs[i]));
collectedComponent.setPosition(start.x, start.y);
Action c = Actions.sequence(Actions.delay(animationSpeed * (isPlayerMove ? componentActor.getComponent().getX() : 7 - componentActor.getComponent().getX()) / 4f + 0.7f - 0.2f), Actions.scaleTo(1, 4 * animationSpeed), Actions.fadeIn(0.2f * animationSpeed), Actions.parallel(Actions.moveTo(end.x, end.y, Math.abs(end.y - start.y) / 100f * animationSpeed, Interpolation.exp5), Actions.sequence(Actions.scaleTo(1, 10, Math.abs(end.y - start.y) / 200f * animationSpeed, Interpolation.circleIn), Actions.scaleTo(1, 1, Math.abs(end.y - start.y) / 200f * animationSpeed, Interpolation.circleOut))), Actions.parallel(Actions.moveBy(isPlayerMove ? -13 : 13, 0, 0.1f * animationSpeed, Interpolation.exp5), Actions.scaleTo(2, 1, 0.1f * animationSpeed)), Actions.fadeOut(0.1f * animationSpeed), Actions.run(new Runnable() {
@Override
public void run() {
if (progressActor == null) {
computerActor.getComputer().recieveProgress(1);
computerActor.addProgress(1);
} else {
progressActor.getSoftware().recieveProgress(1);
for (Actor actor : progressActor.getLEDs().getChildren()) {
LEDActor led = (LEDActor) actor;
if (led.getComponentColor().equals(SoftwareActor.components.get(component.getColor()))) {
led.setLightOn(true);
}
}
}
}
}), Actions.delay(0.5f * animationSpeed), Actions.run(new Runnable() {
@Override
public void run() {
if (progressActor != null) {
for (Actor actor : progressActor.getLEDs().getChildren()) {
LEDActor led = (LEDActor) actor;
if (led.getComponentColor().equals(SoftwareActor.components.get(component.getColor()))) {
led.setLightOn(false);
}
}
}
}
}), Actions.removeActor());
c.setActor(collectedComponent);
popAction.add(a);
popAction.add(b);
popAction.add(c);
}
}
}
actions.add(popAction);
return actions;
}
use of com.janfic.games.computercombat.actors.ComputerActor in project computercombat by janfic.
the class DrawAnimation method animate.
@Override
public List<List<Action>> animate(String currentPlayerUID, String playerUID, MatchScreen screen, float animationSpeed) {
Table leftPanel = screen.getLeftPanel();
Table rightPanel = screen.getRightPanel();
Table panel;
if (playerUID.equals(currentPlayerUID)) {
panel = leftPanel;
} else {
panel = rightPanel;
}
List<List<Action>> animations = new ArrayList<>();
ComputerCombatGame game = (ComputerCombatGame) Gdx.app.getApplicationListener();
if (newSoftware.size() > 0) {
List<Action> cardAnimation = new ArrayList<>();
Table t = new Table();
t.setFillParent(true);
Card loadNewCard = SQLAPI.getSingleton().getCardById(newSoftware.get(0).getID(), newSoftware.get(0).getOwnerUID());
loadNewCard.setMatchID(newSoftware.get(0).getMatchID());
CollectionCard card = new CollectionCard(game, screen.getSkin(), loadNewCard, 1);
card.setTouchable(Touchable.disabled);
Stage stage = screen.getMainStage();
stage.addActor(t);
card.setVisible(false);
card.setPosition(stage.getWidth() / 2, -300);
t.add(card).expand().center();
Action cardAction = Actions.sequence(Actions.moveBy(0, -400), Actions.visible(true), Actions.moveBy(0, 400, 1 * animationSpeed, Interpolation.fastSlow), Actions.delay(1 * animationSpeed), Actions.moveBy(0, -400, 1 * animationSpeed, Interpolation.slowFast));
cardAction.setActor(card);
cardAnimation.add(cardAction);
animations.add(cardAnimation);
List<SoftwareActor> softwareActors = screen.getSoftwareActors().get(currentPlayerUID);
ComputerActor computerActor = screen.getComputerActors().get(currentPlayerUID);
List<Action> softwareAnimation = new ArrayList<>();
SoftwareActor softwareActor = new SoftwareActor(screen.getSkin(), !playerUID.equals(currentPlayerUID), loadNewCard, game);
panel.clear();
for (SoftwareActor s : softwareActors) {
panel.add(s).row();
}
panel.add(softwareActor).row();
panel.add(computerActor).expandY().growX().bottom();
softwareActor.setVisible(false);
softwareActors.add(softwareActor);
Action softwareActorAction = Actions.sequence(Actions.moveBy(0, -400), Actions.visible(true), Actions.moveBy(0, 400, 1 * animationSpeed, Interpolation.fastSlow));
softwareActorAction.setActor(softwareActor);
softwareAnimation.add(softwareActorAction);
animations.add(softwareAnimation);
}
return animations;
}
use of com.janfic.games.computercombat.actors.ComputerActor in project computercombat by janfic.
the class AttackAnimation method animate.
@Override
public List<List<Action>> animate(String currentPlayerUID, String playerUID, MatchScreen screen, float animationSpeed) {
List<List<Action>> animations = new ArrayList<>();
for (String key : attacks.keySet()) {
List<Action> attackActions = new ArrayList<>();
System.out.println(" HERE " + key);
SoftwareActor attackerActor = screen.getSoftwareActorByMatchID(attackerUID, Integer.parseInt(key));
attackerActor.setZIndex(1000);
attackerActor.getParent().setZIndex(Integer.MAX_VALUE);
for (Integer matchID : attacks.get(key)) {
Card attacker = attackerActor.getSoftware();
Card attacked = screen.getSoftwareActorByMatchID(attackedUID, matchID).getSoftware();
if (attacked.getID() > 0) {
SoftwareActor attackedActor = screen.getSoftwareActorByMatchID(attackedUID, matchID);
Vector2 posBack = attackerActor.localToStageCoordinates(new Vector2(attackerActor.getX(), attackerActor.getY()));
Vector2 pos = attackedActor.localToStageCoordinates(new Vector2(attackedActor.getX(), attackedActor.getY()));
posBack = attackerActor.stageToLocalCoordinates(posBack);
pos = attackerActor.stageToLocalCoordinates(pos);
Action attack = Actions.sequence(Actions.moveTo(pos.x, pos.y, 0.5f * animationSpeed, Interpolation.exp5In), Actions.moveTo(posBack.x, posBack.y, 0.5f * animationSpeed, Interpolation.exp5Out));
Action attackedAction;
Card a = attackedActor.getSoftware();
int armorDecrease = a.getArmor() > 0 ? Math.min(a.getArmor(), attacker.getAttack()) : 0;
int healthDecrease = a.getHealth() <= attacker.getAttack() - armorDecrease ? a.getHealth() : attacker.getAttack() - armorDecrease;
attackedAction = Actions.sequence(Actions.delay(0.5f * animationSpeed), Actions.color(Color.RED), Actions.color(Color.WHITE, 0.4f * animationSpeed), new ChangeStatAction(0.5f * animationSpeed, "armor", -armorDecrease), new ChangeStatAction(0.5f * animationSpeed, "health", -healthDecrease));
attackedAction.setActor(attackedActor);
attack.setActor(attackerActor);
attackActions.add(attack);
attackActions.add(attackedAction);
} else if (attacked.getID() == 0) {
ComputerActor attackedActor = screen.getComputerActors().get(attackedUID);
Action attackedAction;
Vector2 posBack = attackerActor.localToStageCoordinates(new Vector2(attackerActor.getX(), attackerActor.getY()));
Vector2 pos = attackedActor.localToStageCoordinates(new Vector2(attackedActor.getX(), attackedActor.getY()));
posBack = attackerActor.stageToLocalCoordinates(posBack);
pos = attackerActor.stageToLocalCoordinates(pos);
Action attack = Actions.sequence(Actions.moveTo(pos.x, pos.y, 0.5f * animationSpeed, Interpolation.exp5In), Actions.moveTo(posBack.x, posBack.y, 0.5f * animationSpeed, Interpolation.exp5Out));
int healthDecrease = attacker.getAttack();
attackedAction = Actions.sequence(Actions.delay(0.5f * animationSpeed), Actions.color(Color.RED), Actions.color(Color.WHITE, 0.4f * animationSpeed), new ChangeStatAction(0.5f * animationSpeed, "health", -healthDecrease));
attackedAction.setActor(attackedActor);
attack.setActor(attackerActor);
attackActions.add(attack);
attackActions.add(attackedAction);
}
}
animations.add(attackActions);
}
return animations;
}
Aggregations