Ejemplo n.º 1
0
        void NextBlock()
        {
            _movementAxis = BlockUtils.SwapXZAxis(_movementAxis);
            Bounds  topBlockBounds = _topBlock.Bounds;
            Bounds  movingBounds   = BlockUtils.CalculateAboveBounds(ref topBlockBounds);
            Vector3 spawnOffset    = GetSpawnOffset(_movementAxis);

            _movingBlock = _blockFactory.GeneratePingPongBlock(ref movingBounds, spawnOffset + movingBounds.center, movingBounds.center - spawnOffset, transform, true);
        }
Ejemplo n.º 2
0
 Vector3 GetSpawnOffset(XZAxis axis)
 {
     return((axis == XZAxis.Z_AXIS ? Vector3.forward : Vector3.left) * _stackConfig.SpawnDistanceFromStack);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Calculates the XZ overhang (opposite to overlap) region of the provided bounds along a specific axis.
        /// </summary>
        public static Bounds CalculateOverhangBounds(ref Bounds above, ref Bounds below, XZAxis axis)
        {
            Bounds diffBounds = new Bounds();
            float  minX = above.min.x, maxX = above.max.x;
            float  minZ = above.min.z, maxZ = above.max.z;

            if (axis == XZAxis.X_AXIS)
            {
                if (Mathf.Sign(above.max.x - below.max.x) > 0)
                {
                    minX = below.max.x;
                    maxX = above.max.x;
                }
                else
                {
                    minX = above.min.x;
                    maxX = below.min.x;
                }
            }
            else if (axis == XZAxis.Z_AXIS)
            {
                if (Mathf.Sign(above.max.z - below.max.z) > 0)
                {
                    minZ = below.max.z;
                    maxZ = above.max.z;
                }
                else
                {
                    minZ = above.min.z;
                    maxZ = below.min.z;
                }
            }

            diffBounds.SetMinMax(new Vector3(minX, above.min.y, minZ),
                                 new Vector3(maxX, above.max.y, maxZ));

            return(diffBounds);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Swaps the provided axis.
 /// </summary>
 /// <returns>The swapped axis</returns>
 /// <param name="axis">Current Axis</param>
 public static XZAxis SwapXZAxis(XZAxis axis)
 {
     return(axis == XZAxis.X_AXIS ? XZAxis.Z_AXIS : XZAxis.X_AXIS);
 }