示例#1
0
 public ZertzRingRenderer RemoveRing(HexLocation loc)
 {
     ZertzRingRenderer zrr = rings[loc.X,loc.Y];
     ringlocs.Remove(zrr);
     rings[loc.X,loc.Y] = null;
     return zrr;
 }
示例#2
0
 public ZertzBallRenderer RemoveBall(HexLocation loc)
 {
     ZertzBallRenderer zbr = balls[loc.X,loc.Y];
     balllocs.Remove(zbr);
     balls[loc.X,loc.Y] = null;
     return zbr;
 }
示例#3
0
 private void perform_CaptureBall(HexLocation loc, ZertzBallContainerType zbct)
 {
     lock(this.handlers) {
         foreach(IZertzActionHandler izah in this.handlers) {
             izah.CaptureBall(loc,zbct);
         }
     }
 }
示例#4
0
 public ZertzGame(out HexLocation[] hls)
 {
     //this.players = new IPlayer[] {playerA,playerB};
     this.board = ZertzBoard.OffsetBoard(out hls);
     this.playersPools = new ZertzBallContainer[] {ZertzBallContainer.Empty(),ZertzBallContainer.Empty()};
     this.turn = 0x00;
     this.zmc = new ZertzMoveCreator(this);
 }
示例#5
0
 public ZertzRingRenderer(ZertzGame game, HexLocation hexLocation, Vector3 tileVector, Vector3 tileEscape, float time)
 {
     register();
     this.tt = new Vector3((float) UniversalRandom.NextDouble(),(float) UniversalRandom.NextDouble(),0.0f);
     this.hexLocation = hexLocation;
     this.boardLocation = Maths.HexVector(hexLocation,2.0f*OUTER_RADIUS+SPACING,0.5f*THICKNESS);
     this.tileVector = tileVector;
     this.RenderMover = RenderMoveManager.GenerateWaitMover(time,this.tileVector,RenderMoveManager.GenerateMoveMover(this.tileVector,tileEscape,2.0f,RenderMoveManager.GenerateHopMover(tileEscape,this.boardLocation,1.5f,null)));
     //this.RenderMover = RenderMoveManager.GenerateStaticMover(this.tileVector);
 }
示例#6
0
 public void TestConstructor()
 {
     HexLocation zl;
     for(sbyte x = sbyte.MinValue; x < sbyte.MaxValue; x++) {
         for(sbyte y = sbyte.MinValue; y < sbyte.MaxValue; y++) {
             zl = new HexLocation(x,y);
             Assert.AreEqual(x,zl.X);
             Assert.AreEqual(y,zl.Y);
         }
     }
 }
示例#7
0
 public void TestShiftOperator()
 {
     for(int i = 0x00; i < 0x08; i++) {
         sbyte bm = (sbyte) (sbyte.MinValue>>i);
         sbyte bM = (sbyte) (sbyte.MaxValue>>i);
         for(sbyte b = bm; b < bM; b++) {
             for(sbyte c = bm; c < bM; c++) {
                 HexLocation hl = new HexLocation(b,c)<<i;
                 Assert.AreEqual(b<<i,hl.X);
                 Assert.AreEqual(c<<i,hl.Y);
             }
         }
     }
 }
示例#8
0
 public override ZertzMoveState CaptureLand(HexLocation location)
 {
     //GUARDS
     if (!this.Board.CanCapture(location))
     {
         throw new InvalidZertzActionException("Unable to do this action: This land cannot be captured!");
     }
     //ACTIONS
     this.Game.PutToPool(this.Board.CaptureLandPieces(location));
     //EVENTS
     this.Creator.perform_ChangeState(0x05);
     //NEXT_STATE
     return(new CaptureLandZertzMoveState(this.Creator));
 }
 public override BehaviourResult Clicked(RayMeshGeometry3DHitTestResult rayMeshResult, BoardVisual board)
 {
     HexVisual hexVisual = rayMeshResult.VisualHit as HexVisual;
     if (hexVisual != null)
     {
         ResourceHex resourceHex = hexVisual.Hex as ResourceHex;
         if (resourceHex != null)
         {
             _Location = resourceHex.Location;
             return BehaviourResult.Success;
         }
     }
     return BehaviourResult.NoSuccess;
 }
示例#10
0
        public void TestConstructor()
        {
            HexLocation zl;

            for (sbyte x = sbyte.MinValue; x < sbyte.MaxValue; x++)
            {
                for (sbyte y = sbyte.MinValue; y < sbyte.MaxValue; y++)
                {
                    zl = new HexLocation(x, y);
                    Assert.AreEqual(x, zl.X);
                    Assert.AreEqual(y, zl.Y);
                }
            }
        }
示例#11
0
 public override ZertzMoveState SelectPiece(HexLocation location)
 {
     //GUARDS
     if (!this.Board.IsFree(location))
     {
         throw new InvalidZertzActionException("Unable to do this action: This piece can't be removed!");
     }
     //ACTIONS
     this.Board.RemoveZertzPiece(location);
     //EVENT
     this.Creator.perform_RemovePiece(location);
     this.Creator.perform_ChangeState(0x05);
     //NEXT_STATE
     return(new CaptureLandZertzMoveState(this.Creator));
 }
示例#12
0
 public override ZertzMoveState SelectPiece(HexLocation location)
 {
     //GUARDS
     if (!this.Board.IsVacant(location))
     {
         throw new InvalidZertzActionException("Unable to do this action: ball must be put on a vacant piece!");
     }
     //ACTIONS
     this.Board.PutZertzBall(location, this.Ball);
     //EVENT
     this.Creator.perform_PutBall(this.source, this.ball, location);
     this.Creator.perform_ChangeState(0x03);
     //NEXT_STATE
     return(new PlacRem2ZertzMoveState(this.Creator));
 }
示例#13
0
 public void TestShiftOperator()
 {
     for (int i = 0x00; i < 0x08; i++)
     {
         sbyte bm = (sbyte)(sbyte.MinValue >> i);
         sbyte bM = (sbyte)(sbyte.MaxValue >> i);
         for (sbyte b = bm; b < bM; b++)
         {
             for (sbyte c = bm; c < bM; c++)
             {
                 HexLocation hl = new HexLocation(b, c) << i;
                 Assert.AreEqual(b << i, hl.X);
                 Assert.AreEqual(c << i, hl.Y);
             }
         }
     }
 }
示例#14
0
        private HexLocation[] generateAllLocations()
        {
            HexLocation[] hls = new HexLocation[0x25];
            int           k = 0x00;
            sbyte         j, o1, o2;

            for (sbyte i = 0x00; i <= 0x06; i++)
            {
                o1 = (sbyte)Math.Max(0x00, 0x03 - i);
                o2 = (sbyte)Math.Min(0x06, 0x09 - i);
                for (j = o1; j <= o2; j++)
                {
                    hls[k++] = new HexLocation(i, j);
                }
            }
            return(hls);
        }
示例#15
0
        private void innerTestIsVacant(ZertzBoard board, HexLocation[] vacant)
        {
            HashSet <HexLocation> hls = new HashSet <HexLocation>();

            foreach (HexLocation l in vacant)
            {
                hls.Add(l);
            }
            HexLocation hl;

            for (sbyte i = 0x00; i < 0x07; i++)
            {
                for (sbyte j = 0x00; j < 0x07; j++)
                {
                    hl = new HexLocation(i, j);
                    Assert.AreEqual(hls.Contains(hl), board.IsVacant(hl));
                }
            }
        }
示例#16
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));
        }
