Created
January 19, 2014 18:35
-
-
Save MrBluePotato/8508981 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Interval(SchedulerTask task) | |
{ | |
//check to stop Interval | |
if (_world == null) | |
{ | |
_world = null; | |
task.Stop(); | |
return; | |
#if DEBUG | |
Server.Message("World was null"); | |
#endif | |
} | |
if (_world.gameMode != GameMode.PropHunt) | |
{ | |
_world = null; | |
task.Stop(); | |
return; | |
#if DEBUG | |
Server.Message("Gamemode was not prophunt"); | |
#endif | |
} | |
if (!isOn) | |
{ | |
//Time delay if it is the on-demand instance of the game | |
if (startTime != null && (DateTime.Now - startTime).TotalSeconds > timeDelay && startMode != Game.StartMode.PropHunt) | |
{ | |
foreach (Player p in _world.Players) | |
{ | |
beginGame(p); | |
chooseSeeker(); | |
p.isPlayingPropHunt = true; | |
if (!p.isPropHuntSeeker) | |
{ | |
p.Model = blockId[randBlock.Next(0, blockId.Length)]; | |
} | |
} | |
} | |
//Handlers for various things | |
Player.Moving += PlayerMovingHandler; | |
Player.Clicking += PlayerClickingHandler; | |
Player.Connected += PlayerConnectedHandler; | |
checkIdlesTask = Scheduler.NewTask(CheckIdles).RunForever(CheckIdlesInterval); | |
isOn = true; | |
lastChecked = DateTime.Now; //used for intervals | |
#if DEBUG | |
Server.Message("It is on and stuff..."); | |
#endif | |
} | |
timeLeft = Convert.ToInt16(((timeDelay + timeLimit) - (DateTime.Now - startTime).TotalSeconds)); | |
if (isOn) | |
{ | |
#if !(DEBUG) | |
if (_world.Players.Count(player => player.isPropHuntSeeker) == _world.Players.Count()) | |
{ | |
//Many things will happen here. | |
} | |
if (_world.Players.Count(player => player.isPropHuntSeeker) == 0 && _world.Players.Count() > 0) | |
{ | |
//Lots of things will happen here. | |
} | |
#endif | |
//Ondemand prophunt | |
if (timeLeft == 0 && startMode == Game.StartMode.None) | |
{ | |
Server.Message("The seeker was unable to find all the blocks!69"); | |
return; | |
} | |
//Startup prophunt | |
if (timeLeft == 0 && startMode == Game.StartMode.PropHunt) | |
{ | |
_world.Players.Message("The seeker was unable to find all the blocks!"); | |
roundEnd = DateTime.Now; | |
roundStarted = false; | |
//takeVote(); | |
} | |
} | |
if (lastChecked != null && (DateTime.Now - lastChecked).TotalSeconds > 30 && timeLeft <= timeLimit) | |
{ | |
_world.Players.Message("There are currently {0} block(s) and {1} seeker(s) left on {2}", _world.Players.Count() - _world.Players.Count(player => !player.isPropHuntSeeker), _world.Players.Count(player => player.isPropHuntSeeker), _world.ClassyName); | |
_world.Players.Message("There are {0} seconds left!", timeLeft); | |
lastChecked = DateTime.Now; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment