From b5eaa7d4d2677c21299d7a9817c4429528c776e2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 22 Mar 2016 22:55:12 +1100 Subject: [PATCH] Fix 'round end' being shown twice when the round ended with humans surviving, fix entities being repeatedly respawned, update /time to also show the time left in the round when running with zombie survival. --- Commands/Information/CmdTime.cs | 66 ++++++++++++++----------- Games/ZombieSurvival/ZombieGame.Core.cs | 5 +- Games/ZombieSurvival/ZombieGame.cs | 2 +- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/Commands/Information/CmdTime.cs b/Commands/Information/CmdTime.cs index 7027c3826..ca1fd3c8a 100644 --- a/Commands/Information/CmdTime.cs +++ b/Commands/Information/CmdTime.cs @@ -1,43 +1,51 @@ /* - Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. + Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. */ using System; -namespace MCGalaxy.Commands -{ - public sealed class CmdTime : Command - { +using MCGalaxy.Games; + +namespace MCGalaxy.Commands { + + public sealed class CmdTime : Command { public override string name { get { return "time"; } } - public override string shortcut { get { return ""; } } + public override string shortcut { get { return "ti"; } } public override string type { get { return CommandTypes.Information; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public CmdTime() { } - public override void Use(Player p, string message) - { - string time = DateTime.Now.ToString("HH:mm:ss"); - message = "Server time is " + time; - Player.SendMessage(p, message); - //message = "full Date/Time is " + DateTime.Now.ToString(); - //Player.SendMessage(p, message); + public override void Use(Player p, string message) { + string time = DateTime.Now.ToString("HH:mm:ss"); //DateTime.Now.ToString(); + Player.SendMessage(p, "Server time is " + time); + if (Server.zombie.Status != ZombieGameStatus.NotStarted) { + int delta = (int)(DateTime.UtcNow - Server.zombie.RoundEnd); + if (delta > 0) { + Player.SendMessage(p, "&a" + delta + " %Sseconds until the round ends."); + } else { + delta = (int)(DateTime.UtcNow - Server.zombie.RoundStart); + if (delta > 0) + Player.SendMessage(p, "&a" + delta + " %Sseconds until the round starts."); + } + } } - public override void Help(Player p) - { + + public override void Help(Player p) { Player.SendMessage(p, "/time - Shows the server time."); + Player.SendMessage(p, "If zombie survival is running, shows time left until round end or start."); } } } diff --git a/Games/ZombieSurvival/ZombieGame.Core.cs b/Games/ZombieSurvival/ZombieGame.Core.cs index dbeaeb7b1..3452189f5 100644 --- a/Games/ZombieSurvival/ZombieGame.Core.cs +++ b/Games/ZombieSurvival/ZombieGame.Core.cs @@ -156,7 +156,7 @@ namespace MCGalaxy.Games { UpdatePlayerColor(pKiller, Colors.red); bool aliveChanged = false; foreach (Player pAlive in alive) { - UpdatePlayerColor(pAlive, pAlive.group.color); + UpdatePlayerColor(pAlive, pAlive.color); if (Math.Abs(pAlive.pos[0] - pKiller.pos[0]) > HitboxPrecision || Math.Abs(pAlive.pos[1] - pKiller.pos[1]) > HitboxPrecision || Math.Abs(pAlive.pos[2] - pKiller.pos[2]) > HitboxPrecision) @@ -228,7 +228,7 @@ namespace MCGalaxy.Games { Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); } - public void EndRound(object sender, ElapsedEventArgs e) { + void EndRound(object sender, ElapsedEventArgs e) { if (Status == ZombieGameStatus.NotStarted) return; CurrentLevel.ChatLevel("%4Round End:%f 5"); Thread.Sleep(1000); CurrentLevel.ChatLevel("%4Round End:%f 4"); Thread.Sleep(1000); @@ -239,6 +239,7 @@ namespace MCGalaxy.Games { } public void HandOutRewards() { + if (!RoundInProgress) return; RoundInProgress = false; RoundStart = DateTime.MinValue; RoundEnd = DateTime.MinValue; diff --git a/Games/ZombieSurvival/ZombieGame.cs b/Games/ZombieSurvival/ZombieGame.cs index 09b555cc5..21198e505 100644 --- a/Games/ZombieSurvival/ZombieGame.cs +++ b/Games/ZombieSurvival/ZombieGame.cs @@ -155,7 +155,7 @@ namespace MCGalaxy.Games { Infected.Remove(p); Alive.Add(p); p.infected = false; - UpdatePlayerColor(p, p.group.color); + UpdatePlayerColor(p, p.color); UpdateAllPlayerStatus(); }