|
using System;
namespace gma.Mobile.Mines
{
public delegate void OnMovePassedEvent(Player aCurrentPalyer);
/// <summary>
/// Zusammenfassung f�r MultiPlayerGame.
/// </summary>
public class MultiPlayerGame: GameBase
{
public MultiPlayerGame(byte aWidth, byte aHeight, byte aBombCount): base(aWidth, aHeight, aBombCount)
{
_flagsToWin=(int)Math.Floor(_field.BombCount / 2 );
}
private int _flagsToWin=0;
public int FlagsToWin
{
get {return _flagsToWin;}
}
public override void ClickCell(byte x, byte y)
{
if (_field.CellStates[x,y]!=CellState.Closed) return;
if (_field.Bombs[x,y]==Field.ISBOMB) SetFlagIntern( x, y);
else
{
base.ClickCell(x,y);
PassMove();
}
}
public override void SetFlag(byte x, byte y)
{
ClickCell(x,y);
}
private void SetFlagIntern(byte x, byte y)
{
if (_field.CellStates[x,y]==CellState.FlagBlue || _field.CellStates[x,y]==CellState.FlagRed) return;
if (_field.CellStates[x,y]==CellState.Open) return;
CellState BeforeState = _field.CellStates[x,y];
_field.CellStates[x,y]=GetFlagColorOfCurrentPlayer();
// inform others that this cell was modified.
CellChanged(x,y, BeforeState, _field.CellStates[x,y]);
if (FlagCountRed > _flagsToWin) GameOver(Player.Red);
if (FlagCountBlue > _flagsToWin) GameOver(Player.Blue);
}
public event OnMovePassedEvent OnMovePassed;
public void PassMove()
{
switch (CurrentPlayer)
{
case Player.Blue:
CurrentPlayer=Player.Red;
break;
case Player.Red:
CurrentPlayer=Player.Blue;
break;
}
if (OnMovePassed!=null) OnMovePassed(CurrentPlayer);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.