Ejemplo n.º 1
0
        private static void Rotate(DrawableBase drawable, float angle)
        {
            if (_grid.TryRotate(drawable, angle))
            {
                _selectionController.ClearSelection();

                drawable.RotateAroundPivot(angle);
                _grid.SetGridCells(drawable.transform.position, drawable);

                if (drawable.GetType().IsSubclassOf(typeof(CharacterBase)))
                {
                    var charBase = (CharacterBase)drawable;
                    charBase.RemoveAllConnections();
                    charBase.UpdateConnectionPoints();
                }

                _selectionController.AddToSelection(drawable);
            }
        }
Ejemplo n.º 2
0
        private static void SetDrawablePosition(DrawableBase s, Vector2 snapPosition)
        {
            var currGridPos = s.PositionOnGrid;

            s.GetComponent <RectTransform>().position = snapPosition;
            _grid.SetGridCells(snapPosition, s);
            s.Image.color = Color.white;

            var newGridPos = s.PositionOnGrid;
            var diff       = newGridPos - currGridPos;

            if (s.GetType().IsSubclassOf(typeof(CharacterBase)))
            {
                var charBase = (CharacterBase)s;
                charBase.UpdateConnectionPoints();
            }
            else if (s.GetType() == typeof(WirePiece))
            {
                var wire = (WirePiece)s;
                wire.MoveConnectionsOnGrid(diff);
            }

            _selectionController.AddToSelection(s);
        }