Esempio n. 1
0
    public bool move(TilemapHandler tmh, Vector2Int to)
    {
        if (tooFarAway(to))
        {
            return(false);
        }

        kicksBall = false;

        TileHandler onTile = TilemapHandler.getTile(tilePositionOrigin.x, tilePositionOrigin.y).GetComponent <TileHandler>();

        if (TilemapHandler.getTile(to).GetComponent <TileHandler>().getCharacter() != null)
        {
            if ((to - tilePositionOrigin).y == 0)
            {
                to += Vector2Int.right * (((to - tilePositionOrigin).x < 0) ? -1 : 1);
            }
            else
            {
                to += Vector2Int.up * (((to - tilePositionOrigin).y < 0) ? -1 : 1);
            }
        }

        tmh.moveCharacter(tilePosition, to);

        if (hasBall = onTile.getHasBall())
        {
            GameObject.Find("Ball").GetComponent <BallController>().owner = transform;
            GameObject.Find("Ball").transform.position = transform.position - new Vector3(0, 0.5f);
        }

        return(true);
    }
Esempio n. 2
0
    public void move(TilemapHandler tmh, Vector2Int to)
    {
        if (tooFarAway(to))
        {
            return;
        }

        kicksBall = false;

        TileHandler onTile = TilemapHandler.getTile(tilePositionOrigin.x, tilePositionOrigin.y).GetComponent <TileHandler>();

        tmh.moveCharacter(tilePosition, to);

        if (hasBall = onTile.getHasBall())
        {
            GameObject.Find("Ball").transform.position = transform.position - new Vector3(0, 0.5f);
        }
    }