Example #1
0
        /// <summary>
        /// Setup the specified instance. Places object at location.
        /// </summary>
        /// <param name="location">Location.</param>
        /// <param name="lockedAxis">Locked axis.</param>
        public void Setup(BoundsLocation location, Axis lockedAxis)
        {
            if (spriteRenderer == null)
            {
                Debug.LogError("No spriterenderer found: stopping placement");
                return;
            }

            this.boundsLocation = location;
            this.lockAxis       = lockedAxis;

            transform.localPosition = Vector3.zero;

            if (BothAxisLocked())
            {
                Debug.Log("Both Axis locked: stopping placement");
                return;
            }

            Vector2 desiredPosition = GetDesiredPosition();

            if (lockAxis == Axis.X)
            {
                desiredPosition.x = transform.position.x;
            }
            else if (lockAxis == Axis.Y)
            {
                desiredPosition.y = transform.position.y;
            }

            transform.position = desiredPosition;
        }
Example #2
0
 private void UpdateObstacleSideData(ObstacleIndividualData data, Vector2 multiplyBy,
                                     Side lockRatioTo,
                                     BoundsLocation location,
                                     Axis lockedAxis, bool basedOnHeightOnly)
 {
     data.scale.Setup(multiplyBy, lockRatioTo, basedOnHeightOnly);
     data.placement.Setup(location, lockedAxis);
 }
Example #3
0
        /// <summary>
        /// Setups child obstacle.
        /// </summary>
        /// <param name="side">Side.</param>
        /// <param name="multiplyBy">Multiply by.</param>
        /// <param name="lockRatioTo">Lock ratio to.</param>
        /// <param name="location">Location.</param>
        /// <param name="lockedAxis">Locked axis.</param>
        /// <param name="basedOnHeightOnly">If set to <c>true</c> based on height only.</param>
        public void SetupObstacle(ObstacleSide side, Vector2 multiplyBy,
                                  Side lockRatioTo, BoundsLocation location, Axis lockedAxis, bool basedOnHeightOnly)
        {
            var data = GetDataFromSide(side);

            UpdateObstacleSideData(data, multiplyBy, lockRatioTo,
                                   location, lockedAxis, basedOnHeightOnly);
        }
        /// <summary>
        /// Creates and returns a <see cref="Avoidance.BoundsPlacement"/> based on <see cref="Avoidance.BoundsLocation"/>.
        /// </summary>
        public BoundsPlacement Make(BoundsLocation location)
        {
            BoundsPlacement boundsPlacement = null;

            switch (location)
            {
            case BoundsLocation.Top:
                boundsPlacement = new BoundsPlacementTop();
                break;

            case BoundsLocation.TopOffScreen:
                boundsPlacement = new BoundsPlacementTopOffScreen();
                break;

            case BoundsLocation.Right:
                boundsPlacement = new BoundsPlacementRight();
                break;

            case BoundsLocation.RightOffScreen:
                boundsPlacement = new BoundsPlacementRightOffScreen();
                break;

            case BoundsLocation.Left:
                boundsPlacement = new BoundsPlacementLeft();
                break;

            case BoundsLocation.LeftOffScreen:
                boundsPlacement = new BoundsPlacementLeftOffScreen();
                break;

            case BoundsLocation.Bottom:
                boundsPlacement = new BoundsPlacementBottom();
                break;

            case BoundsLocation.BottomOffScreen:
                boundsPlacement = new BoundsPlacementBottomOffScreen();
                break;

            default:
                Debug.LogError("Bounds placement not set");
                break;
            }

            return(boundsPlacement);
        }
Example #5
0
 /// <summary>
 /// Setups the parent object.
 /// </summary>
 /// <param name="location">Location.</param>
 /// <param name="lockedAxis">Locked axis.</param>
 /// <param name="moveDirection">Move direction.</param>
 /// <param name="moveDistancePerSecond">Move distance per second.</param>
 public void SetupParent(BoundsLocation location, Axis lockedAxis,
                         Direction moveDirection, float moveDistancePerSecond)
 {
     placementMain.Setup(location, lockedAxis);
     movement.Setup(moveDirection, moveDistancePerSecond);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Avoidance.ObstacleHorizontalDataImpl"/> class.
 /// </summary>
 /// <param name="moveDirection">Move direction.</param>
 /// <param name="boundsLocation">Bounds location.</param>
 public ObstacleHorizontalDataImpl(Direction moveDirection,
                                   BoundsLocation boundsLocation) : base(moveDirection, boundsLocation)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Avoidance.ObstacleDirectionalDataImpl"/> class.
 /// </summary>
 /// <param name="moveDirection">Move direction.</param>
 /// <param name="boundsLocation">Bounds location.</param>
 public ObstacleDirectionalDataImpl(Direction moveDirection, BoundsLocation boundsLocation)
 {
     this.moveDirection  = moveDirection;
     this.boundsLocation = boundsLocation;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Avoidance.ObstacleVerticalDataImpl"/> class.
 /// </summary>
 /// <param name="moveDirection">Move direction.</param>
 /// <param name="boundsLocation">Bounds location.</param>
 public ObstacleVerticalDataImpl(Direction moveDirection,
                                 BoundsLocation boundsLocation) : base(moveDirection, boundsLocation)
 {
 }