示例#17
0
        public bool IsFree(HexLocation hl)           //IF
        {
            ZertzPiece zp = this[hl];

            if (zp.IsAlive && !zp.ContainsBall)
            {
                HexLocation zla, zlb;
                zlb = HexLocation.NeighbourDirections[0x05] + hl;
                for (int i = 0x00; i < 0x06; i++)
                {
                    zla = zlb;
                    zlb = HexLocation.NeighbourDirections[i];
                    if (!this[zla].IsAlive && !this[hl + zlb].IsAlive && !this[zla + zlb].IsAlive)
                    {
                        return(true);
                    }
                    zlb += hl;
                }
            }
            return(false);
        }
示例#18
0
 public ZertzPiece this [HexLocation zl] {
     get {
         if (zl.X < 0x00 || zl.Y < 0x00 || zl.X >= this.pieces.GetLength(0x00) || zl.Y >= this.pieces.GetLength(0x01))
         {
             return(ZertzPiece.Dead);
         }
         else
         {
             return(this.pieces[zl.X, zl.Y]);
         }
     }
     internal set {
         if (zl.X < 0x00 || zl.Y < 0x00 || zl.X >= this.pieces.GetLength(0x00) || zl.Y >= this.pieces.GetLength(0x01))
         {
             throw new InvalidZertzActionException("Unable to set a piece out of range!");
         }
         else
         {
             this.pieces[zl.X, zl.Y] = value;
         }
     }
 }
