Пример #1
0
        void SelectPiece()
        {
            Point?tmpInput = null;

            if (nocca.isMyTurn.Value)
            {
                tmpInput = myMove.GetInputPoint();
            }
            else
            {
                tmpInput = oppMove.GetInputPoint();
            }

            if (tmpInput != null && tmpInput != myMove.clickedNonIMyInputObject)
            {
                canMovePoints = nocca.CanMovePointsFrom(tmpInput.Value);
                if (canMovePoints.Length > 0)
                {
                    //移動できる駒が選択された
                    gameState                      = GameState.waiteForMovingPoint;
                    selectedPieceScript            = getPieceScript(tmpInput.Value);
                    selectedPieceScript.isSelected = true;
                }
            }
        }
Пример #2
0
 public void RestartGame()
 {
     nocca.RestartGame();
     nocca.InverseTurn(oppFirst);
     PiecesBoardGenerator.InitPiecesPlace();
     gameState           = GameState.noinited;
     selectedPieceScript = null;
     canMovePoints       = new Point[] { };
 }
Пример #3
0
        // Start is called before the first frame update
        void Start()
        {
            nocca.InverseTurn(oppFirst);
            gameState           = GameState.noinited;
            selectedPieceScript = null;
            canMovePoints       = new Point[] { };

            myMove = getMoveGenerator("MyMove");
            myMove.setPlayer(1);
            oppMove = getMoveGenerator("OppMove");
            oppMove.setPlayer(-1);
        }
Пример #4
0
 private void GeneratePiece()
 {
     foreach (int x in new int[] { 0, NOCCACore.XRANGE - 1 })
     {
         for (int z = 0; z < NOCCACore.ZRANGE; z++)
         {
             var pieceObject = Instantiate(piece, piece.transform.position, piece.transform.rotation);
             pieceObject.tag = "PieceTag";
             PieceScript pieceScript = pieceObject.GetComponent <PieceScript>();
             pieceScript.Init(new Point(x, z), x == 0);
         }
     }
 }
Пример #5
0
        PieceScript getPieceScript(Point p)
        {
            var         pieces     = GameObject.FindGameObjectsWithTag("PieceTag");
            var         maxStep    = -1;
            PieceScript ansPscript = null;

            foreach (GameObject tmpPobj in pieces)
            {
                var tmpPscript = tmpPobj.GetComponent <PieceScript>();
                if (tmpPscript.GetPoint() == p && tmpPscript.GetStep() > maxStep)
                {
                    maxStep    = tmpPscript.GetStep();
                    ansPscript = tmpPscript;
                }
            }
            return(ansPscript);
        }
Пример #6
0
        void SelectMovePoint()
        {
            Point?tmpInput = null;

            if (nocca.isMyTurn.Value)
            {
                tmpInput = myMove.GetInputPoint();
            }
            else
            {
                tmpInput = oppMove.GetInputPoint();
            }

            if (tmpInput != null)
            {
                if (tmpInput != myMove.clickedNonIMyInputObject)
                {
                    //IMyInputがクリックされた
                    if (Array.IndexOf(canMovePoints, tmpInput.Value) != -1)
                    {
                        //移動先が選択された
                        int step = nocca.Move(selectedPieceScript.GetPoint(), tmpInput.Value);
                        selectedPieceScript.changePoint(tmpInput.Value, step);
                    }
                }
                //クリックされた常に実行
                selectedPieceScript.isSelected = false;
                selectedPieceScript            = null;
                canMovePoints = new Point[] { };

                if (nocca.isGameOver)
                {
                    gameState = GameState.gameover;
                }
                else
                {
                    gameState = GameState.waiteForSlectingPiece;
                }
            }
        }