Skip to content
Snippets Groups Projects
Commit 9b579b16 authored by Sabvente's avatar Sabvente
Browse files

hangok megállítása kilépésnél; Tower range fix #2

parent aaaca59d
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,8 @@ import interfaces.ITickable;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
......@@ -81,6 +83,16 @@ public class Engine
gameWindow.setSize(1000, 750);
gameWindow.setResizable(false);
gameWindow.setContentPane(new GamePanel(world));
gameWindow.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent e)
{
isGameRunning = false;
Sounds.StopAllSound();
}
});
isGameRunning = true;
}
......
......@@ -2,6 +2,7 @@ package view;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
......@@ -10,6 +11,7 @@ import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
public class Sounds {
private static ArrayList<Clip> clips = new ArrayList<Clip>();
public static void LoopSound(String file) {
AudioInputStream aStream = null;
try {
......@@ -44,8 +46,17 @@ public class Sounds {
clip.open(aStream);
clip.setFramePosition(0);
clip.start();
clips.add(clip);
} catch (LineUnavailableException | IOException e1) {
e1.printStackTrace();
}
}
public static void StopAllSound()
{
for (Clip c : clips) {
c.stop();
}
clips.clear();
}
}
......@@ -76,9 +76,15 @@ public class Tower extends Placeable implements ITickable, IEnemyObserver,
for (Field field : visibleFields) {
if (field == null)
continue;
newVisible.addAll(field.getNeighbours());
for (Field neigh : field.getNeighbours()) {
if(!newVisible.contains(neigh))
newVisible.add(neigh);
}
}
for (Field neigh : newVisible) {
if(!visibleFields.contains(neigh))
visibleFields.add(neigh);
}
visibleFields.addAll(newVisible);
getVisibleFields(visibleFields, iterations - 1);
}
......@@ -86,7 +92,6 @@ public class Tower extends Placeable implements ITickable, IEnemyObserver,
enemiesInRange.clear();
ArrayList<Field> visibleFields = new ArrayList<Field>();
visibleFields.add(field);
getVisibleFields(visibleFields, range);
if (fogDescends)
getVisibleFields(visibleFields, range - 1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment