Пример #1
0
        void Start()
        {
            _thisTog.onValueChanged.AddListener((result) =>
            {
                if (_thisTog.isOn && isFirstSelect)
                {
                    ESelectStartColor selectStartColor = BoardManage.instance.presentPieces.eSelectSide;
                    var _remove = selectStartColor.Equals(ESelectStartColor.FirstColor) ? BoardManage.instance.chessManage.allPiecesFirstPlayers.Remove(BoardManage.instance.presentPieces) : BoardManage.instance.chessManage.allPiecesSecondPlayers.Remove(BoardManage.instance.presentPieces);
                    BoardManage.instance.presentTargetBox.ClearChild();
                    BasePieces _piece  = Instantiate(SelectPieces(), BoardManage.instance.presentTargetBox.transform);
                    _piece.eSelectSide = selectStartColor;

                    if (selectStartColor.Equals(ESelectStartColor.FirstColor))
                    {
                        _piece.meshRdr.material = BoardManage.instance.firstPlayerMat;
                        BoardManage.instance.chessManage.allPiecesFirstPlayers.Add(_piece);
                    }
                    else
                    {
                        _piece.meshRdr.material = BoardManage.instance.secondPlayerMat;
                        BoardManage.instance.chessManage.allPiecesSecondPlayers.Add(_piece);
                    }
                    EnchantPawn.CallBackSelectEnchant?.Invoke(false);
                }
                isFirstSelect = result;
            });
        }
Пример #2
0
        void PawnHottInstant(BasePieces pawnHott)
        {
            PawnHottSpawn(ESelectStartSide.FirstSide, new Vector2Int(0, 1), BoardManage.instance.firstPlayerMat, allPiecesFirstPlayers);    // PawnLineFirstPlayer
            PawnHottSpawn(ESelectStartSide.SecondSide, new Vector2Int(6, 7), BoardManage.instance.secondPlayerMat, allPiecesSecondPlayers); // PawnLineSecondPlayer
            void PawnHottSpawn(ESelectStartSide eSelectStartColor, Vector2Int slot, Material mat, List <BasePieces> basePieces)
            {
                for (int i = 0; i < BoardManage.instance.detailBoxes[slot.x].boxManages.Length; i++)
                {
                    if (i % 2 == 0)
                    {
                        BasePieces _pieces = Instantiate(pawnHott, BoardManage.instance.detailBoxes[slot.x].boxManages[i].transform);
                        _pieces.eSelectSide      = eSelectStartColor;
                        _pieces.meshRdr.material = mat;
                        basePieces.Add(_pieces);
                    }
                }

                for (int i = 0; i < BoardManage.instance.detailBoxes[slot.y].boxManages.Length; i++)
                {
                    if (i % 2 != 0)
                    {
                        BasePieces _pieces = Instantiate(pawnHott, BoardManage.instance.detailBoxes[slot.y].boxManages[i].transform);
                        _pieces.eSelectSide      = eSelectStartColor;
                        _pieces.meshRdr.material = mat;
                        basePieces.Add(_pieces);
                    }
                }
            }
        }
Пример #3
0
        void SpawnPieceSingle(ESelectStartSide eSelectStartColor, BasePieces piece, Vector2Int slot, Material mat, List <BasePieces> basePieces)
        {
            Spawn(BoardManage.instance.detailBoxes[slot.x].boxManages[slot.y].transform);
            void Spawn(Transform parentPiece)
            {
                BasePieces _pieces = Instantiate(piece, parentPiece);

                _pieces.eSelectSide      = eSelectStartColor;
                _pieces.meshRdr.material = mat;
                basePieces.Add(_pieces);
            }
        }
