Exemplo n.º 1
0
        public static Vec2 MoveFigure(Vec2 from, FigureMoveType figureMoveType)
        {
            var new_position = from;

            switch (figureMoveType)
            {
            case FigureMoveType.Left:
                new_position.x--;
                break;

            case FigureMoveType.Top:
                new_position.y++;
                break;

            case FigureMoveType.Right:
                new_position.x++;
                break;

            case FigureMoveType.Bottom:
                new_position.y--;
                break;

            default:
                throw new System.NotImplementedException("Move function not implemented completely!");
            }

            return(new_position);
        }
Exemplo n.º 2
0
        public bool TryMoveFigure(Vec2 from, FigureMoveType figureMoveType)
        {
            Vec2 to = from;

            switch (figureMoveType)
            {
            case FigureMoveType.Left:
                to.x--;
                break;

            case FigureMoveType.Top:
                to.y++;
                break;

            case FigureMoveType.Right:
                to.x++;
                break;

            case FigureMoveType.Bottom:
                to.y--;
                break;

            default:
                throw new System.NotImplementedException("TryMoveFigure function not implemented completely!");
            }

            if (FigureItemsTable[to.x, to.y].FigureType != FigureItemType.no_access)
            {
                IFigureItem temp = FigureItemsTable[from.x, from.y];
                FigureItemsTable[from.x, from.y] = FigureItemsTable[to.x, to.y];
                FigureItemsTable[to.x, to.y]     = temp;
                return(true);
            }
            else
            {
                return(false);
            }
        }