Esempio n. 1
0
 public void ClearHighlight()
 {
     if (_gridCellHighlight != null)
     {
         _gridCellHighlightPool.Despawn(_gridCellHighlight);
         _gridCellHighlight = null;
     }
 }
Esempio n. 2
0
        private void HandleMouseOnTile(IntVector2 tileCoords)
        {
            if (_gridCellHighlight != null)
            {
                _gridCellHighlightPool.Despawn(_gridCellHighlight);
            }

            _gridCellHighlight = _gridCellHighlightPool.Spawn(tileCoords, new Color(1, 0, 0, 0.4f));
        }
Esempio n. 3
0
        public void StopEditing()
        {
            _cancellationTokenSource?.Cancel();
            _cancellationTokenSource = null;

            if (_gridCellHighlight != null)
            {
                _gridCellHighlightPool.Despawn(_gridCellHighlight);
                _gridCellHighlight = null;
            }

            _observers.ForEach(x => x.Dispose());
            SetDefaultCursor();
        }
Esempio n. 4
0
        private async void HandleTileClicked(IntVector2 tileCoords)
        {
            // Trigger highlight for mobile since mouse over does not happen there.
            HandleMouseOnTile(tileCoords);
            SetDefaultCursor();

            // Allow cancellation when "StopEditing" is called.
            _cancellationTokenSource = new CancellationTokenSource();
            // The task is ran "as uni task" to avoid opening a new thread.
            // We are showing a view controller which will require MonoBehaviours (needs main thread).
            await _delegate.Show(tileCoords, _cancellationTokenSource.Token).SuppressCancellationThrow();

            _cancellationTokenSource = null;

            // Update highlight to match new mouse position
            _gridCellHighlightPool.Despawn(_gridCellHighlight);
            _gridCellHighlight = null;
            if (_gridInputManager.TileAtMousePosition != null)
            {
                HandleMouseOnTile(_gridInputManager.TileAtMousePosition.Value);
            }

            SetSectionTileCursor();
        }
Esempio n. 5
0
 public void Despawn(IGridCellHighlight gridCellHighlight)
 {
     _monoPool.Despawn((GridCellHighlight)gridCellHighlight);
     _spawnedHighlights.Remove(gridCellHighlight);
 }
Esempio n. 6
0
 private void HandleMouseOnTile(IntVector2 tileCoords)
 {
     ClearHighlight();
     _gridCellHighlight = _gridCellHighlightPool.Spawn(tileCoords, HIGHLIGHT_COLOR);
 }