public void UpdateSprite() { Vector2 rotatedOffset = TileTransformer.InverseRotateCoord(new Vector2(xOffset, yOffset)); transform.position = TileTransformer.CoordToWorld(character.x + rotatedOffset.x, character.y + rotatedOffset.y); SpriteRenderer sr = GetComponent <SpriteRenderer>(); sr.sortingOrder = SortingOrders.TileOrder(character.roundedX, character.roundedY, TileSubLayer.Character); }
public virtual IQueryable <T> Filter <Key>(System.Linq.Expressions.Expression <Func <T, Key> > sortingSelector, System.Linq.Expressions.Expression <Func <T, bool> > filter, out int total, SortingOrders sortby = SortingOrders.Asc, int index = 0, int size = 50) { var query = sortby == SortingOrders.Asc ? Cache.OrderBy(sortingSelector.Compile()).Where(filter.Compile()) : Cache.OrderByDescending(sortingSelector.Compile()).Where(filter.Compile()); total = query.Count(); var skipCount = index * size; return(skipCount > 0 ? query.Skip(skipCount).Take(size).AsQueryable <T>() : query.Take(size).AsQueryable <T>()); }
public override void UpdateCursors(Vector2 mousePosition) { base.UpdateCursors(mousePosition); Vector3Int currentWallPos = WallTransformer.ScreenToCoord(mousePosition); Vector2 worldPos = WallTransformer.CoordToWorld(currentWallPos); // Static cursors if (validClickStart) { GameObject cursorPrefab = Resources.Load <GameObject>(GamePaths.CursorPrefab); if (selectedPositions.ContainsKey(currentWallPos) == false && IsWallAt(currentWallPos)) { GameObject staticCursor = SimplePool.Spawn(cursorPrefab, worldPos, Quaternion.identity); SpriteRenderer staticCursorSr = staticCursor.GetComponent <SpriteRenderer>(); staticCursorSr.sprite = GetCursorSprite(currentWallPos); staticCursorSr.sortingLayerName = mainCursorSr.sortingLayerName; staticCursorSr.sortingOrder = SortingOrders.WallOrder(currentWallPos.x, currentWallPos.y, currentWallPos.z, TileSubLayer.FirstWallCursor); selectedPositions.Add(currentWallPos, staticCursor); } } // Main cursor else { if (IsWallAt(currentWallPos)) { mainCursorSr.enabled = true; mainCursorSr.sortingOrder = SortingOrders.WallOrder(currentWallPos.x, currentWallPos.y, currentWallPos.z, TileSubLayer.FirstWallCursor); mainCursorSr.sprite = GetCursorSprite(currentWallPos); mainCursorGo.transform.position = worldPos; } else { mainCursorSr.enabled = false; } } // Arrow cursor arrowCursor.transform.position = WallTransformer.CoordToWorld(currentWallPos) + new Vector2(Settings.TILE_WIDTH / 4, Settings.TILE_HEIGHT / 4); arrowCursor.GetComponent <SpriteRenderer>().sortingOrder = SortingOrders.WallOrder(currentWallPos.x, currentWallPos.y, currentWallPos.z, TileSubLayer.SecondWallCursor); }
public override void UpdateCursors(Vector2 mousePosition) { Vector2Int tilePos = TileTransformer.ScreenToCoord(mousePosition); if (level.IsTileInBounds(tilePos.x, tilePos.y)) { mainCursorSr.enabled = true; mainCursorSr.sortingOrder = SortingOrders.TileOrder(tilePos.x, tilePos.y, TileSubLayer.Furniture); IFurnitureSprite sprite = DataManager.furnitureSpriteData.GetDataById(index); mainCursorSr.sprite = sprite.GetSprite(orientation); mainCursorGo.transform.position = TileTransformer.CoordToWorld(tilePos); } else { mainCursorSr.enabled = false; } }
public override void UpdateCursors(Vector2 mousePosition) { Vector2Int coords = TileTransformer.ScreenToCoord(mousePosition); if (level.IsTileInBounds(coords.x, coords.y)) { mainCursorSr.enabled = true; mainCursorSr.sortingOrder = SortingOrders.FloorOrder(coords.x, coords.y, FloorSubLayer.Cursor); mainCursorGo.transform.position = TileTransformer.CoordToWorld(coords); mainCursorSr.sprite = GetCursorSprite(coords); } else { mainCursorSr.enabled = false; } return; }
public override void UpdateCursors(Vector2 mousePosition) { base.UpdateCursors(mousePosition); while (activeStaticCursors.Count > 0) { SimplePool.Despawn(activeStaticCursors.Pop()); } if (!validClickStart) { return; } Vector2Int startCoords = dragStartCoords; Vector2Int endCoords = TileTransformer.ScreenToCoord(mousePosition); Vector2Int minCoords = CoordUtil.MinCoords(startCoords, endCoords); Vector2Int maxCoords = CoordUtil.MaxCoords(startCoords, endCoords); GameObject cursorPrefab = Resources.Load <GameObject> (GamePaths.CursorPrefab); for (int x = minCoords.x; x <= maxCoords.x; x++) { for (int y = minCoords.y; y <= maxCoords.y; y++) { Vector3 pos = TileTransformer.CoordToWorld(x, y); GameObject staticCursorGo = SimplePool.Spawn(cursorPrefab, pos, Quaternion.identity); SpriteRenderer staticCursorSr = staticCursorGo.GetComponent <SpriteRenderer> (); staticCursorSr.sprite = GetCursorSprite(new Vector2Int(x, y)); staticCursorSr.sortingLayerName = mainCursorSr.sortingLayerName; staticCursorSr.sortingOrder = SortingOrders.FloorOrder(x, y, FloorSubLayer.Cursor); activeStaticCursors.Push(staticCursorGo); } } return; }
public virtual IQueryable <TObject> Filter <Key>(Expression <Func <TObject, Key> > sortingSelector, Expression <Func <TObject, bool> > filter, out int total, SortingOrders sortby = SortingOrders.Asc, int index = 0, int size = 50) { int skipCount = index * size; var _resultSet = filter != null?DbSet.Where(filter).AsQueryable() : DbSet.AsQueryable(); total = _resultSet.Count(); _resultSet = sortby == SortingOrders.Asc ? _resultSet.OrderBy(sortingSelector).AsQueryable() : _resultSet.OrderByDescending(sortingSelector).AsQueryable(); _resultSet = skipCount == 0 ? _resultSet.Take(size) : _resultSet.Skip(skipCount).Take(size); return(_resultSet); }
private void Update() { sr.sortingOrder = SortingOrders.TileOrder(character.roundedX, character.roundedY, TileSubLayer.Character); }
public override void UpdateCursors(Vector2 mousePosition) { Vector2Int vertexCoords = VertexTransfomer.ScreenToVertex(mousePosition); // Main cursor if (level.IsVertexInBounds(vertexCoords.x, vertexCoords.y)) { mainCursorSr.enabled = true; mainCursorSr.sortingOrder = SortingOrders.VertexOrder(vertexCoords.x, vertexCoords.y, TileSubLayer.SecondWallCursor); mainCursorSr.sprite = Input.GetButton("InverseFunction") ? DataManager.cursorSpriteData.wallBulldozeSprite : DataManager.cursorSpriteData.wallBuildSprite; Vector3 pos = VertexTransfomer.VertexToWorld(vertexCoords); mainCursorGo.transform.position = new Vector3(pos.x, pos.y, 0f); } else { mainCursorSr.enabled = false; } // Static cursors while (activeStaticCursors.Count > 0) { SimplePool.Despawn(activeStaticCursors.Pop()); } if (!validClickStart) { return; } Vector2Int diff = new Vector2Int(Mathf.Abs(vertexCoords.x - dragStartVertexCoords.x), Mathf.Abs(vertexCoords.y - dragStartVertexCoords.y)); Vector2Int endDragCoords = vertexCoords; if (diff.x > diff.y) { endDragCoords.y = dragStartVertexCoords.y; } else { endDragCoords.x = dragStartVertexCoords.x; } GameObject cursorPrefab = Resources.Load <GameObject>(GamePaths.CursorPrefab); for (int x = Mathf.Min(dragStartVertexCoords.x, endDragCoords.x); x <= Mathf.Max(dragStartVertexCoords.x, endDragCoords.x); x++) { for (int y = Mathf.Min(dragStartVertexCoords.y, endDragCoords.y); y <= Mathf.Max(dragStartVertexCoords.y, endDragCoords.y); y++) { Vector2Int currentCoord = new Vector2Int(x, y); GameObject staticCursorGo = SimplePool.Spawn(cursorPrefab, VertexTransfomer.VertexToWorld(currentCoord), Quaternion.identity); SpriteRenderer staticCursorSr = staticCursorGo.GetComponent <SpriteRenderer>(); staticCursorSr.sprite = Input.GetButton("InverseFunction") ? DataManager.cursorSpriteData.wallBulldozeSprite : DataManager.cursorSpriteData.wallBuildSprite; staticCursorSr.sortingLayerName = mainCursorSr.sortingLayerName; staticCursorSr.sortingOrder = SortingOrders.VertexOrder(currentCoord.x, currentCoord.y, TileSubLayer.FirstWallCursor); activeStaticCursors.Push(staticCursorGo); } } return; }
public IQueryable <T> Where <T, Key>(Expression <Func <T, Key> > sortingSelector, Expression <Func <T, bool> > filter, out int total, SortingOrders sortby = SortingOrders.Asc, int index = 0, int size = 50) where T : class { return(GetRepository <T>().Filter(sortingSelector, filter, out total, sortby, index, size)); }