示例#19
0
        public bool CanHop(HexLocation zl, HexDirection dir)           //CH3
        {
            HexLocation zla   = zl;
            ZertzPiece  zp    = this[zla];
            HexLocation hldir = HexLocation.NeighbourDirections[(byte)dir];

            if (zp.IsAlive && zp.ContainsBall)
            {
                zla += hldir;
                zp   = this[zla];
                if (zp.IsAlive && zp.ContainsBall)
                {
                    zla += hldir;
                    zp   = this[zla];
                    if (zp.IsAlive && !zp.ContainsBall)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#20
0
        public void TestOperators()
        {
            HexLocation hla = new HexLocation(0, 0);
            HexLocation hlb = new HexLocation(1, 0);
            HexLocation hlc = new HexLocation(-1, 0);
            HexLocation hld = new HexLocation(0, 1);
            HexLocation hle = new HexLocation(0, -1);
            HexLocation hlf = new HexLocation(1, -1);
            HexLocation hlg = new HexLocation(-1, 1);
            HexLocation hlh = new HexLocation(2, 0);
            HexLocation hli = new HexLocation(2, 1);
            HexLocation hlj = new HexLocation(2, 2);
            HexLocation hlk = new HexLocation(1, 3);
            HexLocation hll = new HexLocation(0, 4);
            HexLocation hlm = new HexLocation(-4, 4);

            Assert.AreEqual(hlb, hlb - hla);
            Assert.AreEqual(hlc, hlc - hla);
            Assert.AreEqual(hld, hld - hla);
            Assert.AreEqual(hle, hle - hla);
            Assert.AreEqual(hlf, hlf - hla);
            Assert.AreEqual(hlg, hlg - hla);
            Assert.AreEqual(hlh, hlh - hla);
            Assert.AreEqual(hlb, hlb + hla);
            Assert.AreEqual(hlc, hlc + hla);
            Assert.AreEqual(hld, hld + hla);
            Assert.AreEqual(hle, hle + hla);
            Assert.AreEqual(hlf, hlf + hla);
            Assert.AreEqual(hlg, hlg + hla);
            Assert.AreEqual(hlh, hlh + hla);
            Assert.AreEqual(hlb, !hlh);
            Assert.AreEqual(HexLocation.Invalid, !hli);
            Assert.AreEqual(HexLocation.Invalid, !hlj);
            Assert.AreEqual(HexLocation.Invalid, !hlk);
            Assert.AreEqual(hld, !hll);
            Assert.AreEqual(hlg, !hlm);
        }
示例#21
0
            public override ZertzMoveState SelectPiece(HexLocation location)
            {
                HexLocation dir = !(location - this.HopLocation);

                //GUARDS
                if (dir == HexLocation.Invalid)
                {
                    throw new InvalidZertzActionException("Unable to perform this action: No direction specified!");
                }
                else if (!this.Board.CanHop(this.HopLocation, dir.HexDirection))
                {
                    throw new InvalidZertzActionException("Unable to perform this action: Can't hop in the given direction!");
                }
                //ACTIONS
                this.Game.PutToPool(this.Board.DoHopMove(this.HopLocation, dir.HexDirection));
                //EVENTS
                this.Creator.perform_ChangeState(0x04);
                this.Creator.perform_PerformHop(hopLocation, location);
                //TODO: insert capture action
                //NEXT_STATE
                HexLocation newl = this.HopLocation + (dir << 0x01);

                return(new Capture2ZertzMoveState(this.Creator, newl));
            }
示例#22
0
 public void TestOperators()
 {
     HexLocation hla = new HexLocation(0,0);
     HexLocation hlb = new HexLocation(1,0);
     HexLocation hlc = new HexLocation(-1,0);
     HexLocation hld = new HexLocation(0,1);
     HexLocation hle = new HexLocation(0,-1);
     HexLocation hlf = new HexLocation(1,-1);
     HexLocation hlg = new HexLocation(-1,1);
     HexLocation hlh = new HexLocation(2,0);
     HexLocation hli = new HexLocation(2,1);
     HexLocation hlj = new HexLocation(2,2);
     HexLocation hlk = new HexLocation(1,3);
     HexLocation hll = new HexLocation(0,4);
     HexLocation hlm = new HexLocation(-4,4);
     Assert.AreEqual(hlb,hlb-hla);
     Assert.AreEqual(hlc,hlc-hla);
     Assert.AreEqual(hld,hld-hla);
     Assert.AreEqual(hle,hle-hla);
     Assert.AreEqual(hlf,hlf-hla);
     Assert.AreEqual(hlg,hlg-hla);
     Assert.AreEqual(hlh,hlh-hla);
     Assert.AreEqual(hlb,hlb+hla);
     Assert.AreEqual(hlc,hlc+hla);
     Assert.AreEqual(hld,hld+hla);
     Assert.AreEqual(hle,hle+hla);
     Assert.AreEqual(hlf,hlf+hla);
     Assert.AreEqual(hlg,hlg+hla);
     Assert.AreEqual(hlh,hlh+hla);
     Assert.AreEqual(hlb,!hlh);
     Assert.AreEqual(HexLocation.Invalid,!hli);
     Assert.AreEqual(HexLocation.Invalid,!hlj);
     Assert.AreEqual(HexLocation.Invalid,!hlk);
     Assert.AreEqual(hld,!hll);
     Assert.AreEqual(hlg,!hlm);
 }
示例#23
0
 public ZertzBallContainer CaptureLandPieces(HexLocation hl)
 {
     //CLP
     HashSet<HexLocation> visited = new HashSet<HexLocation>();
     Stack<HexLocation> todo = new Stack<HexLocation>();
     ZertzBallContainer zbc = ZertzBallContainer.Empty();
     ZertzPiece zp;
     zbc[this[hl].BallType]++;
     this[hl] = ZertzPiece.Dead;
     visited.Add(hl);
     todo.Push(hl);
     HexLocation hla, nei;
     while(todo.Count > 0x00) {
         hla = todo.Pop();
         for(int i = 0x00; i < 0x06; i++) {
             nei = hla+HexLocation.NeighbourDirections[i];
             if(!visited.Contains(nei)) {
                 visited.Add(nei);
                 zp = this[nei];
                 if(zp.IsAlive) {
                     zbc[zp.BallType]++;
                     this[nei] = ZertzPiece.Dead;
                     todo.Push(nei);
                 }
             }
         }
     }
     return zbc;
 }
示例#24
0
 public bool CanHop(HexLocation hl)
 {
     //CH2
     ZertzPiece zp = this[hl];
     if(!zp.IsAlive || !zp.ContainsBall) {
         return false;
     }
     HexLocation zla, dir;
     for(int i = 0x00; i < 0x06; i++) {
         dir = HexLocation.NeighbourDirections[i];
         zla = hl+dir;
         zp = this[zla];
         if(zp.IsAlive && zp.ContainsBall) {
             zla += dir;
             zp = this[zla];
             if(zp.IsAlive && !zp.ContainsBall) {
                 return true;
             }
         }
     }
     return false;
 }
示例#25
0
 public static ZertzBoard OffsetBoard(out HexLocation[] hls)
 {
     ZertzPiece[,] pieces = new ZertzPiece[0x07,0x07];
     hls = new HexLocation[0x25];
     int o1, o2, j, k = 0x00;
     for(int i = 0x00; i <= 0x06; i++) {
         o1 = Math.Max(0x00,0x03-i);
         o2 = Math.Min(0x06,0x09-i);
         for(j = 0x00; j < o1; j++) {
             pieces[i,j] = ZertzPiece.Dead;
         }
         for(; j <= o2; j++) {
             pieces[i,j] = ZertzPiece.Vacant;
             hls[k++] = new HexLocation((sbyte) i,(sbyte) j);
         }
         for(; j <= 0x06; j++) {
             pieces[i,j] = ZertzPiece.Dead;
         }
     }
     return new ZertzBoard(pieces);
 }
示例#26
0
 public virtual ZertzMoveState CaptureLand(HexLocation location)
 {
     //CL
     return NotPossible();
 }
示例#27
0
 public override ZertzMoveState SelectPiece(HexLocation location)
 {
     //GUARDS
     if(!this.Board.CanHop(location)) {
         throw new InvalidZertzActionException("Unable to do this action: the ball can't hop!");
     }
     //ACTIONS
     //EVENTS
     this.Creator.perform_ChangeState(0x02);
     //NEXT_STATE
     return new Capture1ZertzMoveState(this.Creator,location);
 }
示例#28
0
        private void BuildAndAssertResult(bool expectation, Action <TerraTile> beforeExecute = null, HexLocation location = null)
        {
            var loc  = location ?? new HexLocation(1, 1);
            var tile = this.Board.TileForLocation(loc);

            Func <TerraMysticaAction> prepareAction = () => new BuildAction(this.Board, this.Player, loc);
            Action before = () => beforeExecute?.Invoke(tile);

            this.PerformActionAndAssertResult(expectation, prepareAction, before);
        }
示例#29
0
 public void RemoveZertzPiece(HexLocation hl)
 {
     //RZP
     this[hl] = ZertzPiece.Dead;
 }
示例#30
0
        public void TestBuild_TileAlreadyOwnedFailure()
        {
            var loc = new HexLocation(1, 1);

            this.BuildAndAssertFailure(tile => this.Board.TileForLocation(loc).Owner = new TestPlayer(), loc);
        }
示例#31
0
 private void BuildAndAssertFailure(Action <TerraTile> beforeExecute = null, HexLocation location = null)
 {
     this.BuildAndAssertResult(false, beforeExecute, location);
 }
示例#32
0
 public PutBallRemovePieceZertzMove(HexLocation put, ZertzBallType ball, HexLocation rem)
 {
 }
示例#33
0
 public CaptureZertzMoveState(ZertzMoveCreator creator, HexLocation hopLocation) : base(creator)
 {
     this.hopLocation = hopLocation;
 }
示例#34
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);
         }
     }
 }
