Esempio n. 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();
 }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
 protected override void OnColliderSelected(RaycastHit hit)
 {
     OnChessmanSelected?.Invoke();
 }