private IEnumerator DummyOkeyHardCode() { yield return(new WaitForSeconds(1f)); _dummyOkeyTile = DrawTile(); _dummyOkeyTile.TurnFaceUp(); _dummyOkeyTile.TranslateToPosition(GameDeckView.OkeyPosition.position); }
///<summary> /// Callback is managed by GameManager ///</summary> public void CreateGameTiles(GameTileView p_gameTilePrefab, Action p_callback) { GameTiles = new GameTileView[GameTileDeck.DECK_SIZE]; for (int i = 0; i < GameTileDeck.DECK_SIZE; i++) { GameTiles[i] = Instantiate(p_gameTilePrefab); GameTiles[i].transform.SetParent(_gameTileViewsParent.transform); GameTiles[i].TurnFaceDown(); } StartCoroutine(SmoothDeckReveal(p_callback)); }
private void Update() { if (!CanTakeInput) { return; } if (Input.GetMouseButtonDown(0)) { RaycastHit2D rayHit = Physics2D.GetRayIntersection(Camera.main.ScreenPointToRay(Input.mousePosition)); if (rayHit.transform != null) { _selectedView = rayHit.transform.gameObject.GetComponent <GameTileView>(); if (_selectedView != null) { _lastBoardSlot = _selectedView.BoardSlotView; _lastPosition = _selectedView.transform.position; } } } else if (Input.GetMouseButton(0)) { if (_selectedView != null) { MoveViewToWorldPosition(Input.mousePosition); } } else if (Input.GetMouseButtonUp(0)) { if (_selectedView != null) { CanTakeInput = false; BoardSlotView targetBoardSlot = null; FindPosition(out targetBoardSlot); if (_lastBoardSlot != null) { _lastBoardSlot.UnFill(); targetBoardSlot.Fill(); _selectedView.TranslateToPosition(targetBoardSlot, () => { ViewMoveFinished(); }); } else { _selectedView.TranslateToPosition(_lastPosition, () => { ViewMoveFinished(); }); } _selectedView = null; } } }
private IEnumerator SmoothDeckReveal(Action p_callback) { for (int i = 0; i < GameTileDeck.DECK_SIZE; i++) { yield return(_tileDelay); GameTiles[i].TranslateToPosition(GameDeckView.StackPositions[i / 26].position); } if (p_callback != null) { p_callback.Invoke(); } _dummyOkeyTile = DrawTile(); _dummyOkeyTile.TurnFaceUp(); _dummyOkeyTile.TranslateToPosition(GameDeckView.OkeyPosition.position); }
///<summary> /// GameManager should call this when the time is right ///</summary> public void DealHand(GameTileArranger p_arranger) { PlayerBoard.Reset(); GameTileGroup[] result = p_arranger.Arrange(PlayerHand); GameTileView currentView = null; for (int i = 0; i < result.Length; i++) { for (int j = 0; j < result[i].GameTileCount; j++) { currentView = FindView(result[i][j]); currentView.TranslateToPosition(PlayerBoard.GetNextPosition(), null); currentView.TurnFaceUp(); } PlayerBoard.SkipPosition(); } }
private void Awake() { CanTakeInput = true; _selectedView = null; }
public void AddTile(GameTileView p_gameTileView) { PlayerHandViews.Add(p_gameTileView); PlayerHand.AddGameTile(p_gameTileView.GameTile); }