예제 #1
0
        private void ClampPosition(SpaceBounds spaceBounds)
        {
            var position = transform.position;

            if (position.x > spaceBounds.RightBound.x)
            {
                position.x = spaceBounds.LeftBound.x;
            }

            if (position.x < spaceBounds.LeftBound.x)
            {
                position.x = spaceBounds.RightBound.x;
            }

            if (position.y > spaceBounds.TopBound.y)
            {
                position.y = spaceBounds.BottomBound.y;
            }

            if (position.y < spaceBounds.BottomBound.y)
            {
                position.y = spaceBounds.TopBound.y;
            }

            transform.position = position;
        }
예제 #2
0
        private Vector2 CalculatePosition(SpaceBounds spaceBounds)
        {
            var position = new Vector2
            {
                x = Random.value > 0.5f ? spaceBounds.RightBound.x : spaceBounds.LeftBound.x,
                y = Random.Range(spaceBounds.TopBound.y, spaceBounds.BottomBound.y)
            };

            return(position);
        }
예제 #3
0
        protected override void OnSpaceBoundsUpdate(ref SpaceBounds newBounds)
        {
            base.OnSpaceBoundsUpdate(ref newBounds);

            switch (Shape.Value)
            {
            case ShapeEnum.Box:
                newBounds = new SpaceBounds(GetBox().ToBounds());
                break;

            case ShapeEnum.Cylinder:
                newBounds = new SpaceBounds(GetCylinder().ToBounds());
                break;
            }
        }