Beispiel #1
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);
        }
Beispiel #2
0
 public void Update()
 {
     if (showMouseCoordinates)
     {
         Vector2Int tileCoords = TileTransformer.ScreenToCoord(Input.mousePosition);
         Vector3Int wallCoords = WallTransformer.ScreenToCoord(Input.mousePosition);
         debugTextField.text = string.Format(
             "Tile Coord: {0}, {1}\nWall Coord: {2}, {3}, {4}\nOrientation: {5}",
             tileCoords.x,
             tileCoords.y,
             wallCoords.x,
             wallCoords.y,
             wallCoords.z,
             OrientationManager.currentOrientation);
     }
     else
     {
         debugTextField.text = "";
     }
 }