Пример #4
0
 void PawnInstanc(BasePieces pawn)
 {
     PawnSpawn(ESelectStartSide.FirstSide, 1, BoardManage.instance.firstPlayerMat, allPiecesFirstPlayers);    // PawnLineFirstPlayer
     PawnSpawn(ESelectStartSide.SecondSide, 6, BoardManage.instance.secondPlayerMat, allPiecesSecondPlayers); // PawnLineSecondPlayer
     void PawnSpawn(ESelectStartSide eSelectStartColor, int slot, Material mat, List <BasePieces> basePieces)
     {
         for (int i = 0; i < BoardManage.instance.detailBoxes[slot].boxManages.Length; i++)
         {
             BasePieces _pieces = Instantiate(pawn, BoardManage.instance.detailBoxes[slot].boxManages[i].transform);
             _pieces.eSelectSide      = eSelectStartColor;
             _pieces.meshRdr.material = mat;
             basePieces.Add(_pieces);
         }
     }
 }
Пример #5
0
        void CheckSide(Vector2Int slot)
        {
            BasePieces _piece = BoardManage.instance.detailBoxes[slot.x].boxManages[slot.y].GetPieces();

            if (!_piece)
            {
                _allSlot.Add(new Vector2Int(slot.x, slot.y));
            }
            else
            {
                if (!_piece.eSelectSide.Equals(_side))
                {
                    _allSlot.Add(new Vector2Int(slot.x, slot.y));
                }
            }
        }
Пример #6
0
        void HottMove(bool isChanningEat = false)
        {
            int _slotX = 1;
            int _slotY = 1;

            // UpLeft
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x + _slotX))
            {
                int _slotUpX = _slot.x + _slotX;
                int _slotUpY = _slot.y - _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        if (!isChanningEat)
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }
                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        int _lenghtX = _slot.x + (_slotX + 1);
                        int _lenghtY = _slot.y - (_slotY + 1);
                        if (!_piece.eSelectSide.Equals(_side) && BoardManage.instance.detailBoxes.CheckOutOfRange(_lenghtX))
                        {
                            if (BoardManage.instance.detailBoxes[_lenghtX].boxManages.CheckOutOfRange(_lenghtY))
                            {
                                if (BoardManage.instance.detailBoxes[_lenghtX].boxManages[_lenghtY].transform.childCount <= 0)
                                {
                                    BoardManage.instance.checkersManage.tempEatUpLeft = _piece;
                                    _allSlot.Add(new Vector2Int(_lenghtX, _lenghtY));
                                }
                            }
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            _slotX = 1;
            _slotY = 1;
            // UpRight
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x + _slotX))
            {
                int _slotUpX = _slot.x + _slotX;
                int _slotUpY = _slot.y + _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        if (!isChanningEat)
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }
                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        int _lenghtX = _slot.x + (_slotX + 1);
                        int _lenghtY = _slot.y + (_slotY + 1);
                        if (!_piece.eSelectSide.Equals(_side) && BoardManage.instance.detailBoxes.CheckOutOfRange(_lenghtX))
                        {
                            if (BoardManage.instance.detailBoxes[_lenghtX].boxManages.CheckOutOfRange(_lenghtY))
                            {
                                if (BoardManage.instance.detailBoxes[_lenghtX].boxManages[_lenghtY].transform.childCount <= 0)
                                {
                                    BoardManage.instance.checkersManage.tempEatUpRight = _piece;
                                    _allSlot.Add(new Vector2Int(_lenghtX, _lenghtY));
                                }
                            }
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            _slotX = 1;
            _slotY = 1;
            // DownLeft
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x - _slotX))
            {
                int _slotUpX = _slot.x - _slotX;
                int _slotUpY = _slot.y - _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        if (!isChanningEat)
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }

                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        int _lenghtX = _slot.x - (_slotX + 1);
                        int _lenghtY = _slot.y - (_slotY + 1);
                        if (!_piece.eSelectSide.Equals(_side) && BoardManage.instance.detailBoxes.CheckOutOfRange(_lenghtX))
                        {
                            if (BoardManage.instance.detailBoxes[_lenghtX].boxManages.CheckOutOfRange(_lenghtY))
                            {
                                if (BoardManage.instance.detailBoxes[_lenghtX].boxManages[_lenghtY].transform.childCount <= 0)
                                {
                                    BoardManage.instance.checkersManage.tempEatDownLeft = _piece;
                                    _allSlot.Add(new Vector2Int(_lenghtX, _lenghtY));
                                }
                            }
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            _slotX = 1;
            _slotY = 1;
            // DownRight
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x - _slotX))
            {
                int _slotUpX = _slot.x - _slotX;
                int _slotUpY = _slot.y + _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        if (!isChanningEat)
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }
                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        int _lenghtX = _slot.x - (_slotX + 1);
                        int _lenghtY = _slot.y + (_slotY + 1);
                        if (!_piece.eSelectSide.Equals(_side) && BoardManage.instance.detailBoxes.CheckOutOfRange(_lenghtX))
                        {
                            if (BoardManage.instance.detailBoxes[_lenghtX].boxManages.CheckOutOfRange(_lenghtY))
                            {
                                if (BoardManage.instance.detailBoxes[_lenghtX].boxManages[_lenghtY].transform.childCount <= 0)
                                {
                                    BoardManage.instance.checkersManage.tempEatDownRight = _piece;
                                    _allSlot.Add(new Vector2Int(_lenghtX, _lenghtY));
                                }
                            }
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }
        }