示例#35
0
 public bool HasNeighbours(HexLocation zl)
 {
     foreach(HexLocation dir in HexLocation.NeighbourDirections) {
         if(this[zl+dir].IsAlive) {
             return true;
         }
     }
     return false;
 }
示例#36
0
 public override ZertzMoveState CaptureLand(HexLocation location)
 {
     //GUARDS
     if(this.Board.HasFree()) {
         throw new InvalidZertzActionException("Unable to do this action: An free piece must first be removed!");
     }
     if(!this.Board.CanCapture(location)) {
         throw new InvalidZertzActionException("Unable to do this action: This land cannot be captured!");
     }
     //ACTIONS
     this.Game.PutToPool(this.Board.CaptureLandPieces(location));
     //EVENTS
     this.Creator.perform_ChangeState(0x05);
     //TODO: insert event
     //NEXT_STATE
     return new CaptureLandZertzMoveState(this.Creator);
 }
示例#37
0
 public bool IsVacant(HexLocation hl)
 {
     //IV
     return this[hl].IsVacant;
 }
示例#38
0
 public void CaptureLand(HexLocation location)
 {
     this.setState(state.CaptureLand(location));
 }
示例#39
0
 public Capture2ZertzMoveState(ZertzMoveCreator creator, HexLocation hopLocation) : base(creator, hopLocation)
 {
 }
