コード例 #1
0
        private void OnChessmanSelected(ChessmanType type, ChessmanColorType colorType, BoardCoord coord)
        {
            switch (_currentState.TurnState)
            {
            case MatchTurnState.Idle:
            {
                if (colorType == _currentState.Player)
                {
                    SelectChessman(coord);
                }
                break;
            }

            case MatchTurnState.ChessmanSelected:
            {
                if (colorType == _currentState.Player)
                {
                    SelectChessman(coord);
                }
                else
                {
                    if (_currentState.PossibleMoves.Contains(coord))
                    {
                        Move(_currentState.SelectedCoord, coord, SwitchTurn);
                    }
                }
                break;
            }
            }
        }
コード例 #2
0
ファイル: BoardDataModel.cs プロジェクト: gndw/emvici-chess
        public bool IsBoardCoordinateOccupiedByEnemy(ChessmanColorType playerType, BoardCoord coord)
        {
            ChessmanDataModel cdm;

            if (Data.TryGetValue(coord, out cdm))
            {
                return(cdm.ColorType != playerType);
            }
            return(false);
        }
コード例 #3
0
 public void Init(PrefabController prefabController, Func <BoardCoord, Vector3> getBoardPosition, Func <ChessmanColorType, Vector3> getFacingDirection, BoardCoord coordinate, ChessmanColorType colorType)
 {
     _prefabController       = prefabController;
     _getBoardPosition       = getBoardPosition;
     _getFacingDirection     = getFacingDirection;
     _currentBoardCoordinate = coordinate;
     _colorType = colorType;
     _view      = _prefabController.GetObject <T>(GetViewPrefabPath(_colorType), _getBoardPosition(_currentBoardCoordinate), Quaternion.LookRotation(getFacingDirection(_colorType)), null);
     _view.OnChessmanSelected += () => OnChessmanSelected?.Invoke();
 }
コード例 #4
0
ファイル: BishopController.cs プロジェクト: gndw/emvici-chess
        protected override string GetViewPrefabPath(ChessmanColorType colorType)
        {
            switch (colorType)
            {
            case ChessmanColorType.Light:
                return(PrefabConstant.PathBishopLightView);

            case ChessmanColorType.Dark:
                return(PrefabConstant.PathBishopDarkView);

            default:
                return(null);
            }
        }
コード例 #5
0
        public Vector3 GetFacingDirection(ChessmanColorType colorType)
        {
            switch (colorType)
            {
            case ChessmanColorType.Light:
                return(GetBoardPosition(new BoardCoord(1, 8)) - GetBoardPosition(new BoardCoord(1, 1)));

            case ChessmanColorType.Dark:
                return(GetBoardPosition(new BoardCoord(1, 1)) - GetBoardPosition(new BoardCoord(1, 8)));

            default:
                return(Vector3.zero);
            }
        }
コード例 #6
0
 public MatchState(ChessmanColorType playerType)
 {
     Player = playerType;
     Reset();
 }
コード例 #7
0
 protected abstract string GetViewPrefabPath(ChessmanColorType colorType);
コード例 #8
0
 public ChessmanDataModel(ChessmanType type, ChessmanColorType colorType)
 {
     Type      = type;
     ColorType = colorType;
 }