Exemplo n.º 1
0
    private void MoveChessMan(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            //distroy piece
            Chessman c = Chessmans[x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                ////end Game
                //if (c.GetType() == typeof(King))
                //{
                //    EndGame();
                //    return;
                //}

                activeChessMan.Remove(c.gameObject);
                Destroy(c.gameObject);
            }
            if (selectedChessman.GetType() == typeof(Pawn))
            {
                Promotion_pawn(x, y);
            }
            Chessmans[selectedChessman.currentX, selectedChessman.currentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;
            isWhiteTurn     = !isWhiteTurn;
        }
        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
    }
Exemplo n.º 2
0
    private void ChangePiecePosition(int x, int y)
    {
        previousLocation = new Vector2Int(selectedChessman.CurrentX, selectedChessman.CurrentY);
        Chessman c = Chessmen[x, y];

        if (c != null && c.isWhite != isWhiteTurn)
        {
            activeChessman.Remove(c.gameObject);
            c.gameObject.SetActive(false);
            var k = c.gameObject.transform.GetChild(0).gameObject;
            k.transform.parent = transform;
            k.SetActive(true);
            SoundManager.Instance.ShatterSound();
            Destroy(k.gameObject, 2f);
        }
        Chessmen[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
        //selectedChessman.transform.position = GetTileCenter(x, y);
        StartCoroutine(CoroutineAnimationChangePiecePosition(x, y, selectedChessman));
        selectedChessman.SetPosition(x, y);
        Chessmen[x, y] = selectedChessman;
        if (selectedChessman.GetType() == typeof(King))
        {
            if (isWhiteTurn)
            {
                whiteKing = new Vector2Int(x, y);
            }
            else
            {
                blackKing = new Vector2Int(x, y);
            }
        }
    }
Exemplo n.º 3
0
    // move the selected chess piece
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];

            // if there's a piece there and it's not your team
            if (c != null && c.isWhite != isWhiteTurn)
            {
                if (c.GetType() == typeof(King))
                {
                    // End the game
                    return;
                }

                // capture a piece
                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            // remove the piece from it's original position in the 2d array
            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;

            // get the position of the selected piece
            selectedChessman.transform.position = GetTileCenter(x, y);

            //
            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;
            isWhiteTurn     = !isWhiteTurn;
        }
        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
    }
Exemplo n.º 4
0
    private void MoveChessman(int[] boardQuadrant)
    {
        if (boardQuadrant != null)
        {
            Chessman c = Chessmans[boardQuadrant[0], boardQuadrant[1]];

            if (((c != null && c.isWhite != isWhiteTurn) || (c == null)))
            {
                if (c != null && c.isWhite != isWhiteTurn)
                {
                    Debug.Log("Passed the opposite team check");
                    //Capture a piece

                    activeChessman.Remove(c.gameObject);
                    Destroy(c.gameObject);
                }

                Chessmans[selectedChessman.CurrentTrack, selectedChessman.CurrentSegment] = null;

                Transform gamePieceTransform = selectedChessman.transform;
                gamePieceTransform.position = GetTileCenter(boardQuadrant[0], boardQuadrant[1]);
                gamePieceTransform.rotation = GetBoardOrientation(gamePieceTransform.position);

                selectedChessman.SetPosition(boardQuadrant[0], boardQuadrant[1]);
                Chessmans[boardQuadrant[0], boardQuadrant[1]] = selectedChessman;
                isWhiteTurn = !isWhiteTurn;
            }
        }

        selectedChessman.GetComponentInChildren <MeshRenderer> ().material = previousMat;
        //BoardHighlights.Instance.Hidehighlights ();
        selectedChessman = null;
    }
Exemplo n.º 5
0
    private void MoveChessman(int x, int y)
    {
        //if (selectedChessman.PossibleMove (x, y)) {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans [x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                if (c.GetType() == typeof(King))
                {
                    EndGame();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans [x, y] = selectedChessman;
            isWhiteTurn      = !isWhiteTurn;
        }

        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
    }
Exemplo n.º 6
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                // Capture a piece

                // If it is the king end the game
                if (c.GetType() == typeof(King))
                {
                    EndGame();
                    return;
                }
                activeChessMan.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null; //we move
            selectedChessman.transform.position = GetTileCenter(x, y + 1);
            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;
            isWhiteTurn     = !isWhiteTurn; // swap to other value, only
        }
        BoardHighlights.Instance.Hidehighlights();
        selectedChessman = null; // unselect if click on place doesnt make sense
    }
Exemplo n.º 7
0
    private void MoveChessman(int x, int y)
    {
        //if (selectedChessman.PossibleMove (x, y))
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans [x, y];

            if (c != null && c.isWhite != isWhiteTurn)
            {
                // Capture a piece

                // If it is the king
                if (c.GetType() == typeof(King))
                {
                    //End the game
                    EndGame();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans [x, y] = selectedChessman;

            isWhiteTurn = !isWhiteTurn;
        }

//		selectedChessman.GetComponent<MeshRenderer> ().material = previousMat;
        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
    }
Exemplo n.º 8
0
    private void MoveChessman(int x, int y)
    {
        //Debug.Log("MoveChessman , " + x + "  " + y+" , "+Chessmans[x, y]+ "  "+ selectedChessman);
        //Debug.Log("allowedMove"+allowedMoves[x,y]);
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                //Capture a piece
                //If it is the king
                if (c.GetType() == typeof(King))
                {
                    EndGame();
                    return;
                }

                activechessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }
            //Debug.Log("MoveChessman , " + x + "  " + y+" , "+Chessmans[x, y]+ "  "+ selectedChessman);
            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;
            isWhiteTurn     = !isWhiteTurn;
        }
        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
    }
Exemplo n.º 9
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans [x, y];

            if (c != null && c.isWhite != isWhiteTurn)
            {
                if (c.GetType() == typeof(King))
                {
                    EndGame();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            // Выбор шахматной фигуры

            Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans [x, y] = selectedChessman;
            isWhiteTurn      = !isWhiteTurn;
        }


        selectedChessman.GetComponent <MeshRenderer> ().material = previousMat;
        BoardHighLights.Instance.Hidehighlights();
        selectedChessman = null;
    }
Exemplo n.º 10
0
    public void Promote(int type)
    {
        if (!isWhiteTurn)
        {
            type += 6;
        }
        activeChessman.Remove(selectedChessman.gameObject);
        Destroy(selectedChessman.gameObject);
        SpawnChessman(type, x2, y2);
        selectedChessman = Chessmans[x2, y2];

        Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
        selectedChessman.transform.position = GetTileCenter(x2, y2);
        selectedChessman.SetPosition(x2, y2);
        Chessmans[x2, y2] = selectedChessman;
        isWhiteTurn       = !isWhiteTurn;

        selectedChessman.GetComponent <MeshRenderer>().material = previousMat;
        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
        if (x1 != -1)
        {
            lineRenderer.enabled        = true;
            lineRenderer.startColor     = color;
            lineRenderer.endColor       = color;
            lineRenderer.material.color = color;
            lineRenderer.startWidth     = 0.3f;
            Vector3 vfrom = GetTileCenter(x1, y1);
            Vector3 vto   = GetTileCenter(x2, y2);
            if (vfrom.z < vto.z)
            {
                vfrom.z -= 0.2f;
                vto.z   += 0.2f;
            }
            else if (vfrom.z > vto.z)
            {
                vfrom.z += 0.2f;
                vto.z   -= 0.2f;
            }

            lineRenderer.SetPosition(0, vfrom);
            lineRenderer.SetPosition(1, vto);

            if (!isEngineOn)
            {
                isUserWhite = !isUserWhite;
            }
            if ((isUserWhite != isWhiteTurn || !isEngineOn) && !replay)
            {
                send = true;
            }
        }

        wait = false;
        _queen.Ready();
        _rook.Ready();
        _bishop.Ready();
        _knight.Ready();
    }
Exemplo n.º 11
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans [x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                //capture a piece

                //if it is the king
                if (c.GetType() == typeof(King))
                {
                    EndGame();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }
            //EnPassantMove [1] = -1;
            //EnPassantMove [1] = -1;
            if (selectedChessman.GetType() == typeof(Pawns))
            {
                if (y == 7)
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessman(1, x, y);
                    selectedChessman = Chessmans [x, y];
                }
                if (y == 0)
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessman(7, x, y);
                    selectedChessman = Chessmans [x, y];
                }
                //if(selectedChessman.CurrentY == 1&& y ==3){
                //EnPassantMove [1] = x;
                //EnPassantMove [1] = y - 1;

                //}
                //else if (selectedChessman.CurrentY == 6&& y ==4){
                //EnPassantMove [1] = x;
                //EnPassantMove [1] = y + 1;
                //}
            }

            Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans [x, y] = selectedChessman;
            isWhiteTurn      = !isWhiteTurn;
        }
        selectedChessman.GetComponent <MeshRenderer> ().material = previousMat;
        BoardHighlights.Instance.Hidehighlights();
        selectedChessman = null;
    }
Exemplo n.º 12
0
    private void MoveFromTo(int srcX, int srcY, int dstX, int dstY)
    {
        Chessman chess = Chessmans[srcX, srcY];

        Chessmans[srcX, srcY]    = null;
        chess.transform.position = GetTileCenter(dstX, dstY);
        chess.SetPosition(dstX, dstY);
        Chessmans[dstX, dstY] = chess;
    }
Exemplo n.º 13
0
    private void MoveChessman(int x, int y)
    {
        if (selectedChessman.PossibleMove(x, y))
        {
            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);

            Chessmans[x, y] = selectedChessman;

            if (!throwAgain)
            {
                isWhiteTurn = !isWhiteTurn;
            }
        }
        move             = 0;
        selectedChessman = null;
    }
Exemplo n.º 14
0
    private void MoveSelectedChessmanTo(int x, int y, float delays)
    {
        Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;

        selectedChessman.MoveAfter(delays, GetTileCenter(x, y));

        selectedChessman.SetPosition(x, y);
        Chessmans[x, y] = selectedChessman;
    }
Exemplo n.º 15
0
    //말을 움직인다 (상대 말을 없애는 것도 있음)
    void MoveChessman(int x, int y)
    {
        if (AllowedMoves[x, y])           //배열안에 값이 있다면
        {
            Number--;                     //횟수를 깍는다
            Chessman c = Chessmans[x, y]; //Chessmans배열을(위치를) 넣은 Chessman형 변수 선언
            sound.Play();

            if (c != null && c.isWhite != isWhiteTurn) //c가 null값이 아니고 isWhite와 isWhiteTurn이 서로 다를때(흑-흑이나 백-백이아닌 상황일때)
            {                                          //이동한곳에 c가 있다면(흑 - 백 / 백 - 흑) 이런 상황 // isWhite는 도달한곳에 있는 말이 흑인지 백인지를 나타낸다.
                ActiveEnemy.Remove(c.gameObject);      // 해당gameObject가 들어가있는 activeChessman리스트를 지운다.
                Destroy(c.gameObject);                 //해당gameObject를 없앤다.
                Debug.Log(ActiveEnemy.Count);
                if (Number > -1)                       //number가 -1보다 클때
                {
                    if (ActiveEnemy.Count == 0)        //ActiveEnemy리스트안에 아무것도 없다면(체스판에 검은돌이 없다면)
                    {
                        Clear++;                       //Clear + 1 올린다.
                        Number = 10;                   //횟수를 10으로 초기화시킨다.(다음 스테이지를 위해)
                        if (Clear == 2)                //1스테이지를 깼을때
                        {
                            EndGame1();                //2스테이지를 불러오는 함수를 부른다.
                            //Debug.Log(ActiveChessman.Count);
                        }
                        if (Clear == 3) //2스테이지를 깼을때
                        {
                            EndGame2(); //3스테이지를 불러오는 함수를 부른다.
                        }
                        if (Clear == 4) //3스테이지를 깼을때
                        {
                            Vic_ChangeScene();
                        }
                    }
                }
            }
            if (Number == 0)
            {
                if (ActiveEnemy.Count > 0)
                {
                    Defeat_ChangeScene();
                }
            }

            Chessmans[SelectedChessman.CurrentX, SelectedChessman.CurrentY] = null; //다른 위치로 옮길 것이기 때문에 현재위치를 null로 바꿈
            SelectedChessman.transform.position = GetTileCenter(x, y);              //체스말을 놓을 좌표를 잡아주는 함수에다가 이동시킬 좌표를 넣는다
            SelectedChessman.SetPosition(x, y);                                     //선택한 말에 현재위치값을 바꿔준다(SetPosition 함수에서 바꿔준다)
            Chessmans[x, y] = SelectedChessman;                                     //움직인 말의 현재위치를 Chessmans배열(8 x 8)에 넣는다
            //isWhiteTurn = !isWhiteTurn; //말을 움직이면 턴이 바뀐다.
        }

        SelectedChessman.GetComponent <MeshRenderer>().material = previousMat; //선택한 material을 기존걸로 바꾼다.
        BoardHighlights.Instance.Hidehighlights();                             //하이라이트를 숨기는 함수를 부른다.
        SelectedChessman = null;                                               //턴이 바뀌고 다시 null값이 된다.
    }
Exemplo n.º 16
0
    } //通用移動

    public Vector3 generalMoveGetNewV3(Chessman chessmans, Vector2 newPos)
    {
        int x = (int)newPos.x;
        int y = (int)newPos.y;

        Chessmans[chessmans.CurrentX, chessmans.CurrentY] = null; //清空Chessmans array裡的當前位置
        chessmans.SetPosition(x, y);                              //gamemodel 改變目標chessmans的坐標(背景數值上改變
        Chessmans[x, y] = chessmans;                              //安排Chessmans去array裡新的位置

        return(getTileCenter(x, y));                              // gameview 改變目標chessmans的坐標(顯示上改變
    }
Exemplo n.º 17
0
    } //選擇棋子,條件判斷可否行動

    /// <summary>
    /// 目標chessmans e.g.Chessmans[ 2, 4 ], 你想要的新位置
    /// </summary>
    public void generalMove(Chessman chessmans, Vector2 newPos)
    {
        int x = (int)newPos.x;
        int y = (int)newPos.y;

        Chessmans[chessmans.CurrentX, chessmans.CurrentY] = null; //清空Chessmans array裡的當前位置
        chessmans.SetPosition(x, y);                              //gamemodel 改變目標chessmans的坐標(背景數值上改變
        Chessmans[x, y] = chessmans;                              //安排Chessmans去array裡新的位置

        chessmans.transform.position = getTileCenter(x, y);       // gameview 改變目標chessmans的坐標(顯示上改變
    } //通用移動
Exemplo n.º 18
0
 private void MoveChessman(int x, int y)
 {
     if (allowedMoves[x, y])
     {
         Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
         selectedChessman.transform.position = GetTileCenter(x, y);
         selectedChessman.SetPosition(x, y);
         Chessmans[x, y] = selectedChessman;
         isWhiteTurn     = !isWhiteTurn;
     }
     BoardHighlights.Instance.Hidehighlights();
     selectedChessman = null;
 }
Exemplo n.º 19
0
 private void MoveChessman(int x, int y)
 {
     if (allowedMoves[x, y] && whetherMove)
     {
         Chessman c = Chessmans [x, y];
         if (c != null)
         {
             selectedChessman = null;
             //whetherMove = false;
             //Chessmans [x, y] = Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY];
         }
         else
         {
             Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
             selectedChessman.transform.position = GetTileCenter(x, y);
             selectedChessman.SetPosition(x, y);
             Chessmans [x, y]         = selectedChessman;
             selectedChessman.isWhite = false;
         }            //isWhiteTurn = !isWhiteTurn;
     }
     BoardHighlights.Instance.Hidehighlights();
     selectedChessman = null;
 }
Exemplo n.º 20
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves [x, y])
        {
            Chessman c = Chessmans [x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                // SI c'est le ROI
                if (c.GetType() == typeof(King))
                {
                    // FIN de la Partie
                    EndGame();
                    return;
                }

                //Capturer une piece
                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }


            Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            //
            selectedChessman.SetPosition(x, y);
            Chessmans [x, y] = selectedChessman;
            //Changer le tour apres un deplacement
            isWhiteTurn = !isWhiteTurn;
            message_tour_humains.enabled = true;
            StartCoroutine("endMoveHumains");
        }
        BoardHighlights.Instance.Hidehighlights();
        selectedChessman            = null;
        message_tour_enfers.enabled = true;
        StartCoroutine("endMoveEnfers");
    }
Exemplo n.º 21
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans [x, y];

            if (c != null && c.isWhite != isWhiteTurn)
            {
                // CAPTURE A PIECE

                // IF IT IS THE KING
                if (c.GetType() == typeof(King))
                {
                    EndGame();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            if (x == EnPassantMove[0] && y == EnPassantMove[1])
            {
                c = Chessmans[x, isWhiteTurn ? y - 1 : y + 1];

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }
            EnPassantMove[0] = -1;
            EnPassantMove[1] = -1;
            if (selectedChessman.GetType() == typeof(Pawn))
            {
                if (y == 7)
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessman(1, x, y);
                    selectedChessman = Chessmans[x, y];
                }

                else if (y == 0)
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessman(7, x, y);
                }

                if (selectedChessman.CurrentY == 1 && y == 3)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y - 1;
                }
                else if (selectedChessman.CurrentY == 6 && y == 4)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y + 1;
                }
            }

            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;
            isWhiteTurn     = !isWhiteTurn;
        }

        selectedChessman.GetComponent <MeshRenderer>().material = previousMat;
        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
    }
Exemplo n.º 22
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];

            if (c != null && c.isWhite != isWhiteTurn)
            {
                //Capture a piece

                //If it is the king
                if (c.GetType() == typeof(King))
                {
                    EndGame();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            if (x == EnPassantMove[0] && y == EnPassantMove[1])
            {
                if (isWhiteTurn)
                {
                    c = Chessmans[x, y - 1];
                    activeChessman.Remove(c.gameObject);
                    Destroy(c.gameObject);
                }
                else
                {
                    c = Chessmans[x, y + 1];
                    activeChessman.Remove(c.gameObject);
                    Destroy(c.gameObject);
                }
            }
            EnPassantMove[0] = -1;
            EnPassantMove[1] = -1;
            if (selectedChessman.GetType() == typeof(Pawn))
            {
                if (y == 7)
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessman(1, x, y);
                    selectedChessman = Chessmans[x, y];
                }
                else if (y == 0)
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessman(7, x, y);
                    selectedChessman = Chessmans[x, y];
                }

                if (selectedChessman.CurrentY == 1 && y == 3)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y - 1;
                }
                else if (selectedChessman.CurrentY == 6 && y == 4)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y + 1;
                }
            }

            Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans [x, y] = selectedChessman;
            isWhiteTurn      = !isWhiteTurn;
        }
        BoardHighlights.Instance.Hidehighlights();
        selectedChessman = null;
    }
Exemplo n.º 23
0
    //kretnja figura
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];

            //Ako pojedemo figuru
            if (c != null && c.isWhite != isWhiteTurn)
            {
                //Kad pojedemo kralja
                if (c.GetType() == typeof(King))
                {
                    //Kraj igre
                    EndGame();
                    return;
                }

                //Unistavanje figura kad se pojedu
                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            //Enpassa
            if (x == EnPassantMove[0] && y == EnPassantMove[1])//Ako smo izveli enpasant
            {
                //Bijeli
                if (isWhiteTurn)
                {
                    c = Chessmans[x, y - 1];
                }
                //Crni
                else
                {
                    c = Chessmans[x, y + 1];
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }
            EnPassantMove[0] = -1;//Resetiranje funkcije
            EnPassantMove[1] = -1;

            if (selectedCehessman.GetType() == typeof(Pawn))
            {
                //Promotion
                //Bjeli
                if (y == 7)
                {
                    activeChessman.Remove(selectedCehessman.gameObject);
                    Destroy(selectedCehessman.gameObject);
                    SpawnChessman(1, x, y, whiteRot);
                    selectedCehessman = Chessmans[x, y];
                }
                //Crni
                else if (y == 0)
                {
                    activeChessman.Remove(selectedCehessman.gameObject);
                    Destroy(selectedCehessman.gameObject);
                    SpawnChessman(7, x, y, blackRot);
                    selectedCehessman = Chessmans[x, y];
                }

                //Bjeli
                if (selectedCehessman.CurrentY == 1 && y == 3)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y - 1;
                }
                //Crni
                else if (selectedCehessman.CurrentY == 6 && y == 4)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y + 1;
                }
            }

            Chessmans [selectedCehessman.CurrentX, selectedCehessman.CurrentY] = null;
            selectedCehessman.transform.position = GetTileCenter(x, y);
            selectedCehessman.SetPosition(x, y);
            Chessmans [x, y] = selectedCehessman;
            //Promjena reda
            isWhiteTurn = !isWhiteTurn;
        }

        selectedCehessman.GetComponent <MeshRenderer>().material = previousMat;

        //Sakrivanje plane objekta (sprjecavanje spawnanja vise kopija)
        BoardHighlights.Instance.HideHighlights();
        //Deselect ako kliknemo bilo gdje izvan moguceg odabira
        selectedCehessman = null;
    }
Exemplo n.º 24
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];

            if (c != null && c.isWhite != isWhiteTurn)
            {
                //Capture a piece
                activeChessPieces.Remove(c.gameObject);
                Destroy(c.gameObject);
                destroySound.Play();
            }

            // enpassant move
            if (x == EnPassantMove[0] && y == EnPassantMove[1])
            {
                if (isWhiteTurn)
                {
                    c = Chessmans[x, y - 1];
                }
                else
                {
                    c = Chessmans[x, y + 1];
                }

                activeChessPieces.Remove(c.gameObject);
                Destroy(c.gameObject);
                destroySound.Play();
            }
            EnPassantMove[0] = -1;
            EnPassantMove[1] = -1;
            if (selectedChessman.GetType() == typeof(Pawn))
            {
                // promote for white rook
                if (y == 7)
                {
                    activeChessPieces.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessPieces(0, x, y);
                    selectedChessman = Chessmans[x, y];
                    promotionSound.Play();
                }
                // promote for black rook
                else if (y == 0)
                {
                    activeChessPieces.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnChessPieces(2, x, y);
                    selectedChessman = Chessmans[x, y];
                    promotionSound.Play();
                }

                if (selectedChessman.CurrentY == 1 && y == 3)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y - 1;
                }
                else if (selectedChessman.CurrentY == 6 && y == 4)
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y + 1;
                }
            }

            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;
            isWhiteTurn     = !isWhiteTurn;
            moveSound.Play();
        }

        selectedChessman.GetComponent <MeshRenderer>().material = previousMat;
        BoardHighlights.Instance.HideHighlights();
        selectedChessman = null;
    }
Exemplo n.º 25
0
    public void MoveChessmanAI()
    {
        // Cancello l'highlight dell'ultima mossa
        BoardHighlights.Instance.Hidelastmove();

        // Posizione finale
        Chessman c = Chessmans[pendingX, pendingY];

        // Cattura pezzo
        if (c != null)
        {
            // Se è il re
            if (c.GetType() == typeof(King))
            {
                // End the game
                //EndGame();
                return;
            }

            activeChessman.Remove(c.gameObject);
            Destroy(c.gameObject);
            selectedChessman = null;
        }
        BoardHighlights.Instance.Hidelastmove();
        // Evidenzia la mossa
        bool[,] lastMove = new bool[8, 8];
        lastMove[selectionX, selectionY] = true;
        lastMove[pendingX, pendingY]     = true;
        BoardHighlights.Instance.HighlightLastMove(lastMove);
        // Partenza
        selectedChessman          = Chessmans[selectionX, selectionY];
        selectedChessman.CurrentX = selectionX;
        selectedChessman.CurrentY = selectionY;
        Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;

        // Arrocco
        if (selectedChessman.GetType() == typeof(KingUci) && canCastling_AI)
        {
            Castling_AI();
        }
        // EnPassant
        if (selectedChessman.GetType() == typeof(PawnUci) && c == null)
        {
            EnPassant_AI(pendingX, pendingY);
        }
        // Arrivo
        selectedChessman.transform.position = Utility.Instance.GetTileCenter(pendingX, pendingY);
        selectedChessman.SetPosition(pendingX, pendingY);
        Chessmans[pendingX, pendingY] = selectedChessman;

        // Cambio turno
        isPending   = false;
        isWhiteTurn = !isWhiteTurn;

        // Cambio Materiale
        previousMat             = selectedChessman.GetComponent <MeshRenderer>().material;
        selectedMat.mainTexture = previousMat.mainTexture;
        selectedChessman.GetComponent <MeshRenderer>().material = selectedMat;
        selectedChessman.GetComponent <MeshRenderer>().material = previousMat;

        // reset
        selectedChessman = null;
    }
Exemplo n.º 26
0
    public void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman opponent = Chessmans[x, y];

            if (opponent != null)
            {
                // Capture an opponent piece
                ActiveChessmans.Remove(opponent.gameObject);
                Destroy(opponent.gameObject);
            }
            // -------EnPassant Move Manager------------
            // If it is an EnPassant move than Destroy the opponent
            if (EnPassant[0] == x && EnPassant[1] == y && SelectedChessman.GetType() == typeof(Pawn))
            {
                if (isWhiteTurn)
                {
                    opponent = Chessmans[x, y + 1];
                }
                else
                {
                    opponent = Chessmans[x, y - 1];
                }

                ActiveChessmans.Remove(opponent.gameObject);
                Destroy(opponent.gameObject);
            }

            // Reset the EnPassant move
            EnPassant[0] = EnPassant[1] = -1;

            // Set EnPassant available for opponent
            if (SelectedChessman.GetType() == typeof(Pawn))
            {
                //-------Promotion Move Manager------------
                if (y == 7)
                {
                    ActiveChessmans.Remove(SelectedChessman.gameObject);
                    Destroy(SelectedChessman.gameObject);
                    SpawnChessman(10, new Vector3(x, 0, y));
                    SelectedChessman = Chessmans[x, y];
                }
                if (y == 0)
                {
                    ActiveChessmans.Remove(SelectedChessman.gameObject);
                    Destroy(SelectedChessman.gameObject);
                    SpawnChessman(4, new Vector3(x, 0, y));
                    SelectedChessman = Chessmans[x, y];
                }
                //-------Promotion Move Manager Over-------

                if (SelectedChessman.currentY == 1 && y == 3)
                {
                    EnPassant[0] = x;
                    EnPassant[1] = y - 1;
                }
                if (SelectedChessman.currentY == 6 && y == 4)
                {
                    EnPassant[0] = x;
                    EnPassant[1] = y + 1;
                }
            }
            // -------EnPassant Move Manager Over-------

            // -------Castling Move Manager------------
            // If the selectef chessman is King and is trying Castling move which needs two steps
            if (SelectedChessman.GetType() == typeof(King) && System.Math.Abs(x - SelectedChessman.currentX) == 2)
            {
                // King Side (towards (0, 0))
                if (x - SelectedChessman.currentX < 0)
                {
                    // Moving Rook1
                    Chessmans[x + 1, y] = Chessmans[x - 1, y];
                    Chessmans[x - 1, y] = null;
                    Chessmans[x + 1, y].SetPosition(x + 1, y);
                    Chessmans[x + 1, y].transform.position = new Vector3(x + 1, 0, y);
                    Chessmans[x + 1, y].isMoved            = true;
                }
                // Queen side (away from (0, 0))
                else
                {
                    // Moving Rook2
                    Chessmans[x - 1, y] = Chessmans[x + 2, y];
                    Chessmans[x + 2, y] = null;
                    Chessmans[x - 1, y].SetPosition(x - 1, y);
                    Chessmans[x - 1, y].transform.position = new Vector3(x - 1, 0, y);
                    Chessmans[x - 1, y].isMoved            = true;
                }
                // Note : King will move as a SelectedChessman by this function later
            }
            // -------Castling Move Manager Over-------

            Chessmans[SelectedChessman.currentX, SelectedChessman.currentY] = null;
            Chessmans[x, y] = SelectedChessman;
            SelectedChessman.SetPosition(x, y);
            SelectedChessman.transform.position = new Vector3(x, 0, y);
            SelectedChessman.isMoved            = true;
            isWhiteTurn = !isWhiteTurn;

            // to be deleted
            // printBoard();
        }

        // De-select the selected chessman
        SelectedChessman = null;
        // Disabling all highlights
        BoardHighlights.Instance.DisableAllHighlights();

        // ------- King Check Alert Manager -----------
        // Is it Check to the King
        // If now White King is in Check
        if (isWhiteTurn)
        {
            if (WhiteKing.InDanger())
            {
                BoardHighlights.Instance.SetTileCheck(WhiteKing.currentX, WhiteKing.currentY);
            }
        }
        // If now Black King is in Check
        else
        {
            if (BlackKing.InDanger())
            {
                BoardHighlights.Instance.SetTileCheck(BlackKing.currentX, BlackKing.currentY);
            }
        }
        // ------- King Check Alert Manager Over ----


        // Check if it is Checkmate
        isCheckmate();
    }
Exemplo n.º 27
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];

            if (c != null && c.isWhite != isWhiteTurn)
            {
                // Cattura pezzo

                // Se è il re
                if (c.GetType() == typeof(KingUci))
                {
                    // End the game
                    //EndGame();
                    return;
                }
                // Tolgo il pezzo
                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }

            // Prendo la posizione iniziale del pezzo
            initialX = selectedChessman.CurrentX;
            initialY = selectedChessman.CurrentY;

            string initial   = Utility.Instance.Translate(initialX, initialY);
            string ending    = Utility.Instance.Translate(x, y);
            string finalMove = initial + ending;
            Debug.Log(finalMove);
            //---MOSSE LEGALI---

            /*
             * if (!(IsLegal(finalMove)))
             * {
             *  Debug.Log("Mossa illegale!");
             *  return;
             * }*/

            // Metto a null la casa da cui muovo
            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            // Muovo effettivamente il pezzo
            selectedChessman.transform.position = Utility.Instance.GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;

            // Arrocco
            if (selectedChessman.GetType() == typeof(KingUci) && canCastling)
            {
                Castling(finalMove);
            }
            // Promozione
            if (selectedChessman.GetType() == typeof(PawnUci) && ending[1] == '8')
            {
                Promote(finalMove, x, y);
                return;
            }
            // EnPassant
            if (selectedChessman.GetType() == typeof(PawnUci) && c == null)
            {
                EnPassant(x, y);
            }

            // Invio la mossa al server
            Middleware.Instance.DoMove(finalMove);
            //Cambio turno
            isWhiteTurn = !isWhiteTurn;
        }
        // Togli l'evidenzia
        selectedChessman.GetComponent <MeshRenderer>().material = previousMat;
        // Eliminazione degli highlight
        BoardHighlights.Instance.Hidehighlights();

        selectedChessman = null;
    }
Exemplo n.º 28
0
    private void MoveChessman(int x, int y)
    {
        if (allowedMoves[x, y])
        {
            Chessman c = Chessmans[x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                //Capture/remove a piece after it has been killed

                //If the capture piece is a king , game ends!!
                if (c.GetType() == typeof(King))
                {
                    // Game over
                    GameOver();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }
            //EnPassant and Promotion rules are established here
            if (x == EnPassantMove[0] && y == EnPassantMove[1])
            {
                if (isWhiteTurn)
                {
                    c = Chessmans[x, y - 1];
                }
                else
                {
                    c = Chessmans[x, y + 1];
                }
                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }
            EnPassantMove[0] = -1;
            EnPassantMove[1] = -1;
            if (selectedChessman.GetType() == typeof(Pawn))
            {
                if (y == 7)  //white player pawn promotion conditions
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnPieces(1, x, y);
                    selectedChessman = Chessmans[x, y];
                }
                else if (y == 0)  //black player pawn promotion conditions
                {
                    activeChessman.Remove(selectedChessman.gameObject);
                    Destroy(selectedChessman.gameObject);
                    SpawnPieces(7, x, y);
                    selectedChessman = Chessmans[x, y];
                }

                if (selectedChessman.CurrentY == 1 && y == 3)   //for white player
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y - 1;
                }
                else if (selectedChessman.CurrentY == 6 && y == 4)  //for black player
                {
                    EnPassantMove[0] = x;
                    EnPassantMove[1] = y + 1;
                }
            }
            Chessmans [selectedChessman.CurrentX, selectedChessman.CurrentY] = null;
            selectedChessman.transform.position = GetTileCenter(x, y);

            selectedChessman.SetPosition(x, y);
            Chessmans[x, y] = selectedChessman;
            isWhiteTurn     = !isWhiteTurn;
        }

        selectedChessman.GetComponent <MeshRenderer>().material = previousMat;

        BoardFeedback.Instance.HideHighlights();       //not sure why this is an error, works in Unity
        selectedChessman = null;
    }
Exemplo n.º 29
0
    /// <summary>
    /// Сделать ход
    /// </summary>
    /// <param name="x">Координата X</param>
    /// <param name="y">Координата Y</param>
    private void MoveChessman(int x, int y)
    {
        // Можно ли сделать ход на выбранную клетку
        if (allowedMoves[x, y])
        {
            // На выбранной клетке нет фигур или есть фигура противоположного цвета
            Chessman c = Chessmans[x, y];
            if (c != null && c.isWhite != isWhiteTurn)
            {
                // На выбранной клетке стоит Король противоположного цвета
                if (c.GetType() == typeof(King))
                {
                    // Конец игры
                    activeChessman.Remove(c.gameObject);
                    Destroy(c.gameObject);
                    EndGame();
                    return;
                }

                activeChessman.Remove(c.gameObject);
                Destroy(c.gameObject);
            }


            // Ходит Король
            if (selectedChessman.GetType() == typeof(King) && ((King)selectedChessman).isRavirovka)
            {
                // Король больше не может рокироваться
                ((King)selectedChessman).isRavirovka = false;

                if (x == selectedChessman.CurrentX + 2) // Рокировка вправо
                {
                    Chessman rook = Chessmans[7, selectedChessman.CurrentY];
                    Chessmans[rook.CurrentX, rook.CurrentY] = null;
                    rook.transform.position = GetTileCenter(x - 1, y);
                    rook.SetPosition(x - 1, y);
                    Chessmans[x - 1, y] = rook;
                }
                else if (x == selectedChessman.CurrentX - 2) // Рокировка влево
                {
                    Chessman rook = Chessmans[0, selectedChessman.CurrentY];
                    Chessmans[rook.CurrentX, rook.CurrentY] = null;
                    rook.transform.position = GetTileCenter(x + 1, y);
                    rook.SetPosition(x + 1, y);
                    Chessmans[x + 1, y] = rook;
                }
            }
            // Ход Ладьёй
            else if (selectedChessman.GetType() == typeof(Rook) &&
                     ((Rook)selectedChessman).isRavirovka)
            {
                // Ладья больше не может рокироваться
                ((Rook)selectedChessman).isRavirovka = false;
            }


            // Переместить фигуру
            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null; // На выбранной клетке больше нет фигуры
            selectedChessman.transform.position = GetTileCenter(x, y);              // Переместить выбранную фигуру на новое место
            selectedChessman.SetPosition(x, y);                                     // Установить новое положение на доске у фиуры
            Chessmans[x, y] = selectedChessman;                                     // Установить на данной позиции новую фигуру

            // Замена пешки на другую фигуру, если она дошла до
            // противоположного края доски
            if (selectedChessman.GetType() == typeof(Pawn) &&
                (y == 7 || y == 0))
            {
                // Запомнить пешку, которую нужно заменить
                deleteChessman = selectedChessman;
                // Отобразить UI замены пешки
                ReplacePawn.gameIsPaused = true;
            }

            // Изменить условие, чей цвет ходит
            isWhiteTurn = !isWhiteTurn;
        }

        // Установить стандартный материал на выбранной фигуре
        selectedChessman.GetComponent <MeshRenderer>().material = previousMat;

        // Скрыть доступные ходы
        BoardHighLights.Instance.Hidehighlights();
        // Сбросить выделенную фигуру (никакая фигура не выбрана)
        selectedChessman = null;
    }
Exemplo n.º 30
0
    private void commitMove(int x, int y)
    {
        //ここから駒を消すとこ
        Chessman c = Chessmans[x, y];

        if (c != null && c.isWhite != isWhiteTurn)
        {
            //Capture a piece

            //王様について
            //If it is the king
            if (c.GetType() == typeof(ou))
            {
                EndGame();
                return;
            }

            activeChessman.Remove(c.gameObject);
            Destroy(c.gameObject);
        }
        //移動元をnullにする

        if (selectedChessman.CurrentY != -1)
        {
            Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null;

            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
        }
        else
        {
            maisuuInt[koma_id]--;

            if (maisuuInt[koma_id] != 0)
            {
                if (isWhiteTurn)
                {
                    GameObject motigoma = Instantiate(chessmanPrefabs[koma_id], selectedChessman.transform.position, orientation) as GameObject;
                    whiteKomadai[koma_id] = motigoma.GetComponent <Chessman>();
                    whiteKomadai[koma_id].SetPosition(-1, -1);
                }
                else
                {
                    GameObject motigoma = Instantiate(chessmanPrefabs[koma_id], selectedChessman.transform.position, orientation) as GameObject;
                    blackKomadai[koma_id] = motigoma.GetComponent <Chessman>();
                    blackKomadai[koma_id].SetPosition(-1, -1);
                }
            }
            if (maisuuInt[koma_id] <= 1)
            {
                Destroy(maisuuTexts[koma_id]);
            }
            else
            {
                maisuuTexts[koma_id].GetComponent <Text>().text = maisuuInt[koma_id].ToString();
            }
            selectedChessman.transform.position = GetTileCenter(x, y);
            selectedChessman.SetPosition(x, y);
        }

        //成り選択画面の後Chessmans[x, y] がnullになっている ※解決済み
        //Debug.Log(Chessmans[x, y] != null);
        if (Chessmans[x, y] != null)
        {
            int        koma_index;
            Chessman[] playerKomadai;
            GameObject komadaiObject;
            Vector3    komadaip;
            Vector3    maisuPos;


            if (isWhiteTurn)
            {
                koma_index = -1;
                if (Chessmans[x, y].GetType() == typeof(hisya))
                {
                    koma_index = 1;
                }
                if (Chessmans[x, y].GetType() == typeof(kaku))
                {
                    koma_index = 2;
                }
                if (Chessmans[x, y].GetType() == typeof(kin))
                {
                    koma_index = 3;
                }
                if (Chessmans[x, y].GetType() == typeof(gin))
                {
                    koma_index = 4;
                }
                if (Chessmans[x, y].GetType() == typeof(kei))
                {
                    koma_index = 5;
                }
                if (Chessmans[x, y].GetType() == typeof(kyou))
                {
                    koma_index = 6;
                }
                if (Chessmans[x, y].GetType() == typeof(hu))
                {
                    koma_index = 7;
                }
                if (Chessmans[x, y].GetType() == typeof(Ryuu))
                {
                    koma_index = 1;
                }
                if (Chessmans[x, y].GetType() == typeof(Uma))
                {
                    koma_index = 2;
                }
                if (Chessmans[x, y].GetType() == typeof(NariGin))
                {
                    koma_index = 4;
                }
                if (Chessmans[x, y].GetType() == typeof(NariKei))
                {
                    koma_index = 5;
                }
                if (Chessmans[x, y].GetType() == typeof(NariKyou))
                {
                    koma_index = 6;
                }
                if (Chessmans[x, y].GetType() == typeof(To))
                {
                    koma_index = 7;
                }
                playerKomadai = whiteKomadai;
                komadaiObject = komadai;

                komadaip = new Vector3(1.0f, 0f, -0.7f) + Vector3.right * (7 - koma_index);
                maisuPos = komadaip + new Vector3(0.2f, 0f, 0.5f);
            }
            else
            {
                koma_index = -1;
                if (Chessmans[x, y].GetType() == typeof(hisya))
                {
                    koma_index = 9;
                }
                if (Chessmans[x, y].GetType() == typeof(kaku))
                {
                    koma_index = 10;
                }
                if (Chessmans[x, y].GetType() == typeof(kin))
                {
                    koma_index = 11;
                }
                if (Chessmans[x, y].GetType() == typeof(gin))
                {
                    koma_index = 12;
                }
                if (Chessmans[x, y].GetType() == typeof(kei))
                {
                    koma_index = 13;
                }
                if (Chessmans[x, y].GetType() == typeof(kyou))
                {
                    koma_index = 14;
                }
                if (Chessmans[x, y].GetType() == typeof(hu))
                {
                    koma_index = 15;
                }
                if (Chessmans[x, y].GetType() == typeof(Ryuu))
                {
                    koma_index = 9;
                }
                if (Chessmans[x, y].GetType() == typeof(Uma))
                {
                    koma_index = 10;
                }
                if (Chessmans[x, y].GetType() == typeof(NariGin))
                {
                    koma_index = 12;
                }
                if (Chessmans[x, y].GetType() == typeof(NariKei))
                {
                    koma_index = 13;
                }
                if (Chessmans[x, y].GetType() == typeof(NariKyou))
                {
                    koma_index = 14;
                }
                if (Chessmans[x, y].GetType() == typeof(To))
                {
                    koma_index = 15;
                }
                playerKomadai = blackKomadai;
                komadaiObject = komadaiteki;
                komadaip      = new Vector3(1.0f, 0f, 9.7f) + Vector3.right * (koma_index - 8);
                maisuPos      = komadaip - new Vector3(0.2f, 0f, 0.5f);
            }

            {
                //playerKomadai[koma_index] = Chessmans[x, y];
                maisuuInt[koma_index]++;

                int maisuu = 0;

                /*foreach (Chessman koma in playerKomadai)
                 * {
                 *  if (koma.GetType() == Chessmans[x, y].GetType())
                 *      maisuu++;
                 * }*/
                maisuu = maisuuInt[koma_index];

                if (maisuu == 1)
                {
                    //Vector3 komadaip = komadaiObject.transform.position + Vector3.left * 1.2857f * koma_index * 0.5f + Vector3.right;
                    GameObject motigoma = Instantiate(chessmanPrefabs[koma_index], komadaip, orientation) as GameObject;
                    playerKomadai[koma_index] = motigoma.GetComponent <Chessman>();
                    playerKomadai[koma_index].SetPosition(-1, -1);
                }
                else if (maisuu == 2)
                {
                    GameObject text2 = GameObject.Find("Text");


                    //Vector3 maisuPos = new Vector3(1.2f, 0f, -0.2f) + Vector3.right * (7 - koma_index);
                    //Vector3 maisuPos = new Vector3(6.2f, 0f, -0.2f) + Vector3.right * 1.857f * (koma_index - 7) * 5f;

                    Vector3    maisuSize = new Vector3(0.0015f, 0.0015f, 0.0015f);
                    GameObject text      = Instantiate(textPrefab, maisuPos, text2.transform.rotation) as GameObject;
                    text.transform.localScale = maisuSize;
                    maisuuTexts[koma_index]   = text;
                    text.transform.SetParent(canvas.transform);
                    Text texttext = text.GetComponent <Text>();
                    texttext.text = maisuu.ToString();
                    if (!isWhiteTurn)
                    {
                        text.transform.Rotate(new Vector3(180, 180, 0));
                    }
                }
                else
                {
                    maisuuTexts[koma_index].GetComponent <Text>().text = maisuu.ToString();
                }
            }
        }



        Chessmans[x, y] = selectedChessman;
        isWhiteTurn     = !isWhiteTurn;
    }