示例#40
0
 public virtual ZertzMoveState CaptureLand(HexLocation location)               //CL
 {
     return(NotPossible());
 }
示例#41
0
 public override ZertzMoveState SelectPiece(HexLocation location)
 {
     //GUARDS
     if(!this.Board.IsFree(location)) {
         throw new InvalidZertzActionException("Unable to do this action: This piece can't be removed!");
     }
     //ACTIONS
     this.Board.RemoveZertzPiece(location);
     //EVENT
     this.Creator.perform_RemovePiece(location);
     this.Creator.perform_ChangeState(0x05);
     //NEXT_STATE
     return new CaptureLandZertzMoveState(this.Creator);
 }
示例#42
0
 public virtual ZertzMoveState SelectPiece(HexLocation location)               //SP
 {
     return(NotPossible());
 }
示例#43
0
 public void SelectPiece(HexLocation location)
 {
     this.setState(state.SelectPiece(location));
 }
示例#44
0
 public void CaptureBall(HexLocation location, ZertzBallContainerType type)
 {
 }
示例#45
0
 public virtual ZertzMoveState SelectPiece(HexLocation location)
 {
     //SP
     return NotPossible();
 }
示例#46
0
 public void SelectPiece(HexLocation location)
 {
     this.zmc.SelectPiece(location);
 }
示例#47
0
 private void perform_PerformHop(HexLocation fr, HexLocation to)
 {
     lock(this.handlers) {
         foreach(IZertzActionHandler izah in this.handlers) {
             izah.PerformHop(fr,to);
         }
     }
 }
示例#48
0
 public void CaptureLand(HexLocation location)
 {
     this.zmc.CaptureLand(location);
 }
