Commit 97fad971 authored by Nils Hein's avatar Nils Hein
Browse files

Fixed scoring system

parent e70adb99
......@@ -216,42 +216,44 @@ public class GameScreen implements Screen {
if (p.active != null) {
if (p.active.isFlying) {
Hexagon point = getCurrentHex(p.active);
boolean hit = false;
for (Hexagon h : map.getNeighborsOf(point)) {
if (nachbarn.containsKey(h)) {
if (p.active.getPos().dst(getHexCenter(h)) < 2 * (bubblradius * 0.9)) {
p.active.isFlying = false;
if (!nachbarn.containsKey(point)) {
nachbarn.put(point, new Bubble(p.active));
}
p.active = null;
hit = true;
FrozenNumbersGame.assets.get("snd/hit.mp3", Sound.class).play();
p.placedBubbleThisRound = true;
break;
}
}
}
if (p.active != null)
if ((p.active.getPos().y > bound-bubblradius/2.0 && lower) || (p.active.getPos().y < bound+bubblradius/2.0 && !lower)) {
p.active.isFlying = false;
p.active.setVel(new Vector2(0, 0));
if (!nachbarn.containsKey(point))
nachbarn.put(point, new Bubble(p.active));
p.active = null;
FrozenNumbersGame.assets.get("snd/hit.mp3", Sound.class).play();
p.placedBubbleThisRound = true;
}
if ((p.active.getPos().y > bound - bubblradius / 2.0 && lower) || (p.active.getPos().y < bound + bubblradius / 2.0 && !lower)) {
hit = true;
FrozenNumbersGame.assets.get("snd/hit.mp3", Sound.class).play();
}
}
if (p.active != null) {
if (p.active.getPos().x > m_Bounds.getWidth() - (bubblradius)
|| p.active.getPos().x < m_Bounds.getX() + (bubblradius)) {
p.active.setVel(p.active.getVel().scl(-1, 1));
}
p.active.Update(0.1f);
}
if (hit) {
p.active.isFlying = false;
p.active.setVel(new Vector2(0, 0));
if (!nachbarn.containsKey(point))
nachbarn.put(point, new Bubble(p.active));
p.active = null;
p.score += checkScore(point);
for (Hexagon h : map.getNeighborsOf(point)) {
if(nachbarn.containsKey(h))
p.score += checkScore(h);
}
}
}
}
//Moving falling Bubbles
......@@ -279,6 +281,27 @@ public class GameScreen implements Screen {
}
}
private int checkScore(Hexagon h) {
int sum = 0;
Bubble active = nachbarn.get(h);
List<Bubble> nei = new ArrayList<Bubble>();
for (Hexagon n : map.getNeighborsOf(h)) {
if (nachbarn.containsKey(n)) {
sum += 1;
nei.add(nachbarn.get(n));
}
}
if (sum % 10 == active.getValue() && nei.size() > 1) {
if (!nachbarn.get(h).isFrozen()) {
removes.add(h);
removes.addAll(map.getNeighborsOf(h));
}
return sum;
}
return 0;
}
@Override
public void render(float delta) {
removes.clear();
......@@ -299,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