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

@ -1,20 +1,20 @@
/*
Copyright 2011 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.
*/
Copyright 2011 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;
using System.Linq;
@ -64,44 +64,34 @@ 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);
mapon.Blockchange(16, 18, 14, Block.glass);
mapon.Blockchange(15, 17, 14, Block.glass);
mapon.Blockchange(16, 17, 14, Block.glass);
{
mapon.Blockchange(15, 18, 14, Block.glass);
mapon.Blockchange(16, 18, 14, Block.glass);
mapon.Blockchange(15, 17, 14, Block.glass);
mapon.Blockchange(16, 17, 14, Block.glass);
}
{
mapon.Blockchange(14, 17, 15, Block.glass);
mapon.Blockchange(14, 18, 16, Block.glass);
mapon.Blockchange(14, 17, 16, Block.glass);
mapon.Blockchange(14, 18, 15, Block.glass);
}
{
mapon.Blockchange(15, 17, 17, Block.glass);
mapon.Blockchange(16, 18, 17, Block.glass);
mapon.Blockchange(15, 18, 17, Block.glass);
mapon.Blockchange(16, 17, 17, Block.glass);
}
{
mapon.Blockchange(17, 17, 16, Block.glass);
mapon.Blockchange(17, 18, 15, Block.glass);
mapon.Blockchange(17, 18, 16, Block.glass);
mapon.Blockchange(17, 17, 15, Block.glass);
}
}
{
mapon.Blockchange(14, 17, 15, Block.glass);
mapon.Blockchange(14, 18, 16, Block.glass);
mapon.Blockchange(14, 17, 16, Block.glass);
mapon.Blockchange(14, 18, 15, Block.glass);
}
{
mapon.Blockchange(15, 17, 17, Block.glass);
mapon.Blockchange(16, 18, 17, Block.glass);
mapon.Blockchange(15, 18, 17, Block.glass);
mapon.Blockchange(16, 17, 17, Block.glass);
}
{
mapon.Blockchange(17, 17, 16, Block.glass);
mapon.Blockchange(17, 18, 15, Block.glass);
mapon.Blockchange(17, 18, 16, Block.glass);
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;
@ -289,43 +279,25 @@ 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()
{
{
{
@ -475,7 +454,7 @@ namespace MCGalaxy
playersleftlist.Remove(p);
switch (playersleft)
{
case 1:
case 1:
mapon.ChatLevel(playersleftlist.Last().color + playersleftlist.Last().name + Server.DefaultColor + " is the winner!!");
End(playersleftlist.Last());
break;

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,38 +900,28 @@ 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
{
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 };
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)
{
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)
{
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]);
}
GlobalSpawn(this, x, y, z, rot[0], rot[1], true);
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);
}
catch (Exception e)
{
Server.ErrorLog(e);
Server.s.Log("Error spawning player \"" + name + "\"");
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) {
Server.ErrorLog(e);
Server.s.Log("Error spawning player \"" + name + "\"");
}
Loading = false;
}