Example #1
0
        public override void Update(float time)
        {
            int i, j, f = 0;

            for (i = 0; i < GridSize.X; ++i)
            {
                for (j = 0; j < GridSize.Y; ++j)
                {
                    CCTile item = Tiles [f];
                    item.Position = new CCPoint((item.Delta.X * time), (item.Delta.Y * time));
                    PlaceTile(i, j, item);

                    f++;
                }
            }
        }
Example #2
0
        protected internal override void StartWithTarget(CCNode target)
        {
            base.StartWithTarget(target);

            if (m_nSeed != -1)
            {
                m_nSeed = CCRandom.Next();
            }

            m_nTilesCount = m_sGridSize.X * m_sGridSize.Y;
            m_pTilesOrder = new int[m_nTilesCount];
            int i, j;
            int k;

            /**
             * Use k to loop. Because m_nTilesCount is unsigned int,
             * and i is used later for int.
             */
            for (k = 0; k < m_nTilesCount; ++k)
            {
                m_pTilesOrder[k] = k;
            }

            Shuffle(ref m_pTilesOrder, m_nTilesCount);

            m_pTiles = new CCTile[m_nTilesCount];

            int f = 0;

            for (i = 0; i < m_sGridSize.X; ++i)
            {
                for (j = 0; j < m_sGridSize.Y; ++j)
                {
                    m_pTiles[f] = new CCTile
                    {
                        Position      = new CCPoint(i, j),
                        StartPosition = new CCPoint(i, j),
                        Delta         = GetDelta(new CCGridSize(i, j))
                    };

                    f++;
                }
            }
        }
Example #3
0
        public void PlaceTile(CCGridSize pos, CCTile t)
        {
            CCQuad3 coords = OriginalTile(pos);

            CCPoint step = m_pTarget.Grid.Step;
            coords.BottomLeft.X += (int) (t.Position.X * step.X);
            coords.BottomLeft.Y += (int) (t.Position.Y * step.Y);

            coords.BottomRight.X += (int) (t.Position.X * step.X);
            coords.BottomRight.Y += (int) (t.Position.Y * step.Y);

            coords.TopLeft.X += (int) (t.Position.X * step.X);
            coords.TopLeft.Y += (int) (t.Position.Y * step.Y);

            coords.TopRight.X += (int) (t.Position.X * step.X);
            coords.TopRight.Y += (int) (t.Position.Y * step.Y);

            SetTile(pos, ref coords);
        }
Example #4
0
        public void PlaceTile(CCGridSize pos, CCTile t)
        {
            CCQuad3 coords = OriginalTile(pos);

            CCPoint step = m_pTarget.Grid.Step;
            coords.BottomLeft.X += (int) (t.Position.X * step.X);
            coords.BottomLeft.Y += (int) (t.Position.Y * step.Y);

            coords.BottomRight.X += (int) (t.Position.X * step.X);
            coords.BottomRight.Y += (int) (t.Position.Y * step.Y);

            coords.TopLeft.X += (int) (t.Position.X * step.X);
            coords.TopLeft.Y += (int) (t.Position.Y * step.Y);

            coords.TopRight.X += (int) (t.Position.X * step.X);
            coords.TopRight.Y += (int) (t.Position.Y * step.Y);

            SetTile(pos, ref coords);
        }
Example #5
0
        protected void PlaceTile(int x, int y, CCTile tile)
        {
            CCQuad3 coords = OriginalTile(x, y);

            CCPoint step = Target.Grid.Step;

            coords.BottomLeft.X += (int)(tile.Position.X * step.X);
            coords.BottomLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.BottomRight.X += (int)(tile.Position.X * step.X);
            coords.BottomRight.Y += (int)(tile.Position.Y * step.Y);

            coords.TopLeft.X += (int)(tile.Position.X * step.X);
            coords.TopLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.TopRight.X += (int)(tile.Position.X * step.X);
            coords.TopRight.Y += (int)(tile.Position.Y * step.Y);

            SetTile(x, y, ref coords);
        }
Example #6
0
        protected void PlaceTile(CCGridSize pos, CCTile tile)
        {
            CCQuad3 coords = OriginalTile(pos);

            var step = ((CCNodeGrid)Target).Grid.Step;

            coords.BottomLeft.X += (int)(tile.Position.X * step.X);
            coords.BottomLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.BottomRight.X += (int)(tile.Position.X * step.X);
            coords.BottomRight.Y += (int)(tile.Position.Y * step.Y);

            coords.TopLeft.X += (int)(tile.Position.X * step.X);
            coords.TopLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.TopRight.X += (int)(tile.Position.X * step.X);
            coords.TopRight.Y += (int)(tile.Position.Y * step.Y);

            SetTile(pos, ref coords);
        }
Example #7
0
        protected void PlaceTile(int x, int y, CCTile tile)
        {
            CCQuad3 coords = OriginalTile(x, y);

            var step = (Target is CCNodeGrid) ?  ((CCNodeGrid)Target).Grid.Step : Target.Grid.Step;

            coords.BottomLeft.X += (int)(tile.Position.X * step.X);
            coords.BottomLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.BottomRight.X += (int)(tile.Position.X * step.X);
            coords.BottomRight.Y += (int)(tile.Position.Y * step.Y);

            coords.TopLeft.X += (int)(tile.Position.X * step.X);
            coords.TopLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.TopRight.X += (int)(tile.Position.X * step.X);
            coords.TopRight.Y += (int)(tile.Position.Y * step.Y);

            SetTile(x, y, ref coords);
        }
