Merge branch 'pregametutorial' of http://184.154.0.242:7990/scm/min/mineplex into type-wars
# Conflicts: # Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java
This commit is contained in:
commit
dfb1837e81
@ -29,9 +29,13 @@ public abstract class GameTutorial
|
||||
|
||||
private int _tick;
|
||||
|
||||
private long _started;
|
||||
|
||||
public boolean SetTutorialPositions = true;
|
||||
public boolean TeleportOnEnd = true;
|
||||
public boolean RunTasksSync = true;
|
||||
public boolean PlayTutorialSounds = false;
|
||||
public boolean ShowPrepareTimer = false;
|
||||
|
||||
public long TimeBetweenPhase = 0;
|
||||
public long StartAfterTutorial = 5000;
|
||||
@ -50,8 +54,9 @@ public abstract class GameTutorial
|
||||
for(TutorialPhase phase : _phases)
|
||||
phase.setTutorial(this);
|
||||
|
||||
Manager.GetGame().PrepareTime = 60000;
|
||||
//Manager.GetGame().PrepareTime = 60000;
|
||||
Manager.GetChat().Silence(60000, false);
|
||||
_started = System.currentTimeMillis();
|
||||
Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this));
|
||||
onStart();
|
||||
preparePlayers();
|
||||
@ -78,11 +83,19 @@ public abstract class GameTutorial
|
||||
onEnd();
|
||||
_hasEnded = true;
|
||||
endTutorial();
|
||||
Manager.getPluginManager().callEvent(new GameTutorialEndEvent(this));
|
||||
final GameTutorial tutorial = this;
|
||||
Manager.runSyncLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial));
|
||||
}
|
||||
}, 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.GetChat().Silence(7000, false);
|
||||
Manager.GetChat().Silence(70000, false);
|
||||
onPhaseChange(_currentPhase);
|
||||
Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase));
|
||||
_currentPhase.start(phaseOne);
|
||||
@ -96,11 +109,18 @@ public abstract class GameTutorial
|
||||
|
||||
private void endTutorial()
|
||||
{
|
||||
for(Player player : _players.keySet())
|
||||
for(final Player player : _players.keySet())
|
||||
{
|
||||
VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers());
|
||||
Manager.runSyncLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
}, 5);
|
||||
if(TeleportOnEnd)
|
||||
{
|
||||
Manager.runSyncLater(new Runnable()
|
||||
@ -192,4 +212,24 @@ public abstract class GameTutorial
|
||||
_tick++;
|
||||
return _tick;
|
||||
}
|
||||
|
||||
public TutorialPhase[] getPhases()
|
||||
{
|
||||
return _phases;
|
||||
}
|
||||
|
||||
public long getTutorialStart()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
|
||||
public long getRunning()
|
||||
{
|
||||
return System.currentTimeMillis() - _started;
|
||||
}
|
||||
|
||||
public long getPhaseTime()
|
||||
{
|
||||
return _currentPhase.getPhaseTime();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ public abstract class TutorialPhase
|
||||
private Location _target;
|
||||
private boolean _hasEnded;
|
||||
|
||||
private long _started;
|
||||
|
||||
private TutorialText _currentText;
|
||||
|
||||
public TutorialPhase(TutorialText[] text)
|
||||
@ -28,6 +30,7 @@ public abstract class TutorialPhase
|
||||
final public void start(boolean phaseOne)
|
||||
{
|
||||
_hasEnded = false;
|
||||
_started = System.currentTimeMillis();
|
||||
onStart();
|
||||
if(!phaseOne)
|
||||
{
|
||||
@ -70,6 +73,8 @@ public abstract class TutorialPhase
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(!_hasEnded && !getTutorial().hasEnded())
|
||||
{
|
||||
for(Player player : _tutorial.getPlayers().keySet())
|
||||
{
|
||||
@ -78,6 +83,7 @@ public abstract class TutorialPhase
|
||||
player.teleport(_location);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
try
|
||||
{
|
||||
@ -121,6 +127,11 @@ public abstract class TutorialPhase
|
||||
int i = 0;
|
||||
for(Player player : _tutorial.getPlayers().keySet())
|
||||
{
|
||||
if(_tutorial.PlayTutorialSounds)
|
||||
{
|
||||
if(text.getSound() != null)
|
||||
player.playSound(player.getLocation(), text.getSound(), 2f, 2f);
|
||||
}
|
||||
players[i] = player;
|
||||
i++;
|
||||
}
|
||||
@ -212,6 +223,11 @@ public abstract class TutorialPhase
|
||||
return _target;
|
||||
}
|
||||
|
||||
public long getPhaseTime()
|
||||
{
|
||||
return _started;
|
||||
}
|
||||
|
||||
public void onStart(){}
|
||||
|
||||
public void onMessageDisplay(TutorialText text){}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package nautilus.game.arcade.gametutorial;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
|
||||
public class TutorialText
|
||||
{
|
||||
@ -7,17 +9,29 @@ public class TutorialText
|
||||
private String _text;
|
||||
private int _stayTime;
|
||||
private int _id;
|
||||
private Sound _sound;
|
||||
|
||||
public TutorialText(String text, int stayTime, int id)
|
||||
public TutorialText(String text, int stayTime, int id, Sound sound)
|
||||
{
|
||||
_text = text;
|
||||
_id = id;
|
||||
_stayTime = stayTime;
|
||||
_sound = sound;
|
||||
}
|
||||
|
||||
public TutorialText(String text, int id)
|
||||
{
|
||||
this(text, (int) (Math.round(1.5 * text.length()) + 25), id);
|
||||
this(text, (int) (Math.round(1.5 * text.length()) + 25), id, Sound.NOTE_PLING);
|
||||
}
|
||||
|
||||
public TutorialText(String text, int id, Sound sound)
|
||||
{
|
||||
this(text, (int) (Math.round(1.5 * text.length()) + 25), id, sound);
|
||||
}
|
||||
|
||||
public TutorialText(String text, int stayTime, int id)
|
||||
{
|
||||
this(text, stayTime, id, Sound.NOTE_PLING);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
@ -30,6 +44,11 @@ public class TutorialText
|
||||
return _id;
|
||||
}
|
||||
|
||||
public Sound getSound()
|
||||
{
|
||||
return _sound;
|
||||
}
|
||||
|
||||
public int getStayTime()
|
||||
{
|
||||
return _stayTime;
|
||||
|
@ -19,33 +19,31 @@ import mineplex.core.disguise.disguises.DisguiseWither;
|
||||
import mineplex.core.gadget.gadgets.MorphWither;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.core.mount.Mount;
|
||||
import mineplex.core.mount.types.MountDragon;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.RestartServerEvent;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GamePrepareCountdownCommence;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.games.uhc.UHC;
|
||||
import nautilus.game.arcade.gametutorial.GameTutorial;
|
||||
import nautilus.game.arcade.gametutorial.TutorialPhase;
|
||||
import nautilus.game.arcade.gametutorial.TutorialText;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -122,7 +120,7 @@ public class GameManager implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInTutorial()
|
||||
public boolean isInTutorial(boolean checkForTimer)
|
||||
{
|
||||
if (Manager.GetGame() == null || Manager.GetGame().GetState() != GameState.Prepare)
|
||||
return false;
|
||||
@ -147,21 +145,44 @@ public class GameManager implements Listener
|
||||
if(player.getWorld() == Manager.GetLobby().GetSpawn().getWorld())
|
||||
return true;
|
||||
}
|
||||
long prepTime = 0;
|
||||
for(GameTeam team : game.GetTeamList())
|
||||
{
|
||||
long timeUsage = 0;
|
||||
if(team.getTutorial() != null)
|
||||
{
|
||||
if(!team.getTutorial().hasStarted())
|
||||
{
|
||||
team.getTutorial().setTeam(team);
|
||||
team.getTutorial().start();
|
||||
timeUsage = team.getTutorial().StartAfterTutorial;
|
||||
timeUsage = timeUsage + (team.getTutorial().TimeBetweenPhase * team.getTutorial().getPhases().length);
|
||||
for(TutorialPhase phase : team.getTutorial().getPhases())
|
||||
{
|
||||
for(TutorialText text : phase.getText())
|
||||
{
|
||||
timeUsage = timeUsage + (text.getStayTime() * 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!team.getTutorial().hasEnded())
|
||||
{
|
||||
finished = false;
|
||||
}
|
||||
if(checkForTimer)
|
||||
{
|
||||
if(team.getTutorial().ShowPrepareTimer)
|
||||
finished = false;
|
||||
else
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
if(prepTime <= timeUsage)
|
||||
prepTime = timeUsage;
|
||||
}
|
||||
if(prepTime > 0)
|
||||
Manager.GetGame().PrepareTime = prepTime;
|
||||
|
||||
if(!finished)
|
||||
return true;
|
||||
}
|
||||
@ -179,7 +200,7 @@ public class GameManager implements Listener
|
||||
|
||||
Game game = Manager.GetGame();
|
||||
|
||||
if(isInTutorial())
|
||||
if(isInTutorial(true))
|
||||
return;
|
||||
|
||||
double percentage = (double) (System.currentTimeMillis() - game.GetStateTime()) / game.PrepareTime;
|
||||
@ -265,7 +286,7 @@ public class GameManager implements Listener
|
||||
}
|
||||
else if (game.GetState() == GameState.Prepare)
|
||||
{
|
||||
if(isInTutorial())
|
||||
if(isInTutorial(false))
|
||||
return;
|
||||
|
||||
if (game.CanStartPrepareCountdown())
|
||||
|
Loading…
Reference in New Issue
Block a user