示例#49
0
 public bool CanCapture(HexLocation hl)
 {
     ZertzPiece zp = this[hl];
     if(!zp.IsAlive || !zp.ContainsBall) {
         return false;
     }
     HashSet<HexLocation> visited = new HashSet<HexLocation>();
     Stack<HexLocation> todo = new Stack<HexLocation>();
     visited.Add(hl);
     todo.Push(hl);
     HexLocation hla, nei;
     while(todo.Count > 0x00) {
         hla = todo.Pop();
         for(int i = 0x00; i < 0x06; i++) {
             nei = hla+HexLocation.NeighbourDirections[i];
             zp = this[nei];
             if(zp.IsAlive) {
                 if(zp.ContainsBall) {
                     if(!visited.Contains(nei)) {
                         visited.Add(nei);
                         todo.Push(nei);
                     }
                 }
                 else {
                     return false;
                 }
             }
         }
     }
     int nIsland = visited.Count;
     int nCurrent;
     int m = this.pieces.GetLength(0x00);
     int n = this.pieces.GetLength(0x01);
     bool unique = true;
     //not the main part (or it is the only island!)
     for(sbyte i = 0x00; i < m; i++) {
         for(sbyte j = 0x00; j < n; j++) {
             hla = new HexLocation(i,j);
             zp = this[hla];
             if(zp.IsAlive && !visited.Contains(hla)) {
                 //we discovered a new island
                 unique = false;
                 nCurrent = 0x01;
                 visited.Add(hla);
                 todo.Push(hla);
                 while(todo.Count > 0x00) {
                     hla = todo.Pop();
                     for(int k = 0x00; k < 0x06; k++) {
                         nei = hla+HexLocation.NeighbourDirections[k];
                         zp = this[nei];
                         if(zp.IsAlive) {
                             if(!visited.Contains(nei)) {
                                 visited.Add(nei);
                                 todo.Push(nei);
                                 nCurrent++;
                                 if(nCurrent >= nIsland) {
                                     return true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return unique;
 }
示例#50
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);
        }
示例#51
0
 public bool CanHop(HexLocation zl, HexDirection dir)
 {
     //CH3
     HexLocation zla = zl;
     ZertzPiece zp = this[zla];
     HexLocation hldir = HexLocation.NeighbourDirections[(byte) dir];
     if(zp.IsAlive && zp.ContainsBall) {
         zla += hldir;
         zp = this[zla];
         if(zp.IsAlive && zp.ContainsBall) {
             zla += hldir;
             zp = this[zla];
             if(zp.IsAlive && !zp.ContainsBall) {
                 return true;
             }
         }
     }
     return false;
 }
示例#52
0
 public CaptureZertzMove(HexLocation offset, params HexDirection[] hops)
 {
     this.offset = offset;
     this.hops   = hops;
 }
示例#53
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));
 }
示例#54
0
 public ZertzRingRenderer GetRingAt(HexLocation loc)
 {
     return(this.rings[loc.X, loc.Y]);
 }
示例#55
0
 public bool IsFree(HexLocation hl)
 {
     //IF
     ZertzPiece zp = this[hl];
     if(zp.IsAlive && !zp.ContainsBall) {
         HexLocation zla, zlb;
         zlb = HexLocation.NeighbourDirections[0x05]+hl;
         for(int i = 0x00; i < 0x06; i++) {
             zla = zlb;
             zlb = HexLocation.NeighbourDirections[i];
             if(!this[zla].IsAlive && !this[hl+zlb].IsAlive && !this[zla+zlb].IsAlive) {
                 return true;
             }
             zlb += hl;
         }
     }
     return false;
 }
示例#56
0
 public void CaptureLand(HexLocation location)
 {
     this.setState(state.CaptureLand(location));
 }
示例#57
0
 public void PutZertzBall(HexLocation hl, ZertzBallType type)
 {
     //PZB
     ZertzPiece piece = ZertzPiece.Vacant;
     piece.PutBall(type);
     this[hl] = piece;
 }
示例#58
0
 public override ZertzMoveState SelectPiece(HexLocation location)
 {
     //GUARDS
     if(!this.Board.IsVacant(location)) {
         throw new InvalidZertzActionException("Unable to do this action: ball must be put on a vacant piece!");
     }
     //ACTIONS
     this.Board.PutZertzBall(location,this.Ball);
     //EVENT
     this.Creator.perform_PutBall(this.source,this.ball,location);
     this.Creator.perform_ChangeState(0x03);
     //NEXT_STATE
     return new PlacRem2ZertzMoveState(this.Creator);
 }
示例#59
0
 public ZertzPiece this[HexLocation zl]
 {
     get {
         if(zl.X < 0x00 || zl.Y < 0x00 || zl.X >= this.pieces.GetLength(0x00) || zl.Y >= this.pieces.GetLength(0x01)) {
             return ZertzPiece.Dead;
         }
         else {
             return this.pieces[zl.X,zl.Y];
         }
     }
     internal set {
         if(zl.X < 0x00 || zl.Y < 0x00 || zl.X >= this.pieces.GetLength(0x00) || zl.Y >= this.pieces.GetLength(0x01)) {
             throw new InvalidZertzActionException("Unable to set a piece out of range!");
         }
         else {
             this.pieces[zl.X,zl.Y] = value;
         }
     }
 }
示例#60
0
 public void SelectPiece(HexLocation location)
 {
     this.setState(state.SelectPiece(location));
 }