コード例 #1
0
ファイル: Auto_CTF.cs プロジェクト: tommyz56/MCGalaxy
 /// <summary>
 /// Start the CTF game
 /// </summary>
 public void Start()
 {
     if (Level.Find("ctf") != null)
     {
         Command.all.Find("unload").Use(null, "ctf");
         Thread.Sleep(1000);
     }
     if (started)
         return;
     blueteam = new Teams("blue");
     redteam = new Teams("red");
     LoadMap(maps[new Random().Next(maps.Count)]);
     if (look)
     {
         for (ushort y = 0; y < mainlevel.Height; y++)
             for (ushort z = 0; z < mainlevel.Length; z++)
                 for (ushort x = 0; x < mainlevel.Width; x++)
         {
             if (mainlevel.GetTile(x, y, z) == Block.red)
             {
                 redbase.x = x; redbase.y = y; redbase.z = z;
             }
             else if (mainlevel.GetTile(x, y, z) == Block.blue || mainlevel.GetTile(x, y, z) == Block.cyan)
             {
                 bluebase.x = x; bluebase.y = y; bluebase.z = z;
             }
         }
         zline = mainlevel.Length / 2;
     }
     redbase.block = Block.red;
     bluebase.block = Block.blue;
     Server.s.Log("[Auto_CTF] Running...");
     started = true;
     Database.executeQuery("CREATE TABLE if not exists CTF (ID INTEGER " + (Server.useMySQL ? "" : "PRIMARY KEY ") + "AUTO" + (Server.useMySQL ? "_" : "") + "INCREMENT NOT NULL, Name VARCHAR(20), Points MEDIUMINT UNSIGNED, Captures MEDIUMINT UNSIGNED, tags MEDIUMINT UNSIGNED" + (Server.useMySQL ? ", PRIMARY KEY (ID)" : "") + ");");
 }
コード例 #2
0
ファイル: Auto_CTF.cs プロジェクト: tommyz56/MCGalaxy
 void End()
 {
     started = false;
     string nextmap = "";
     string winner = "";
     Teams winnerteam = null;
     if (blueteam.points >= maxpoints || blueteam.points > redteam.points)
     {
         winnerteam = blueteam;
         winner = "blue team";
     }
     else if (redteam.points >= maxpoints || redteam.points > blueteam.points)
     {
         winnerteam = redteam;
         winner = "red team";
     }
     else
     {
         Chat.GlobalMessageLevel(mainlevel, "The game ended in a tie!");
     }
     Chat.GlobalMessageLevel(mainlevel, "The winner was " + winnerteam.color + winner + "!!");
     Thread.Sleep(4000);
     //MYSQL!
     cache.ForEach(delegate(Data d)
     {
         string commandString =
        "UPDATE CTF SET Points=@Points, Captures=@Captures, tags=@Tags WHERE Name=@Name";
         d.hasflag = false;
         Database.AddParams("@Points", d.points);
         Database.AddParams("@Captures", d.cap);
         Database.AddParams("@Tags", d.tag);
         Database.AddParams("@Name", d.p.name);
         Database.executeQuery(commandString);
     });
     nextmap = Vote();
     Chat.GlobalMessageLevel(mainlevel, "Starting a new game!");
     redbase = null;
     redteam = null;
     bluebase = null;
     blueteam = null;
     bluebase = new Base();
     redbase = new Base();
     Thread.Sleep(2000);
     LoadMap(nextmap);
 }
コード例 #3
0
ファイル: Auto_CTF.cs プロジェクト: tommyz56/MCGalaxy
 public Base(ushort x, ushort y, ushort z, Teams team)
 {
     this.x = x; this.y = y; this.z = z;
 }