Beispiel #1
0
    private void FixedUpdate()
    {
        if (_dragFinger != null)
        {
            //if (RootController.Instance.MultiplayerIsClient())
            //TrackFinger();

            GameObject newTile = FindNearestTile();
            if (newTile != null && !_dragTiles.Contains(newTile))
            {
                if (_dragTiles.Count == 0)
                {
                    _dragTiles.Add(newTile);
                }
                else if (newTile.GetComponent <HexTile>().type.Type == _dragTiles[0].GetComponent <HexTile>().type.Type)
                {
                    if (newTile.GetComponent <HexTile>().IsAdjacentTo(_dragTiles[_dragTiles.Count - 1]))
                    {
                        _dragTiles.Add(newTile);
                    }
                }
            }
            else if (newTile != null && _dragTiles.Contains(newTile))
            {
                if (_lingerTile == null)
                {
                    _lingerTile  = newTile;
                    _lingerTimer = 0;
                }
                else
                {
                    _lingerTimer += Time.fixedDeltaTime;
                }

                if (_lingerTimer > .24f)
                {
                    int index = _dragTiles.IndexOf(newTile);
                    for (int i = index + 1; i < _dragTiles.Count; i++)
                    {
                        _dragTiles.RemoveAt(i);
                    }
                    _lingerTile = null;
                }
            }

            _line.positionCount = _dragTiles.Count;

            foreach (HexTile tile in _gridController.AllTilesAsHexTile())
            {
                tile.selected = false;
            }

            GetDestructionPrediction();
        }
    }