Пример #7
0
        void BishopMove()
        {
            int _slotX = 1;
            int _slotY = 1;

            // UpLeft
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x + _slotX))
            {
                int _slotUpX = _slot.x + _slotX;
                int _slotUpY = _slot.y - _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        if (!_piece.eSelectSide.Equals(_side))
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            _slotX = 1;
            _slotY = 1;
            // UpRight
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x + _slotX))
            {
                int _slotUpX = _slot.x + _slotX;
                int _slotUpY = _slot.y + _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        if (!_piece.eSelectSide.Equals(_side))
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            _slotX = 1;
            _slotY = 1;
            // DownLeft
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x - _slotX))
            {
                int _slotUpX = _slot.x - _slotX;
                int _slotUpY = _slot.y - _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        if (!_piece.eSelectSide.Equals(_side))
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            _slotX = 1;
            _slotY = 1;
            // DownRight
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x - _slotX))
            {
                int _slotUpX = _slot.x - _slotX;
                int _slotUpY = _slot.y + _slotY;

                if (BoardManage.instance.detailBoxes[_slotUpX].boxManages.CheckOutOfRange(_slotUpY))
                {
                    BasePieces _piece = BoardManage.instance.detailBoxes[_slotUpX].boxManages[_slotUpY].GetPieces();
                    if (!_piece)
                    {
                        _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        _slotX++;
                        _slotY++;
                    }
                    else
                    {
                        if (!_piece.eSelectSide.Equals(_side))
                        {
                            _allSlot.Add(new Vector2Int(_slotUpX, _slotUpY));
                        }

                        break;
                    }
                }
                else
                {
                    break;
                }
            }
        }
Пример #8
0
        void RookMove()
        {
            int _slotX = 1;
            int _slotY = 1;

            //Check UP
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x + _slotX))
            {
                int        _slotUp = _slot.x + _slotX;
                BasePieces _piece  = BoardManage.instance.detailBoxes[_slotUp].boxManages[_slot.y].GetPieces();
                if (!_piece)
                {
                    _allSlot.Add(new Vector2Int(_slotUp, _slot.y));
                    _slotX++;
                }
                else
                {
                    if (!_piece.eSelectSide.Equals(_side))
                    {
                        _allSlot.Add(new Vector2Int(_slotUp, _slot.y));
                    }

                    break;
                }
            }
            //Check Down
            _slotX = 1;
            while (BoardManage.instance.detailBoxes.CheckOutOfRange(_slot.x - _slotX))
            {
                int        _slotDown = _slot.x - _slotX;
                BasePieces _piece    = BoardManage.instance.detailBoxes[_slotDown].boxManages[_slot.y].GetPieces();
                if (!_piece)
                {
                    _allSlot.Add(new Vector2Int(_slotDown, _slot.y));
                    _slotX++;
                }
                else
                {
                    if (!_piece.eSelectSide.Equals(_side))
                    {
                        _allSlot.Add(new Vector2Int(_slotDown, _slot.y));
                    }

                    break;
                }
            }
            //Check Right
            while (BoardManage.instance.detailBoxes[_slot.x].boxManages.CheckOutOfRange(_slot.y + _slotY))
            {
                int        _slotRight = _slot.y + _slotY;
                BasePieces _piece     = BoardManage.instance.detailBoxes[_slot.x].boxManages[_slotRight].GetPieces();
                if (!_piece)
                {
                    _allSlot.Add(new Vector2Int(_slot.x, _slotRight));
                    _slotY++;
                }
                else
                {
                    if (!_piece.eSelectSide.Equals(_side))
                    {
                        _allSlot.Add(new Vector2Int(_slot.x, _slotRight));
                    }

                    break;
                }
            }
            //Check Left
            _slotY = 1;
            while (BoardManage.instance.detailBoxes[_slot.x].boxManages.CheckOutOfRange(_slot.y - _slotY))
            {
                int        _slotRight = _slot.y - _slotY;
                BasePieces _piece     = BoardManage.instance.detailBoxes[_slot.x].boxManages[_slotRight].GetPieces();
                if (!_piece)
                {
                    _allSlot.Add(new Vector2Int(_slot.x, _slotRight));
                    _slotY++;
                }
                else
                {
                    if (!_piece.eSelectSide.Equals(_side))
                    {
                        _allSlot.Add(new Vector2Int(_slot.x, _slotRight));
                    }

                    break;
                }
            }
        }
