示例#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
        protected override void OnColliderSelected(RaycastHit hit)
        {
            Vector3 preciseLocation           = hit.point - _collider.transform.position + _collider.size / 2;
            Vector3 normalizedPreciseLocation = new Vector3(preciseLocation.x / _collider.size.x, 0, preciseLocation.z / _collider.size.z);
            int     x = Mathf.Clamp(Mathf.FloorToInt(normalizedPreciseLocation.x * 8) + 1, 1, 8);
            int     y = Mathf.Clamp(Mathf.FloorToInt(normalizedPreciseLocation.z * 8) + 1, 1, 8);

            OnBoardSelected?.Invoke(new BoardCoord(x, y));
        }