mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 14:54:12 -04:00
Move zombie game block handing into IGame.HandlesManualChange implementation.
This commit is contained in:
parent
21d527e741
commit
644c1552f7
@ -17,10 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MCGalaxy.Games {
|
namespace MCGalaxy {
|
||||||
|
|
||||||
public abstract class IGame {
|
public abstract class IGame {
|
||||||
|
|
||||||
|
public virtual bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
||||||
}
|
byte action, byte tile, byte b) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
56
Games/ZombieGame.Game.cs
Normal file
56
Games/ZombieGame.Game.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/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;
|
||||||
|
|
||||||
|
namespace MCGalaxy {
|
||||||
|
|
||||||
|
public sealed partial class ZombieGame : IGame {
|
||||||
|
|
||||||
|
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
||||||
|
byte action, byte tile, byte b) {
|
||||||
|
if (action == 1 && Server.noPillaring && !p.referee) {
|
||||||
|
if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) {
|
||||||
|
p.blocksStacked++;
|
||||||
|
} else {
|
||||||
|
p.blocksStacked = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.blocksStacked == 2 ) {
|
||||||
|
p.SendMessage("You are pillaring! Stop before you get kicked!");
|
||||||
|
}
|
||||||
|
if (p.blocksStacked == 4 ) {
|
||||||
|
Command.all.Find("kick").Use(null, p.name + " No pillaring allowed!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.lastXblock = x; p.lastYblock = y; p.lastZblock = z;
|
||||||
|
|
||||||
|
if (action == 1 || (action == 0 && p.painting)) {
|
||||||
|
if (p.level.name != Server.zombie.currentLevelName || p.referee) return false;
|
||||||
|
|
||||||
|
if (p.blockCount == 0 ) {
|
||||||
|
p.SendMessage("You have no blocks left.");
|
||||||
|
p.RevertBlock(x, y, z); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.blockCount--;
|
||||||
|
if ((p.blockCount % 10) == 0 || (p.blockCount >= 0 && p.blockCount <= 10)) {
|
||||||
|
p.SendMessage("Blocks Left: " + c.maroon + p.blockCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,7 @@ using System.Timers;
|
|||||||
|
|
||||||
namespace MCGalaxy
|
namespace MCGalaxy
|
||||||
{
|
{
|
||||||
public sealed class ZombieGame
|
public sealed partial class ZombieGame
|
||||||
{
|
{
|
||||||
public int amountOfRounds = 0;
|
public int amountOfRounds = 0;
|
||||||
public int limitRounds = 0;
|
public int limitRounds = 0;
|
||||||
|
@ -401,6 +401,7 @@
|
|||||||
<Compile Include="Drawing\DrawOps\SpheroidDrawOp.cs" />
|
<Compile Include="Drawing\DrawOps\SpheroidDrawOp.cs" />
|
||||||
<Compile Include="Drawing\DrawOps\PyramidDrawOp.cs" />
|
<Compile Include="Drawing\DrawOps\PyramidDrawOp.cs" />
|
||||||
<Compile Include="Games\IGame.cs" />
|
<Compile Include="Games\IGame.cs" />
|
||||||
|
<Compile Include="Games\ZombieGame.Game.cs" />
|
||||||
<Compile Include="Levels\IO\ConvertDAT.cs" />
|
<Compile Include="Levels\IO\ConvertDAT.cs" />
|
||||||
<Compile Include="Levels\IO\LvlFile.cs" />
|
<Compile Include="Levels\IO\LvlFile.cs" />
|
||||||
<Compile Include="Levels\IO\LvlProperties.cs" />
|
<Compile Include="Levels\IO\LvlProperties.cs" />
|
||||||
|
@ -1072,23 +1072,6 @@ namespace MCGalaxy {
|
|||||||
extType = type;
|
extType = type;
|
||||||
type = Block.custom_block;
|
type = Block.custom_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( action == 1 && Server.ZombieModeOn && Server.noPillaring ) {
|
|
||||||
if ( !referee ) {
|
|
||||||
if ( lastYblock == y - 1 && lastXblock == x && lastZblock == z ) {
|
|
||||||
blocksStacked++;
|
|
||||||
} else {
|
|
||||||
blocksStacked = 0;
|
|
||||||
}
|
|
||||||
if ( blocksStacked == 2 ) {
|
|
||||||
SendMessage("You are pillaring! Stop before you get kicked!");
|
|
||||||
}
|
|
||||||
if ( blocksStacked == 4 ) {
|
|
||||||
Command.all.Find("kick").Use(null, name + " No pillaring allowed!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastXblock = x; lastYblock = y; lastZblock = z;
|
|
||||||
ManualChange(x, y, z, action, type, extType);
|
ManualChange(x, y, z, action, type, extType);
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
// Don't ya just love it when the server tattles?
|
// Don't ya just love it when the server tattles?
|
||||||
@ -1120,23 +1103,8 @@ namespace MCGalaxy {
|
|||||||
RevertBlock(x, y, z); return;
|
RevertBlock(x, y, z); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Server.ZombieModeOn && ( action == 1 || ( action == 0 && this.painting ) ) ) {
|
if (Server.ZombieModeOn && Server.zombie != null
|
||||||
if ( Server.zombie != null && this.level.name == Server.zombie.currentLevelName ) {
|
&& Server.zombie.HandlesManualChange(this, x, y, z, action, type, b)) return;
|
||||||
if ( blockCount == 0 ) {
|
|
||||||
if ( !referee ) {
|
|
||||||
SendMessage("You have no blocks left.");
|
|
||||||
RevertBlock(x, y, z); return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !referee ) {
|
|
||||||
blockCount--;
|
|
||||||
if ( blockCount == 40 || blockCount == 30 || blockCount == 20 || blockCount <= 10 && blockCount >= 0 ) {
|
|
||||||
SendMessage("Blocks Left: " + c.maroon + blockCount + Server.DefaultColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( Server.lava.active && Server.lava.HasPlayer(this) && Server.lava.IsPlayerDead(this) ) {
|
if ( Server.lava.active && Server.lava.HasPlayer(this) && Server.lava.IsPlayerDead(this) ) {
|
||||||
SendMessage("You are out of the round, and cannot build.");
|
SendMessage("You are out of the round, and cannot build.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user