|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJTP.ProgressHandler
public class ProgressHandler
Provides methods for storing highscore and progress data to disk and handling of area unlocking.
Field Summary | |
---|---|
static int |
EDITOR
Progress milestone: Editor |
static int |
FAILED_TO_SAVE
Indicates progress data could not be saved. |
static int |
LOAD_CUSTOM
Progress milestone: Loading of custom levelsets |
static int |
ONEP_CHALLENGE
Progress milestone: Single player challenge mode |
static int |
SAVED
Indicates progress data was saved. |
static int |
TWOP_CHALLENGE
Progress milestone: Two player challenge mode |
static int |
TWOP_COOP
Progress milestone: Two player cooperative mode |
static int |
TWOP_VS
Progress milestone: Two player versus mode |
static int |
TWOP_VS_ALT
Progress milestone: Two player versus alternate mode |
static int |
UNLOCKED
Indivates progress data was saved and an area unlocked. |
Constructor Summary | |
---|---|
ProgressHandler()
|
Method Summary | |
---|---|
static boolean |
areaUnlocked(int type)
Checks whether a particular area has been unlocked. |
static int |
getAreaUnlockPoint(int type)
Returns level which unlocks a certain area. |
static String |
getProgressFilePath()
Returns location of progress file. |
static int |
getReachedLevel(boolean coop)
Returns which level has been reached. |
static String |
getRequestMessage(int type,
boolean inGame)
Creates message informing player which level they have to beat to unlock a particular area. |
static String |
getUnlockMessage(int levelIndex)
Returns string representation of unlocked area. |
static int |
levelWillUnlockMode(int levelIndex)
Returns whether a particular level will unlock an area |
static Progress |
loadProgress()
Loads progress data from disk. |
static boolean |
progressMade(boolean coop)
Checks whether any progress has been made in a levelset. |
static void |
saveProgress(Progress progress)
Saves progress data to disk. |
static void |
setProgressFilePath(String path)
Sets location of progress file. |
static int |
setReachedLevel(int levelNumber,
boolean coop)
Updates progress made in levelset. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FAILED_TO_SAVE
public static final int SAVED
public static final int UNLOCKED
public static final int ONEP_CHALLENGE
public static final int TWOP_COOP
public static final int TWOP_CHALLENGE
public static final int TWOP_VS
public static final int TWOP_VS_ALT
public static final int LOAD_CUSTOM
public static final int EDITOR
Constructor Detail |
---|
public ProgressHandler()
Method Detail |
---|
public static void setProgressFilePath(String path) throws NullPointerException
path
- the relative or absolute path (and name) of the progress
file
NullPointerException
- if path
is null
public static String getProgressFilePath()
public static String getUnlockMessage(int levelIndex)
levelIndex
- level currently unlocked.
null
if
completing the given level did not unlock a new area.public static int levelWillUnlockMode(int levelIndex)
levelIndex
- the level to check against
-1
otherwise.public static int getAreaUnlockPoint(int type)
type
- one of ONEP_CHALLENGE
, TWOP_COOP
,
TWOP_CHALLENGE
, TWOP_VS
,
TWOP_VS_ALT
or EDITOR
.
IllegalArgumentException
- if type
is not a valid area.public static String getRequestMessage(int type, boolean inGame)
type
- one of ONEP_CHALLENGE
, TWOP_COOP
,
TWOP_CHALLENGE
, TWOP_VS
,
TWOP_VS_ALT
or EDITOR
.
IllegalArgumentException
- if type
is not a valid area.public static boolean areaUnlocked(int type) throws IllegalArgumentException
type
- one of ONEP_CHALLENGE
, TWOP_COOP
,
TWOP_CHALLENGE
, TWOP_VS
,
TWOP_VS_ALT
or EDITOR
.
IllegalArgumentException
- if type
is not a valid area.public static boolean progressMade(boolean coop)
coop
- either Progress.SINGLE
or
Progress.COOP
.
true
if at least one level has been completed.public static int getReachedLevel(boolean coop)
Integer.MAX_VALUE
.
coop
- either Progress.SINGLE
or
Progress.COOP
.
0
if no progress has been made, or
-1
if progress data could not be loaded from disk.public static int setReachedLevel(int levelNumber, boolean coop) throws IllegalArgumentException
levelNumber
- the level reached.coop
- either Progress.SINGLE
or
Progress.COOP
.
SAVED
if the updated progress was saved to diskUNLOCKED
if progress was saved and a new are has been
unlocked, orFAILED_TO_SAVE
if there was a problem in writing the
progress information to disk.IllegalArgumentException
- if levelNumber < 0
.public static Progress loadProgress()
Progress
if
loading from disk failed.public static void saveProgress(Progress progress) throws IOException, NullPointerException
progress
- the progress information to save.
IOException
- if there was a problem in writing the progress
information to disk
NullPointerException
- if progress
is null
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |