예제 #1
0
    protected virtual void InitBoardItems()
    {
        UnityCustoms.DestroyAllChilds(board_items_parent = GameObject.Find(ChessConstants.BoardItemsObjectName));
        UnityCustoms.DestroyGameObjects(ChessConstants.BoardItemsObjectName);
        board_items_parent = new GameObject(ChessConstants.BoardItemsObjectName);
        board_items_parent.transform.SetParent(GameObject.Find(ChessConstants.BoardObjectName).transform);

        boardItemsMono = new List <BoardItemMonoBase>();

        for (int i = 0; i < boardSizeX; i++)
        {
            for (int j = 0; j < boardSizeY; j++)
            {
                GameObject item_obj = GameObject.Instantiate(
                    (i + j) % 2 == 0 ? MainMenu.Singleton.GetCurrentBoardPrefabs().dark_board_item : MainMenu.Singleton.GetCurrentBoardPrefabs().bright_board_item) as GameObject;
                item_obj.name = "board_item_x_" + i + "_y_" + j;

                BoardItemMono item_scr = item_obj.GetComponent <BoardItemMono>();
                item_scr.SetPosition(new Vector2Int(i, j));
                boardItemsMono.Add(item_scr);
                item_obj.transform.SetParent(board_items_parent.transform);
                item_obj.transform.position = GetBoardPosition(i, j);
                UnityCustoms.SetSpriteRendererObjectSize(item_obj, boardSpriteSize);
            }
        }
    }
예제 #2
0
    protected override void InitBoardItems()
    {
        UnityCustoms.DestroyAllChilds(board_items_parent = GameObject.Find(ChessConstants.BoardItemsObjectName));
        UnityCustoms.DestroyGameObjects(ChessConstants.BoardItemsObjectName);
        board_items_parent = new GameObject(ChessConstants.BoardItemsObjectName);
        board_items_parent.transform.SetParent(GameObject.Find(ChessConstants.BoardObjectName).transform);

        boardItemsMono = new List <BoardItemMonoBase>();

        for (int i = 0; i < boardSizeX; i++)
        {
            for (int j = 0; j < boardSizeY; j++)
            {
                GameObject item_obj = new GameObject("board_item_x_" + i + "_y_" + j);
                var        item_scr = item_obj.AddComponent <BoardItemMonoCircled>();
                item_scr.SetPosition(new Vector2Int(i, j));
                boardItemsMono.Add(item_scr);
                item_obj.transform.SetParent(board_items_parent.transform);
                //item_obj.transform.position = GetBoardPosition(i, j);
                UnityCustoms.SetSpriteRendererObjectSize(item_obj, boardSpriteSize);
            }
        }
    }
예제 #3
0
    public void RecoveryChessItem(ChessItemProperties props)
    {
        GameObject chess_obj = null;

        if (!props.isNullObject)
        {
            if (new byte[]
            {
                (byte)ClassicChessItemType.pawn,
                (byte)LosAlamosChessItemType.pawn,
                (byte)ChaturangaChessItemType.pawn,
                (byte)CircledChessItemType.pawn_left,
                (byte)CircledChessItemType.pawn_right
            }.Contains(props.type))
            {
                chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].pawn) as GameObject;
                chess_obj.name = props.side.ToString() + "_chess_";
            }
            else if (new byte[]
            {
                (byte)ClassicChessItemType.rook,
                (byte)LosAlamosChessItemType.rook,
                (byte)ChaturangaChessItemType.rook,
                (byte)CircledChessItemType.rook
            }.Contains(props.type))
            {
                chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].rook) as GameObject;
                chess_obj.name = props.side.ToString() + "_chess_";
            }
            else if (new byte[]
            {
                (byte)ClassicChessItemType.knight,
                (byte)LosAlamosChessItemType.knight,
                (byte)ChaturangaChessItemType.knight,
                (byte)CircledChessItemType.knight
            }.Contains(props.type))
            {
                chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].knight) as GameObject;
                chess_obj.name = props.side.ToString() + "_chess_";
            }
            else if (new byte[]
            {
                (byte)ClassicChessItemType.bishop,
                (byte)CircledChessItemType.bishop
            }.Contains(props.type))
            {
                chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].bishop) as GameObject;
                chess_obj.name = props.side.ToString() + "_chess_";
            }
            else if (new byte[]
            {
                (byte)ClassicChessItemType.queen,
                (byte)LosAlamosChessItemType.queen,
                (byte)ChaturangaChessItemType.queen,
                (byte)CircledChessItemType.queen
            }.Contains(props.type))
            {
                chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].queen) as GameObject;
                chess_obj.name = props.side.ToString() + "_chess_";
            }
            else if (new byte[]
            {
                (byte)ClassicChessItemType.king,
                (byte)LosAlamosChessItemType.king,
                (byte)ChaturangaChessItemType.king,
                (byte)CircledChessItemType.king
            }.Contains(props.type))
            {
                chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].king) as GameObject;
                chess_obj.name = props.side.ToString() + "_chess_";
            }

            ChessItemMono chess_scr = chess_obj.GetComponent <ChessItemMono>();
            chess_scr.props = props;
            chessItemsMono.Add(chess_scr);
            chess_obj.transform.SetParent(board_items_parent.transform);
            Vector3 pos = GetBoardPosition(props.pos.x, props.pos.y);
            chess_obj.transform.position = new Vector3(pos.x, pos.y, pos.z - 0.1f);

            UnityCustoms.SetSpriteRendererObjectSize(chess_obj, boardSpriteSize);
            chess_scr.RecoveryFigure();
        }
    }
예제 #4
0
    protected virtual void InitChessItems()
    {
        UnityCustoms.DestroyAllChilds(chess_items_parent = GameObject.Find(ChessConstants.ChessItemsObjectName));
        UnityCustoms.DestroyGameObjects(ChessConstants.ChessItemsObjectName);
        chess_items_parent = new GameObject(ChessConstants.ChessItemsObjectName);
        chess_items_parent.transform.SetParent(GameObject.Find(ChessConstants.BoardObjectName).transform);

        chessItemsMono = new List <ChessItemMonoBase>();
        int idx = 0;

        for (int i = 0; i < boardSizeX; i++)
        {
            for (int j = 0; j < boardSizeY; j++)
            {
                GameObject          chess_obj = null;
                ChessItemProperties props     = board[i, j];
                if (!props.isNullObject)
                {
                    if (new byte[]
                    {
                        (byte)ClassicChessItemType.pawn,
                        (byte)LosAlamosChessItemType.pawn,
                        (byte)ChaturangaChessItemType.pawn,
                    }.Contains(props.type))
                    {
                        chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].pawn) as GameObject;
                        chess_obj.name = props.side.ToString() + "_chess_" + idx++;
                    }
                    else if (new byte[]
                    {
                        (byte)ClassicChessItemType.rook,
                        (byte)LosAlamosChessItemType.rook,
                        (byte)ChaturangaChessItemType.rook,
                    }.Contains(props.type))
                    {
                        chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].rook) as GameObject;
                        chess_obj.name = props.side.ToString() + "_chess_" + idx++;
                    }
                    else if (new byte[]
                    {
                        (byte)ClassicChessItemType.knight,
                        (byte)LosAlamosChessItemType.knight,
                        (byte)ChaturangaChessItemType.knight,
                    }.Contains(props.type))
                    {
                        chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].knight) as GameObject;
                        chess_obj.name = props.side.ToString() + "_chess_" + idx++;
                    }
                    else if (new byte[]
                    {
                        (byte)ClassicChessItemType.bishop,
                    }.Contains(props.type))
                    {
                        chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].bishop) as GameObject;
                        chess_obj.name = props.side.ToString() + "_chess_" + idx++;
                    }
                    else if (new byte[]
                    {
                        (byte)ClassicChessItemType.queen,
                        (byte)LosAlamosChessItemType.queen,
                        (byte)ChaturangaChessItemType.queen,
                    }.Contains(props.type))
                    {
                        chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].queen) as GameObject;
                        chess_obj.name = props.side.ToString() + "_chess_" + idx++;
                    }
                    else if (new byte[]
                    {
                        (byte)ClassicChessItemType.king,
                        (byte)LosAlamosChessItemType.king,
                        (byte)ChaturangaChessItemType.king,
                    }.Contains(props.type))
                    {
                        chess_obj      = GameObject.Instantiate(MainMenu.Singleton.GetCurrentBoardPrefabs().chessPackList[(byte)props.side].king) as GameObject;
                        chess_obj.name = props.side.ToString() + "_chess_" + idx++;
                    }


                    ChessItemMonoBase chess_scr = chess_obj.GetComponent <ChessItemMono>();
                    chess_scr.props = props;
                    chessItemsMono.Add(chess_scr);
                    chess_obj.transform.SetParent(chess_items_parent.transform);
                    Vector3 pos = GetBoardPosition(i, j);
                    chess_obj.transform.position = new Vector3(pos.x, pos.y, pos.z - 0.1f);
                    UnityCustoms.SetSpriteRendererObjectSize(chess_obj, boardSpriteSize);
                }
            }
        }
    }