コード例 #1
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();
 }
コード例 #2
0
ファイル: BoardController.cs プロジェクト: gndw/emvici-chess
        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);
            }
        }
コード例 #3
0
ファイル: ChessmanView.cs プロジェクト: gndw/emvici-chess
 protected override void OnColliderSelected(RaycastHit hit)
 {
     OnChessmanSelected?.Invoke();
 }