Пример #1
0
 void InitFeagure(FeagureType type, Color color)
 {
     Source         = FeagureImages.GetImage(color, type);
     _possibleMoves = RuleProvider.GetMoveRule(color, type);
     _hits          = RuleProvider.GetHitRule(color, type);
     _type          = type;
     _color         = color;
 }
Пример #2
0
        public static BitmapImage GetImage(Color color, FeagureType type)
        {
            switch (color)
            {
            case Color.White:
                switch (type)
                {
                case FeagureType.Bishop:
                    return(_whiteBishop);

                case FeagureType.King:
                    return(_whiteKing);

                case FeagureType.Knight:
                    return(_whiteKnight);

                case FeagureType.Pawn:
                    return(_whitePawn);

                case FeagureType.Queen:
                    return(_whiteQueen);

                case FeagureType.Rook:
                    return(_whiteRook);

                default:
                    throw new Exception("No such white feagure");
                }

            case Color.Black:
                switch (type)
                {
                case FeagureType.Bishop:
                    return(_blackBishop);

                case FeagureType.King:
                    return(_blackKing);

                case FeagureType.Knight:
                    return(_blackKnight);

                case FeagureType.Pawn:
                    return(_blackPawn);

                case FeagureType.Queen:
                    return(_blackQueen);

                case FeagureType.Rook:
                    return(_blackRook);

                default:
                    throw new Exception("No such black feagure");
                }

            default:
                throw new Exception("No such image");
            }
        }
Пример #3
0
        public void Mutate(FeagureType type)
        {
            if (_type != FeagureType.Pawn)
            {
                throw new Exception("Impossible to mutate.");
            }

            InitFeagure(type, _color);
        }
Пример #4
0
        internal Chessman(Point position, FeagureType type, Color color)
        {
            Width = Height = 70;

            _currentPosition = position;

            InitFeagure(type, color);

            Gameboard.AddFeagure(position, this);
        }
Пример #5
0
 internal static Func <Point, IEnumerable <Point> > GetHitRule(Color color, FeagureType type)
 {
     return(_hitRules[Tuple.Create(color, type)]);
 }