Esempio n. 1
0
        public CCGridActionState(CCGridAction action, CCNode target) : base(action, target)
        {
            GridSize = action.GridSize;
            CCGridBase targetGrid = Target.Grid;

            if (targetGrid != null && targetGrid.ReuseGrid > 0)
            {
                Grid = targetGrid;

                if (targetGrid.Active && targetGrid.GridSize.X == GridSize.X && targetGrid.GridSize.Y == GridSize.Y)
                {
                    targetGrid.Reuse();
                }
                else
                {
                    Debug.Assert(false);
                }
            }
            else
            {
                if (targetGrid != null && targetGrid.Active)
                {
                    targetGrid.Active = false;
                }

                CCGridBase newgrid = Grid;

                Target.Grid        = newgrid;
                Target.Grid.Active = true;
            }
        }
        public CCGridActionState(CCGridAction action, CCNodeGrid target) : base(action, target)
        {
            GridSize = action.GridSize;

            // If target is not a CCNodeGrid we will want to emmit a message and
            // return or there can be possible NRE's later on.
            var gridNodeTarget = Target as CCNodeGrid;

            if (gridNodeTarget == null)
            {
                Debug.Assert(false, "Grid Actions only target CCNodeGrids.");
                CCLog.Log("Grid Actions only target CCNodeGrids.");
                return;
            }

            CCGridBase targetGrid = target.Grid;

            if (targetGrid != null && targetGrid.ReuseGrid > 0)
            {
                Grid = targetGrid;

                if (targetGrid.Active && targetGrid.GridSize.X == GridSize.X && targetGrid.GridSize.Y == GridSize.Y)
                {
                    targetGrid.Reuse();
                }
                else
                {
                    Debug.Assert(false);
                }
            }
            else
            {
                if (targetGrid != null && targetGrid.Active)
                {
                    targetGrid.Active = false;
                }

                CCGridBase newgrid = Grid;
                if (target != null)
                {
                    target.Grid        = newgrid;
                    target.Grid.Active = true;
                }
            }
        }