Ejemplo n.º 1
0
    private System.Collections.Generic.IEnumerable <AreaTile> GetTileGrid(AreaTile currentTile, AreaTile targetTile)
    {
        for (int z = -1; z < 2; z++)
        {
            for (int x = -1; x < 2; x++)
            {
                Vector3 position = currentTile.position;
                position.X += x;
                position.Z += z;


                if (parent.PositionWithinObject(parent.gameObject, position) & childObjects.All(obj => !parent.PositionWithinObject(obj.gameObject, position)))
                {
                    AreaTile gridTile = new AreaTile
                    {
                        position = position,
                        Parent   = currentTile,
                        Cost     = currentTile.Cost + 1
                    };

                    gridTile.SetDistance(targetTile.position);

                    yield return(gridTile);
                }
            }
        }
    }