Esempio n. 1
0
 // #nullable enable
 private GameObject GetFigureByType(FigureType figureType)
 {
     if (figureType == FigureType.pawn)
     {
         return(pawn);
     }
     if (figureType == FigureType.rook)
     {
         return(rook);
     }
     if (figureType == FigureType.queen)
     {
         return(queen);
     }
     if (figureType == FigureType.king)
     {
         return(king);
     }
     if (figureType == FigureType.knight)
     {
         return(knight);
     }
     if (figureType == FigureType.bishop)
     {
         return(bishop);
     }
     return(pawn);
 }
Esempio n. 2
0
 /// <summary>
 /// Конструктор образа - на основе входных данных для сенсоров, при этом можно указать класс образа, или не указывать
 /// </summary>
 /// <param name="inputValues"></param>
 /// <param name="sampleClass"></param>
 public Sample(double[] inputValues, FigureType sampleClass = FigureType.Undef)
 {
     //  Клонируем массивчик
     input           = (double[])inputValues.Clone();
     recognizedClass = FigureType.Undef;
     actualClass     = sampleClass;
 }
Esempio n. 3
0
 public void Initialize(Vector2 position, float scale, int zRotation, FigureType type)
 {
     transform.localPosition    = position;
     transform.localScale       = new Vector3(scale, scale, 1);
     transform.localEulerAngles = new Vector3(0, 0, zRotation);
     _figureType = type;
 }
