void UpdateSprite(IWall wall)
        {
            if (gameobjects.ContainsKey(wall) == false)
            {
                return;
            }

            GameObject wall_go = gameobjects[wall];

            wall_go.transform.position = WallTransformer.CoordToWorld(wall.X, wall.Y, wall.Z);

            SpriteRenderer sr = wall_go.GetComponent <SpriteRenderer> ();

            sr.sprite       = DataManager.wallSpriteData.GetDataById(wall.Type).GetSprite(wall, GetClippingForWall(wall));
            sr.sortingOrder = SortingOrders.WallOrder(wall.X, wall.Y, wall.Z, TileSubLayer.Wall);

            //sr.color = Random.ColorHSV(0, 1, 0, 1, 0.4f, 1);
        }
Beispiel #2
0
        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);
        }