Move zombie and game-related variables to a separate class.

This commit is contained in:
UnknownShadow200 2016-03-29 22:39:11 +11:00
parent 5951661748
commit e827023e9d
19 changed files with 179 additions and 128 deletions

View File

@ -28,11 +28,12 @@ namespace MCGalaxy.Commands {
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override void Use(Player p, string message) {
bool showInfected = p.aka; p.aka = !p.aka;
bool showInfected = p.Game.Aka;
p.Game.Aka = !p.Game.Aka;
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
if (pl.level != p.level || p == pl || !Player.CanSee(p, pl) || pl.referee) continue;
if (pl.level != p.level || p == pl || !Player.CanSee(p, pl) || pl.Game.Referee) continue;
p.SendDespawn(pl.id);
Player.SpawnEntity(pl, p, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
}

View File

@ -50,7 +50,7 @@ namespace MCGalaxy.Commands {
case "members":
HandleMembers(p, args); break;
default:
Team team = p.GameTeam;
Team team = p.Game.Team;
if (team == null) {
Player.SendMessage(p, "You need to be in a team first to send a team message."); return;
}
@ -59,7 +59,7 @@ namespace MCGalaxy.Commands {
}
void HandleOwner(Player p, string[] args) {
Team team = p.GameTeam;
Team team = p.Game.Team;
if (team == null) { Player.SendMessage(p, "You need to be in a team first."); return; }
if (args.Length == 1) {
@ -74,7 +74,7 @@ namespace MCGalaxy.Commands {
}
void HandleKick(Player p, string[] args) {
Team team = p.GameTeam;
Team team = p.Game.Team;
if (team == null) { Player.SendMessage(p, "You need to be in a team first."); return; }
if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the name of the player to kick."); return;
@ -87,7 +87,7 @@ namespace MCGalaxy.Commands {
team.Action(p, "kicked " + args[1] + " from the team.");
Player who = PlayerInfo.FindExact(args[1]);
if (who != null) {
who.GameTeam = null;
who.Game.Team = null;
who.SetPrefix();
}
Team.SaveList();
@ -97,7 +97,7 @@ namespace MCGalaxy.Commands {
}
void HandleColor(Player p, string[] args) {
Team team = p.GameTeam;
Team team = p.Game.Team;
if (team == null) { Player.SendMessage(p, "You need to be in a team first."); return; }
if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the new color."); return;
@ -114,7 +114,7 @@ namespace MCGalaxy.Commands {
}
void HandleCreate(Player p, string[] args) {
Team team = p.GameTeam;
Team team = p.Game.Team;
if (team != null) { Player.SendMessage(p, "You need to leave your current team before you can create one."); return; }
if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the name of the new team."); return;
@ -122,7 +122,7 @@ namespace MCGalaxy.Commands {
team = Team.FindTeam(args[1]);
if (team != null) { Player.SendMessage(p, "There is already an existing team with that name."); return; }
team = new Team(args[1], p.name);
p.GameTeam = team;
p.Game.Team = team;
p.SetPrefix();
Team.TeamsList[team.Name] = team;
Team.SaveList();
@ -130,21 +130,21 @@ namespace MCGalaxy.Commands {
}
void HandleJoin(Player p, string[] args) {
Team team = p.GameTeam;
if (p.GameTeamInvite == null) { Player.SendMessage(p, "You do not currently have any invitation to join a team."); return; }
Team team = p.Game.Team;
if (p.Game.TeamInvite == null) { Player.SendMessage(p, "You do not currently have any invitation to join a team."); return; }
if (team != null) { Player.SendMessage(p, "You need to leave your current team before you can join another one."); return; }
team = Team.FindTeam(p.GameTeamInvite);
team = Team.FindTeam(p.Game.TeamInvite);
if (team == null) { Player.SendMessage(p, "The team you were invited to no longer exists."); return; }
team.Members.Add(p.name);
team.Action(p, "joined the team.");
p.GameTeam = team;
p.Game.Team = team;
p.SetPrefix();
Team.SaveList();
}
void HandleInvite(Player p, string[] args) {
Team team = p.GameTeam;
Team team = p.Game.Team;
if (team == null) { Player.SendMessage(p, "You need to be in a team first to invite players."); return; }
if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the name of the person to invite."); return;
@ -154,22 +154,22 @@ namespace MCGalaxy.Commands {
Player.SendMessage(p, "Invited " + who.FullName + " %Sto join your team.");
Player.SendMessage(who, p.color + p.DisplayName + " %Sinvited you to join the " + team.Color + team.Name + " %Steam.");
who.GameTeamInvite = team.Name;
who.Game.TeamInvite = team.Name;
}
void HandleLeave(Player p, string[] args) {
Team team = p.GameTeam;
Team team = p.Game.Team;
if (team == null) { Player.SendMessage(p, "You need to be in a team first to leave one."); return; }
team.Action(p, "left the team.");
team.Remove(p.name);
p.GameTeam = null;
p.Game.Team = null;
p.SetPrefix();
Team.SaveList();
}
void HandleMembers(Player p, string[] args) {
Team team = p.GameTeam;
Team team = p.Game.Team;
if (args.Length == 1) {
if (team == null) { Player.SendMessage(p, "You are not in a team, so must provide a team name."); return; }
} else {

View File

@ -31,9 +31,9 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
if (p.ratedMap) { Player.SendMessage(p, "You have already liked this map."); return; }
if (p.Game.RatedMap) { Player.SendMessage(p, "You have already liked this map."); return; }
p.level.Likes++;
p.ratedMap = true;
p.Game.RatedMap = true;
Player.SendMessage(p, "You have liked this map.");
}
@ -53,9 +53,9 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
if (p.ratedMap) { Player.SendMessage(p, "You have already disliked this map."); return; }
if (p.Game.RatedMap) { Player.SendMessage(p, "You have already disliked this map."); return; }
p.level.Dislikes++;
p.ratedMap = true;
p.Game.RatedMap = true;
Player.SendMessage(p, "You have disliked this map.");
}

View File

@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
if (!p.level.guns) {
Player.SendMessage(p, Weapon + "s cannot be used on this map!"); return;
}
if (p.hasflag != null) {
if (p.Game.hasflag != null) {
Player.SendMessage(p, "You can't use a " + Weapon.ToLower() + " while you have the flag!"); return;
}

View File

@ -31,9 +31,9 @@ namespace MCGalaxy.Commands {
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return;
if (!who.infected || !Server.zombie.RoundInProgress) {
if (!who.Game.Infected || !Server.zombie.RoundInProgress) {
Player.SendMessage(p, "Cannot disinfect player");
} else if (!who.referee) {
} else if (!who.Game.Referee) {
Server.zombie.DisinfectPlayer(who);
Player.GlobalMessage(who.color + who.DisplayName + " %Swas disinfected!");
}

View File

@ -30,11 +30,11 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
if (p.pledgeSurvive) {
if (p.Game.PledgeSurvive) {
Player.SendMessage(p, "You cannot un-pledge that you will be infected."); return;
}
p.pledgeSurvive = true;
p.Game.PledgeSurvive = true;
Server.zombie.CurLevel
.ChatLevel(p.color + p.DisplayName + " %Spledges that they will not succumb to the infection!");
}

View File

@ -31,9 +31,9 @@ namespace MCGalaxy.Commands {
Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return;
if (who.infected || !Server.zombie.RoundInProgress) {
if (who.Game.Infected || !Server.zombie.RoundInProgress) {
Player.SendMessage(p, "Cannot infect player");
} else if (!who.referee) {
} else if (!who.Game.Referee) {
Server.zombie.InfectPlayer(who);
Player.GlobalMessage(who.color + who.DisplayName + " %Swas infected!");
}

View File

@ -30,7 +30,7 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
if (p.referee) {
if (p.Game.Referee) {
Player.SendChatFrom(p, p.FullName + " %Sis no longer a referee", false);
if (p.level == Server.zombie.CurLevel)
Server.zombie.PlayerJoinedLevel(p, Server.zombie.CurLevel, Server.zombie.CurLevel);
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands {
Server.zombie.PlayerLeftServer(p);
Player.GlobalDespawn(p, false);
}
p.referee = !p.referee;
p.Game.Referee = !p.Game.Referee;
}
public override void Help(Player p) {

View File

@ -34,7 +34,7 @@ namespace MCGalaxy.Commands {
ushort x = (ushort)(16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32);
ushort y = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32);
ushort z = (ushort)(16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32);
if (!p.referee && !p.infected && Server.zombie.RoundInProgress)
if (!p.Game.Referee && !p.Game.Infected && Server.zombie.RoundInProgress)
Server.zombie.InfectPlayer(p);
if (p.PlayingTntWars) {

View File

@ -39,7 +39,7 @@ namespace MCGalaxy.Eco {
"%c to buy " + (count * 10) + " " + Name + "."); return;
}
p.blockCount += 10 * count;
p.Game.BlocksLeft += 10 * count;
MakePurchase(p, Price * count, "%3Blocks: " + (10 * count));
}
}
@ -90,8 +90,8 @@ namespace MCGalaxy.Eco {
}
PlayerDB.AppendInfectMessage(p.name, text);
if (p.infectMessages == null) p.infectMessages = new List<string>();
p.infectMessages.Add(text);
if (p.Game.InfectMessages == null) p.Game.InfectMessages = new List<string>();
p.Game.InfectMessages.Add(text);
Player.SendMessage(p, "%aAdded infect message: %f" + text);
MakePurchase(p, Price, "%3InfectMessage: " + message);
}

View File

@ -39,16 +39,16 @@ namespace MCGalaxy.Games
public void AddMember(Player p)
{
if (p.team != this)
if (p.Game.team != this)
{
if (p.team != null) { p.team.RemoveMember(p); }
p.team = this;
if (p.Game.team != null) { p.Game.team.RemoveMember(p); }
p.Game.team = this;
Player.GlobalDespawn(p, false);
//p.CTFtempcolor = p.color;
//p.CTFtempprefix = p.prefix;
p.color = "&" + color;
//p.carryingFlag = false;
p.hasflag = null;
p.Game.hasflag = null;
p.prefix = p.color + "[" + Colors.Name("&" + color).ToUpper() + "] ";
players.Add(p);
mapOn.ChatLevel(p.FullName + " %Shas joined the " + teamstring + ".");
@ -58,14 +58,14 @@ namespace MCGalaxy.Games
public void RemoveMember(Player p)
{
if (p.team == this)
if (p.Game.team == this)
{
p.team = null;
p.Game.team = null;
Player.GlobalDespawn(p, false);
//p.color = p.CTFtempcolor;
//p.prefix = p.CTFtempprefix;
//p.carryingFlag = false;
p.hasflag = null;
p.Game.hasflag = null;
players.Remove(p);
mapOn.ChatLevel(p.FullName + " %Shas left the " + teamstring + ".");
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);

67
Games/GameProps.cs Normal file
View File

@ -0,0 +1,67 @@
/*
Copyright 2015 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;
using System.Collections.Generic;
namespace MCGalaxy.Games {
public class GameProps {
/// <summary> Team the player is currently in. </summary>
public Team Team;
/// <summary> Last team the player was invited to. </summary>
public string TeamInvite;
/// <summary> Whether the player has liked or disliked the map in this round. </summary>
internal bool RatedMap = false;
/// <summary> Whether the player has pledged that they will survive/win in this round. </summary>
internal bool PledgeSurvive = false;
//CTF
public CtfTeam team;
public CtfTeam hasflag;
//Zombie
/// <summary> Whether this play is acting as a referee (spectator) in the game. </summary>
public bool Referee = false;
/// <summary> Remaining number of blocks the player can place this round. </summary>
internal int BlocksLeft = 50;
/// <summary> Number of blocks the player has sequentially pillared up. </summary>
internal int BlocksStacked = 0;
internal int LastX, LastY, LastZ;
/// <summary> Whether this player is currently infected/dead. </summary>
public bool Infected = false;
/// <summary> Whether the real names of zombies are always shown to the player. </summary>
public bool Aka = false;
/// <summary> Number of other players infected this round. </summary>
internal int NumInfected = 0;
/// <summary> Last name colour sent to other players from a call to GlobalSpawn. </summary>
internal string lastSpawnColor = "";
/// <summary> List of custom infect messages this player has. </summary>
internal List<string> InfectMessages = null;
}
}

View File

@ -302,8 +302,8 @@ namespace MCGalaxy.Games
{
Player[] online = PlayerInfo.Online.Items;
foreach (Player pl in online) {
pl.ratedMap = false;
pl.pledgeSurvive = false;
pl.Game.RatedMap = false;
pl.Game.PledgeSurvive = false;
if (pl.level == oldMap)
{
if (sendAfkMain && Server.afkset.Contains(pl.name)) Command.all.Find("main").Use(pl, "");

View File

@ -68,7 +68,7 @@ namespace MCGalaxy.Games {
Player first = PickFirstZombie(random, players);
CurLevel.ChatLevel(first.color + first.name + " %Sstarted the infection!");
first.infected = true;
first.Game.Infected = true;
PlayerMoneyChanged(first);
UpdatePlayerColor(first, InfectCol);
@ -83,7 +83,7 @@ namespace MCGalaxy.Games {
Player[] online = PlayerInfo.Online.Items;
foreach (Player p in online) {
if (p.level == null || p.level != CurLevel || p.referee) continue;
if (p.level == null || p.level != CurLevel || p.Game.Referee) continue;
if (p != first) Alive.Add(p);
}
@ -131,7 +131,7 @@ namespace MCGalaxy.Games {
Player[] online = PlayerInfo.Online.Items;
foreach (Player p in online) {
if (!p.referee && p.level.name.CaselessEq(CurLevelName)) {
if (!p.Game.Referee && p.level.name.CaselessEq(CurLevelName)) {
players.Add(p);
nonRefPlayers++;
}
@ -156,7 +156,7 @@ namespace MCGalaxy.Games {
}
foreach (Player pKiller in infected) {
pKiller.infected = true;
pKiller.Game.Infected = true;
UpdatePlayerColor(pKiller, InfectCol);
bool aliveChanged = false;
foreach (Player pAlive in alive) {
@ -166,12 +166,12 @@ namespace MCGalaxy.Games {
|| Math.Abs(pAlive.pos[2] - pKiller.pos[2]) > HitboxPrecision)
continue;
if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive
if (!pAlive.Game.Infected && pKiller.Game.Infected && !pAlive.Game.Referee && !pKiller.Game.Referee && pKiller != pAlive
&& pKiller.level.name.CaselessEq(CurLevelName) && pAlive.level.name.CaselessEq(CurLevelName))
{
InfectPlayer(pAlive);
aliveChanged = true;
pAlive.blockCount = 25;
pAlive.Game.BlocksLeft = 25;
if (lastPlayerToInfect == pKiller.name) {
infectCombo++;
@ -186,7 +186,7 @@ namespace MCGalaxy.Games {
}
lastPlayerToInfect = pKiller.name;
pKiller.playersInfected++;
pKiller.Game.NumInfected++;
ShowInfectMessage(random, pAlive, pKiller);
CheckHumanPledge(pAlive);
CheckBounty(pAlive, pKiller);
@ -200,8 +200,8 @@ namespace MCGalaxy.Games {
}
void CheckHumanPledge(Player pAlive) {
if (!pAlive.pledgeSurvive) return;
pAlive.pledgeSurvive = false;
if (!pAlive.Game.PledgeSurvive) return;
pAlive.Game.PledgeSurvive = false;
CurLevel.ChatLevel(pAlive.FullName + "%Sbroke their pledge of not being infected.");
pAlive.money = Math.Max(pAlive.money - 2, 0);
pAlive.OnMoneyChanged();
@ -209,7 +209,7 @@ namespace MCGalaxy.Games {
void ShowInfectMessage(Random random, Player pAlive, Player pKiller) {
string text = null;
List<string> infectMsgs = pKiller.infectMessages;
List<string> infectMsgs = pKiller.Game.InfectMessages;
if (infectMsgs != null && random.Next(0, 10) < 5)
text = infectMsgs[random.Next(infectMsgs.Count)];
else
@ -235,8 +235,8 @@ namespace MCGalaxy.Games {
}
static void UpdatePlayerColor(Player p, string color) {
if (p.lastSpawnColor == color) return;
p.lastSpawnColor = color;
if (p.Game.lastSpawnColor == color) return;
p.Game.lastSpawnColor = color;
Player.GlobalDespawn(p, false);
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
}
@ -275,7 +275,7 @@ namespace MCGalaxy.Games {
ResetPlayer(pl, ref playersString);
} else {
foreach (Player pl in alive) {
if (pl.pledgeSurvive) {
if (pl.Game.PledgeSurvive) {
pl.SendMessage("You received &a5 %3" + Server.moneys +
"%s for successfully pledging that you would survive.");
pl.money += 5;
@ -296,10 +296,10 @@ namespace MCGalaxy.Games {
if (pl.CheckIfInsideBlock()) {
money = -1;
} else if (alive.Length == 0) {
money = rand.Next(1, 5 + pl.playersInfected);
} else if (alive.Length == 1 && !pl.infected) {
money = rand.Next(1 + pl.Game.NumInfected, 5 + pl.Game.NumInfected);
} else if (alive.Length == 1 && !pl.Game.Infected) {
money = rand.Next(5, 10);
} else if (alive.Length > 1 && !pl.infected) {
} else if (alive.Length > 1 && !pl.Game.Infected) {
money = rand.Next(2, 6);
}
@ -311,11 +311,11 @@ namespace MCGalaxy.Games {
pl.SendMessage( Colors.gold + "You gained " + money + " " + Server.moneys);
}
pl.blockCount = 50;
pl.playersInfected = 0;
pl.Game.BlocksLeft = 50;
pl.Game.NumInfected = 0;
pl.money += money;
pl.infected = false;
if (pl.referee) {
pl.Game.Infected = false;
if (pl.Game.Referee) {
pl.SendMessage("You gained one " + Server.moneys + " because you're a ref. Would you like a medal as well?");
pl.money++;
}
@ -327,9 +327,9 @@ namespace MCGalaxy.Games {
}
void ResetPlayer(Player p, ref string playersString) {
p.blockCount = 50;
p.infected = false;
p.playersInfected = 0;
p.Game.BlocksLeft = 50;
p.Game.Infected = false;
p.Game.NumInfected = 0;
if (p.level.name.CaselessEq(CurLevelName))
playersString += p.color + p.DisplayName + Colors.white + ", ";

View File

@ -32,33 +32,33 @@ namespace MCGalaxy.Games {
p.RevertBlock(x, y, z); return true;
}
if (action == 1 && !CurLevel.Pillaring && !p.referee) {
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
p.blocksStacked++;
if (action == 1 && !CurLevel.Pillaring && !p.Game.Referee) {
if (p.Game.LastY == y - 1 && p.Game.LastX == x && p.Game.LastZ == z ) {
p.Game.BlocksStacked++;
} else {
p.blocksStacked = 0;
p.Game.BlocksStacked = 0;
}
if (p.blocksStacked == 2 ) {
if (p.Game.BlocksStacked == 2 ) {
p.SendMessage("You are pillaring! Stop before you get kicked!");
}
if (p.blocksStacked == 4 ) {
if (p.Game.BlocksStacked == 4 ) {
p.Kick("No pillaring allowed!"); return true;
}
}
p.lastXblock = x; p.lastYblock = y; p.lastZblock = z;
p.Game.LastX = x; p.Game.LastY = y; p.Game.LastZ = z;
if (action == 1 || (action == 0 && p.painting)) {
if (!p.level.name.CaselessEq(CurLevelName) || p.referee) return false;
if (!p.level.name.CaselessEq(CurLevelName) || p.Game.Referee) return false;
if (p.blockCount == 0 ) {
if (p.Game.BlocksLeft == 0 ) {
p.SendMessage("You have no blocks left.");
p.RevertBlock(x, y, z); return true;
}
p.blockCount--;
if ((p.blockCount % 10) == 0 || (p.blockCount >= 0 && p.blockCount <= 10))
p.SendMessage("Blocks Left: " + Colors.maroon + p.blockCount);
p.Game.BlocksLeft--;
if ((p.Game.BlocksLeft % 10) == 0 || (p.Game.BlocksLeft >= 0 && p.Game.BlocksLeft <= 10))
p.SendMessage("Blocks Left: " + Colors.maroon + p.Game.BlocksLeft);
}
return false;
}
@ -66,7 +66,7 @@ namespace MCGalaxy.Games {
public override bool HandlesMovement(Player p, ushort x, ushort y, ushort z,
byte rotX, byte rotY) {
if (!Running || (p.level == null || !p.level.name.CaselessEq(CurLevelName))) return false;
if (!p.referee && noRespawn) {
if (!p.Game.Referee && noRespawn) {
if (p.pos[0] >= x + 70 || p.pos[0] <= x - 70 ) {
p.SendPos(0xFF, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
return true;
@ -84,16 +84,16 @@ namespace MCGalaxy.Games {
if (Server.votingforlevel && HandleVote(p, message)) return true;
if (message[0] == '~' && message.Length > 1) {
Player[] players = p.infected ? Infected.Items : Alive.Items;
string type = p.infected ? " &cto zombies%S: " : " &ato humans%S: ";
Player[] players = p.Game.Infected ? Infected.Items : Alive.Items;
string type = p.Game.Infected ? " &cto zombies%S: " : " &ato humans%S: ";
foreach (Player pl in players)
pl.SendMessage(p.color + p.DisplayName + type + message.Substring(1));
return true;
} else if (message[0] == '`' && message.Length > 1) {
if (p.GameTeam == null) {
if (p.Game.Team == null) {
p.SendMessage("You are not on a team, so cannot send a team message."); return true;
}
p.GameTeam.Chat(p, message.Substring(1));
p.Game.Team.Chat(p, message.Substring(1));
return true;
}
return false;
@ -127,7 +127,7 @@ namespace MCGalaxy.Games {
if (RoundInProgress && lvl.name.CaselessEq(CurLevelName)) {
if (Running && p != null) {
p.SendMessage("You joined in the middle of a round. &cYou are now infected!");
p.blockCount = 50;
p.Game.BlocksLeft = 50;
InfectPlayer(p);
}
}
@ -165,7 +165,7 @@ namespace MCGalaxy.Games {
if (!oldLvl.name.CaselessEq(CurLevelName)) return true;
if (lvl.name.CaselessEq(CurLevelName)) return true;
if (RoundInProgress && !p.referee) {
if (RoundInProgress && !p.Game.Referee) {
p.SendMessage("Sorry, you cannot leave a zombie survival map until the current round has ended.");
return false;
}
@ -175,7 +175,7 @@ namespace MCGalaxy.Games {
public override void PlayerMoneyChanged(Player p) {
if (!Running || !p.level.name.CaselessEq(CurLevelName)) return;
string moneyMsg = "&a" + p.money + " %S" + Server.moneys;
string stateMsg = " and you are " + (p.infected ? "&cdead" : "&aalive");
string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive");
p.SendCpeMessage(CpeMessageType.Status3, moneyMsg + stateMsg);
}
}

View File

@ -130,7 +130,7 @@ namespace MCGalaxy.Games {
if (alive.Length == 0) return;
int index = random.Next(alive.Length);
while (alive[index].referee || !alive[index].level.name.CaselessEq(CurLevelName)) {
while (alive[index].Game.Referee || !alive[index].level.name.CaselessEq(CurLevelName)) {
if (index >= alive.Length - 1) {
index = 0;
alive = Alive.Items;
@ -150,7 +150,7 @@ namespace MCGalaxy.Games {
Infected.Add(p);
Alive.Remove(p);
p.infected = true;
p.Game.Infected = true;
UpdatePlayerColor(p, Colors.red);
UpdateAllPlayerStatus();
PlayerMoneyChanged(p);
@ -161,7 +161,7 @@ namespace MCGalaxy.Games {
Infected.Remove(p);
Alive.Add(p);
p.infected = false;
p.Game.Infected = false;
UpdatePlayerColor(p, p.color);
UpdateAllPlayerStatus();
PlayerMoneyChanged(p);
@ -172,7 +172,7 @@ namespace MCGalaxy.Games {
if (CurLevel != null) {
bool saveSettings = false;
foreach (Player pl in online)
saveSettings |= pl.ratedMap;
saveSettings |= pl.Game.RatedMap;
if (saveSettings) Level.SaveSettings(CurLevel);
CurLevel.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower());
@ -188,8 +188,8 @@ namespace MCGalaxy.Games {
online = PlayerInfo.Online.Items;
foreach (Player pl in online) {
pl.ratedMap = false;
pl.pledgeSurvive = false;
pl.Game.RatedMap = false;
pl.Game.PledgeSurvive = false;
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
pl.SendMessage("Going to the next map - &a" + next);
Command.all.Find("goto").Use(pl, next);
@ -213,8 +213,8 @@ namespace MCGalaxy.Games {
Player[] online = PlayerInfo.Online.Items;
foreach (Player pl in online) {
pl.ratedMap = false;
pl.pledgeSurvive = false;
pl.Game.RatedMap = false;
pl.Game.PledgeSurvive = false;
}
}

View File

@ -435,6 +435,7 @@
<Compile Include="Games\Countdown\CountdownGame.Game.cs" />
<Compile Include="Games\Countdown\CountdownMapGen.cs" />
<Compile Include="Games\CTF\CtfTeam.cs" />
<Compile Include="Games\GameProps.cs" />
<Compile Include="Games\IGame.cs" />
<Compile Include="Games\LavaSurvival\LavaSurvival.Game.cs" />
<Compile Include="Games\LavaSurvival\LavaSurvival.cs" />

View File

@ -467,7 +467,7 @@ namespace MCGalaxy {
if (!Directory.Exists("players"))
Directory.CreateDirectory("players");
PlayerDB.Load(this);
GameTeam = Team.FindTeam(this);
Game.Team = Team.FindTeam(this);
SetPrefix();
playerDb.Dispose();
@ -529,7 +529,7 @@ namespace MCGalaxy {
}
Server.s.Log(name + " [" + ip + "] has joined the server.");
infectMessages = PlayerDB.GetInfectMessages(this);
Game.InfectMessages = PlayerDB.GetInfectMessages(this);
Server.zombie.PlayerJoinedServer(this);
try {
ushort x = (ushort)((0.5 + level.spawnx) * 32);
@ -1061,12 +1061,12 @@ return;
Chat.GlobalChatLevel(this, FullName + "%S" + customMessage, false);
break;
}
if ( team != null && this.level.ctfmode ) {
if ( Game.team != null && this.level.ctfmode ) {
//if (carryingFlag)
//{
// level.ctfgame.DropFlag(this, hasflag);
//}
team.SpawnPlayer(this);
Game.team.SpawnPlayer(this);
//this.health = 100;
}
else if ( Server.Countdown.playersleftlist.Contains(this) ) {

View File

@ -172,12 +172,9 @@ namespace MCGalaxy {
public bool useCheckpointSpawn = false;
public int lastCheckpointIndex = -1;
public ushort checkpointX, checkpointY, checkpointZ;
public Team GameTeam;
public string GameTeamInvite;
//CTF
public CtfTeam team;
public CtfTeam hasflag;
public bool voted = false;
public bool flipHead = false;
public GameProps Game = new GameProps();
//Countdown
public bool playerofcountdown = false;
@ -186,21 +183,6 @@ namespace MCGalaxy {
public ushort countdowntempz;
public bool countdownsettemps = false;
//Zombie
public bool referee = false;
internal int blockCount = 50;
public bool voted = false;
internal int blocksStacked = 0;
internal int lastYblock = 0, lastXblock = 0, lastZblock = 0;
public bool infected = false;
public bool aka = false;
public bool flipHead = false;
internal int playersInfected = 0;
internal string lastSpawnColor = "";
internal bool ratedMap = false;
internal bool pledgeSurvive = false;
internal List<string> infectMessages = null;
//Tnt Wars
public bool PlayingTntWars = false;
public int CurrentAmountOfTnt = 0;
@ -326,7 +308,7 @@ namespace MCGalaxy {
}
public void SetPrefix() {
Team team = GameTeam;
Team team = Game.Team;
prefix = team != null ? "<" + team.Color + team.Name + color + "> " : "";
string viptitle = isDev ? string.Format("{1}[{0}Dev{1}] ", Colors.blue, color) :
@ -452,8 +434,8 @@ namespace MCGalaxy {
Last50Chat.Add(chatmessage);
if (showname) {
String referee = "";
if (from.referee)
string referee = "";
if (from.Game.Referee)
referee = Colors.green + "[Referee] ";
message = referee + from.color + from.voicestring + from.color + from.prefix + from.DisplayName + ": %r&f" + message;
}
@ -492,10 +474,10 @@ namespace MCGalaxy {
public static void GlobalSpawn(Player p, ushort x, ushort y, ushort z,
byte rotx, byte roty, bool self, string possession = "") {
Player[] players = PlayerInfo.Online.Items;
p.lastSpawnColor = p.infected ? ZombieGame.InfectCol : p.color;
p.Game.lastSpawnColor = p.Game.Infected ? ZombieGame.InfectCol : p.color;
foreach (Player other in players) {
if ((other.Loading && p != other) || p.level != other.level) continue;
if ((p.hidden || p.referee) && !self) continue;
if ((p.hidden || p.Game.Referee) && !self) continue;
if (p != other) {
SpawnEntity(p, other, p.id, x, y, z, rotx, roty, possession);
@ -509,11 +491,11 @@ namespace MCGalaxy {
internal static void SpawnEntity(Player p, Player dst, byte id, ushort x, ushort y, ushort z,
byte rotx, byte roty, string possession = "") {
if (!Server.zombie.Running || !p.infected) {
if (!Server.zombie.Running || !p.Game.Infected) {
dst.SendSpawn(id, p.color + p.name + possession, x, y, z, rotx, roty); return;
}
if (Server.zombie.ZombieName != "" && !dst.aka)
if (Server.zombie.ZombieName != "" && !dst.Game.Aka)
dst.SendSpawn(id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty);
else
dst.SendSpawn(id, Colors.red + p.name + possession, x, y, z, rotx, roty);
@ -605,7 +587,7 @@ namespace MCGalaxy {
}
Server.zombie.PlayerLeftServer(this);
if ( team != null ) team.RemoveMember(this);
if ( Game.team != null ) Game.team.RemoveMember(this);
Server.Countdown.PlayerLeftServer(this);
TntWarsGame tntwarsgame = TntWarsGame.GetTntWarsGame(this);
if ( tntwarsgame != null ) {