mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Refactor majority of CTF code, and probably break it in the process.
This commit is contained in:
parent
7c4d6f0394
commit
e27c8ec482
@ -29,20 +29,20 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static |
|
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static |
|
||||||
BindingFlags.Public | BindingFlags.NonPublic;
|
BindingFlags.Public | BindingFlags.NonPublic;
|
||||||
public static ConfigElement[] GetAll(params Type[] types) {
|
|
||||||
|
public static ConfigElement[] GetAll(Type type) {
|
||||||
List<ConfigElement> elems = new List<ConfigElement>();
|
List<ConfigElement> elems = new List<ConfigElement>();
|
||||||
foreach (Type type in types) {
|
FieldInfo[] fields = type.GetFields(flags);
|
||||||
FieldInfo[] fields = type.GetFields(flags);
|
|
||||||
for (int i = 0; i < fields.Length; i++) {
|
for (int i = 0; i < fields.Length; i++) {
|
||||||
FieldInfo field = fields[i];
|
FieldInfo field = fields[i];
|
||||||
Attribute[] attributes = Attribute.GetCustomAttributes(field, typeof(ConfigAttribute));
|
Attribute[] attributes = Attribute.GetCustomAttributes(field, typeof(ConfigAttribute));
|
||||||
if (attributes.Length == 0) continue;
|
if (attributes.Length == 0) continue;
|
||||||
|
|
||||||
ConfigElement elem;
|
ConfigElement elem;
|
||||||
elem.Field = field;
|
elem.Field = field;
|
||||||
elem.Attrib = (ConfigAttribute)attributes[0];
|
elem.Attrib = (ConfigAttribute)attributes[0];
|
||||||
elems.Add(elem);
|
elems.Add(elem);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return elems.ToArray();
|
return elems.ToArray();
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public static void Serialise(ConfigElement[] elements, string suffix,
|
public static void Serialise(ConfigElement[] elements, string suffix,
|
||||||
StreamWriter dst, object instance) {
|
StreamWriter dst, object instance) {
|
||||||
Dictionary<string, List<ConfigElement>> sections
|
Dictionary<string, List<ConfigElement>> sections
|
||||||
= new Dictionary<string, List<ConfigElement>>();
|
= new Dictionary<string, List<ConfigElement>>();
|
||||||
|
|
||||||
foreach (ConfigElement elem in elements) {
|
foreach (ConfigElement elem in elements) {
|
||||||
|
@ -31,6 +31,7 @@ namespace MCGalaxy.Config {
|
|||||||
if (color == "") {
|
if (color == "") {
|
||||||
color = Colors.Name(value);
|
color = Colors.Name(value);
|
||||||
if (color != "") return value;
|
if (color != "") return value;
|
||||||
|
|
||||||
Logger.Log(LogType.Warning, "Config key \"{0}\" is not a valid color, using default of {1}", Name, DefaultValue);
|
Logger.Log(LogType.Warning, "Config key \"{0}\" is not a valid color, using default of {1}", Name, DefaultValue);
|
||||||
return DefaultValue;
|
return DefaultValue;
|
||||||
}
|
}
|
||||||
|
@ -1,85 +1,93 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 MCForge
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
Written by fenderrock87
|
Written by fenderrock87
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
not use this file except in compliance with the Licenses. You may
|
not use this file except in compliance with the Licenses. You may
|
||||||
obtain a copy of the Licenses at
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using MCGalaxy.Config;
|
||||||
using System.IO;
|
|
||||||
using MCGalaxy.SQL;
|
namespace MCGalaxy.Games {
|
||||||
|
|
||||||
namespace MCGalaxy.Games {
|
public sealed class CTFConfig {
|
||||||
public sealed partial class CTFGame {
|
|
||||||
|
[ConfigInt("base.red.x", null, 0)]
|
||||||
void LineProcessor(string key, string value) {
|
public int RedFlagX;
|
||||||
switch (key.ToLower()) {
|
[ConfigInt("base.red.y", null, 0)]
|
||||||
case "base.red.x":
|
public int RedFlagY;
|
||||||
redbase.x = ushort.Parse(value); break;
|
[ConfigInt("base.red.z", null, 0)]
|
||||||
case "base.red.y":
|
public int RedFlagZ;
|
||||||
redbase.y = ushort.Parse(value); break;
|
[ConfigByte("base.red.block", null, 0)]
|
||||||
case "game.maxpoints":
|
public byte RedFlagBlock;
|
||||||
maxpoints = int.Parse(value); break;
|
|
||||||
case "game.tag.points-gain":
|
[ConfigInt("base.blue.x", null, 0)]
|
||||||
tagpoint = int.Parse(value); break;
|
public int BlueFlagX;
|
||||||
case "game.tag.points-lose":
|
[ConfigInt("base.blue.y", null, 0)]
|
||||||
taglose = int.Parse(value); break;
|
public int BlueFlagY;
|
||||||
case "game.capture.points-gain":
|
[ConfigInt("base.blue.z", null, 0)]
|
||||||
cappoint = int.Parse(value); break;
|
public int BlueFlagZ;
|
||||||
case "game.capture.points-lose":
|
[ConfigByte("base.blue.block", null, 0)]
|
||||||
caplose = int.Parse(value); break;
|
public byte BlueFlagBlock;
|
||||||
case "auto.setup":
|
|
||||||
needSetup = bool.Parse(value); break;
|
[ConfigInt("base.red.spawnx", null, 0)]
|
||||||
case "base.red.z":
|
public int RedSpawnX;
|
||||||
redbase.z = ushort.Parse(value); break;
|
[ConfigInt("base.red.spawny", null, 0)]
|
||||||
case "base.red.block":
|
public int RedSpawnY;
|
||||||
redbase.block = ExtBlock.FromRaw(byte.Parse(value)); break;
|
[ConfigInt("base.red.spawnz", null, 0)]
|
||||||
case "base.blue.block":
|
public int RedSpawnZ;
|
||||||
bluebase.block = ExtBlock.FromRaw(byte.Parse(value)); break;
|
|
||||||
case "base.blue.spawnx":
|
[ConfigInt("base.blue.spawnx", null, 0)]
|
||||||
bluebase.spawnx = ushort.Parse(value); break;
|
public int BlueSpawnX;
|
||||||
case "base.blue.spawny":
|
[ConfigInt("base.blue.spawny", null, 0)]
|
||||||
bluebase.spawny = ushort.Parse(value); break;
|
public int BlueSpawnY;
|
||||||
case "base.blue.spawnz":
|
[ConfigInt("base.blue.spawnz", null, 0)]
|
||||||
bluebase.spawnz = ushort.Parse(value); break;
|
public int BlueSpawnZ;
|
||||||
case "base.red.spawnx":
|
|
||||||
redbase.spawnx = ushort.Parse(value); break;
|
[ConfigInt("map.line.z", null, 0)]
|
||||||
case "base.red.spawny":
|
public int ZDivider;
|
||||||
redbase.spawny = ushort.Parse(value); break;
|
[ConfigInt("game.maxpoints", null, 0)]
|
||||||
case "base.red.spawnz":
|
public int MaxPoints;
|
||||||
redbase.spawnz = ushort.Parse(value); break;
|
[ConfigInt("game.tag.points-gain", null, 0)]
|
||||||
case "base.blue.x":
|
public int Tag_PointsGained;
|
||||||
bluebase.x = ushort.Parse(value); break;
|
[ConfigInt("game.tag.points-lose", null, 0)]
|
||||||
case "base.blue.y":
|
public int Tag_PointsLost;
|
||||||
bluebase.y = ushort.Parse(value); break;
|
[ConfigInt("game.capture.points-gain", null, 0)]
|
||||||
case "base.blue.z":
|
public int Capture_PointsGained;
|
||||||
bluebase.z = ushort.Parse(value); break;
|
[ConfigInt("game.capture.points-lose", null, 0)]
|
||||||
case "map.line.z":
|
public int Capture_PointsLost;
|
||||||
zline = ushort.Parse(value); break;
|
|
||||||
}
|
public void SetDefaults(Level map) {
|
||||||
}
|
ZDivider = map.Length / 2;
|
||||||
|
RedFlagBlock = Block.red;
|
||||||
bool LoadConfig() {
|
BlueFlagBlock = Block.blue;
|
||||||
//Load some configs
|
int midX = map.Width / 2, maxZ = map.Length - 1;
|
||||||
if (!Directory.Exists("CTF")) Directory.CreateDirectory("CTF");
|
|
||||||
if (!File.Exists("CTF/maps.config")) return false;
|
RedFlagX = midX; RedSpawnX = midX * 32;
|
||||||
|
RedFlagY = 6; RedSpawnY = 4 * 32 + Entities.CharacterHeight;
|
||||||
string[] lines = File.ReadAllLines("CTF/maps.config");
|
RedFlagZ = 0; RedSpawnZ = 0 * 32;
|
||||||
maps = new List<string>(lines);
|
|
||||||
return maps.Count > 0;
|
BlueFlagX = midX; BlueSpawnX = midX * 32;
|
||||||
}
|
BlueFlagY = 6; BlueSpawnY = 4 * 32 + Entities.CharacterHeight;
|
||||||
}
|
BlueFlagZ = maxZ; BlueSpawnZ = maxZ * 32;
|
||||||
}
|
|
||||||
|
MaxPoints = 3;
|
||||||
|
Tag_PointsGained = 5;
|
||||||
|
Tag_PointsLost = 5;
|
||||||
|
Capture_PointsGained = 10;
|
||||||
|
Capture_PointsLost = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2011 MCForge
|
|
||||||
|
|
||||||
Written by fenderrock87
|
|
||||||
|
|
||||||
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 MCGalaxy.Config;
|
|
||||||
|
|
||||||
namespace MCGalaxy.Games {
|
|
||||||
|
|
||||||
public sealed class CTFConfig {
|
|
||||||
|
|
||||||
[ConfigInt("base.red.x", null, 0)]
|
|
||||||
public int RedFlagX;
|
|
||||||
[ConfigInt("base.red.y", null, 0)]
|
|
||||||
public int RedFlagY;
|
|
||||||
[ConfigInt("base.red.z", null, 0)]
|
|
||||||
public int RedFlagZ;
|
|
||||||
[ConfigByte("base.red.block", null, 0)]
|
|
||||||
public byte RedFlagBlock;
|
|
||||||
|
|
||||||
[ConfigInt("base.blue.x", null, 0)]
|
|
||||||
public int BlueFlagX;
|
|
||||||
[ConfigInt("base.blue.y", null, 0)]
|
|
||||||
public int BlueFlagY;
|
|
||||||
[ConfigInt("base.blue.z", null, 0)]
|
|
||||||
public int BlueFlagZ;
|
|
||||||
[ConfigByte("base.blue.block", null, 0)]
|
|
||||||
public byte BlueFlagBlock;
|
|
||||||
|
|
||||||
[ConfigInt("base.red.spawnx", null, 0)]
|
|
||||||
public int RedSpawnX;
|
|
||||||
[ConfigInt("base.red.spawny", null, 0)]
|
|
||||||
public int RedSpawnY;
|
|
||||||
[ConfigInt("base.red.spawnz", null, 0)]
|
|
||||||
public int RedSpawnZ;
|
|
||||||
|
|
||||||
[ConfigInt("base.blue.spawnx", null, 0)]
|
|
||||||
public int BlueSpawnX;
|
|
||||||
[ConfigInt("base.blue.spawny", null, 0)]
|
|
||||||
public int BlueSpawnY;
|
|
||||||
[ConfigInt("base.blue.spawnz", null, 0)]
|
|
||||||
public int BlueSpawnZ;
|
|
||||||
|
|
||||||
[ConfigBool("auto.setup", null, false)]
|
|
||||||
public bool NeedSetup;
|
|
||||||
[ConfigInt("map.line.z", null, 0)]
|
|
||||||
public int ZLine;
|
|
||||||
|
|
||||||
[ConfigInt("game.maxpoints", null, 0)]
|
|
||||||
public int MaxPoints;
|
|
||||||
[ConfigInt("game.tag.points-gain", null, 0)]
|
|
||||||
public int Tag_PointsGained;
|
|
||||||
[ConfigInt("game.tag.points-lose", null, 0)]
|
|
||||||
public int Tag_PointsLost;
|
|
||||||
[ConfigInt("game.capture.points-gain", null, 0)]
|
|
||||||
public int Capture_PointsGained;
|
|
||||||
[ConfigInt("game.capture.points-lose", null, 0)]
|
|
||||||
public int Capture_PointsLost;
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,69 +23,16 @@ using System.IO;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using MCGalaxy.Commands.World;
|
using MCGalaxy.Commands.World;
|
||||||
using MCGalaxy.Events;
|
using MCGalaxy.Events;
|
||||||
|
using MCGalaxy.Maths;
|
||||||
using MCGalaxy.SQL;
|
using MCGalaxy.SQL;
|
||||||
|
|
||||||
namespace MCGalaxy.Games {
|
namespace MCGalaxy.Games {
|
||||||
/// <summary> This is the team class for CTF </summary>
|
|
||||||
public sealed class Teams {
|
|
||||||
public string color;
|
|
||||||
public int points = 0;
|
|
||||||
public List<Player> members;
|
|
||||||
|
|
||||||
/// <summary> Create a new Team Object </summary>
|
|
||||||
public Teams(string color) {
|
|
||||||
color = Colors.Parse(color);
|
|
||||||
members = new List<Player>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Add a player to the team </summary>
|
|
||||||
public void Add(Player p) {
|
|
||||||
members.Add(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Checks to see if the player is on this team </summary>
|
|
||||||
public bool Has(Player p) {
|
|
||||||
return members.IndexOf(p) != -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal sealed class Data {
|
internal sealed class Data {
|
||||||
public Player p;
|
public Player p;
|
||||||
public int cap, tag, points;
|
public int cap, Tags, points;
|
||||||
public bool hasflag, tagging, chatting;
|
public bool hasflag, tagging, chatting;
|
||||||
public bool blue;
|
public Data(Player p) { this.p = p; }
|
||||||
|
|
||||||
public Data(bool team, Player p) {
|
|
||||||
blue = team; this.p = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal sealed class Base {
|
|
||||||
public ushort x, y, z;
|
|
||||||
public ushort spawnx, spawny, spawnz;
|
|
||||||
public ExtBlock block;
|
|
||||||
|
|
||||||
public void SendToSpawn(Level mainlevel, CTFGame game, Player p1) {
|
|
||||||
Position pos = new Position(spawnx, spawny, spawny);
|
|
||||||
if (spawnx == 0 && spawny == 0 && spawnz == 0) {
|
|
||||||
Random rand = new Random();
|
|
||||||
ushort xx, yy, zz;
|
|
||||||
do {
|
|
||||||
xx = (ushort)(rand.Next(0, mainlevel.Width));
|
|
||||||
yy = (ushort)(rand.Next(0, mainlevel.Height));
|
|
||||||
zz = (ushort)(rand.Next(0, mainlevel.Length));
|
|
||||||
} while (!mainlevel.IsAirAt(xx, yy, zz) && game.OnSide(zz, this));
|
|
||||||
|
|
||||||
pos.X = xx * 32; pos.Y = yy * 32; pos.Z = zz * 32;
|
|
||||||
}
|
|
||||||
p1.SendPos(Entities.SelfID, pos, p1.Rot);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Base(ushort x, ushort y, ushort z, Teams team) {
|
|
||||||
this.x = x; this.y = y; this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Base() { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed partial class CTFGame {
|
public sealed partial class CTFGame {
|
||||||
@ -97,42 +44,21 @@ namespace MCGalaxy.Games {
|
|||||||
string map1 = "";
|
string map1 = "";
|
||||||
string map2 = "";
|
string map2 = "";
|
||||||
string map3 = "";
|
string map3 = "";
|
||||||
public int xline;
|
|
||||||
public bool started = false;
|
public bool started = false;
|
||||||
public int zline;
|
|
||||||
public int yline;
|
CtfTeam2 red;
|
||||||
int tagpoint = 5;
|
CtfTeam2 blue;
|
||||||
int cappoint = 10;
|
Level map;
|
||||||
int taglose = 5;
|
|
||||||
int caplose = 10;
|
|
||||||
bool needSetup = false;
|
|
||||||
public int maxpoints = 3;
|
|
||||||
Teams redteam;
|
|
||||||
Teams blueteam;
|
|
||||||
Base bluebase;
|
|
||||||
Base redbase;
|
|
||||||
Level mainlevel;
|
|
||||||
List<string> maps = new List<string>();
|
List<string> maps = new List<string>();
|
||||||
List<Data> cache = new List<Data>();
|
List<Data> cache = new List<Data>();
|
||||||
string mapname = "";
|
|
||||||
|
|
||||||
/// <summary> Load a map into CTF </summary>
|
public CTFConfig Config = new CTFConfig();
|
||||||
/// <param name="map">The map to load</param>
|
ConfigElement[] ctfConfigElems;
|
||||||
public void LoadMap(string map) {
|
|
||||||
mapname = map;
|
|
||||||
PropertiesFile.Read("CTF/" + mapname + ".config", LineProcessor);
|
|
||||||
Command.all.Find("unload").Use(null, "ctf");
|
|
||||||
if (File.Exists("levels/ctf.lvl"))
|
|
||||||
File.Delete("levels/ctf.lvl");
|
|
||||||
File.Copy("CTF/maps/" + mapname + ".lvl", "levels/ctf.lvl");
|
|
||||||
CmdLoad.LoadLevel(null, "ctf");
|
|
||||||
mainlevel = LevelInfo.FindExact("ctf");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Create a new CTF object </summary>
|
/// <summary> Create a new CTF object </summary>
|
||||||
public CTFGame() {
|
public CTFGame() {
|
||||||
redbase = new Base();
|
red = new CtfTeam2("Red", Colors.red);
|
||||||
bluebase = new Base();
|
blue = new CtfTeam2("Blue", Colors.blue);
|
||||||
|
|
||||||
tagging.Elapsed += CheckTagging;
|
tagging.Elapsed += CheckTagging;
|
||||||
tagging.Start();
|
tagging.Start();
|
||||||
@ -144,7 +70,7 @@ namespace MCGalaxy.Games {
|
|||||||
tagging.Stop();
|
tagging.Stop();
|
||||||
tagging.Dispose();
|
tagging.Dispose();
|
||||||
|
|
||||||
mainlevel = null;
|
map = null;
|
||||||
started = false;
|
started = false;
|
||||||
if (LevelInfo.FindExact("ctf") != null)
|
if (LevelInfo.FindExact("ctf") != null)
|
||||||
Command.all.Find("unload").Use(null, "ctf");
|
Command.all.Find("unload").Use(null, "ctf");
|
||||||
@ -159,66 +85,93 @@ namespace MCGalaxy.Games {
|
|||||||
Level.LevelUnload += HandleLevelUnload;
|
Level.LevelUnload += HandleLevelUnload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary> Load a map into CTF </summary>
|
||||||
|
public void LoadMap(string mapName) {
|
||||||
|
Command.all.Find("unload").Use(null, "ctf");
|
||||||
|
if (File.Exists("levels/ctf.lvl"))
|
||||||
|
File.Delete("levels/ctf.lvl");
|
||||||
|
|
||||||
|
File.Copy("CTF/maps/" + mapName + ".lvl", "levels/ctf.lvl");
|
||||||
|
CmdLoad.LoadLevel(null, "ctf");
|
||||||
|
map = LevelInfo.FindExact("ctf");
|
||||||
|
LoadMapConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadMapConfig() {
|
||||||
|
if (ctfConfigElems == null)
|
||||||
|
ctfConfigElems = ConfigElement.GetAll(typeof(CTFConfig));
|
||||||
|
|
||||||
|
Config.SetDefaults(map);
|
||||||
|
PropertiesFile.Read("CTF/" + map.name + ".config", LineProcessor);
|
||||||
|
CTFConfig cfg = Config;
|
||||||
|
|
||||||
|
red.FlagBlock = ExtBlock.FromRaw(cfg.RedFlagBlock);
|
||||||
|
red.FlagPos = new Vec3U16((ushort)cfg.RedFlagX, (ushort)cfg.RedFlagY, (ushort)cfg.RedFlagZ);
|
||||||
|
red.SpawnPos = new Position(cfg.RedSpawnX, cfg.RedSpawnY, cfg.RedSpawnZ);
|
||||||
|
|
||||||
|
blue.FlagBlock = ExtBlock.FromRaw(cfg.BlueFlagBlock);
|
||||||
|
blue.FlagPos = new Vec3U16((ushort)cfg.BlueFlagX, (ushort)cfg.BlueFlagY, (ushort)cfg.BlueFlagZ);
|
||||||
|
blue.SpawnPos = new Position(cfg.BlueSpawnX, cfg.BlueSpawnY, cfg.BlueSpawnZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineProcessor(string key, string value) {
|
||||||
|
if (!ConfigElement.Parse(ctfConfigElems, key, value, Config)) {
|
||||||
|
Logger.Log(LogType.Warning, "\"{0}\" was not a recognised CTF config key.", key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadConfig() {
|
||||||
|
//Load some configs
|
||||||
|
if (!Directory.Exists("CTF")) Directory.CreateDirectory("CTF");
|
||||||
|
if (!File.Exists("CTF/maps.config")) return false;
|
||||||
|
|
||||||
|
string[] lines = File.ReadAllLines("CTF/maps.config");
|
||||||
|
maps = new List<string>(lines);
|
||||||
|
return maps.Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CheckTagging(object sender, System.Timers.ElapsedEventArgs e) {
|
void CheckTagging(object sender, System.Timers.ElapsedEventArgs e) {
|
||||||
Player[] online = PlayerInfo.Online.Items;
|
Player[] online = PlayerInfo.Online.Items;
|
||||||
foreach (Player p in online) {
|
foreach (Player p in online) {
|
||||||
if (p.level != mainlevel) continue;
|
if (p.level != map) continue;
|
||||||
|
|
||||||
Base b = null;
|
CtfTeam2 team = TeamOf(p);
|
||||||
if (redteam.members.Contains(p)) {
|
if (team == null || DataOf(p).tagging) continue;
|
||||||
b = redbase;
|
if (!OnOwnTeamSide(p.Pos.BlockZ, team)) continue;
|
||||||
} else if (blueteam.members.Contains(p)) {
|
CtfTeam2 opposing = Opposing(team);
|
||||||
b = bluebase;
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetPlayer(p).tagging) continue;
|
|
||||||
if (!OnSide(p.Pos.BlockZ, b)) continue;
|
|
||||||
|
|
||||||
List<Player> opponents = redteam.members;
|
|
||||||
if (redteam.members.Contains(p))
|
|
||||||
opponents = blueteam.members;
|
|
||||||
|
|
||||||
|
Player[] opponents = opposing.Members.Items;
|
||||||
foreach (Player other in opponents) {
|
foreach (Player other in opponents) {
|
||||||
if (!MovementCheck.InRange(p, other, 5 * 32)) continue;
|
if (!MovementCheck.InRange(p, other, 2 * 32)) continue;
|
||||||
|
|
||||||
GetPlayer(other).tagging = true;
|
DataOf(other).tagging = true;
|
||||||
Player.Message(other, p.ColoredName + " %Stagged you!");
|
Player.Message(other, p.ColoredName + " %Stagged you!");
|
||||||
b.SendToSpawn(mainlevel, this, other);
|
team.SendToSpawn(other);
|
||||||
Thread.Sleep(300);
|
Thread.Sleep(300);
|
||||||
|
|
||||||
if (GetPlayer(other).hasflag) {
|
if (DataOf(other).hasflag) DropFlag(p, opposing);
|
||||||
Chat.MessageLevel(mainlevel, redteam.color + p.name + " DROPPED THE FLAG!");
|
DataOf(p).points += Config.Tag_PointsGained;
|
||||||
GetPlayer(other).points -= caplose;
|
DataOf(other).points -= Config.Tag_PointsLost;
|
||||||
mainlevel.Blockchange(b.x, b.y, b.z, b.block);
|
DataOf(p).Tags++;
|
||||||
GetPlayer(other).hasflag = false;
|
DataOf(other).tagging = false;
|
||||||
}
|
|
||||||
|
|
||||||
GetPlayer(p).points += tagpoint;
|
|
||||||
GetPlayer(other).points -= taglose;
|
|
||||||
GetPlayer(p).tag++;
|
|
||||||
GetPlayer(other).tagging = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePlayerDisconnect(Player p, string reason) {
|
void HandlePlayerDisconnect(Player p, string reason) {
|
||||||
if (p.level != mainlevel) return;
|
if (p.level != map) return;
|
||||||
|
CtfTeam2 team = TeamOf(p);
|
||||||
|
if (team == null) return;
|
||||||
|
|
||||||
if (blueteam.members.Contains(p)) {
|
DropFlag(p, team);
|
||||||
//cache.Remove(GetPlayer(p));
|
team.Remove(p);
|
||||||
blueteam.members.Remove(p);
|
Chat.MessageLevel(map, team.Color + p.DisplayName + " %Sleft the ctf game");
|
||||||
Chat.MessageLevel(mainlevel, p.ColoredName + " " + blueteam.color + "left the ctf game");
|
|
||||||
} else if (redteam.members.Contains(p)) {
|
|
||||||
//cache.Remove(GetPlayer(p));
|
|
||||||
redteam.members.Remove(p);
|
|
||||||
Chat.MessageLevel(mainlevel, p.ColoredName + " " + redteam.color + "left the ctf game");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleLevelUnload(Level l) {
|
void HandleLevelUnload(Level l) {
|
||||||
if (started && l == mainlevel) {
|
if (started && l == map) {
|
||||||
Logger.Log(LogType.GameActivity, "Unload Failed!, A ctf game is currently going on!");
|
Logger.Log(LogType.GameActivity, "Unload Failed!, A ctf game is currently going on!");
|
||||||
Plugin.CancelLevelEvent(LevelEvents.LevelUnload, l);
|
Plugin.CancelLevelEvent(LevelEvents.LevelUnload, l);
|
||||||
}
|
}
|
||||||
@ -246,47 +199,23 @@ namespace MCGalaxy.Games {
|
|||||||
Player.Message(p, "No CTF maps were found."); return false;
|
Player.Message(p, "No CTF maps were found."); return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
blueteam = new Teams("blue");
|
blue = new CtfTeam2("blue", Colors.blue);
|
||||||
redteam = new Teams("red");
|
red = new CtfTeam2("red", Colors.red);
|
||||||
LoadMap(maps[new Random().Next(maps.Count)]);
|
LoadMap(maps[new Random().Next(maps.Count)]);
|
||||||
|
|
||||||
if (needSetup) AutoSetup();
|
Logger.Log(LogType.GameActivity, "[CTF] Running...");
|
||||||
redbase.block = (ExtBlock)Block.red;
|
|
||||||
bluebase.block = (ExtBlock)Block.blue;
|
|
||||||
Logger.Log(LogType.GameActivity, "[Auto_CTF] Running...");
|
|
||||||
started = true;
|
started = true;
|
||||||
|
|
||||||
Database.Backend.CreateTable("CTF", createSyntax);
|
Database.Backend.CreateTable("CTF", createSyntax);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoSetup() {
|
|
||||||
for (ushort y = 0; y < mainlevel.Height; y++)
|
|
||||||
for (ushort z = 0; z < mainlevel.Length; z++)
|
|
||||||
for (ushort x = 0; x < mainlevel.Width; x++)
|
|
||||||
{
|
|
||||||
byte block = mainlevel.GetTile(x, y, z);
|
|
||||||
if (block == Block.red) {
|
|
||||||
redbase.x = x; redbase.y = y; redbase.z = z;
|
|
||||||
} else if (block == Block.blue || block == Block.cyan) {
|
|
||||||
bluebase.x = x; bluebase.y = y; bluebase.z = z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zline = mainlevel.Length / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void SpawnPlayer(Player p) {
|
internal void SpawnPlayer(Player p) {
|
||||||
if (p.level != mainlevel) return;
|
if (p.level != map) return;
|
||||||
|
CtfTeam2 team = TeamOf(p);
|
||||||
if (GetPlayer(p).blue) {
|
if (team != null) team.SendToSpawn(p);
|
||||||
bluebase.SendToSpawn(mainlevel, this, p);
|
|
||||||
} else {
|
|
||||||
redbase.SendToSpawn(mainlevel, this, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Vote()
|
string Vote() {
|
||||||
{
|
|
||||||
started = false;
|
started = false;
|
||||||
vote1 = 0;
|
vote1 = 0;
|
||||||
vote2 = 0;
|
vote2 = 0;
|
||||||
@ -298,147 +227,131 @@ namespace MCGalaxy.Games {
|
|||||||
map2 = maps1[rand.Next(maps1.Count)];
|
map2 = maps1[rand.Next(maps1.Count)];
|
||||||
maps1.Remove(map2);
|
maps1.Remove(map2);
|
||||||
map3 = maps1[rand.Next(maps1.Count)];
|
map3 = maps1[rand.Next(maps1.Count)];
|
||||||
Chat.MessageLevel(mainlevel, "%2VOTE:");
|
Chat.MessageLevel(map, "%2VOTE:");
|
||||||
Chat.MessageLevel(mainlevel, "1. " + map1 + " 2. " + map2 + " 3. " + map3);
|
Chat.MessageLevel(map, "1. " + map1 + " 2. " + map2 + " 3. " + map3);
|
||||||
voting = true;
|
voting = true;
|
||||||
int seconds = rand.Next(15, 61);
|
int seconds = rand.Next(15, 61);
|
||||||
Chat.MessageLevel(mainlevel, "You have " + seconds + " seconds to vote!");
|
Chat.MessageLevel(map, "You have " + seconds + " seconds to vote!");
|
||||||
Thread.Sleep(seconds * 1000);
|
Thread.Sleep(seconds * 1000);
|
||||||
voting = false;
|
voting = false;
|
||||||
Chat.MessageLevel(mainlevel, "VOTING ENDED!");
|
Chat.MessageLevel(map, "VOTING ENDED!");
|
||||||
Thread.Sleep(rand.Next(1, 10) * 1000);
|
Thread.Sleep(rand.Next(1, 10) * 1000);
|
||||||
if (vote1 > vote2 && vote1 > vote3)
|
if (vote1 > vote2 && vote1 > vote3)
|
||||||
{
|
{
|
||||||
Chat.MessageLevel(mainlevel, map1 + " WON!");
|
Chat.MessageLevel(map, map1 + " WON!");
|
||||||
return map1;
|
return map1;
|
||||||
}
|
}
|
||||||
if (vote2 > vote1 && vote2 > vote3)
|
if (vote2 > vote1 && vote2 > vote3)
|
||||||
{
|
{
|
||||||
Chat.MessageLevel(mainlevel, map2 + " WON!");
|
Chat.MessageLevel(map, map2 + " WON!");
|
||||||
return map2;
|
return map2;
|
||||||
}
|
}
|
||||||
if (vote3 > vote2 && vote3 > vote1)
|
if (vote3 > vote2 && vote3 > vote1)
|
||||||
{
|
{
|
||||||
Chat.MessageLevel(mainlevel, map3 + " WON!");
|
Chat.MessageLevel(map, map3 + " WON!");
|
||||||
return map3;
|
return map3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Chat.MessageLevel(mainlevel, "There was a tie!");
|
Chat.MessageLevel(map, "There was a tie!");
|
||||||
Chat.MessageLevel(mainlevel, "I'll choose!");
|
Chat.MessageLevel(map, "I'll choose!");
|
||||||
return maps[rand.Next(maps.Count)];
|
return maps[rand.Next(maps.Count)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void End()
|
|
||||||
{
|
void End() {
|
||||||
started = false;
|
started = false;
|
||||||
string nextmap = "";
|
string nextmap = "";
|
||||||
string winner = "";
|
if (blue.Points >= Config.MaxPoints || blue.Points > red.Points) {
|
||||||
Teams winnerteam = null;
|
Chat.MessageLevel(map, blue.ColoredName + " %Swon this round of CTF!");
|
||||||
if (blueteam.points >= maxpoints || blueteam.points > redteam.points)
|
} else if (red.Points >= Config.MaxPoints || red.Points > blue.Points) {
|
||||||
{
|
Chat.MessageLevel(map, red.ColoredName + " %Swon this round of CTF!");
|
||||||
winnerteam = blueteam;
|
} else {
|
||||||
winner = "blue team";
|
Chat.MessageLevel(map, "The round ended in a tie!");
|
||||||
}
|
}
|
||||||
else if (redteam.points >= maxpoints || redteam.points > blueteam.points)
|
|
||||||
{
|
|
||||||
winnerteam = redteam;
|
|
||||||
winner = "red team";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Chat.MessageLevel(mainlevel, "The game ended in a tie!");
|
|
||||||
}
|
|
||||||
Chat.MessageLevel(mainlevel, "The winner was " + winnerteam.color + winner + "!!");
|
|
||||||
Thread.Sleep(4000);
|
Thread.Sleep(4000);
|
||||||
//MYSQL!
|
//MYSQL!
|
||||||
cache.ForEach(delegate(Data d) {
|
cache.ForEach(delegate(Data d) {
|
||||||
d.hasflag = false;
|
d.hasflag = false;
|
||||||
Database.Backend.UpdateRows("CTF", "Points=@1, Captures=@2, tags=@3",
|
Database.Backend.UpdateRows("CTF", "Points=@1, Captures=@2, tags=@3",
|
||||||
"WHERE Name = @0", d.p.name, d.points, d.cap, d.tag);
|
"WHERE Name = @0", d.p.name, d.points, d.cap, d.Tags);
|
||||||
});
|
});
|
||||||
nextmap = Vote();
|
nextmap = Vote();
|
||||||
Chat.MessageLevel(mainlevel, "Starting a new game!");
|
Chat.MessageLevel(map, "Starting a new game!");
|
||||||
redbase = null;
|
blue.Members.Clear();
|
||||||
redteam = null;
|
red.Members.Clear();
|
||||||
bluebase = null;
|
|
||||||
blueteam = null;
|
|
||||||
bluebase = new Base();
|
|
||||||
redbase = new Base();
|
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
LoadMap(nextmap);
|
LoadMap(nextmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePlayerBlockChange(Player p, ushort x, ushort y, ushort z, ExtBlock block) {
|
void HandlePlayerBlockChange(Player p, ushort x, ushort y, ushort z, ExtBlock block) {
|
||||||
if (!started || p.level != mainlevel) return;
|
if (!started || p.level != map) return;
|
||||||
if (!blueteam.members.Contains(p) && !redteam.members.Contains(p)) {
|
CtfTeam2 team = TeamOf(p);
|
||||||
|
if (team == null) {
|
||||||
p.RevertBlock(x, y, z);
|
p.RevertBlock(x, y, z);
|
||||||
Player.Message(p, "You are not on a team!");
|
Player.Message(p, "You are not on a team!");
|
||||||
Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
|
Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blueteam.members.Contains(p) && x == redbase.x && y == redbase.y && z == redbase.z && !mainlevel.IsAirAt(x, y, z)) {
|
Vec3U16 pos = new Vec3U16(x, y, z);
|
||||||
Chat.MessageLevel(mainlevel, blueteam.color + p.name + " took the " + redteam.color + " red team's FLAG!");
|
if (pos == Opposing(team).FlagPos && !map.IsAirAt(x, y, z)) TakeFlag(p, team);
|
||||||
GetPlayer(p).hasflag = true;
|
if (pos == team.FlagPos && !map.IsAirAt(x, y, z)) ReturnFlag(p, team);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TakeFlag(Player p, CtfTeam2 team) {
|
||||||
|
CtfTeam2 opposing = Opposing(team);
|
||||||
|
Chat.MessageLevel(map, team.Color + p.DisplayName + " took the " + blue.ColoredName + " %Steam's FLAG");
|
||||||
|
DataOf(p).hasflag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReturnFlag(Player p, CtfTeam2 team) {
|
||||||
|
Vec3U16 flagPos = team.FlagPos;
|
||||||
|
p.RevertBlock(flagPos.X, flagPos.Y, flagPos.Z);
|
||||||
|
Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
|
||||||
|
|
||||||
if (redteam.members.Contains(p) && x == bluebase.x && y == bluebase.y && z == bluebase.z && !mainlevel.IsAirAt(x, y, z)) {
|
if (DataOf(p).hasflag) {
|
||||||
Chat.MessageLevel(mainlevel, redteam.color + p.name + " took the " + blueteam.color + " blue team's FLAG");
|
Chat.MessageLevel(map, team.Color + p.DisplayName + " RETURNED THE FLAG!");
|
||||||
GetPlayer(p).hasflag = true;
|
DataOf(p).hasflag = false;
|
||||||
}
|
DataOf(p).points += Config.Capture_PointsGained;
|
||||||
|
DataOf(p).cap++;
|
||||||
if (blueteam.members.Contains(p) && x == bluebase.x && y == bluebase.y && z == bluebase.z && !mainlevel.IsAirAt(x, y, z)) {
|
|
||||||
if (GetPlayer(p).hasflag) {
|
CtfTeam2 opposing = Opposing(team);
|
||||||
Chat.MessageLevel(mainlevel, blueteam.color + p.name + " RETURNED THE FLAG!");
|
team.Points++;
|
||||||
GetPlayer(p).hasflag = false;
|
flagPos = opposing.FlagPos;
|
||||||
GetPlayer(p).cap++;
|
map.Blockchange(flagPos.X, flagPos.Y, flagPos.Z, opposing.FlagBlock);
|
||||||
GetPlayer(p).points += cappoint;
|
|
||||||
blueteam.points++;
|
if (team.Points >= Config.MaxPoints) { End(); return; }
|
||||||
|
} else {
|
||||||
mainlevel.Blockchange(redbase.x, redbase.y, redbase.z, (ExtBlock)Block.red);
|
Player.Message(p, "You cannot take your own flag!");
|
||||||
p.RevertBlock(x, y, z);
|
|
||||||
Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
|
|
||||||
if (blueteam.points >= maxpoints) { End(); return; }
|
|
||||||
} else {
|
|
||||||
Player.Message(p, "You cant take your own flag!");
|
|
||||||
p.RevertBlock(x, y, z);
|
|
||||||
Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (redteam.members.Contains(p) && x == redbase.x && y == redbase.y && z == redbase.z && !mainlevel.IsAirAt(x, y, z)) {
|
|
||||||
if (GetPlayer(p).hasflag) {
|
|
||||||
Chat.MessageLevel(mainlevel, redteam.color + p.name + " RETURNED THE FLAG!");
|
|
||||||
GetPlayer(p).hasflag = false;
|
|
||||||
GetPlayer(p).points += cappoint;
|
|
||||||
GetPlayer(p).cap++;
|
|
||||||
redteam.points++;
|
|
||||||
|
|
||||||
mainlevel.Blockchange(bluebase.x, bluebase.y, bluebase.z, (ExtBlock)Block.blue);
|
|
||||||
p.RevertBlock(x, y, z);
|
|
||||||
Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
|
|
||||||
if (redteam.points >= maxpoints) { End(); return; }
|
|
||||||
} else {
|
|
||||||
Player.Message(p, "You cannot take your own flag!");
|
|
||||||
p.RevertBlock(x, y, z);
|
|
||||||
Plugin.CancelPlayerEvent(PlayerEvents.BlockChange, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Data GetPlayer(Player p) {
|
void DropFlag(Player p, CtfTeam2 team) {
|
||||||
|
if (!DataOf(p).hasflag) return;
|
||||||
|
DataOf(p).hasflag = false;
|
||||||
|
Chat.MessageLevel(map, team.Color + p.DisplayName + " DROPPED THE FLAG!");
|
||||||
|
DataOf(p).points -= Config.Capture_PointsLost;
|
||||||
|
|
||||||
|
CtfTeam2 opposing = Opposing(team);
|
||||||
|
Vec3U16 pos = opposing.FlagPos;
|
||||||
|
map.Blockchange(pos.X, pos.Y, pos.Z, opposing.FlagBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Data DataOf(Player p) {
|
||||||
foreach (Data d in cache) {
|
foreach (Data d in cache) {
|
||||||
if (d.p == p) return d;
|
if (d.p == p) return d;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HandlePlayerCommand(string cmd, Player p, string message) {
|
void HandlePlayerCommand(string cmd, Player p, string message) {
|
||||||
if (!started) return;
|
if (!started) return;
|
||||||
|
|
||||||
if (cmd == "teamchat" && p.level == mainlevel) {
|
if (cmd == "teamchat" && p.level == map) {
|
||||||
if (GetPlayer(p) != null) {
|
if (DataOf(p) != null) {
|
||||||
Data d = GetPlayer(p);
|
Data d = DataOf(p);
|
||||||
if (d.chatting) {
|
if (d.chatting) {
|
||||||
Player.Message(d.p, "You are no longer chatting with your team!");
|
Player.Message(d.p, "You are no longer chatting with your team!");
|
||||||
d.chatting = !d.chatting;
|
d.chatting = !d.chatting;
|
||||||
@ -451,53 +364,36 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd != "goto") return;
|
if (cmd != "goto") return;
|
||||||
if (message == "ctf" && p.level != mainlevel) {
|
if (message == "ctf" && p.level != map) {
|
||||||
if (blueteam.members.Count > redteam.members.Count) {
|
if (blue.Members.Count > red.Members.Count) {
|
||||||
JoinRedTeam(p);
|
JoinTeam(p, red);
|
||||||
} else if (redteam.members.Count > blueteam.members.Count) {
|
} else if (red.Members.Count > blue.Members.Count) {
|
||||||
JoinBlueTeam(p);
|
JoinTeam(p, blue);
|
||||||
} else if (new Random().Next(2) == 0) {
|
} else if (new Random().Next(2) == 0) {
|
||||||
JoinRedTeam(p);
|
JoinTeam(p, red);
|
||||||
} else {
|
} else {
|
||||||
JoinBlueTeam(p);
|
JoinTeam(p, blue);
|
||||||
}
|
|
||||||
} else if (message != "ctf" && p.level == mainlevel) {
|
|
||||||
if (blueteam.members.Contains(p)) {
|
|
||||||
//cache.Remove(GetPlayer(p));
|
|
||||||
blueteam.members.Remove(p);
|
|
||||||
Chat.MessageLevel(mainlevel, p.ColoredName + " " + blueteam.color + "left the ctf game");
|
|
||||||
} else if (redteam.members.Contains(p)) {
|
|
||||||
//cache.Remove(GetPlayer(p));
|
|
||||||
redteam.members.Remove(p);
|
|
||||||
Chat.MessageLevel(mainlevel, p.ColoredName + " " + redteam.color + "left the ctf game");
|
|
||||||
}
|
}
|
||||||
|
} else if (message != "ctf" && p.level == map) {
|
||||||
|
CtfTeam2 team = TeamOf(p);
|
||||||
|
if (team == null) return;
|
||||||
|
|
||||||
|
DropFlag(p, team);
|
||||||
|
team.Remove(p);
|
||||||
|
Chat.MessageLevel(map, team.Color + p.DisplayName + " %Sleft the ctf game");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoinBlueTeam(Player p) {
|
void JoinTeam(Player p, CtfTeam2 team) {
|
||||||
if (GetPlayer(p) == null) {
|
if (DataOf(p) == null) {
|
||||||
cache.Add(new Data(true, p));
|
cache.Add(new Data(p));
|
||||||
} else {
|
} else {
|
||||||
GetPlayer(p).hasflag = false;
|
DataOf(p).hasflag = false;
|
||||||
GetPlayer(p).blue = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blueteam.Add(p);
|
team.Members.Add(p);
|
||||||
Chat.MessageLevel(mainlevel, p.ColoredName + " " + Colors.blue + "joined the BLUE Team");
|
Chat.MessageLevel(map, p.ColoredName + " joined the " + team.ColoredName + " %Steam");
|
||||||
Player.Message(p, Colors.blue + "You are now on the blue team!");
|
Player.Message(p, team.Color + "You are now on the " + team.Name + " team!");
|
||||||
}
|
|
||||||
|
|
||||||
void JoinRedTeam(Player p) {
|
|
||||||
if (GetPlayer(p) == null) {
|
|
||||||
cache.Add(new Data(false, p));
|
|
||||||
} else {
|
|
||||||
GetPlayer(p).hasflag = false;
|
|
||||||
GetPlayer(p).blue = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
redteam.Add(p);
|
|
||||||
Chat.MessageLevel(mainlevel, p.ColoredName + " " + Colors.red + "joined the RED Team");
|
|
||||||
Player.Message(p, Colors.red + "You are now on the red team!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePlayerChat(Player p, string message) {
|
void HandlePlayerChat(Player p, string message) {
|
||||||
@ -521,46 +417,42 @@ namespace MCGalaxy.Games {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!started || p.level != mainlevel) return;
|
if (!started || p.level != map) return;
|
||||||
if (!GetPlayer(p).chatting) return;
|
if (!DataOf(p).chatting) return;
|
||||||
|
|
||||||
if (blueteam.members.Contains(p)) {
|
CtfTeam2 team = TeamOf(p);
|
||||||
Player[] online = PlayerInfo.Online.Items;
|
if (team == null) return;
|
||||||
foreach (Player p1 in online) {
|
Player[] members = team.Members.Items;
|
||||||
if (blueteam.members.Contains(p1))
|
|
||||||
Player.Message(p1, "(Blue) " + p.ColoredName + ":&f " + message);
|
foreach (Player pl in members) {
|
||||||
}
|
Player.Message(pl, "({0}) {1}: &f{2}", team.Name, p.ColoredName, message);
|
||||||
Plugin.CancelPlayerEvent(PlayerEvents.PlayerChat, p);
|
|
||||||
} else if (redteam.members.Contains(p)) {
|
|
||||||
Player[] online = PlayerInfo.Online.Items;
|
|
||||||
foreach (Player p1 in online) {
|
|
||||||
if (redteam.members.Contains(p1))
|
|
||||||
Player.Message(p1, "(Red) " + p.ColoredName + ":&f " + message);
|
|
||||||
}
|
|
||||||
Plugin.CancelPlayerEvent(PlayerEvents.PlayerChat, p);
|
|
||||||
}
|
}
|
||||||
|
Plugin.CancelPlayerEvent(PlayerEvents.PlayerChat, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePlayerDeath(Player p, ExtBlock deathblock) {
|
void HandlePlayerDeath(Player p, ExtBlock deathblock) {
|
||||||
if (!started || p.level != mainlevel) return;
|
if (!started || p.level != map) return;
|
||||||
if (!GetPlayer(p).hasflag) return;
|
if (!DataOf(p).hasflag) return;
|
||||||
|
|
||||||
if (redteam.members.Contains(p)) {
|
CtfTeam2 team = TeamOf(p);
|
||||||
Chat.MessageLevel(mainlevel, redteam.color + p.name + " DROPPED THE FLAG!");
|
if (team != null) DropFlag(p, team);
|
||||||
GetPlayer(p).points -= caplose;
|
|
||||||
mainlevel.Blockchange(redbase.x, redbase.y, redbase.z, (ExtBlock)Block.red);
|
|
||||||
} else if (blueteam.members.Contains(p)) {
|
|
||||||
Chat.MessageLevel(mainlevel, blueteam.color + p.name + " DROPPED THE FLAG!");
|
|
||||||
GetPlayer(p).points -= caplose;
|
|
||||||
mainlevel.Blockchange(bluebase.x, bluebase.y, bluebase.z, (ExtBlock)Block.blue);
|
|
||||||
}
|
|
||||||
GetPlayer(p).hasflag = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool OnSide(int z, Base b) {
|
bool OnOwnTeamSide(int z, CtfTeam2 team) {
|
||||||
if (b.z < zline && z < zline) return true;
|
int baseZ = team.FlagPos.Z, zline = Config.ZDivider;
|
||||||
if (b.z > zline && z > zline) return true;
|
if (baseZ < zline && z < zline) return true;
|
||||||
|
if (baseZ > zline && z > zline) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CtfTeam2 TeamOf(Player p) {
|
||||||
|
if (red.Members.Contains(p)) return red;
|
||||||
|
if (blue.Members.Contains(p)) return blue;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
CtfTeam2 Opposing(CtfTeam2 team) {
|
||||||
|
return team == red ? blue : red;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,189 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 MCForge
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
not use this file except in compliance with the Licenses. You may
|
not use this file except in compliance with the Licenses. You may
|
||||||
obtain a copy of the Licenses at
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
http://www.opensource.org/licenses/ecl2.php
|
http://www.opensource.org/licenses/ecl2.php
|
||||||
http://www.gnu.org/licenses/gpl-3.0.html
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing,
|
Unless required by applicable law or agreed to in writing,
|
||||||
software distributed under the Licenses are distributed on an "AS IS"
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using MCGalaxy.Maths;
|
||||||
namespace MCGalaxy.Games
|
|
||||||
{
|
namespace MCGalaxy.Games {
|
||||||
public sealed class CtfTeam
|
|
||||||
{
|
/// <summary> Represents a team in Capture the Flag. </summary>
|
||||||
public char color;
|
public sealed class CtfTeam2 {
|
||||||
public int points = 0;
|
|
||||||
public ushort[] flagBase = new ushort[3];
|
/// <summary> The name of this team. </summary>
|
||||||
public ushort[] flagLocation = new ushort[3];
|
public string Name;
|
||||||
public List<Spawn> spawns = new List<Spawn>();
|
|
||||||
public List<Player> players = new List<Player>();
|
/// <summary> The color code of this team. </summary>
|
||||||
public Level mapOn;
|
public string Color;
|
||||||
public bool flagishome;
|
|
||||||
public bool spawnset;
|
public string ColoredName { get { return Color + Name; } }
|
||||||
public bool flagmoved;
|
|
||||||
public string teamstring = "";
|
/// <summary> Total points this team has collected. </summary>
|
||||||
public Player holdingFlag = null;
|
public int Points;
|
||||||
public CatchPos tempFlagblock;
|
|
||||||
public CatchPos tfb;
|
/// <summary> Players on this team. </summary>
|
||||||
public int ftcount = 0;
|
public VolatileArray<Player> Members = new VolatileArray<Player>(false);
|
||||||
|
|
||||||
public void AddMember(Player p)
|
|
||||||
{
|
/// <summary> Position in the world the flag is located at. </summary>
|
||||||
if (p.Game.team != this)
|
public Vec3U16 FlagPos;
|
||||||
{
|
|
||||||
if (p.Game.team != null) { p.Game.team.RemoveMember(p); }
|
/// <summary> Position in the world members of this team spawn at. </summary>
|
||||||
p.Game.team = this;
|
public Position SpawnPos;
|
||||||
Entities.GlobalDespawn(p, false);
|
|
||||||
//p.CTFtempcolor = p.color;
|
/// <summary> Block type of this team's flag. </summary>
|
||||||
//p.CTFtempprefix = p.prefix;
|
public ExtBlock FlagBlock;
|
||||||
p.color = "&" + color;
|
|
||||||
//p.carryingFlag = false;
|
public CtfTeam2(string name, string color) { Name = name; Color = color; }
|
||||||
p.Game.hasflag = null;
|
|
||||||
p.prefix = p.color + "[" + Colors.Name("&" + color).ToUpper() + "] ";
|
|
||||||
players.Add(p);
|
/// <summary> Removes a player from this team. </summary>
|
||||||
mapOn.ChatLevel(p.ColoredName + " %Shas joined the " + teamstring + ".");
|
public bool Remove(Player p) { return Members.Remove(p); }
|
||||||
Entities.GlobalSpawn(p, false);
|
|
||||||
}
|
public void SendToSpawn(Player p) {
|
||||||
}
|
p.SendPos(Entities.SelfID, SpawnPos, p.Rot);
|
||||||
|
}
|
||||||
public void RemoveMember(Player p)
|
}
|
||||||
{
|
|
||||||
if (p.Game.team == this)
|
|
||||||
{
|
|
||||||
p.Game.team = null;
|
|
||||||
Entities.GlobalDespawn(p, false);
|
|
||||||
//p.color = p.CTFtempcolor;
|
|
||||||
//p.prefix = p.CTFtempprefix;
|
|
||||||
//p.carryingFlag = false;
|
|
||||||
p.Game.hasflag = null;
|
|
||||||
players.Remove(p);
|
|
||||||
mapOn.ChatLevel(p.ColoredName + " %Shas left the " + teamstring + ".");
|
|
||||||
Entities.GlobalSpawn(p, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SpawnPlayer(Player p)
|
|
||||||
{
|
|
||||||
Position pos = default(Position);
|
|
||||||
byte yaw = 0, pitch = 0;
|
|
||||||
|
|
||||||
if (spawns.Count != 0) {
|
|
||||||
Random random = new Random();
|
|
||||||
int rnd = random.Next(0, spawns.Count);
|
|
||||||
|
|
||||||
pos.X = 16 + spawns[rnd].x * 32;
|
|
||||||
pos.Y = 32 + spawns[rnd].y * 32;
|
|
||||||
pos.Z = 16 + spawns[rnd].z * 32;
|
|
||||||
yaw = (byte)spawns[rnd].rotx;
|
|
||||||
//p.health = 100;
|
|
||||||
} else {
|
|
||||||
pos = mapOn.SpawnPos;
|
|
||||||
yaw = mapOn.rotx; pitch = mapOn.roty;
|
|
||||||
}
|
|
||||||
Entities.Spawn(p, p, pos, new Orientation(yaw, pitch));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddSpawn(ushort x, ushort y, ushort z, ushort rotx, ushort roty)
|
|
||||||
{
|
|
||||||
Spawn workSpawn = new Spawn();
|
|
||||||
workSpawn.x = x;
|
|
||||||
workSpawn.y = y;
|
|
||||||
workSpawn.z = z;
|
|
||||||
workSpawn.rotx = rotx;
|
|
||||||
workSpawn.roty = roty;
|
|
||||||
|
|
||||||
spawns.Add(workSpawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Drawflag()
|
|
||||||
{
|
|
||||||
|
|
||||||
ushort x = flagLocation[0];
|
|
||||||
ushort y = flagLocation[1];
|
|
||||||
ushort z = flagLocation[2];
|
|
||||||
|
|
||||||
if (mapOn.IsAirAt(x, (ushort)(y - 1), z)) {
|
|
||||||
flagLocation[1] = (ushort)(flagLocation[1] - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
mapOn.Blockchange(tfb.x, tfb.y, tfb.z, tfb.type);
|
|
||||||
mapOn.Blockchange(tfb.x, (ushort)(tfb.y + 1), tfb.z, ExtBlock.Air);
|
|
||||||
mapOn.Blockchange(tfb.x, (ushort)(tfb.y + 2), tfb.z, ExtBlock.Air);
|
|
||||||
|
|
||||||
if (holdingFlag == null)
|
|
||||||
{
|
|
||||||
//DRAW ON GROUND SHIT HERE
|
|
||||||
|
|
||||||
tfb.type = mapOn.GetBlock(x, y, z);
|
|
||||||
|
|
||||||
if (mapOn.GetBlock(x, y, z) != (ExtBlock)Block.flagbase) {
|
|
||||||
mapOn.Blockchange(x, y, z, (ExtBlock)Block.flagbase);
|
|
||||||
}
|
|
||||||
if (mapOn.GetBlock(x, (ushort)(y + 1), z) != (ExtBlock)Block.mushroom) {
|
|
||||||
mapOn.Blockchange(x, (ushort)(y + 1), z, (ExtBlock)Block.mushroom);
|
|
||||||
}
|
|
||||||
if (mapOn.GetBlock(x, (ushort)(y + 2), z) != (ExtBlock)GetColorBlock(color)) {
|
|
||||||
mapOn.Blockchange(x, (ushort)(y + 2), z, (ExtBlock)GetColorBlock(color));
|
|
||||||
}
|
|
||||||
|
|
||||||
tfb.x = x;
|
|
||||||
tfb.y = y;
|
|
||||||
tfb.z = z;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//DRAW ON PLAYER HEAD
|
|
||||||
x = (ushort)(holdingFlag.Pos.BlockX);
|
|
||||||
y = (ushort)(holdingFlag.Pos.BlockY + 3);
|
|
||||||
z = (ushort)(holdingFlag.Pos.BlockZ);
|
|
||||||
|
|
||||||
if (tempFlagblock.x == x && tempFlagblock.y == y && tempFlagblock.z == z) { return; }
|
|
||||||
|
|
||||||
|
|
||||||
mapOn.Blockchange(tempFlagblock.x, tempFlagblock.y, tempFlagblock.z, tempFlagblock.type);
|
|
||||||
|
|
||||||
tempFlagblock.type = mapOn.GetBlock(x, y, z);
|
|
||||||
|
|
||||||
mapOn.Blockchange(x, y, z, (ExtBlock)GetColorBlock(color));
|
|
||||||
|
|
||||||
tempFlagblock.x = x;
|
|
||||||
tempFlagblock.y = y;
|
|
||||||
tempFlagblock.z = z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte GetColorBlock(char color)
|
|
||||||
{
|
|
||||||
if (color == '2')
|
|
||||||
return Block.green;
|
|
||||||
if (color == '5')
|
|
||||||
return Block.purple;
|
|
||||||
if (color == '8')
|
|
||||||
return Block.darkgrey;
|
|
||||||
if (color == '9')
|
|
||||||
return Block.blue;
|
|
||||||
if (color == 'c')
|
|
||||||
return Block.red;
|
|
||||||
if (color == 'e')
|
|
||||||
return Block.yellow;
|
|
||||||
if (color == 'f')
|
|
||||||
return Block.white;
|
|
||||||
else
|
|
||||||
return Block.air;
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct CatchPos { public ushort x, y, z; public ExtBlock type; }
|
|
||||||
public struct Spawn { public ushort x, y, z, rotx, roty; }
|
|
||||||
}
|
|
||||||
}
|
}
|
189
MCGalaxy/Games/CTF/CtfTeamOld.cs
Normal file
189
MCGalaxy/Games/CTF/CtfTeamOld.cs
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
|
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 sealed class CtfTeam
|
||||||
|
{
|
||||||
|
public char color;
|
||||||
|
public int points = 0;
|
||||||
|
public ushort[] flagBase = new ushort[3];
|
||||||
|
public ushort[] flagLocation = new ushort[3];
|
||||||
|
public List<Spawn> spawns = new List<Spawn>();
|
||||||
|
public List<Player> players = new List<Player>();
|
||||||
|
public Level mapOn;
|
||||||
|
public bool flagishome;
|
||||||
|
public bool spawnset;
|
||||||
|
public bool flagmoved;
|
||||||
|
public string teamstring = "";
|
||||||
|
public Player holdingFlag = null;
|
||||||
|
public CatchPos tempFlagblock;
|
||||||
|
public CatchPos tfb;
|
||||||
|
public int ftcount = 0;
|
||||||
|
|
||||||
|
public void AddMember(Player p)
|
||||||
|
{
|
||||||
|
if (p.Game.team != this)
|
||||||
|
{
|
||||||
|
if (p.Game.team != null) { p.Game.team.RemoveMember(p); }
|
||||||
|
p.Game.team = this;
|
||||||
|
Entities.GlobalDespawn(p, false);
|
||||||
|
//p.CTFtempcolor = p.color;
|
||||||
|
//p.CTFtempprefix = p.prefix;
|
||||||
|
p.color = "&" + color;
|
||||||
|
//p.carryingFlag = false;
|
||||||
|
p.Game.hasflag = null;
|
||||||
|
p.prefix = p.color + "[" + Colors.Name("&" + color).ToUpper() + "] ";
|
||||||
|
players.Add(p);
|
||||||
|
mapOn.ChatLevel(p.ColoredName + " %Shas joined the " + teamstring + ".");
|
||||||
|
Entities.GlobalSpawn(p, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveMember(Player p)
|
||||||
|
{
|
||||||
|
if (p.Game.team == this)
|
||||||
|
{
|
||||||
|
p.Game.team = null;
|
||||||
|
Entities.GlobalDespawn(p, false);
|
||||||
|
//p.color = p.CTFtempcolor;
|
||||||
|
//p.prefix = p.CTFtempprefix;
|
||||||
|
//p.carryingFlag = false;
|
||||||
|
p.Game.hasflag = null;
|
||||||
|
players.Remove(p);
|
||||||
|
mapOn.ChatLevel(p.ColoredName + " %Shas left the " + teamstring + ".");
|
||||||
|
Entities.GlobalSpawn(p, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SpawnPlayer(Player p)
|
||||||
|
{
|
||||||
|
Position pos = default(Position);
|
||||||
|
byte yaw = 0, pitch = 0;
|
||||||
|
|
||||||
|
if (spawns.Count != 0) {
|
||||||
|
Random random = new Random();
|
||||||
|
int rnd = random.Next(0, spawns.Count);
|
||||||
|
|
||||||
|
pos.X = 16 + spawns[rnd].x * 32;
|
||||||
|
pos.Y = 32 + spawns[rnd].y * 32;
|
||||||
|
pos.Z = 16 + spawns[rnd].z * 32;
|
||||||
|
yaw = (byte)spawns[rnd].rotx;
|
||||||
|
//p.health = 100;
|
||||||
|
} else {
|
||||||
|
pos = mapOn.SpawnPos;
|
||||||
|
yaw = mapOn.rotx; pitch = mapOn.roty;
|
||||||
|
}
|
||||||
|
Entities.Spawn(p, p, pos, new Orientation(yaw, pitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddSpawn(ushort x, ushort y, ushort z, ushort rotx, ushort roty)
|
||||||
|
{
|
||||||
|
Spawn workSpawn = new Spawn();
|
||||||
|
workSpawn.x = x;
|
||||||
|
workSpawn.y = y;
|
||||||
|
workSpawn.z = z;
|
||||||
|
workSpawn.rotx = rotx;
|
||||||
|
workSpawn.roty = roty;
|
||||||
|
|
||||||
|
spawns.Add(workSpawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Drawflag()
|
||||||
|
{
|
||||||
|
|
||||||
|
ushort x = flagLocation[0];
|
||||||
|
ushort y = flagLocation[1];
|
||||||
|
ushort z = flagLocation[2];
|
||||||
|
|
||||||
|
if (mapOn.IsAirAt(x, (ushort)(y - 1), z)) {
|
||||||
|
flagLocation[1] = (ushort)(flagLocation[1] - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
mapOn.Blockchange(tfb.x, tfb.y, tfb.z, tfb.type);
|
||||||
|
mapOn.Blockchange(tfb.x, (ushort)(tfb.y + 1), tfb.z, ExtBlock.Air);
|
||||||
|
mapOn.Blockchange(tfb.x, (ushort)(tfb.y + 2), tfb.z, ExtBlock.Air);
|
||||||
|
|
||||||
|
if (holdingFlag == null)
|
||||||
|
{
|
||||||
|
//DRAW ON GROUND SHIT HERE
|
||||||
|
|
||||||
|
tfb.type = mapOn.GetBlock(x, y, z);
|
||||||
|
|
||||||
|
if (mapOn.GetBlock(x, y, z) != (ExtBlock)Block.flagbase) {
|
||||||
|
mapOn.Blockchange(x, y, z, (ExtBlock)Block.flagbase);
|
||||||
|
}
|
||||||
|
if (mapOn.GetBlock(x, (ushort)(y + 1), z) != (ExtBlock)Block.mushroom) {
|
||||||
|
mapOn.Blockchange(x, (ushort)(y + 1), z, (ExtBlock)Block.mushroom);
|
||||||
|
}
|
||||||
|
if (mapOn.GetBlock(x, (ushort)(y + 2), z) != (ExtBlock)GetColorBlock(color)) {
|
||||||
|
mapOn.Blockchange(x, (ushort)(y + 2), z, (ExtBlock)GetColorBlock(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
tfb.x = x;
|
||||||
|
tfb.y = y;
|
||||||
|
tfb.z = z;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//DRAW ON PLAYER HEAD
|
||||||
|
x = (ushort)(holdingFlag.Pos.BlockX);
|
||||||
|
y = (ushort)(holdingFlag.Pos.BlockY + 3);
|
||||||
|
z = (ushort)(holdingFlag.Pos.BlockZ);
|
||||||
|
|
||||||
|
if (tempFlagblock.x == x && tempFlagblock.y == y && tempFlagblock.z == z) { return; }
|
||||||
|
|
||||||
|
|
||||||
|
mapOn.Blockchange(tempFlagblock.x, tempFlagblock.y, tempFlagblock.z, tempFlagblock.type);
|
||||||
|
|
||||||
|
tempFlagblock.type = mapOn.GetBlock(x, y, z);
|
||||||
|
|
||||||
|
mapOn.Blockchange(x, y, z, (ExtBlock)GetColorBlock(color));
|
||||||
|
|
||||||
|
tempFlagblock.x = x;
|
||||||
|
tempFlagblock.y = y;
|
||||||
|
tempFlagblock.z = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte GetColorBlock(char color)
|
||||||
|
{
|
||||||
|
if (color == '2')
|
||||||
|
return Block.green;
|
||||||
|
if (color == '5')
|
||||||
|
return Block.purple;
|
||||||
|
if (color == '8')
|
||||||
|
return Block.darkgrey;
|
||||||
|
if (color == '9')
|
||||||
|
return Block.blue;
|
||||||
|
if (color == 'c')
|
||||||
|
return Block.red;
|
||||||
|
if (color == 'e')
|
||||||
|
return Block.yellow;
|
||||||
|
if (color == 'f')
|
||||||
|
return Block.white;
|
||||||
|
else
|
||||||
|
return Block.air;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct CatchPos { public ushort x, y, z; public ExtBlock type; }
|
||||||
|
public struct Spawn { public ushort x, y, z, rotx, roty; }
|
||||||
|
}
|
||||||
|
}
|
@ -486,8 +486,8 @@
|
|||||||
<Compile Include="Games\Countdown\CountdownMapGen.cs" />
|
<Compile Include="Games\Countdown\CountdownMapGen.cs" />
|
||||||
<Compile Include="Games\Countdown\CountdownPlugin.cs" />
|
<Compile Include="Games\Countdown\CountdownPlugin.cs" />
|
||||||
<Compile Include="Games\CTF\CtfConfig.cs" />
|
<Compile Include="Games\CTF\CtfConfig.cs" />
|
||||||
<Compile Include="Games\CTF\CtfConfig2.cs" />
|
|
||||||
<Compile Include="Games\CTF\CtfTeam.cs" />
|
<Compile Include="Games\CTF\CtfTeam.cs" />
|
||||||
|
<Compile Include="Games\CTF\CtfTeamOld.cs" />
|
||||||
<Compile Include="Games\GameProps.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" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user