Example #8
0
        public CCShuffleTilesState(CCShuffleTiles action, CCNode target) : base(action, target)
        {
            CCGridSize gridSize = action.GridSize;

            TilesCount = gridSize.X * gridSize.Y;
            int[] shuffledTilesOrder = new int[TilesCount];
            int   i, j, f = 0;

            for (i = 0; i < TilesCount; i++)
            {
                shuffledTilesOrder [i] = i;
            }

            if (action.Seed != CCShuffleTiles.NoSeedSpecified)
            {
                CCRandom.Next(action.Seed);
            }


            Shuffle(ref shuffledTilesOrder, TilesCount);
            TilesOrder = shuffledTilesOrder;

            Tiles = new CCTile[TilesCount];

            for (i = 0; i < gridSize.X; ++i)
            {
                for (j = 0; j < gridSize.Y; ++j)
                {
                    Tiles [f] = new CCTile {
                        Position      = new CCPoint(i, j),
                        StartPosition = new CCPoint(i, j),
                        Delta         = GetDelta(i, j)
                    };

                    f++;
                }
            }
        }
Example #9
0
        protected internal override void StartWithTarget(CCNode target)
        {
            base.StartWithTarget(target);

            if (m_nSeed != -1)
            {
                m_nSeed = CCRandom.Next();
            }

            m_nTilesCount = m_sGridSize.X * m_sGridSize.Y;
            m_pTilesOrder = new int[m_nTilesCount];
            int i, j;
            int k;

            /**
             * Use k to loop. Because m_nTilesCount is unsigned int,
             * and i is used later for int.
             */
            for (k = 0; k < m_nTilesCount; ++k)
            {
                m_pTilesOrder[k] = k;
            }

            Shuffle(ref m_pTilesOrder, m_nTilesCount);

            m_pTiles = new CCTile[m_nTilesCount];

            int f = 0;
            for (i = 0; i < m_sGridSize.X; ++i)
            {
                for (j = 0; j < m_sGridSize.Y; ++j)
                {
                    m_pTiles[f] = new CCTile
                        {
                            Position = new CCPoint(i, j),
                            StartPosition = new CCPoint(i, j),
                            Delta = GetDelta(new CCGridSize(i, j))
                        };

                    f++;
                }
            }
        }
Example #10
0
        public CCShuffleTilesState (CCShuffleTiles action, CCNode target) : base (action, target)
        {
            CCGridSize gridSize = action.GridSize;
            TilesCount = gridSize.X * gridSize.Y;
            int[] shuffledTilesOrder = new int[TilesCount];
            int i, j, f = 0;

            for (i = 0; i < TilesCount; i++) {
                shuffledTilesOrder [i] = i;
            }

            if (action.Seed != CCShuffleTiles.NoSeedSpecified) {
                CCRandom.Next (action.Seed);
            }


            Shuffle (ref shuffledTilesOrder, TilesCount);
            TilesOrder = shuffledTilesOrder;

            Tiles = new CCTile[TilesCount];

            for (i = 0; i < gridSize.X; ++i) {
                for (j = 0; j < gridSize.Y; ++j) {
                    Tiles [f] = new CCTile {
                        Position = new CCPoint (i, j),
                        StartPosition = new CCPoint (i, j),
                        Delta = GetDelta (i, j)
                    };

                    f++;
                }
            }
        }
Example #11
0
        protected void PlaceTile (int x, int y, CCTile tile)
        {
            CCQuad3 coords = OriginalTile (x, y);

            CCPoint step = Target.Grid.Step;
            coords.BottomLeft.X += (int)(tile.Position.X * step.X);
            coords.BottomLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.BottomRight.X += (int)(tile.Position.X * step.X);
            coords.BottomRight.Y += (int)(tile.Position.Y * step.Y);

            coords.TopLeft.X += (int)(tile.Position.X * step.X);
            coords.TopLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.TopRight.X += (int)(tile.Position.X * step.X);
            coords.TopRight.Y += (int)(tile.Position.Y * step.Y);

            SetTile (x, y, ref coords);
        }
        protected void PlaceTile (int x, int y, CCTile tile)
        {
            CCQuad3 coords = OriginalTile (x, y);

            var step = (Target is CCNodeGrid) ?  ((CCNodeGrid)Target).Grid.Step : Target.Grid.Step;

            coords.BottomLeft.X += (int)(tile.Position.X * step.X);
            coords.BottomLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.BottomRight.X += (int)(tile.Position.X * step.X);
            coords.BottomRight.Y += (int)(tile.Position.Y * step.Y);

            coords.TopLeft.X += (int)(tile.Position.X * step.X);
            coords.TopLeft.Y += (int)(tile.Position.Y * step.Y);

            coords.TopRight.X += (int)(tile.Position.X * step.X);
            coords.TopRight.Y += (int)(tile.Position.Y * step.Y);

            SetTile (x, y, ref coords);
        }