예제 #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));
 }
예제 #9
0
 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));
 }