Esempio n. 1
0
    /// <summary>
    /// Update every frame
    /// </summary>
    protected void Update()
    {
        Vector3?position = GameControls.TouchPositionInWorld();

        if (position == null)
        {
            return;
        }

        Vector2 delta = (Vector2)position.Value - basePosition;

        transform.position = selected.transform.position + (Vector3)delta;

        if (GameControls.TouchUp())
        {
            ReleaseTile();
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Select a givent tile
    /// </summary>
    /// <param name="tile">the tile to select</param>
    /// <returns>true if successfuly selected, false overwise</returns>
    public bool SelectTile(GameTile tile)
    {
        if (tile == _selected)
        {
            return(false);
        }

        Vector3?position = GameControls.TouchPositionInWorld();

        if (position == null)
        {
            return(false);
        }

        _selected          = tile;
        basePosition       = position.Value;
        transform.position = tile.transform.position;

        _sRenderer.sprite = GameManager.current.image.sprites[tile.imageIndex];
        _sRenderer.size   = Vector2.one;

        enabled = true;
        return(true);
    }