Esempio n. 1
0
        public void PutZertzBall(HexLocation hl, ZertzBallType type)           //PZB
        {
            ZertzPiece piece = ZertzPiece.Vacant;

            piece.PutBall(type);
            this[hl] = piece;
        }
Esempio n. 2
0
        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));
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 private void perform_PutBall(ZertzBallContainerType containertype, ZertzBallType type, HexLocation location)
 {
     lock (this.handlers) {
         foreach (IZertzActionHandler izah in this.handlers)
         {
             izah.PutBall(containertype, type, location);
         }
     }
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 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);
     }
 }
Esempio n. 9
0
 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;
     }
 }
Esempio n. 10
0
 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);
 }
Esempio n. 11
0
 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
         }
     }
 }
Esempio n. 12
0
        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));
        }
Esempio n. 13
0
 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);
     }
 }
Esempio n. 14
0
            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)
 {
 }
Esempio n. 16
0
 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);
     }
 }
Esempio n. 17
0
 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);
 }
Esempio n. 18
0
 public virtual ZertzMoveState TakeBall(ZertzBallType ball)
 {
     //TB
     return NotPossible();
 }
Esempio n. 19
0
 public void TakeBall(ZertzBallType ball)
 {
     this.zmc.TakeBall(ball);
 }
Esempio n. 20
0
 private void perform_PutBall(ZertzBallContainerType containertype, ZertzBallType type, HexLocation location)
 {
     lock(this.handlers) {
         foreach(IZertzActionHandler izah in this.handlers) {
             izah.PutBall(containertype,type,location);
         }
     }
 }
Esempio n. 21
0
 public PlacRem1ZertzMoveState(ZertzMoveCreator creator, ZertzBallType ball, ZertzBallContainerType source) : base(creator)
 {
     this.ball   = ball;
     this.source = source;
 }
Esempio n. 22
0
 public void DecreasePlayerPool(ZertzBallType type)           //DPP
 {
     this.getCurrentPlayerSourcePool()[type]--;
 }
Esempio n. 23
0
 public virtual ZertzMoveState TakeBall(ZertzBallType ball)               //TB
 {
     return(NotPossible());
 }
Esempio n. 24
0
 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);
 }
Esempio n. 25
0
 public void Add(ZertzBallType ball, byte number)
 {
     this.counters += number << (((byte)ball) << 0x03);
 }
Esempio n. 26
0
 public ZertzBallRenderer(ZertzBallType type)
 {
     register();
     this.type   = type;
     this.colorv = colorVectors[(byte)type];
 }
Esempio n. 27
0
 public void Add(ZertzBallType ball)
 {
     this.counters += 0x01 << (((byte)ball) << 0x03);
 }
Esempio n. 28
0
 public void TakeBall(ZertzBallType ball)
 {
     this.zmc.TakeBall(ball);
 }
Esempio n. 29
0
 public void TakeBall(ZertzBallType ball)
 {
     this.setState(state.TakeBall(ball));
 }
Esempio n. 30
0
 public bool PlayerPoolsContains(ZertzBallType type)           //BHP
 {
     return(this.getCurrentPlayerSourcePool()[type] > 0x00);
 }
Esempio n. 31
0
 public bool PlayerPoolsContains(ZertzBallType type)
 {
     //BHP
     return (this.getCurrentPlayerSourcePool()[type] > 0x00);
 }
Esempio n. 32
0
 public void PutToPool(ZertzBallType type)           //PTP
 {
     this.getCurrentPlayerDestinationPool().Add(type);
 }
Esempio n. 33
0
 public PutBallRemovePieceZertzMove(HexLocation put, ZertzBallType ball, HexLocation rem)
 {
 }
Esempio n. 34
0
 public void PutToPool(ZertzBallType type)
 {
     //PTP
     this.getCurrentPlayerDestinationPool().Add(type);
 }
Esempio n. 35
0
 public void Add(ZertzBallType ball)
 {
     this.counters += 0x01<<(((byte) ball)<<0x03);
 }
Esempio n. 36
0
 public PlacRem1ZertzMoveState(ZertzMoveCreator creator, ZertzBallType ball, ZertzBallContainerType source)
     : base(creator)
 {
     this.ball = ball;
     this.source = source;
 }
Esempio n. 37
0
 public void Add(ZertzBallType ball, byte number)
 {
     this.counters += number<<(((byte) ball)<<0x03);
 }
Esempio n. 38
0
 public void TakeBall(ZertzBallType ball)
 {
     this.setState(state.TakeBall(ball));
 }
Esempio n. 39
0
 public void DecreasePlayerPool(ZertzBallType type)
 {
     //DPP
     this.getCurrentPlayerSourcePool()[type]--;
 }
Esempio n. 40
0
 public void PutZertzBall(HexLocation hl, ZertzBallType type)
 {
     //PZB
     ZertzPiece piece = ZertzPiece.Vacant;
     piece.PutBall(type);
     this[hl] = piece;
 }
Esempio n. 41
0
 public ZertzBallRenderer(ZertzBallType type)
 {
     register();
     this.type = type;
     this.colorv = colorVectors[(byte) type];
 }