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; } } }
public bool IsBoardCoordinateOccupiedByEnemy(ChessmanColorType playerType, BoardCoord coord) { ChessmanDataModel cdm; if (Data.TryGetValue(coord, out cdm)) { return(cdm.ColorType != playerType); } return(false); }
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(); }
protected override string GetViewPrefabPath(ChessmanColorType colorType) { switch (colorType) { case ChessmanColorType.Light: return(PrefabConstant.PathBishopLightView); case ChessmanColorType.Dark: return(PrefabConstant.PathBishopDarkView); default: return(null); } }
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); } }
public MatchState(ChessmanColorType playerType) { Player = playerType; Reset(); }
protected abstract string GetViewPrefabPath(ChessmanColorType colorType);
public ChessmanDataModel(ChessmanType type, ChessmanColorType colorType) { Type = type; ColorType = colorType; }