Пример #9
0
 void KingInstance(BasePieces king)
 {
     SpawnPieceSingle(ESelectStartSide.FirstSide, king, new Vector2Int(0, 4), BoardManage.instance.firstPlayerMat, allPiecesFirstPlayers);    // RookLineFirstPlayer
     SpawnPieceSingle(ESelectStartSide.SecondSide, king, new Vector2Int(7, 4), BoardManage.instance.secondPlayerMat, allPiecesSecondPlayers); // RookLineSecondPlayer
 }
Пример #10
0
 void QueenInstance(BasePieces queen)
 {
     SpawnPieceSingle(ESelectStartSide.FirstSide, queen, new Vector2Int(0, 3), BoardManage.instance.firstPlayerMat, allPiecesFirstPlayers);    // RookLineFirstPlayer
     SpawnPieceSingle(ESelectStartSide.SecondSide, queen, new Vector2Int(7, 3), BoardManage.instance.secondPlayerMat, allPiecesSecondPlayers); // RookLineSecondPlayer
 }
Пример #11
0
 void BishopInstance(BasePieces bishop)
 {
     SpawnPieceTwin(ESelectStartSide.FirstSide, bishop, new Vector2Int(0, 2), new Vector2Int(0, 5), BoardManage.instance.firstPlayerMat, allPiecesFirstPlayers);    // RookLineFirstPlayer
     SpawnPieceTwin(ESelectStartSide.SecondSide, bishop, new Vector2Int(7, 2), new Vector2Int(7, 5), BoardManage.instance.secondPlayerMat, allPiecesSecondPlayers); // RookLineSecondPlayer
 }
Пример #12
0
 void KnightInstanc(BasePieces knight)
 {
     SpawnPieceTwin(ESelectStartSide.FirstSide, knight, new Vector2Int(0, 1), new Vector2Int(0, 6), BoardManage.instance.firstPlayerMat, allPiecesFirstPlayers);    // RookLineFirstPlayer
     SpawnPieceTwin(ESelectStartSide.SecondSide, knight, new Vector2Int(7, 1), new Vector2Int(7, 6), BoardManage.instance.secondPlayerMat, allPiecesSecondPlayers); // RookLineSecondPlayer
 }
Пример #13
0
 void RookInstanc(BasePieces rook)
 {
     SpawnPieceTwin(ESelectStartSide.FirstSide, rook, Vector2Int.zero, new Vector2Int(0, 7), BoardManage.instance.firstPlayerMat, allPiecesFirstPlayers);         // RookLineFirstPlayer
     SpawnPieceTwin(ESelectStartSide.SecondSide, rook, new Vector2Int(7, 0), new Vector2Int(7, 7), BoardManage.instance.secondPlayerMat, allPiecesSecondPlayers); // RookLineSecondPlayer
 }