protected override Piece initPiece(PieceLoadInfo loadInfo, int x, int y)
        {
            if (_inspectInfos == null)
            {
                _inspectInfos = new Dictionary <int, CoVidPlayerInspectInfo>();
                foreach (var playerInfo in coVidPlayers)
                {
                    _inspectInfos.Add(playerInfo.Id, playerInfo);
                }
            }

            var piece = base.initPiece(loadInfo, x, y);

            CoVidAttribute coVidAttribute = null;

            switch (loadInfo.PieceName)
            {
            case "pawn":
                coVidAttribute = new PawnCoVidAttribute();
                break;

            case "knight":
                coVidAttribute = new KnightCoVidAttribute();
                break;

            case "luke":
                coVidAttribute = new LukeCoVidAttribute();
                break;

            case "bishop":
                coVidAttribute = new BishopCoVidAttribute();
                break;

            case "queen":
                coVidAttribute = new QueenCoVidAttribute();
                break;

            case "king":
                coVidAttribute = new KingCoVidAttribute();
                break;
            }

            if (coVidAttribute != null)
            {
                piece.addAttribute(coVidAttribute);
                var coVidPlayer = _inspectInfos[loadInfo.Player.getId()].Player;
                piece.addAttribute(new StayHomeAttribute(coVidAttribute, coVidPlayer));
            }


            return(piece);
        }
Ejemplo n.º 2
0
        protected virtual Piece initPiece(PieceLoadInfo loadInfo, int x, int y)
        {
            var obj   = Instantiate(loadInfo.PiecePrefab, canvas, true);
            var piece = obj.GetComponent <PieceBase>();

            piece.initializePiece(loadInfo.Player);
            piece.moveTo(listBoard.getStartScreenPos(), listBoard.getSquareScale(), new BoardVector(x, y), 1);
            obj.GetComponent <Image>().color = loadInfo.Player.PlayerColor;
            loadInfo.Player.setPieceNum(loadInfo.Player.getPieceNum() + 1);

            if (piece.hasAttribute <PawnAttribute>())
            {
                piece.getAttribute <PawnAttribute>().setStartPos(new BoardVector(x, y));
            }

            return(piece);
        }