public void move(int x, int y, boolean send) { Log.info("Moving unit " + data.id); if (data.x == x && data.y == y) { return; } if (moved && send) { return; } state.mapActors[data.x][data.y] = null; data.x = x; data.y = y; state.mapActors[data.x][data.y] = this; moved = true; PulsatioGame game = PulsatioGame.getSingleton(); if (send && !PulsatioGame.getSingleton().testmode) { MoveUnit mu = new MoveUnit(data.id, x, y); game.opponent.sendTCP(mu); } MapState.clearSelectorActors(); switch (data.team) { case UnitData.TEAM_SERVER_PURPLE: state.adrenalineteam0 += 0.1f; break; case UnitData.TEAM_CLIENT_RED: state.adrenalineteam1 += 0.1f; break; } }
public int attack(UnitActor a, boolean send) { if (attacked && send) { return 0; } int damage = data.attack - a.data.defense; switch (data.team) { case UnitData.TEAM_SERVER_PURPLE: if (state.adrenalineteam0 >= 1) { damage *= 2; state.adrenalineteam0 = 0; } state.adrenalineteam0 += .2f; state.adrenalineteam1 += .4f; break; case UnitData.TEAM_CLIENT_RED: if (state.adrenalineteam1 >= 1) { damage *= 2; state.adrenalineteam1 = 0; } state.adrenalineteam1 += .2f; state.adrenalineteam0 += .4f; break; } state.stage.addActor(new HitEffectActor(a.getX(), a.getY())); attacked = true; if (send && !PulsatioGame.getSingleton().testmode) { AttackUnit au = new AttackUnit(data.id, a.data.id); PulsatioGame.getSingleton().opponent.sendTCP(au); } a.data.health -= damage; if (a.data.health <= 0) { Log.info("KILLED"); if (a.data.team == 0) { state.team0units.remove(a); a.remove(); state.mapActors[a.data.x][a.data.y] = null; } if (a.data.team == 1) { state.team1units.remove(a); a.remove(); state.mapActors[a.data.x][a.data.y] = null; } } return damage; }