some more descriptions for Tutorials

This commit is contained in:
Sarah 2015-12-12 20:03:35 +01:00
parent 09e5aed6e7
commit a92361f2fe
2 changed files with 43 additions and 8 deletions

View File

@ -255,14 +255,6 @@ public abstract class GameTutorial
System.out.println("Only allowed while Custom Ending is enabled"); System.out.println("Only allowed while Custom Ending is enabled");
} }
} }
public void onTick(int tick){}
public void onStart(){}
public void onPhaseChange(TutorialPhase phase){}
public void onEnd(){}
public int tick() public int tick()
{ {
@ -300,4 +292,17 @@ public abstract class GameTutorial
{ {
return _currentPhase.getPhaseTime(); return _currentPhase.getPhaseTime();
} }
/*
* some overrideable methods that can be used to synchronize the tutorial events
*/
public void onTick(int tick){}
public void onStart(){}
public void onPhaseChange(TutorialPhase phase){}
public void onEnd(){}
} }

View File

@ -29,6 +29,9 @@ public abstract class TutorialPhase
_text = text; _text = text;
} }
/**
* start the Phase (never use this as well)
*/
final public void start(boolean phaseOne) final public void start(boolean phaseOne)
{ {
_hasEnded = false; _hasEnded = false;
@ -41,6 +44,9 @@ public abstract class TutorialPhase
displayText(); displayText();
} }
/**
* Teleporting Players and keeping them if SetTutorialPositions == true
*/
final public void teleport() final public void teleport()
{ {
if(!getTutorial().SetTutorialPositions) if(!getTutorial().SetTutorialPositions)
@ -53,6 +59,9 @@ public abstract class TutorialPhase
} }
} }
/**
* preparing Pitch/Yaw of the location
*/
private void prepareLocations() private void prepareLocations()
{ {
Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ()); Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ());
@ -62,6 +71,9 @@ public abstract class TutorialPhase
_location.setYaw(yaw); _location.setYaw(yaw);
} }
/**
* teleporting players until Phase ends
*/
private void updatePlayers() private void updatePlayers()
{ {
new Thread(new Runnable() new Thread(new Runnable()
@ -76,6 +88,7 @@ public abstract class TutorialPhase
@Override @Override
public void run() public void run()
{ {
// teleport Players Sync
if(!_hasEnded && !getTutorial().hasEnded()) if(!_hasEnded && !getTutorial().hasEnded())
{ {
for(Player player : _tutorial.getPlayers().keySet()) for(Player player : _tutorial.getPlayers().keySet())
@ -89,6 +102,7 @@ public abstract class TutorialPhase
}); });
try try
{ {
// sleep for 1 tick
Thread.sleep(50); Thread.sleep(50);
} catch (InterruptedException e) } catch (InterruptedException e)
{ {
@ -99,6 +113,10 @@ public abstract class TutorialPhase
}).start(); }).start();
} }
/**
* displays all messages set in the constructor
* will end Phase if no more messages are available or Tutorial has already ended
*/
public void displayText() public void displayText()
{ {
_thread = new Thread(new Runnable() _thread = new Thread(new Runnable()
@ -111,6 +129,7 @@ public abstract class TutorialPhase
TutorialText text = getNextMessage(); TutorialText text = getNextMessage();
if(text == null) if(text == null)
{ {
// ending Phase
_tutorial.Manager.runSyncLater(new Runnable() _tutorial.Manager.runSyncLater(new Runnable()
{ {
@Override @Override
@ -125,6 +144,7 @@ public abstract class TutorialPhase
} }
else else
{ {
// displaying next message
Player[] players = new Player[_tutorial.getPlayers().keySet().size()]; Player[] players = new Player[_tutorial.getPlayers().keySet().size()];
int i = 0; int i = 0;
for(Player player : _tutorial.getPlayers().keySet()) for(Player player : _tutorial.getPlayers().keySet())
@ -154,6 +174,9 @@ public abstract class TutorialPhase
_thread.start(); _thread.start();
} }
/**
* firing abstract method Sync/Async depending on the RunTasksSync Flag
*/
private void displayMessage(final TutorialText text) private void displayMessage(final TutorialText text)
{ {
if(_tutorial.RunTasksSync) if(_tutorial.RunTasksSync)
@ -173,6 +196,9 @@ public abstract class TutorialPhase
} }
} }
/**
* getting next message
*/
protected TutorialText getNextMessage() protected TutorialText getNextMessage()
{ {
for(TutorialText text : _text) for(TutorialText text : _text)
@ -236,6 +262,10 @@ public abstract class TutorialPhase
return _thread; return _thread;
} }
/*
* some overrideable methods that can be used to synchronize the tutorial events
*/
public void onStart(){} public void onStart(){}
public void onMessageDisplay(TutorialText text){} public void onMessageDisplay(TutorialText text){}