protected override IWorldCommand GetActionCommand(Vector2 mousePosition)
        {
            int        selectedIndex = Input.GetButton("InverseFunction") ? TileIndex.New : index;
            Vector2Int endCoords     = TileTransformer.ScreenToCoord(mousePosition);

            return(new PaintAreaCmd(level, dragStartCoords.x, endCoords.x, dragStartCoords.y, endCoords.y, selectedIndex));
        }
Beispiel #2
0
        protected override IWorldCommand GetActionCommand(Vector2 mousePosition)
        {
            Vector2Int tilePos = TileTransformer.ScreenToCoord(mousePosition);
            ITile      tile    = level.GetTileAt(tilePos.x, tilePos.y);

            if (Input.GetButton("InverseFunction"))
            {
                return(new RemoveFurnitureCommand(level, tilePos.x, tilePos.y));
            }

            IFurniture furniture = new DecorationFurniture(index, level, tile, orientation);

            return(new PlaceFurnitureCommand(level, tilePos.x, tilePos.y, furniture));
        }
Beispiel #3
0
        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;
            }
        }
Beispiel #4
0
        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;
        }
Beispiel #5
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 = "";
     }
 }
        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 override void ClickStart(Vector2 mousePosition)
        {
            base.ClickStart(mousePosition);

            dragStartCoords = TileTransformer.ScreenToCoord(mousePosition);
        }