private void swapBall(BallController origin, BallController moveTo)
        {
            /// 入れ替え中などは入れ替えできない
            if (!origin.isOperating || !moveTo.canSwap)
            {
                return;
            }

            /// ボードインデックスの入れ替え
            var originPoint = new Point(origin.boardPoint.x, origin.boardPoint.y);
            var moveToPoint = new Point(moveTo.boardPoint.x, moveTo.boardPoint.y);

            Debug.Log("swap start");
            Debug.Log("originPoint.x: " + origin.boardPoint.x + "originPoint.y" + origin.boardPoint.y);
            Debug.Log("moveToPoint.x: " + moveTo.boardPoint.x + "moveToPoint.y" + moveTo.boardPoint.y);
            ///入れ替え
            origin.boardPoint = moveToPoint;
            moveTo.boardPoint = originPoint;
            Debug.Log("swap end");
            Debug.Log("originPoint.x: " + origin.boardPoint.x + "originPoint.y" + origin.boardPoint.y);
            Debug.Log("moveToPoint.x: " + moveTo.boardPoint.x + "moveToPoint.y" + moveTo.boardPoint.y);

            /// ボード上での入れ替え
            Board.setElement(origin, origin.boardPoint);
            Board.setElement(moveTo, moveTo.boardPoint);

            onSwapBall(origin, moveTo);
        }
        private void updateBoard()
        {
            var moveDirection = getCurrentBallMovedDirection();

            if (moveDirection[0] == Direction.None &&
                moveDirection[1] == Direction.None)
            {
                /// 移動しなかった
                return;
            }

            Debug.Log("ball moved");

            /// 移動先のボール情報を取得する
            BallController BallMoveTo          = null;
            var            horizontalDirection = moveDirection[0];
            var            verticalDirection   = moveDirection[1];

            if (horizontalDirection != Direction.None) /// 横方向のボールを取得
            {
                Debug.Log("moved horizontal");
                BallMoveTo = Board.getElementByDirection(
                    currentOperatingBall.boardPoint,
                    horizontalDirection);
            }
            else if (verticalDirection != Direction.None)     ///縦方向のボールを取得
            {
                Debug.Log("moved horizontal");
                BallMoveTo = Board.getElementByDirection(
                    currentOperatingBall.boardPoint,
                    verticalDirection);
            }

            /// 斜め方向のボールを取得
            if (horizontalDirection != Direction.None &&
                verticalDirection != Direction.None)
            {
                Debug.Log("moved horizontal and vertical");
                ///斜め方向に移動する時は、必ず水平方向の処理を行うので、引数は垂直方向で良い
                BallMoveTo = Board.getElementByDirection(
                    BallMoveTo.boardPoint,
                    verticalDirection);
            }

            swapBall(currentOperatingBall, BallMoveTo);
        }
Beispiel #3
0
 public StayState(BallController controller) :
     base(controller)
 {
 }
Beispiel #4
0
        public BallStateBase(BallController controller)
        {
            nextState = null;

            ownerController = controller;
        }
Beispiel #5
0
 public MoveState(BallController controller) :
     base(controller)
 {
 }
Beispiel #6
0
 public void registerCurrentOperationBall(BallController controller)
 {
     BoardController.registerOperatingBall(controller);
 }
 private void onSwapBall(BallController origin, BallController moveTo)
 {
     origin.onSwap(BallController.SwapReasonType.Move);
     moveTo.onSwap(BallController.SwapReasonType.Swap);
 }
 public void unregisterOperatingBall()
 {
     currentOperatingBall = null;
 }
 public void registerOperatingBall(BallController controller)
 {
     currentOperatingBall = controller;
 }