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

@ -256,14 +256,6 @@ public abstract class GameTutorial
}
}
public void onTick(int tick){}
public void onStart(){}
public void onPhaseChange(TutorialPhase phase){}
public void onEnd(){}
public int tick()
{
// Fix for Visibility Manager not really working
@ -300,4 +292,17 @@ public abstract class GameTutorial
{
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;
}
/**
* start the Phase (never use this as well)
*/
final public void start(boolean phaseOne)
{
_hasEnded = false;
@ -41,6 +44,9 @@ public abstract class TutorialPhase
displayText();
}
/**
* Teleporting Players and keeping them if SetTutorialPositions == true
*/
final public void teleport()
{
if(!getTutorial().SetTutorialPositions)
@ -53,6 +59,9 @@ public abstract class TutorialPhase
}
}
/**
* preparing Pitch/Yaw of the location
*/
private void prepareLocations()
{
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);
}
/**
* teleporting players until Phase ends
*/
private void updatePlayers()
{
new Thread(new Runnable()
@ -76,6 +88,7 @@ public abstract class TutorialPhase
@Override
public void run()
{
// teleport Players Sync
if(!_hasEnded && !getTutorial().hasEnded())
{
for(Player player : _tutorial.getPlayers().keySet())
@ -89,6 +102,7 @@ public abstract class TutorialPhase
});
try
{
// sleep for 1 tick
Thread.sleep(50);
} catch (InterruptedException e)
{
@ -99,6 +113,10 @@ public abstract class TutorialPhase
}).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()
{
_thread = new Thread(new Runnable()
@ -111,6 +129,7 @@ public abstract class TutorialPhase
TutorialText text = getNextMessage();
if(text == null)
{
// ending Phase
_tutorial.Manager.runSyncLater(new Runnable()
{
@Override
@ -125,6 +144,7 @@ public abstract class TutorialPhase
}
else
{
// displaying next message
Player[] players = new Player[_tutorial.getPlayers().keySet().size()];
int i = 0;
for(Player player : _tutorial.getPlayers().keySet())
@ -154,6 +174,9 @@ public abstract class TutorialPhase
_thread.start();
}
/**
* firing abstract method Sync/Async depending on the RunTasksSync Flag
*/
private void displayMessage(final TutorialText text)
{
if(_tutorial.RunTasksSync)
@ -173,6 +196,9 @@ public abstract class TutorialPhase
}
}
/**
* getting next message
*/
protected TutorialText getNextMessage()
{
for(TutorialText text : _text)
@ -236,6 +262,10 @@ public abstract class TutorialPhase
return _thread;
}
/*
* some overrideable methods that can be used to synchronize the tutorial events
*/
public void onStart(){}
public void onMessageDisplay(TutorialText text){}