public void PutZertzBall(HexLocation hl, ZertzBallType type) //PZB { ZertzPiece piece = ZertzPiece.Vacant; piece.PutBall(type); this[hl] = piece; }
public Vector3 GetNextPosition(ZertzBallType zbt) { float dz = 3.0f * ZertzBallRenderer.RADIUS; float o = this.offset - 4.5f * ZertzBallRenderer.RADIUS; if (this.type == ZertzBallContainerType.Common) { switch (zbt) { case ZertzBallType.Black: return(new Vector3(row, ballHeight, o - black * dz)); case ZertzBallType.Gray: return(new Vector3(-row, ballHeight, o - gray * dz)); case ZertzBallType.White: return(new Vector3(-row, ballHeight, white * dz - o)); default: return(Vector3.Zero); } } else { int factor = 0x03 - 0x02 * (byte)this.type; return(new Vector3((offset - (balls.Count + 1.5f) * 3.0f * ZertzBallRenderer.RADIUS) * factor, ballHeight, factor * row)); } }
public void PutBall(ZertzBallContainerType containertype, ZertzBallType type, HexLocation location) { ZertzContainerRenderer zbcr = this.zcr[containertype]; ZertzBallRenderer zbr = zbcr.GetBallOfType(type); zbcr.Remove(zbr); this.boardR.PutBall(zbr, location); zbr.RenderMover = RenderMoveManager.GenerateHopMover(zbr.Location, Maths.HexVector(location, 2.0f * ZertzRingRenderer.OUTER_RADIUS + ZertzRingRenderer.SPACING, 0.5f * ZertzRingRenderer.THICKNESS), 1.5f, null); }
private void perform_PutBall(ZertzBallContainerType containertype, ZertzBallType type, HexLocation location) { lock (this.handlers) { foreach (IZertzActionHandler izah in this.handlers) { izah.PutBall(containertype, type, location); } } }
public ZertzBallType DropBall() { if (!this.CanDropBall()) { throw new InvalidZertzActionException("Can't drop the ball of a piece containing none."); } ZertzBallType t = (ZertzBallType)((this.state & 0xe) >> 0x02); this.state &= 0xf1; return(t); }
public byte this [ZertzBallType ballType] { get { int sh = ((byte)ballType) << 0x03; return((byte)((counters >> sh) & 0xff)); } set { int sh = ((byte)ballType) << 0x03; this.counters &= ~(0xff << sh); this.counters |= value << sh; } }
public ZertzBallRenderer GetBallOfType(ZertzBallType type) { lock(this.balls) { for(int i = this.balls.Count-0x01; i >= 0x00; i--) { if(this.balls[i].Type == type) { return this.balls[i]; } } } return null; }
public void PutBall(ZertzBallType ballType) { if (!this.CanPutBall()) { throw new InvalidZertzActionException("Unable to put a ball on a piece already containing a ball"); } else { this.state |= (byte)(0x02 << (byte)ballType); } }
public byte this[ZertzBallType ballType] { get { int sh = ((byte) ballType)<<0x03; return (byte) ((counters>>sh)&0xff); } set { int sh = ((byte) ballType)<<0x03; this.counters &= ~(0xff<<sh); this.counters |= value<<sh; } }
public ZertzBallRenderer GetBallOfType(ZertzBallType type) { lock (this.balls) { for (int i = this.balls.Count - 0x01; i >= 0x00; i--) { if (this.balls[i].Type == type) { return(this.balls[i]); } } } return(null); }
public override void Execute(ZertzGame game) { if (this.locationCache == null && !this.CanBeExecuted(game)) { throw new InvalidZertzException("Can't execute invalid move."); } else { ZertzBoard zb = game.Board; zb[this.locationCache[this.hops.Length]].PutBall(zb[offset].DropBall()); for (int i = 0x00; i < hops.Length; i++) { ZertzBallType zbt = game.Board[this.locationCache[i++]].DropBall(); //TODO: collect } } }
public ZertzBallType DoHopMove(HexLocation zl, HexDirection dir) { HexLocation hldir = HexLocation.NeighbourDirections[(byte)dir]; HexLocation zla = zl, zlb = zla + hldir, zlc = zlb + hldir; //if(this[zla].CanDropBall() && this[zlb].CanDropBall() && this[zlc].CanPutBall()) { ZertzPiece zpa = this[zla]; ZertzPiece zpb = this[zlb]; ZertzPiece zpc = this[zlc]; zpc.PutBall(zpa.DropBall()); ZertzBallType t = zpb.DropBall(); this[zla] = zpa; this[zlb] = zpb; this[zlc] = zpc; return(t); //} //throw new InvalidZertzActionException(String.Format("Can't perform this hop operation: [{0}:{1}]",zl,dir)); }
public Vector3 GetNextPosition(ZertzBallType zbt) { float dz = 3.0f*ZertzBallRenderer.RADIUS; float o = this.offset-4.5f*ZertzBallRenderer.RADIUS; if(this.type == ZertzBallContainerType.Common) { switch(zbt) { case ZertzBallType.Black : return new Vector3(row,ballHeight,o-black*dz); case ZertzBallType.Gray : return new Vector3(-row,ballHeight,o-gray*dz); case ZertzBallType.White : return new Vector3(-row,ballHeight,white*dz-o); default : return Vector3.Zero; } } else { int factor = 0x03-0x02*(byte) this.type; return new Vector3((offset-(balls.Count+1.5f)*3.0f*ZertzBallRenderer.RADIUS)*factor,ballHeight,factor*row); } }
public override ZertzMoveState TakeBall(ZertzBallType ball) { //GUARD if (this.Board.CanHop()) { throw new InvalidZertzActionException("Unable to do this action: capture move possible!"); } if (!this.Game.PlayerPoolsContains(ball)) { throw new InvalidZertzActionException("Unable to do this action: player doesn't have this type of ball available!"); } if (!this.Board.HasVacant()) { throw new InvalidZertzActionException("Unable to do this action: no vacant piece available!"); } ZertzBallContainerType source = this.Game.SourceType; //ACTIONS this.Game.DecreasePlayerPool(ball); //EVENTS this.Creator.perform_ChangeState(0x01); //NEXT_STATE return(new PlacRem1ZertzMoveState(this.Creator, ball, source)); }
public PutBallRemovePieceZertzMove(HexLocation put, ZertzBallType ball, HexLocation rem) { }
public void PutBall(ZertzBallType ballType) { if(!this.CanPutBall()) { throw new InvalidZertzActionException("Unable to put a ball on a piece already containing a ball"); } else { this.state |= (byte) (0x02<<(byte) ballType); } }
public override ZertzMoveState TakeBall(ZertzBallType ball) { //GUARD if(this.Board.CanHop()) { throw new InvalidZertzActionException("Unable to do this action: capture move possible!"); } if(!this.Game.PlayerPoolsContains(ball)) { throw new InvalidZertzActionException("Unable to do this action: player doesn't have this type of ball available!"); } if(!this.Board.HasVacant()) { throw new InvalidZertzActionException("Unable to do this action: no vacant piece available!"); } ZertzBallContainerType source = this.Game.SourceType; //ACTIONS this.Game.DecreasePlayerPool(ball); //EVENTS this.Creator.perform_ChangeState(0x01); //NEXT_STATE return new PlacRem1ZertzMoveState(this.Creator,ball,source); }
public virtual ZertzMoveState TakeBall(ZertzBallType ball) { //TB return NotPossible(); }
public void TakeBall(ZertzBallType ball) { this.zmc.TakeBall(ball); }
private void perform_PutBall(ZertzBallContainerType containertype, ZertzBallType type, HexLocation location) { lock(this.handlers) { foreach(IZertzActionHandler izah in this.handlers) { izah.PutBall(containertype,type,location); } } }
public PlacRem1ZertzMoveState(ZertzMoveCreator creator, ZertzBallType ball, ZertzBallContainerType source) : base(creator) { this.ball = ball; this.source = source; }
public void DecreasePlayerPool(ZertzBallType type) //DPP { this.getCurrentPlayerSourcePool()[type]--; }
public virtual ZertzMoveState TakeBall(ZertzBallType ball) //TB { return(NotPossible()); }
public void PutBall(ZertzBallContainerType containertype, ZertzBallType type, HexLocation location) { ZertzContainerRenderer zbcr = this.zcr[containertype]; ZertzBallRenderer zbr = zbcr.GetBallOfType(type); zbcr.Remove(zbr); this.boardR.PutBall(zbr,location); zbr.RenderMover = RenderMoveManager.GenerateHopMover(zbr.Location,Maths.HexVector(location,2.0f*ZertzRingRenderer.OUTER_RADIUS+ZertzRingRenderer.SPACING,0.5f*ZertzRingRenderer.THICKNESS),1.5f,null); }
public void Add(ZertzBallType ball, byte number) { this.counters += number << (((byte)ball) << 0x03); }
public ZertzBallRenderer(ZertzBallType type) { register(); this.type = type; this.colorv = colorVectors[(byte)type]; }
public void Add(ZertzBallType ball) { this.counters += 0x01 << (((byte)ball) << 0x03); }
public void TakeBall(ZertzBallType ball) { this.setState(state.TakeBall(ball)); }
public bool PlayerPoolsContains(ZertzBallType type) //BHP { return(this.getCurrentPlayerSourcePool()[type] > 0x00); }
public bool PlayerPoolsContains(ZertzBallType type) { //BHP return (this.getCurrentPlayerSourcePool()[type] > 0x00); }
public void PutToPool(ZertzBallType type) //PTP { this.getCurrentPlayerDestinationPool().Add(type); }
public void PutToPool(ZertzBallType type) { //PTP this.getCurrentPlayerDestinationPool().Add(type); }
public void Add(ZertzBallType ball) { this.counters += 0x01<<(((byte) ball)<<0x03); }
public void Add(ZertzBallType ball, byte number) { this.counters += number<<(((byte) ball)<<0x03); }
public void DecreasePlayerPool(ZertzBallType type) { //DPP this.getCurrentPlayerSourcePool()[type]--; }
public void PutZertzBall(HexLocation hl, ZertzBallType type) { //PZB ZertzPiece piece = ZertzPiece.Vacant; piece.PutBall(type); this[hl] = piece; }
public ZertzBallRenderer(ZertzBallType type) { register(); this.type = type; this.colorv = colorVectors[(byte) type]; }