Esempio n. 1
0
        /// <summary>
        /// Places the tile at the input position.
        /// </summary>
        /// <param name="inputPos">The position of the input(touch/mouse).</param>
        private void PlaceTile(Vector2 inputPos)
        {
            _currentNode = _grid.GetNodeFromWorldPos(_grid.FindNearestPosition(Camera.main.ScreenToWorldPoint(inputPos)));

            if (_currentNode.GetTileType() == TileType.None)
            {
                if (_numberOfTilesPlaced == 0 && (_currentNode.GetGridPos().y > 0 || _currentNode.GetGridPos().x != 1))
                {
                    return;
                }

                _currentNode.SetTileType(_currentTile.GetComponent <Tile>().GetTileType());

                _finding.CalculatePath(_currentNode, PlaceTileCallback);

                _numberOfTilesPlaced++;
                if (_numberOfTilesPlaced == 2)
                {
                    if (OnLavaStart != null)
                    {
                        OnLavaStart();
                    }
                }
            }
        }