示例#1
0
 public void Init(PrefabController prefabController)
 {
     _prefabController      = prefabController;
     _view                  = _prefabController.GetObject <BoardView>(PrefabConstant.PathBoardView, Vector3.zero, Quaternion.identity, null);
     _view.OnBoardSelected += (boardcoord) => OnBoardSelected?.Invoke(boardcoord);
     SetChessmanOnBoard(BoardDataModel.CreateAsNormalGame());
 }
示例#2
0
        public UserControlPlotDUT()
        {
            InitializeComponent();
            DataContext            = this;
            this.fx3FirmwarePath   = "FX3_Firmware.img";
            this.fx3BootloaderPath = "boot_fw.img";
            this.fx3ProgrammerPath = "USBFlashProg.img";

            // UI initialization. Will be replace by VMMV
            //IsAttachedTextBox.Text = false.ToString();
            //ConnectToggleButton.IsChecked = false;

            // FirmwarePath, set target to "FX3_Firmware.img"
            // BootloaderPath, set target to "boot_fw.img"
            // ProgrammerPath, set target to "USBFlashProg.img"
            fX3Connection = new FX3Connection(this.fx3FirmwarePath, fx3BootloaderPath, fx3ProgrammerPath, DeviceType.IMU);
            _evalBoard    = new ADXL345EB(fX3Connection);

            boardDataM  = new BoardDataModel();
            boardDataVM = new BoardDataViewModel(boardDataM);

            fX3Connection.PartType = DUTType.ADcmXL3021;
            Dut = new AdcmInterface3Axis(fX3Connection);

            InitializePlot();

            RegistersComboBox.ItemsSource = Enum.GetValues(typeof(ADXL345EB.RegisterAddress));
            AxisComboBox.ItemsSource      = Enum.GetValues(typeof(AccelerometerAxis));
            PresetComboBox.ItemsSource    = Enum.GetValues(typeof(ADXL345EB.Presets));
            CheckIfAttached();
        }
示例#3
0
        public BoardDataModel GetBoardDataModel()
        {
            BoardDataModel result = new BoardDataModel();

            _chessmans.ForEach((icc) =>
            {
                result.Data.Add(icc.GetBoardCoord(), new Chessman.Model.ChessmanDataModel(icc.GetChessmanType(), icc.GetChessmanColorType()));
            });
            return(result);
        }
示例#4
0
        public override List <BoardCoord> GetPossibleMoves(BoardDataModel boardDataModel)
        {
            BoardCoord        oneStep;
            BoardCoord        twoStep;
            int               twoStepCoordinate;
            BoardCoord        eatRightStep;
            BoardCoord        eatLeftStep;
            List <BoardCoord> possibleMoves = new List <BoardCoord>();

            switch (_colorType)
            {
            case ChessmanColorType.Light:
            {
                oneStep           = new BoardCoord(_currentBoardCoordinate.X, _currentBoardCoordinate.Y + 1);
                twoStep           = new BoardCoord(_currentBoardCoordinate.X, _currentBoardCoordinate.Y + 2);
                twoStepCoordinate = 2;
                eatRightStep      = new BoardCoord(_currentBoardCoordinate.X + 1, _currentBoardCoordinate.Y + 1);
                eatLeftStep       = new BoardCoord(_currentBoardCoordinate.X - 1, _currentBoardCoordinate.Y + 1);
                break;
            }

            case ChessmanColorType.Dark:
            {
                oneStep           = new BoardCoord(_currentBoardCoordinate.X, _currentBoardCoordinate.Y - 1);
                twoStep           = new BoardCoord(_currentBoardCoordinate.X, _currentBoardCoordinate.Y - 2);
                twoStepCoordinate = 7;
                eatRightStep      = new BoardCoord(_currentBoardCoordinate.X - 1, _currentBoardCoordinate.Y - 1);
                eatLeftStep       = new BoardCoord(_currentBoardCoordinate.X + 1, _currentBoardCoordinate.Y - 1);
                break;
            }

            default:
                return(null);
            }
            if (oneStep.IsValid() && !boardDataModel.IsBoardCoordinateOccupied(oneStep))
            {
                possibleMoves.Add(oneStep);
            }
            if (_currentBoardCoordinate.Y == twoStepCoordinate && twoStep.IsValid() && !boardDataModel.IsBoardCoordinateOccupied(twoStep))
            {
                possibleMoves.Add(twoStep);
            }
            if (eatRightStep.IsValid() && boardDataModel.IsBoardCoordinateOccupiedByEnemy(_colorType, eatRightStep))
            {
                possibleMoves.Add(eatRightStep);
            }
            if (eatLeftStep.IsValid() && boardDataModel.IsBoardCoordinateOccupiedByEnemy(_colorType, eatLeftStep))
            {
                possibleMoves.Add(eatLeftStep);
            }
            return(possibleMoves);
        }
示例#5
0
        public List <BoardCoord> GetPossibleMoves(BoardCoord coord)
        {
            IChessmanController icc;

            if (TryGetChessman(coord, out icc))
            {
                BoardDataModel bdm = GetBoardDataModel();
                return(icc.GetPossibleMoves(bdm));
            }
            else
            {
                return(new List <BoardCoord>());
            }
        }
示例#6
0
        public void SetChessmanOnBoard(BoardDataModel boardDataModel)
        {
            _chessmans.ForEach((cc) => cc.Destroy());
            _chessmans.Clear();
            foreach (var data in boardDataModel.Data)
            {
                IChessmanController icc;
                switch (data.Value.Type)
                {
                case ChessmanType.Pawn:
                    icc = new PawnController();
                    break;

                case ChessmanType.Rook:
                    icc = new RookController();
                    break;

                case ChessmanType.Knight:
                    icc = new KnightController();
                    break;

                case ChessmanType.Bishop:
                    icc = new BishopController();
                    break;

                case ChessmanType.Queen:
                    icc = new QueenController();
                    break;

                case ChessmanType.King:
                    icc = new KingController();
                    break;

                default:
                    throw new System.NotImplementedException();
                }
                icc.Init(_prefabController, _view.GetBoardPosition, _view.GetFacingDirection, data.Key, data.Value.ColorType);
                icc.OnChessmanSelected += () => OnChessmanSelected?.Invoke(icc.GetChessmanType(), icc.GetChessmanColorType(), icc.GetBoardCoord());
                _chessmans.Add(icc);
            }
        }
示例#7
0
 public BoardDataViewModel(BoardDataModel pBoardDataModel)
 {
     boardDataModel = pBoardDataModel;
 }
示例#8
0
 public override List <BoardCoord> GetPossibleMoves(BoardDataModel boardDataModel)
 {
     throw new System.NotImplementedException();
 }
示例#9
0
 public abstract List <BoardCoord> GetPossibleMoves(BoardDataModel boardDataModel);