public Obstacle(GameObject obstacleObject, Bounds bounds) { this.ObstacleObject = obstacleObject; this.PositionRange = new Range() { Min = bounds.Bottom() + ObstacleObject.RendererSize().y / 2, Max = bounds.Top() - ObstacleObject.RendererSize().y / 2, }; }
public static GameObject InstantiateAtBoundsEntrance( this GameObject gameObject, Bounds bounds, Vector2 force = default(Vector2), ForceMode2D forceMode = ForceMode2D.Force) { var size = gameObject.RendererSize(); var position = new Vector2( bounds.Right() + size.x / 2, Random.Range(bounds.Bottom() + size.y /2, bounds.Top() - size.y / 2) ); return gameObject.InstantiateAtPosition(position, force, forceMode); }
public void Move(Vector2 currentPosition, Vector2 inputPosition, Vector2 inputDelta) { movement += inputDelta; if ((currentPosition.x <= warzoneBounds.Left() && movement.x < 0) || (currentPosition.x >= warzoneBounds.Right() && movement.x > 0)) { movement.x = 0; } if ((currentPosition.y <= warzoneBounds.Bottom() && movement.y < 0) || (currentPosition.y >= warzoneBounds.Top() && movement.y > 0)) { movement.y = 0; } }
public static float RandomVerticalPositionWithinBounds(this Bounds bounds, GameObject gameObject) { return(Random.Range(bounds.Bottom() + gameObject.RendererSize().y / 2, bounds.Top() - gameObject.RendererSize().y / 2)); }