Commit 65865a5d authored by Nils Hein's avatar Nils Hein
Browse files

Alternatives zählen der Punkte zum testen

parent 9a7d2540
......@@ -99,7 +99,7 @@ public class GameScreen implements Screen {
nextTop.rotate(180);
nextTop.setCenter(wWidth / 4.0f * 3.0f, wHeight * 0.95f);
nextBottom.setAlpha(0.1f);
nextBottom.setAlpha(0.3f);
nextTop.setAlpha(0.1f);
nextBottomOverlay = new Sprite(FrozenNumbersGame.assets.get("sprites/btn_next.png", Texture.class));
......@@ -226,6 +226,7 @@ public class GameScreen implements Screen {
nachbarn.put(point, new Bubble(p.active));
}
checkScore(point,p.active.getValue(),p);
p.active = null;
FrozenNumbersGame.assets.get("snd/hit.mp3", Sound.class).play();
p.placedBubbleThisRound = true;
......@@ -240,6 +241,7 @@ public class GameScreen implements Screen {
p.active.setVel(new Vector2(0, 0));
if (!nachbarn.containsKey(point))
nachbarn.put(point, new Bubble(p.active));
checkScore(point,p.active.getValue(),p);
p.active = null;
FrozenNumbersGame.assets.get("snd/hit.mp3", Sound.class).play();
p.placedBubbleThisRound = true;
......@@ -281,6 +283,25 @@ public class GameScreen implements Screen {
}
}
private void checkScore(Hexagon h, float val,Player p){
float sum = 0;
List<Bubble> nei = new ArrayList<Bubble>();
for (Hexagon n : map.getNeighborsOf(h)) {
if (nachbarn.containsKey(n)) {
sum += nachbarn.get(n).getValue();
nei.add(nachbarn.get(n));
}
if(sum % 10 == val && nei.size() > 1)
break;
}
if (sum % 10 == val && nei.size() > 1) {
if (!nachbarn.get(h).isFrozen()) {
removes.add(h);
removes.addAll(map.getNeighborsOf(h));
p.score += sum;
}
}
}
@Override
public void render(float delta) {
removes.clear();
......@@ -301,28 +322,6 @@ public class GameScreen implements Screen {
bu.setForce(f);
bu.isDamped = true;
bu.Update(0.1f);
float sum = 0;
List<Bubble> nei = new ArrayList<Bubble>();
for (Hexagon n : map.getNeighborsOf(h)) {
if (nachbarn.containsKey(n)) {
sum += nachbarn.get(n).getValue();
nei.add(nachbarn.get(n));
}
}
if (sum % 10 == bu.getValue() && nei.size() > 1) {
if (!nachbarn.get(h).isFrozen()) {
removes.add(h);
removes.addAll(map.getNeighborsOf(h));
if (p1.placedBubbleThisRound) {
p1.score += sum;
p1.placedBubbleThisRound = false;
}
if (p2.placedBubbleThisRound) {
p2.score += sum;
p2.placedBubbleThisRound = false;
}
}
}
}
//Freezing bubbles
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment