mirror of
https://github.com/jokerx3/HeatUp
synced 2026-07-27 09:59:45 +02:00
Merge branch 'master' of github.com:jokerx3/prp
This commit is contained in:
@@ -6,27 +6,47 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class MapHighscore implements Serializable {
|
public class MapHighscore implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private Map<Integer, ArrayList<String>> highscoreOfAllMaps = new HashMap<Integer, ArrayList<String>>();
|
private Map<Integer, ArrayList<Score>> highscoreOfAllMaps = new HashMap<Integer, ArrayList<Score>>();
|
||||||
|
|
||||||
|
public ArrayList<Score> getHighscores(int mapHash) {
|
||||||
|
if (highscoreOfAllMaps.get(mapHash) == null) {
|
||||||
|
ArrayList<Score> mapHighscores = new ArrayList<Score>();
|
||||||
|
for (int n = 0; n<10; n++) {
|
||||||
|
mapHighscores.add(new Score());
|
||||||
|
}
|
||||||
|
highscoreOfAllMaps.put(mapHash, mapHighscores);
|
||||||
|
}
|
||||||
|
return highscoreOfAllMaps.get(mapHash);
|
||||||
|
}
|
||||||
|
|
||||||
public void setHighscore(int mapHash, String name, int score) {
|
public void setHighscore(int mapHash, String name, int score) {
|
||||||
|
|
||||||
ArrayList<String> mapHighscores = highscoreOfAllMaps.get(mapHash);
|
ArrayList<Score> mapHighscores = highscoreOfAllMaps.get(mapHash);
|
||||||
|
|
||||||
for (int i = 0; i<mapHighscores.size(); i++) {
|
ArrayList<Score> newMapHighscores = new ArrayList<Score>();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i<10; i++) {
|
||||||
|
|
||||||
|
if (mapHighscores.get(i).getScore() > score) {
|
||||||
|
newMapHighscores.add(mapHighscores.get(i));
|
||||||
|
} else {
|
||||||
|
newMapHighscores.add(new Score(name, score));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapHighscores.size()>10) {
|
for (int j = i; j<10; j++) {
|
||||||
mapHighscores.remove(10);
|
|
||||||
|
newMapHighscores.add(mapHighscores.get(j));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
highscoreOfAllMaps.put(mapHash, newMapHighscores);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package de.heatup.highscore;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Score implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private int score;
|
||||||
|
|
||||||
|
public Score() {
|
||||||
|
name = "default";
|
||||||
|
score = 2342;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Score(String name, int score) {
|
||||||
|
this.name = name;
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getScore() {
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScore(int score) {
|
||||||
|
this.score = score;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ import de.heatup.objects.StaticObject;
|
|||||||
public class MapObjectHandler {
|
public class MapObjectHandler {
|
||||||
|
|
||||||
private static final int singleTileWidth = Config.singleTilePixels;
|
private static final int singleTileWidth = Config.singleTilePixels;
|
||||||
//private static final int triggerAreaAddition = Config.triggerAreaAddition;
|
|
||||||
|
|
||||||
private static ArrayList<StaticObject> allMapObjects = new ArrayList<StaticObject>();
|
private static ArrayList<StaticObject> allMapObjects = new ArrayList<StaticObject>();
|
||||||
private static ArrayList<StaticObject> allWallObjects = new ArrayList<StaticObject>();
|
private static ArrayList<StaticObject> allWallObjects = new ArrayList<StaticObject>();
|
||||||
@@ -27,7 +26,7 @@ public class MapObjectHandler {
|
|||||||
}
|
}
|
||||||
protected static void addAllHardwareTiles(MapEngine me) {
|
protected static void addAllHardwareTiles(MapEngine me) {
|
||||||
for (int i = 0; i<me.getAvailableHardwareTileTypes().size(); i++) {
|
for (int i = 0; i<me.getAvailableHardwareTileTypes().size(); i++) {
|
||||||
char currentType = me.getAvailableHardwareTileTypes().get(i); // current type
|
char currentType = me.getAvailableHardwareTileTypes().get(i);
|
||||||
ArrayList<Point> allPointsOfCurrentType = me.getAllCoordinatesOfTileType(currentType);
|
ArrayList<Point> allPointsOfCurrentType = me.getAllCoordinatesOfTileType(currentType);
|
||||||
Point firstPoint = allPointsOfCurrentType.get(0);
|
Point firstPoint = allPointsOfCurrentType.get(0);
|
||||||
Point lastPoint = allPointsOfCurrentType.get(allPointsOfCurrentType.size()-1);
|
Point lastPoint = allPointsOfCurrentType.get(allPointsOfCurrentType.size()-1);
|
||||||
@@ -35,19 +34,9 @@ public class MapObjectHandler {
|
|||||||
int currentTilesTotalWidth = lastPoint.x-firstPoint.x+singleTileWidth;
|
int currentTilesTotalWidth = lastPoint.x-firstPoint.x+singleTileWidth;
|
||||||
int currentTilesTotalHeight = lastPoint.y-firstPoint.y+singleTileWidth;
|
int currentTilesTotalHeight = lastPoint.y-firstPoint.y+singleTileWidth;
|
||||||
|
|
||||||
/* obsolet
|
|
||||||
int currentTriggerTilesTotalWidth = lastPoint.x-firstPoint.x+singleTileWidth+triggerAreaAddition;
|
|
||||||
int currentTriggerTilesTotalHeight = lastPoint.y-firstPoint.y+singleTileWidth+triggerAreaAddition;
|
|
||||||
Point currentTriggerTilesFirstPoint = new Point(firstPoint.x-(triggerAreaAddition/2),firstPoint.y-(triggerAreaAddition/2));
|
|
||||||
*/
|
|
||||||
|
|
||||||
StaticObject newStaticObject = new StaticObject(currentType, firstPoint, currentTilesTotalWidth, currentTilesTotalHeight);
|
StaticObject newStaticObject = new StaticObject(currentType, firstPoint, currentTilesTotalWidth, currentTilesTotalHeight);
|
||||||
// Trigger Object - obsolet
|
|
||||||
// StaticObject newTriggerObject = new StaticObject(currentType, firstPoint, currentTilesTotalWidth, currentTilesTotalHeight, true);
|
|
||||||
MapObjectHandler.allMapObjects.add(newStaticObject);
|
MapObjectHandler.allMapObjects.add(newStaticObject);
|
||||||
// MapObjectHandler.allMapObjects.add(newTriggerObject);
|
|
||||||
MapObjectHandler.allHardwareObjects.add(newStaticObject);
|
MapObjectHandler.allHardwareObjects.add(newStaticObject);
|
||||||
// MapObjectHandler.allHardwareTriggerObjects.add(newTriggerObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected static void addAllWallsAndWaysTiles(MapEngine me) {
|
protected static void addAllWallsAndWaysTiles(MapEngine me) {
|
||||||
|
|||||||
Reference in New Issue
Block a user