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 LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override void Use(Player p, string message) { 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; Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { 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); 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], ""); 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": case "members":
HandleMembers(p, args); break; HandleMembers(p, args); break;
default: default:
Team team = p.GameTeam; Team team = p.Game.Team;
if (team == null) { if (team == null) {
Player.SendMessage(p, "You need to be in a team first to send a team message."); return; 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) { 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 (team == null) { Player.SendMessage(p, "You need to be in a team first."); return; }
if (args.Length == 1) { if (args.Length == 1) {
@ -74,7 +74,7 @@ namespace MCGalaxy.Commands {
} }
void HandleKick(Player p, string[] args) { 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 (team == null) { Player.SendMessage(p, "You need to be in a team first."); return; }
if (args.Length == 1) { if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the name of the player to kick."); return; 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."); team.Action(p, "kicked " + args[1] + " from the team.");
Player who = PlayerInfo.FindExact(args[1]); Player who = PlayerInfo.FindExact(args[1]);
if (who != null) { if (who != null) {
who.GameTeam = null; who.Game.Team = null;
who.SetPrefix(); who.SetPrefix();
} }
Team.SaveList(); Team.SaveList();
@ -97,7 +97,7 @@ namespace MCGalaxy.Commands {
} }
void HandleColor(Player p, string[] args) { 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 (team == null) { Player.SendMessage(p, "You need to be in a team first."); return; }
if (args.Length == 1) { if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the new color."); return; Player.SendMessage(p, "You need to provide the new color."); return;
@ -114,7 +114,7 @@ namespace MCGalaxy.Commands {
} }
void HandleCreate(Player p, string[] args) { 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 (team != null) { Player.SendMessage(p, "You need to leave your current team before you can create one."); return; }
if (args.Length == 1) { if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the name of the new team."); return; 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]); team = Team.FindTeam(args[1]);
if (team != null) { Player.SendMessage(p, "There is already an existing team with that name."); return; } if (team != null) { Player.SendMessage(p, "There is already an existing team with that name."); return; }
team = new Team(args[1], p.name); team = new Team(args[1], p.name);
p.GameTeam = team; p.Game.Team = team;
p.SetPrefix(); p.SetPrefix();
Team.TeamsList[team.Name] = team; Team.TeamsList[team.Name] = team;
Team.SaveList(); Team.SaveList();
@ -130,21 +130,21 @@ namespace MCGalaxy.Commands {
} }
void HandleJoin(Player p, string[] args) { void HandleJoin(Player p, string[] args) {
Team team = p.GameTeam; Team team = p.Game.Team;
if (p.GameTeamInvite == null) { Player.SendMessage(p, "You do not currently have any invitation to join a team."); return; } 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; } 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; } if (team == null) { Player.SendMessage(p, "The team you were invited to no longer exists."); return; }
team.Members.Add(p.name); team.Members.Add(p.name);
team.Action(p, "joined the team."); team.Action(p, "joined the team.");
p.GameTeam = team; p.Game.Team = team;
p.SetPrefix(); p.SetPrefix();
Team.SaveList(); Team.SaveList();
} }
void HandleInvite(Player p, string[] args) { 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 (team == null) { Player.SendMessage(p, "You need to be in a team first to invite players."); return; }
if (args.Length == 1) { if (args.Length == 1) {
Player.SendMessage(p, "You need to provide the name of the person to invite."); return; 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(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."); 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) { 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; } 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.Action(p, "left the team.");
team.Remove(p.name); team.Remove(p.name);
p.GameTeam = null; p.Game.Team = null;
p.SetPrefix(); p.SetPrefix();
Team.SaveList(); Team.SaveList();
} }
void HandleMembers(Player p, string[] args) { void HandleMembers(Player p, string[] args) {
Team team = p.GameTeam; Team team = p.Game.Team;
if (args.Length == 1) { if (args.Length == 1) {
if (team == null) { Player.SendMessage(p, "You are not in a team, so must provide a team name."); return; } if (team == null) { Player.SendMessage(p, "You are not in a team, so must provide a team name."); return; }
} else { } else {

View File

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

View File

@ -32,7 +32,7 @@ namespace MCGalaxy.Commands {
if (!p.level.guns) { if (!p.level.guns) {
Player.SendMessage(p, Weapon + "s cannot be used on this map!"); return; 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; 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); Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return; if (who == null) return;
if (!who.infected || !Server.zombie.RoundInProgress) { if (!who.Game.Infected || !Server.zombie.RoundInProgress) {
Player.SendMessage(p, "Cannot disinfect player"); Player.SendMessage(p, "Cannot disinfect player");
} else if (!who.referee) { } else if (!who.Game.Referee) {
Server.zombie.DisinfectPlayer(who); Server.zombie.DisinfectPlayer(who);
Player.GlobalMessage(who.color + who.DisplayName + " %Swas disinfected!"); 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) { public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; } 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; Player.SendMessage(p, "You cannot un-pledge that you will be infected."); return;
} }
p.pledgeSurvive = true; p.Game.PledgeSurvive = true;
Server.zombie.CurLevel Server.zombie.CurLevel
.ChatLevel(p.color + p.DisplayName + " %Spledges that they will not succumb to the infection!"); .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); Player who = message == "" ? p : PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return; if (who == null) return;
if (who.infected || !Server.zombie.RoundInProgress) { if (who.Game.Infected || !Server.zombie.RoundInProgress) {
Player.SendMessage(p, "Cannot infect player"); Player.SendMessage(p, "Cannot infect player");
} else if (!who.referee) { } else if (!who.Game.Referee) {
Server.zombie.InfectPlayer(who); Server.zombie.InfectPlayer(who);
Player.GlobalMessage(who.color + who.DisplayName + " %Swas infected!"); 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) { public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; } if (p == null) { MessageInGameOnly(p); return; }
if (p.referee) { if (p.Game.Referee) {
Player.SendChatFrom(p, p.FullName + " %Sis no longer a referee", false); Player.SendChatFrom(p, p.FullName + " %Sis no longer a referee", false);
if (p.level == Server.zombie.CurLevel) if (p.level == Server.zombie.CurLevel)
Server.zombie.PlayerJoinedLevel(p, Server.zombie.CurLevel, Server.zombie.CurLevel); Server.zombie.PlayerJoinedLevel(p, Server.zombie.CurLevel, Server.zombie.CurLevel);
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands {
Server.zombie.PlayerLeftServer(p); Server.zombie.PlayerLeftServer(p);
Player.GlobalDespawn(p, false); Player.GlobalDespawn(p, false);
} }
p.referee = !p.referee; p.Game.Referee = !p.Game.Referee;
} }
public override void Help(Player p) { 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 x = (ushort)(16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32);
ushort y = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32); ushort y = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32);
ushort z = (ushort)(16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 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); Server.zombie.InfectPlayer(p);
if (p.PlayingTntWars) { if (p.PlayingTntWars) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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