Esempio n. 4
0
        public static Bitmap GetBitmapRepresentation(FigureType type, PlayerColor color)
        {
            switch (type)
            {
            case FigureType.Queen:
                return(color == PlayerColor.White ? WhiteQueenBitmap : BlackQueenBitmap);

            case FigureType.King:
                return(color == PlayerColor.White ? WhiteKingBitmap : BlackKingBitmap);

            case FigureType.Rook:
                return(color == PlayerColor.White ? WhiteRookBitmap : BlackRookBitmap);

            case FigureType.Knight:
                return(color == PlayerColor.White ? WhiteKnightBitmap : BlackKnightBitmap);

            case FigureType.Bishop:
                return(color == PlayerColor.White ? WhiteBishopBitmap : BlackBishopBitmap);

            case FigureType.Pawn:
                return(color == PlayerColor.White ? WhitePawnBitmap : BlackPawnBitmap);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 5
0
        public static string GetDescription(this FigureType figureType)
        {
            FieldInfo fi = figureType.GetType().GetField(figureType.ToString());

            DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
            return(attributes.Length > 0 ? attributes[0].Description : figureType.ToString());
        }
Esempio n. 6
0
 public Figure(FigureType type, byte owner, Pos cell, Pos?prevCell = null)
 {
     Type     = type;
     Owner    = owner;
     Cell     = cell;
     PrevCell = prevCell;
 }
Esempio n. 7
0
 private void SetupBlackFigures (FigureType[] figures, int[,] coordinates) {
     for (int i = 0; i < figures.Length; i++) {
         int x = coordinates[i, 0];
         int y = coordinates[i, 1];
         AddBlackFigure(figures[i], new IntVector2(x, y));
     }
 }
Esempio n. 8
0
 public Figure(int c, int r, FigureColor color, FigureType type = FigureType.NORMAL)
 {
     col   = c;
     row   = r;
     Color = color;
     Type  = type;
 }
Esempio n. 9
0
 public Figure(Figure copyFigure)
 {
     col   = copyFigure.col;
     row   = copyFigure.row;
     Color = copyFigure.Color;
     Type  = copyFigure.Type;
 }
    public static Vector3Int[] Get(FigureType type, int player)
    {
        switch (type)
        {
        case FigureType.Lazer:
            if (player == 1)
            {
                return new Vector3Int[1] {
                           Lazer
                }
            }
            ;
            else
            {
                return(Mul_Y_ToMinusOne(new Vector3Int[1] {
                    Lazer
                }));
            }

        case FigureType.Pillar:
            if (player == 1)
            {
                return new Vector3Int[1] {
                           Pillar
                }
            }
            ;
            else
            {
                return(Mul_Y_ToMinusOne(new Vector3Int[1] {
                    Pillar
                }));
            }

        case FigureType.Prizm:
            if (player == 1)
            {
                return(Prizm);
            }
            else
            {
                return(Mul_Y_ToMinusOne(Prizm));
            }

        case FigureType.Mirror:
            if (player == 1)
            {
                return(Mirror);
            }
            else
            {
                return(Mul_Y_ToMinusOne(Mirror));
            }

        default: return(new Vector3Int[1] {
                Vector3Int.zero
            });
        }
        ;
    }
Esempio n. 11
0
    public event BecameSuper BecameSuperEvent; //Callback когда фигура стала "дамкой"

    //Конструкторы
    public Figure()
    {
        col   = 0;
        row   = 0;
        Color = FigureColor.WHITE;
        Type  = FigureType.NORMAL;
    }
Esempio n. 12
0
        public static Shape Create(FigureType figureType)
        {
            switch (figureType)
            {
            case FigureType.Circle:
                return(CreateCircle());

            case FigureType.Disk:
                return(CreateDisk());

            case FigureType.Ring:
                return(CreateRing());

            case FigureType.Line:
                return(CreateLine());

            case FigureType.Triangle:
                return(CreateEquilateralTriangle());

            case FigureType.Rectangle:
                return(CreateRectangle());

            case FigureType.Square:
                return(CreateSquare());

            default: return(null);
            }
        }
Esempio n. 13
0
        private static void TryMoveFigure(Dictionary <char, Dictionary <char, char> > board, string start, string end)
        {
            char figureSymbol = board[start[0]][start[1]];

            if (figureSymbol == ' ')
            {
                Console.WriteLine("На стартовой точке нет фигуры. Нажмите любую клавишу, чтобы повторить...");
                return;
            }

            bool       isCorrect = false;
            FigureType figure    = (FigureType)figureSymbol;

            switch (figure)
            {
            case FigureType.Pawn:   TryMove(board, start, end, IsPawnCorrect, figure); break;

            case FigureType.Rook:   TryMove(board, start, end, IsRookCorrect, figure); break;

            case FigureType.Bishop: TryMove(board, start, end, IsBishopCorrect, figure); break;

            case FigureType.Knight: TryMove(board, start, end, IsKnightCorrect, figure); break;

            case FigureType.Queen:  TryMove(board, start, end, IsQueenCorrect, figure); break;

            case FigureType.King:   TryMove(board, start, end, IsKingCorrect, figure); break;
            }

            if (!isCorrect)
            {
                // Вывести ошибку
                return;
            }
        }
Esempio n. 14
0
        //----------------------------------------------------------------------------------------------------------------------------------------

        public ModelItem(Int32 aX, Int32 aY, Colors aColor, FigureType aFigureType)
        {
            x          = aX;
            y          = aY;
            figureItem = new FigureItem(aColor, aFigureType);
            index      = (aX * 8 + aY);
        }
Esempio n. 15
0
 public OneAttritube(int figure, AttributeData ad
                     , FigureType figureType = FigureType.basic)
 {
     this.figure = figure; this.index = (int)ad;
     this.isAD   = true;
     this.Type   = figureType;
 }
Esempio n. 16
0
    //Методы

    public void Move(MoveTobit move, ref Figure[,] board)
    {
        board[move.row, move.col] = this;
        board[row, col]           = null;
        col = move.col;
        row = move.row;
        if (move.haveKill)
        {
            board[move.delRow, move.delCol] = null;
        }
        if (Type == FigureType.SUPER)
        {
            return;
        }
        int rows = board.GetLength(0) - 1;

        if (Color == FigureColor.WHITE && row == rows)
        {
            Type = FigureType.SUPER;
        }
        if (Color == FigureColor.BLACK && row == 0)
        {
            Type = FigureType.SUPER;
        }
    }
Esempio n. 17
0
 public OneAttritube(int figure, StateTag ad
                     , FigureType figureType = FigureType.basic)
 {
     this.figure = figure; this.index = (int)ad;
     this.isAD   = false;
     this.Type   = figureType;
 }
Esempio n. 18
0
        public PartialViewResult FiguresMenu(FigureType figureType = FigureType.All)
        {
            FiguresMenuView figuresMenu = new FiguresMenuView()
            {
                Figures = new List <FigureMenuView>()
                {
                    new FigureMenuView()
                    {
                        Type = FigureType.Circle, Name = "Circle", ControllerName = "Circles"
                    },
                    new FigureMenuView()
                    {
                        Type = FigureType.Square, Name = "Square", ControllerName = "Squares"
                    },
                    new FigureMenuView()
                    {
                        Type = FigureType.Rectangle, Name = "Rectangle", ControllerName = "Rectangles"
                    }
                }
                ,
                SelectedFigureType = figureType
            };

            return(PartialView(figuresMenu));
        }
Esempio n. 19
0
        private static void ShowFigure(FigureType figureType, string delimeter)
        {
            switch (figureType)
            {
            case FigureType.King:
                Console.Write('K' + delimeter);
                break;

            case FigureType.Queen:
                Console.Write('Q' + delimeter);
                break;

            case FigureType.Rook:
                Console.Write('R' + delimeter);
                break;

            case FigureType.Bishop:
                Console.Write('B' + delimeter);
                break;

            case FigureType.Knight:
                Console.Write('N' + delimeter);
                break;

            case FigureType.Pawn:
                Console.Write('p' + delimeter);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(figureType), figureType, null);
            }
        }
Esempio n. 20
0
        private static void PawnMove(FigureType figure, Movements movement)
        {
            int dirX = 0, dirY = 0, pawnXCoordinate = -1, pawnYCoordinate = -1;

            FindFigure(figure, ref pawnXCoordinate, ref pawnYCoordinate);

            if (pawnXCoordinate == -1 || (!FigureFactory.IsPawn(figure)))
            {
                throw new IllegalMoveExeception();
            }

            DecodeMovement(movement, ref dirX, ref dirY);

            if (dirY == -1 || pawnXCoordinate + dirX < 0 || pawnXCoordinate + dirX > BoardSize - 1 ||
                pawnYCoordinate + dirY < 0 || pawnYCoordinate + dirY > BoardSize - 1)
            {
                throw new IllegalMoveExeception();
            }

            var figureToMove = ChessBoard[pawnXCoordinate + dirX, pawnYCoordinate + dirY];

            if (figureToMove == null || FigureFactory.IsKing(figureToMove))
            {
                ChessBoard[pawnXCoordinate + dirX, pawnYCoordinate + dirY] =
                    ChessBoard[pawnXCoordinate, pawnYCoordinate];

                ChessBoard[pawnXCoordinate, pawnYCoordinate] = null;
            }
            else
            {
                throw new IllegalMoveExeception();
            }
        }
Esempio n. 21
0
        protected MapItem()
        {
            _points = new List<Point>();
            _pointsInFigures = new List<int>();

            _visible = true;
            _syncronized = false;
            _type = FigureType.Point;
            _opacity = 1.0;
            _outlineVisible = false;
            _color = Colors.Black;
            _borderColor = Colors.Black;
            _borderOpacity = 1.0;
            _size = 0.25;
            _lineWidth = 1;
            _outlineWidth = 1;

            _style = new SymbolStyle
            {
                Symbol = _imageSuorce == null ? null : new Bitmap { Data = _imageSuorce },
                Line = new Pen(GetColor(_color, _opacity), (float)_lineWidth),
                Outline = new Pen(_outlineVisible ? GetColor(_borderColor, _opacity) : System.Drawing.Color.Transparent, OutlineVisible ? 1 : 0),
                Fill = new SolidBrush(GetColor(_color, _opacity)),
                SymbolScale = _size,
            };
        }
Esempio n. 22
0
 internal Figure(FigureColor color, FigureType type, Position position)
 {
     this.color = color;
     this.type = type;
     this.position = position;
     CalculateValidMoves(position);
 }
    public int GetCellValue(FigureType figureType, Vector2Int cell, bool white = true)
    {
        switch (figureType)
        {
        case FigureType.Pawn:
            //int value = white ? pawnBoardValues[cell.y * boardSize + cell.x] : pawnBoardMirroredValues[cell.y * boardSize + cell.x];
            //if(boardData.IsCellOccupied(boardData.GetFigureType(cell), cell) && (boardData.IsCellOccupied(white ? FigureType.Black : FigureType.White, cell))) {
            //    value += 30 * (white ? 1 : -1);
            //}
            //return value;
            return(white ? pawnBoardValues[cell.y * boardSize + cell.x] : pawnBoardMirroredValues[cell.y * boardSize + cell.x]);

        case FigureType.Rook:
            return(white ? rookBoardValues[cell.y * boardSize + cell.x] : rookBoardMirroredValues[cell.y * boardSize + cell.x]);

        case FigureType.Knight:
            return(white ? knightBoardValues[cell.y * boardSize + cell.x] : knightBoardMirroredValues[cell.y * boardSize + cell.x]);

        case FigureType.Bishop:
            return(white ? bishopBoardValues[cell.y * boardSize + cell.x] : bishopBoardMirroredValues[cell.y * boardSize + cell.x]);

        case FigureType.Queen:
            return(white ? queenBoardValues[cell.y * boardSize + cell.x] : queenBoardMirroredValues[cell.y * boardSize + cell.x]);

        case FigureType.King:
            return(white ? kingBoardMiddleGameValues[cell.y * boardSize + cell.x] : kingBoardMirroredMiddleGameValues[cell.y * boardSize + cell.x]);

        default:
            Debug.LogError("Illegal call to GetCellValue. You can call this only on figures.");
            break;
        }

        return(0);
    }
Esempio n. 24
0
    public void AssignTypeBehaviour(FigureType type)
    {
        switch (type)
        {
        case FigureType.Pawn:
            SetMoveBehaviour(new PawnMove());
            break;

        case FigureType.Rook:
            SetMoveBehaviour(new RookMove());
            break;

        case FigureType.Knight:
            SetMoveBehaviour(new KnightMove());
            break;

        case FigureType.Bishop:
            SetMoveBehaviour(new BishopMove());
            break;

        case FigureType.Queen:
            SetMoveBehaviour(new QueenMove());
            break;

        case FigureType.King:
            SetMoveBehaviour(new KingMove());
            break;
        }
        figureType = type;
    }
Esempio n. 25
0
 public Figure(FigureType type, int r, int c, Board b)
 {
     _figureType = type;
     _row        = r;
     _col        = c;
     _board      = b;
 }
    // TODO: Oh boy...
    // TODO: Castling
    // TODO: En passant https://en.wikipedia.org/wiki/En_passant
    // TODO: Pawn promotion
    public Vector2Int[] GetPossibleMoves(FigureType type, int col, int row, bool whitesTurn = true)
    {
        switch (type)
        {
        case FigureType.Pawn:
            return(GetPawnPossibleMoves(col, row, whitesTurn).ToArray());

        case FigureType.Rook:
            return(GetRookPossibleMoves(col, row, whitesTurn).ToArray());

        case FigureType.Knight:
            return(GetKnightPossibleMoves(col, row, whitesTurn).ToArray());

        case FigureType.Bishop:
            return(GetBishopPossibleMoves(col, row, whitesTurn).ToArray());

        case FigureType.Queen:
            return(GetQueenPossibleMoves(col, row, whitesTurn).ToArray());

        case FigureType.King:
            return(GetKingPossibleMoves(col, row, whitesTurn).ToArray());

        default:
            Debug.LogError("Illegal call to GetPossibleMoves. You can call this only on figures.");
            break;
        }
        return(new Vector2Int[0]);
    }
Esempio n. 27
0
        void DrawFigure(CairoContextEx gr, double x, double y, FigureType type)
        {
            double space_x, space_y;

            space_x = (rect_w - figure_size) / 2;
            space_y = (rect_h - figure_size) / 2;

            switch (type)
            {
            case FigureType.Triangle:
                gr.DrawEquilateralTriangle(x + space_x, y + space_y, figure_size);
                break;

            case FigureType.Square:
                gr.Rectangle(x + space_x, y + space_y, figure_size, figure_size);
                gr.Stroke();
                break;

            case FigureType.Pentagon:
                gr.DrawPentagon(x + space_x, y + space_y, figure_size);
                break;

            case FigureType.Circle:
                gr.Arc(x + space_x + figure_size / 2, y + space_y + figure_size / 2, figure_size / 2, 0, 2 * Math.PI);
                gr.Stroke();
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Esempio n. 28
0
    // TODO: Remove return bool
    // TODO: Look into this function to make it prettier
    public bool MoveFigure(Vector2Int from, Vector2Int to)
    {
        if (!IsCellOccupiedGlobal(from))
        {
            Debug.Log("There is no chess piece by coordinates X: " + from.x + ", Y: " + from.y);
            return(false);
        }

        // Get figure type and free the corresponding board
        FigureType type = GetFigureType(from);

        SetCellFree(type, from);

        // Cell with that figure type is free. Now only color left. Get Color and remove if from corresponding color board
        FigureType color = GetFigureType(from);

        SetCellFree(color, from);

        // Do the same but for the new coordinates so we remove any chess piece there is
        FigureType oldType = GetFigureType(to);

        SetCellFree(oldType, to);

        FigureType oldColor = GetFigureType(to);

        SetCellFree(oldColor, to);

        // Set figure and it's color to a new position
        SetCellOccupied(type, to);
        SetCellOccupied(color, to);

        CheckWinConditions(oldType, oldColor);
        return(true);
    }
Esempio n. 29
0
 public FigureStructure(BoardFirureId firureId, FigureType initialType, FigureType currentType, FigureTeamType teamType)
 {
     FirureId    = firureId;
     InitialType = initialType;
     CurrentType = currentType;
     TeamType    = teamType;
 }
Esempio n. 30
0
    public void OnPressCircle()
    {
        buttonCircle.interactable = false;
        buttonCross.interactable  = true;

        figure = FigureType.CIRCLE;
    }
Esempio n. 31
0
    // TODO: Make private
    // Added this function to improve readability of the code
    public ref long GetBoardByReference(FigureType boardType)
    {
        switch (boardType)
        {
        case FigureType.Pawn:
            return(ref pawnsBoard);

        case FigureType.Rook:
            return(ref rooksBoard);

        case FigureType.Knight:
            return(ref knightsBoard);

        case FigureType.Bishop:
            return(ref bishopsBoard);

        case FigureType.Queen:
            return(ref queensBoard);

        case FigureType.King:
            return(ref kingsBoard);

        case FigureType.White:
            return(ref whiteFiguresBoard);

        case FigureType.Black:
            return(ref blackFiguresBoard);

        case FigureType.Empty:
            break;
        }
        dummyBoard = 0L;
        return(ref dummyBoard);
    }
Esempio n. 32
0
 public Figure(FigureType type, char displaySymbol)
 {
     this.Type = type;
     this.DisplaySymbol = displaySymbol;
     this.Row = 0;
     this.Column = 0;
 }
Esempio n. 33
0
    private GameObject GetFigureToSpawn(int c, int r)
    {
        Vector2Int pos        = new Vector2Int(c, r);
        FigureType figureType = boardData.GetFigureType(pos);

        switch (figureType)
        {
        case FigureType.Pawn:
            return(boardData.IsCellOccupied(FigureType.White, pos) ? whiteFigurePrefabs.pawn : blackFigurePrefabs.pawn);

        case FigureType.Rook:
            return(boardData.IsCellOccupied(FigureType.White, pos) ? whiteFigurePrefabs.rook : blackFigurePrefabs.rook);

        case FigureType.Knight:
            return(boardData.IsCellOccupied(FigureType.White, pos) ? whiteFigurePrefabs.knight : blackFigurePrefabs.knight);

        case FigureType.Bishop:
            return(boardData.IsCellOccupied(FigureType.White, pos) ? whiteFigurePrefabs.bishop : blackFigurePrefabs.bishop);

        case FigureType.Queen:
            return(boardData.IsCellOccupied(FigureType.White, pos) ? whiteFigurePrefabs.queen : blackFigurePrefabs.queen);

        case FigureType.King:
            return(boardData.IsCellOccupied(FigureType.White, pos) ? whiteFigurePrefabs.king : blackFigurePrefabs.king);
        }

        return(null);
    }
Esempio n. 34
0
        public static Image GetFigureImage(PlayerType player, FigureType figure)
        {
            switch (player)
            {
            case PlayerType.WHITE:
                switch (figure)
                {
                case FigureType.PAWN:
                    return(Properties.Resources.wp);

                case FigureType.KNIGHT:
                    return(Properties.Resources.wn);

                case FigureType.BISHOP:
                    return(Properties.Resources.wb);

                case FigureType.ROOK:
                    return(Properties.Resources.wr);

                case FigureType.QUEEN:
                    return(Properties.Resources.wq);

                case FigureType.KING:
                    return(Properties.Resources.wk);

                default:
                    return(null);
                }
                ;

            case PlayerType.BLACK:
                switch (figure)
                {
                case FigureType.PAWN:
                    return(Properties.Resources.bp);

                case FigureType.KNIGHT:
                    return(Properties.Resources.bn);

                case FigureType.BISHOP:
                    return(Properties.Resources.bb);

                case FigureType.ROOK:
                    return(Properties.Resources.br);

                case FigureType.QUEEN:
                    return(Properties.Resources.bq);

                case FigureType.KING:
                    return(Properties.Resources.bk);

                default:
                    return(null);
                }
                ;

            default:
                return(null);
            }
        }
Esempio n. 35
0
 public Figure(FigureType t, int number, int player)
 {
     type        = t;
     direction   = 0;
     this.player = player;
     position    = DefaultFigurePositions.Get(type, player)[number];
 }
Esempio n. 36
0
 public FigureData(Velocity velocity, bool isMoved, Color borderColor, Rectangle area, FigureType type)
 {
     Velocity = velocity;
     IsMoved = isMoved;
     Area = area;
     BorderColor = borderColor;
     Type = type;
 }
Esempio n. 37
0
        public AnimationTaskItem(FigureType fig_p, Point from_p,
					  Point to_p)
        {
            fig = fig_p;
            from = from_p;
            to = to_p;
            progress = 0.0;
        }
Esempio n. 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Figure"/> class.
 /// </summary>
 /// <param name="id">The unique id of the figure.</param>
 /// <param name="type">The position type of the figure.</param>
 public Figure(int id, FigureType type)
 {
     Id = id;
     Corners = new List<FigurePoint>();
     path = new GraphicsPath();
     Type = type;
     LineStrength = 2;
 }
Esempio n. 39
0
 internal Bishop(FigureColor color, FigureType type, Position position)
     : base(color, type, position)
 {
     switch (color)
     {
         case FigureColor.Black:
             draw = "\u265D";
             break;
         case FigureColor.White:
             draw = "\u2657";
             break;
     }
 }
Esempio n. 40
0
 internal Knight(FigureColor color, FigureType type, Position position)
     : base(color, type, position)
 {
     switch (color)
     {
         case FigureColor.Black:
             draw = "\u265E";
             break;
         case FigureColor.White:
             draw = "\u2658";
             break;
     }
 }
Esempio n. 41
0
        public frmFlat(FigureType type,int side,int w=0,int h=0)
        {
            InitializeComponent();

            _side = side;
            _figureType= type;
            _w = w;
            _h = h;
            switch (_figureType) {
                case FigureType.square: this.Text ="Квадрат"; break;
                case FigureType.round: this.Text ="Круг"; break;
                case FigureType.rectangle: this.Text = "Прямоугольник"; break;
            }
        }
Esempio n. 42
0
    private void ConfigureBlack (FigureType figureType, GameObject figureObject) {
		Figure figureComponent = null;
		switch (figureType) {
		case FigureType.Pawn:
			figureObject.GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Sprites/Figures/Black/Pawn");
			figureComponent = figureObject.AddComponent<Pawn> ();
            figureComponent.Type = FigureType.Pawn;
            figureObject.name = "Black-Pawn";
			break;
		case FigureType.Bishop:
			figureObject.GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Sprites/Figures/Black/Bishop");
			figureComponent = figureObject.AddComponent<Bishop> ();
            figureComponent.Type = FigureType.Bishop;
            figureObject.name = "Black-Bishop";
            break;
		case FigureType.Rook:
			figureObject.GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Sprites/Figures/Black/Rook");
			figureComponent = figureObject.AddComponent<Rook> ();
            figureComponent.Type = FigureType.Rook;
            figureObject.name = "Black-Rook";
			break;
		case FigureType.King:
			figureObject.GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Sprites/Figures/Black/King");
			figureComponent = figureObject.AddComponent<King> ();
            figureComponent.Type = FigureType.King;
            figureObject.name = "Black-King";
			break;
		case FigureType.Knight:
			figureObject.GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Sprites/Figures/Black/Knight");
			figureComponent = figureObject.AddComponent<Knight> ();
            figureComponent.Type = FigureType.Knight;
            figureObject.name = "Black-Knight";
			break;
		case FigureType.Queen:
			figureObject.GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Sprites/Figures/Black/Queen");
			figureComponent = figureObject.AddComponent<Queen> ();
            figureComponent.Type = FigureType.Queen;
            figureObject.name = "Black-Queen";
			break;
		}
		figureComponent.FigureSide = GameSide.Black;
	}
Esempio n. 43
0
		private void DrawPiece (Cairo.Context cairo, FigureType fig,
					int x, int y, int size)
		{
			DrawPiece (cairo,
				   colors.ForegroundColor, fm,
				   fig, x, y, size);
		}
Esempio n. 44
0
 public void AddBlackFigure(FigureType figureType, IntVector2 coordinates) {
     GameObject figureObject = _figureFactory.GetBlackFigure(figureType, coordinates) as GameObject;
     Figure figureComponent = figureObject.GetComponent<Figure>();
     Tile owner = GetTile(coordinates);
     GameManager.TheFigureManager.RegisterFigure(figureComponent, owner);
 }    
Esempio n. 45
0
 /// <summary>
 /// Обработчик нажатий клавиш
 /// </summary>
 /// <param name="sender">источник</param>
 /// <param name="e">аргумент</param>
 private void glControl_KeyDown(object sender, KeyEventArgs e)
 {
     bool invalidate = true;
     switch (e.KeyCode)
     {
         case (Keys)219:
             if (scaleFactor > 0.3)
                 scaleFactor -= 0.1f;
             break;
         case (Keys)221:
             if (scaleFactor < 2.0)
                 scaleFactor += 0.1f;
             break;
         case Keys.D1:
             figureType = FigureType.MobiusStrip;
             BuildCoords(sizeWidth);
             break;
         case Keys.D2:
             figureType = FigureType.KleinBottle;
             BuildCoords(sizeWidth);
             break;
         case Keys.D3:
             figureType = FigureType.KleinBottle2;
             BuildCoords(sizeWidth);
             break;
         case Keys.R:
             additionalWireFrame = !additionalWireFrame;
             break;
         case Keys.Add:
             if (sizeWidth < 100)
                 BuildCoords(sizeWidth * 2);
             break;
         case Keys.Subtract:
             if (sizeWidth > 5)
                 BuildCoords(sizeWidth / 2);
             break;
         case Keys.E:
             tm.Enabled = !tm.Enabled;
             break;
         case Keys.W:
             viewAngleX += 1.0f;
             if (viewAngleX > maxAngle)
                 viewAngleX -= maxAngle;
             break;
         case Keys.S:
             viewAngleX -= 1.0f;
             if (viewAngleX < 0.0f)
                 viewAngleX += maxAngle;
             break;
         case Keys.Z:
             viewAngleZ += 1.0f;
             if (viewAngleZ > maxAngle)
                 viewAngleZ -= maxAngle;
             break;
         case Keys.X:
             viewAngleZ -= 1.0f;
             if (viewAngleZ < 0.0f)
                 viewAngleZ += maxAngle;
             break;
         case Keys.A:
             viewAngleY += 3.0f;
             if (viewAngleY > maxAngle)
                 viewAngleY -= maxAngle;
             break;
         case Keys.D:
             viewAngleY -= 3.0f;
             if (viewAngleY < 0.0f)
                 viewAngleY += maxAngle;
             break;
         case Keys.Q:
             wireFrame = !wireFrame;
             break;
         case Keys.T:
             if (opacity == 0.3f)
                 opacity = 0.6f;
             else if (opacity == 0.6f)
                 opacity = 1.0f;
             else opacity = 0.3f;
             break;
         case Keys.L:
             lighting = !lighting;
             break;
         default:
             invalidate = false;
             break;
     }
     if (invalidate)
     {
         e.Handled = true;
         glControl.Invalidate();
     }
 }
Esempio n. 46
0
 public MapItem GetItem(FigureType type)
 {
     switch (type)
     {
         case FigureType.Line:
             return new LineItem();
         case FigureType.MultiLine:
             return new MultiLineItem();
         case FigureType.MultiPolygon:
             return new MultiPolygonItem();
         case FigureType.Point:
             return new PointItem();
         case FigureType.Polygon:
             return new PolygonItem();
         default:
             return null;
     }
 }
Esempio n. 47
0
 public Figure(FigureColor color, FigureType type)
 {
     this.color = color;
     this.type = type;
 }
Esempio n. 48
0
 public GameObject GetWhiteFigure(FigureType figureType, IntVector2 coordinates) {
     GameObject figureObject = GetFigureObject(coordinates);
     ConfigureWhite(figureType, figureObject);
     return figureObject;
 }
Esempio n. 49
0
    public GameObject GetBlackFigure (FigureType figureType, IntVector2 coordinates) {
        GameObject figureObject = GetFigureObject(coordinates);
        ConfigureBlack (figureType, figureObject);
        return figureObject;
	}
Esempio n. 50
0
        public ArrayList SetPositionAnimate(ArrayList pos)
        {
            int i = 0, j = 0;
            int k = 0, l = 0;

            ArrayList result = new ArrayList ();

            FigureType[,] board_start = new FigureType[8, 8];
            FigureType[,] board_end = new FigureType[8, 8];

            for (i = 0; i < 8; i++)
                for (j = 0; j < 8; j++)
                    board_start[i, j] =
                        GetFigureAt (i, j);

            position = pos;

            for (i = 0; i < 8; i++)
                for (j = 0; j < 8; j++)
                    board_end[i, j] = GetFigureAt (i, j);

            for (i = 0; i < 8; i++)
                for (j = 0; j < 8; j++)
                  {

                      if (board_start[i, j] ==
                          board_end[i, j]
                          && board_start[i,
                                 j] !=
                          FigureType.None)
                        {
                            AnimationTaskItem item =
                                new
                                AnimationTaskItem
                                (board_start
                                 [i, j],
                                 new Point (i, j),
                                 new Point (i,
                                    j));

                            board_start[i, j] =
                                FigureType.None;
                            board_end[i, j] =
                                FigureType.None;
                            result.Add (item);
                        }
                  }

            bool finished = false;

            while (true)
              {

                  finished = true;

                  for (i = 0; i < 8; i++)
                    {
                        for (j = 0; j < 8; j++)
                          {
                              if (board_end[i, j] !=
                              FigureType.None)
                            {
                                finished =
                                    false;
                                break;
                            }
                          }
                        if (!finished)
                            break;
                    }

                  if (finished)
                      break;

                  bool found = false;
                  FigureType fig = board_end[i, j];

                  for (k = 0; k < 8; k++)
                    {
                        for (l = 0; l < 8; l++)
                          {
                              if (board_start[k, l] ==
                              fig)
                            {

                                found = true;
                                board_start[k,
                                        l]
                                    =
                                    FigureType.
                                    None;
                                break;

                            }
                          }
                        if (found)
                          {
                              break;
                          }
                    }

                  AnimationTaskItem item = null;

                  if (found)
                    {
                        item = new
                            AnimationTaskItem
                            (board_end[i, j],
                             new Point (k, l),
                             new Point (i, j));
                    }
                  else
                    {
                        item = new
                            AnimationTaskItem
                            (board_end[i, j],
                             new Point (k, l),
                             new Point (i, j));
                    }

                  board_end[i, j] = FigureType.None;

                  result.Add (item);
              }

            return result;
        }
Esempio n. 51
0
        public void Take(Point point)
        {
            takenFig = GetFigureAt (point.x, point.y);
            takenPosition = new ArrayList (position);

            string str = (string) position[point.y + 2];

            string str_new = str.Substring (0,
                            point.x * 2) + '.' +
                str.Substring (point.x * 2 + 1,
                           str.Length - point.x * 2 - 1);
            position[point.y + 2] = str_new;
        }
Esempio n. 52
0
 protected FigureData GetData(FigureType type)
 {
     return new FigureData(velocity, isMoved, borderColor, figureArea, type);
 }
Esempio n. 53
0
		public static void DrawPiece (Cairo.Context cairo,
					      FigureManager fm,
					      FigureType fig, int x, int y,
					      int size)
		{
			DrawPiece (cairo, new Cairo.Color (0, 0, 0, 1), fm,
				   fig, x, y, size);
		}
 public ArrayList GetPoints(FigureType type)
 {
     ArrayList list = (ArrayList) pointsMap[type];
     return list;
 }
Esempio n. 55
0
		public static void DrawPiece (Cairo.Context cairo,
					      Cairo.Color fill,
					      FigureManager fm,
					      FigureType fig, int x, int y,
					      int size)
		{
			//fill = new Cairo.Color (0, 0, 0, 1);

			ArrayList list = fm.GetPoints (fig);

			for (int i = 0; i < list.Count; i++)
			  {
				  SvgInfo info = (SvgInfo) list[i];
				  if (info.cmd == 'M')
				    {
					    cairo.MoveTo (x + info.x,
							  y + info.y);
					    continue;
				    }
				  else if (info.cmd == 'L')
				    {
					    cairo.LineTo (x + info.x,
							  y + info.y);
					    continue;
				    }
				  else if (info.cmd == 'z')
				    {
					    continue;
				    }

				  SvgInfo info2 = (SvgInfo) list[++i];
				  SvgInfo info3 = (SvgInfo) list[++i];

				  cairo.CurveTo (x + info.x, y + info.y,
						 x + info2.x, y + info2.y,
						 x + info3.x, y + info3.y);
			  }
			cairo.Color = fill;
			cairo.Fill ();
		}
Esempio n. 56
0
 public Pixbuf GetPixbuf(FigureType type)
 {
     return (Pixbuf) pixbufs[(int) type];
 }
        private Figure AddFigureToGame(FigureType figureType, char figureSymbol, int row, int column)
        {
            if (this.Figures.Where(f => f.DisplaySymbol == figureSymbol).Count()>0)
            {
                throw new FigureExistsException(string.Format("Figure {0} already exists!", figureSymbol));
            }

            var figure = new Figure(figureType, figureSymbol, row, column);
            Figures.Add(figure);

            return figure;
        }
Esempio n. 58
0
        void DrawFigure(CairoContextEx gr, double x, double y, FigureType type)
        {
            double space_x, space_y;

            space_x = (rect_w - figure_size) / 2;
            space_y = (rect_h - figure_size) / 2;

            switch (type) {
            case FigureType.Triangle:
                gr.DrawEquilateralTriangle (x + space_x, y + space_y, figure_size);
                break;
            case FigureType.Square:
                gr.Rectangle (x + space_x, y + space_y, figure_size, figure_size);
                gr.Stroke ();
                break;
            case FigureType.Pentagon:
                gr.DrawPentagon (x + space_x, y + space_y, figure_size);
                break;
            case FigureType.Circle:
                gr.Arc (x + space_x + figure_size / 2, y + space_y + figure_size / 2, figure_size / 2, 0, 2 * Math.PI);
                gr.Stroke ();
                break;
            default:
                throw new InvalidOperationException ();
            }
        }
Esempio n. 59
0
 public Figure(FigureType type, char displaySymbol, int row, int column)
     : this(type, displaySymbol)
 {
     this.Row = row;
     this.Column = column;
 }
Esempio n. 60
0
 internal string ToString(FigureType type)
 {
     switch (type) {
     case FigureType.Triangle:
         return Translations.GetString ("Triangle");
     case FigureType.Square:
         return Translations.GetString ("Square");
     case FigureType.Pentagon:
         return Translations.GetString ("Pentagon");
     case FigureType.Circle:
         return Translations.GetString ("Circle");
     default:
         throw new InvalidOperationException ();
     }
 }