More cleanup of zombie game/countdown related functions.

This commit is contained in:
UnknownShadow200 2016-01-25 18:46:18 +11:00
parent 52fa4f53ca
commit babd9b517e
5 changed files with 89 additions and 113 deletions

View File

@ -14,7 +14,7 @@
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;
using System.Linq;
@ -64,12 +64,7 @@ namespace MCGalaxy
break;
}
{
{
mapon.Blockchange(15, 27, 16, Block.glass);
mapon.Blockchange(16, 27, 15, Block.glass);
mapon.Blockchange(16, 27, 16, Block.glass);
mapon.Blockchange(15, 27, 15, Block.glass);
}
ChangeSquare(15, 27, 15, Block.glass);
{
{
mapon.Blockchange(15, 18, 14, Block.glass);
@ -96,12 +91,7 @@ namespace MCGalaxy
mapon.Blockchange(17, 17, 15, Block.glass);
}
}
{
mapon.Blockchange(16, 16, 15, Block.glass);
mapon.Blockchange(15, 16, 16, Block.glass);
mapon.Blockchange(15, 16, 15, Block.glass);
mapon.Blockchange(16, 16, 16, Block.glass);
}
ChangeSquare(15, 16, 15, Block.glass);
}
mapon.ChatLevel("Countdown is about to start!!");
mapon.permissionbuild = LevelPermission.Nobody;
@ -290,42 +280,24 @@ namespace MCGalaxy
}
}
public static void RemoveSquare(string square)
{
static void RemoveSquare(string square) {
int column = int.Parse(square.Split(':')[0]);
int row = int.Parse(square.Split(':')[1]);
ushort x1 = (ushort)(27 - (row * 3));
ushort x2 = (ushort)(28 - (row * 3));
ushort x2 = (ushort)(x1 + 1);
ushort y = 4;
ushort z1 = (ushort)(27 - (column * 3));
ushort z2 = (ushort)(28 - (column * 3));
ushort z2 = (ushort)(z1 + 1);
{
{ //3
mapon.Blockchange(x1, y, z1, Block.yellow);
mapon.Blockchange(x2, y, z1, Block.yellow);
mapon.Blockchange(x2, y, z2, Block.yellow);
mapon.Blockchange(x1, y, z2, Block.yellow);
}
ChangeSquare(x1, y, z1, Block.yellow);
Thread.Sleep(speed);
{ //2
mapon.Blockchange(x1, y, z1, Block.orange);
mapon.Blockchange(x2, y, z1, Block.orange);
mapon.Blockchange(x2, y, z2, Block.orange);
mapon.Blockchange(x1, y, z2, Block.orange);
}
ChangeSquare(x1, y, z1, Block.orange);
Thread.Sleep(speed);
{ //1
mapon.Blockchange(x1, y, z1, Block.red);
mapon.Blockchange(x2, y, z1, Block.red);
mapon.Blockchange(x2, y, z2, Block.red);
mapon.Blockchange(x1, y, z2, Block.red);
}
ChangeSquare(x1, y, z1, Block.red);
Thread.Sleep(speed);
{ //poof
mapon.Blockchange(x1, y, z1, Block.air);
mapon.Blockchange(x2, y, z1, Block.air);
mapon.Blockchange(x2, y, z2, Block.air);
mapon.Blockchange(x1, y, z2, Block.air);
ChangeSquare(x1, y, z1, Block.air);
{ //beneath this is checking the glass next to the square
bool up = false;
bool left = false;
@ -380,7 +352,14 @@ namespace MCGalaxy
}
}
public static void PopulateSquaresLeft()
static void ChangeSquare(ushort x, ushort y, ushort z, byte block) {
mapon.Blockchange(x, y, z, block);
mapon.Blockchange((ushort)(x + 1), y, z, block);
mapon.Blockchange(x, y, (ushort)(z + 1), block);
mapon.Blockchange((ushort)(x + 1), y, (ushort)(z + 1), block);
}
static void PopulateSquaresLeft()
{
int column = 1;
int row = 1;
@ -396,7 +375,7 @@ namespace MCGalaxy
}
}
public static void AfterStart()
static void AfterStart()
{
{
{

View File

@ -74,5 +74,11 @@ namespace MCGalaxy {
public override void PlayerLeftServer(Player p) {
InfectedPlayerDC();
}
public override void PlayerJoinedServer(Player p) {
if (ZombieStatus() != 0)
Player.SendMessage(p, "There is a Zombie Survival game currently in-progress! " +
"Join it by typing /g " + Server.zombie.currentLevelName);
}
}
}

View File

@ -401,7 +401,8 @@
<Compile Include="Drawing\DrawOps\SpheroidDrawOp.cs" />
<Compile Include="Drawing\DrawOps\PyramidDrawOp.cs" />
<Compile Include="Games\IGame.cs" />
<Compile Include="Games\ZombieGame.Game.cs" />
<Compile Include="Games\ZombieSurvival\ZombieGame.cs" />
<Compile Include="Games\ZombieSurvival\ZombieGame.Game.cs" />
<Compile Include="Levels\IO\ConvertDAT.cs" />
<Compile Include="Levels\IO\LvlFile.cs" />
<Compile Include="Levels\IO\LvlProperties.cs" />
@ -554,7 +555,6 @@
</Compile>
<Compile Include="Player\VIP.cs" />
<Compile Include="Server\Extra\Warp.cs" />
<Compile Include="Games\ZombieGame.cs" />
<Compile Include="API\WebServer.cs" />
<Compile Include="API\WhoWas.cs" />
<Compile Include="util\SparseBitSet.cs" />
@ -697,6 +697,7 @@
<Folder Include="Commands\World" />
<Folder Include="Commands\Other" />
<Folder Include="Drawing\DrawOps" />
<Folder Include="Games\ZombieSurvival" />
<Folder Include="Levels\IO" />
<Folder Include="Levels\Physics" />
<Folder Include="Player\Group" />

View File

@ -900,39 +900,29 @@ namespace MCGalaxy {
Server.s.Log(name + " [" + ip + "] has joined the server.");
if (Server.zombie.ZombieStatus() != 0) { Player.SendMessage(this, "There is a Zombie Survival game currently in-progress! Join it by typing /g " + Server.zombie.currentLevelName); }
{
try
{
Server.zombie.PlayerJoinedServer(this);
try {
ushort x = (ushort)((0.5 + level.spawnx) * 32);
ushort y = (ushort)((1 + level.spawny) * 32);
ushort z = (ushort)((0.5 + level.spawnz) * 32);
pos = new ushort[3] { x, y, z }; rot = new byte[2] { level.rotx, level.roty };
GlobalSpawn(this, x, y, z, rot[0], rot[1], true);
foreach (Player p in players)
{
foreach (Player p in players) {
if (p.level == level && p != this && !p.hidden)
{
SendSpawn(p.id, p.color + p.name, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
}
if (HasCpeExt(CpeExt.ChangeModel))
{
SendChangeModel(p.id, p.model);
}
}
foreach (PlayerBot pB in PlayerBot.playerbots)
{
foreach (PlayerBot pB in PlayerBot.playerbots) {
if (pB.level == level)
SendSpawn(pB.id, pB.color + pB.name, pB.pos[0], pB.pos[1], pB.pos[2], pB.rot[0], pB.rot[1]);
}
}
catch (Exception e)
{
} catch (Exception e) {
Server.ErrorLog(e);
Server.s.Log("Error spawning player \"" + name + "\"");
}
}
Loading = false;
}