Exemplo n.º 1
0
        public static Vector2 AnchorToViewPoint(TouchControlAnchor touchControlAnchor)
        {
            switch (touchControlAnchor)
            {
            case TouchControlAnchor.TopLeft:
                return(new Vector2(0f, 1f));

            case TouchControlAnchor.CenterLeft:
                return(new Vector2(0f, 0.5f));

            case TouchControlAnchor.BottomLeft:
                return(new Vector2(0f, 0f));

            case TouchControlAnchor.TopCenter:
                return(new Vector2(0.5f, 1f));

            case TouchControlAnchor.Center:
                return(new Vector2(0.5f, 0.5f));

            case TouchControlAnchor.BottomCenter:
                return(new Vector2(0.5f, 0f));

            case TouchControlAnchor.TopRight:
                return(new Vector2(1f, 1f));

            case TouchControlAnchor.CenterRight:
                return(new Vector2(1f, 0.5f));

            case TouchControlAnchor.BottomRight:
                return(new Vector2(1f, 0f));

            default:
                return(Vector2.zero);
            }
        }
Exemplo n.º 2
0
		public static Vector2 AnchorToViewPoint( TouchControlAnchor touchControlAnchor )
		{
			switch (touchControlAnchor)
			{
				case TouchControlAnchor.TopLeft:
					return new Vector2( 0.0f, 1.0f );
				case TouchControlAnchor.CenterLeft:
					return new Vector2( 0.0f, 0.5f );
				case TouchControlAnchor.BottomLeft:
					return new Vector2( 0.0f, 0.0f );
				
				case TouchControlAnchor.TopCenter:
					return new Vector2( 0.5f, 1.0f );
				case TouchControlAnchor.Center:
					return new Vector2( 0.5f, 0.5f );
				case TouchControlAnchor.BottomCenter:
					return new Vector2( 0.5f, 0.0f );
				
				case TouchControlAnchor.TopRight:
					return new Vector2( 1.0f, 1.0f );
				case TouchControlAnchor.CenterRight:
					return new Vector2( 1.0f, 0.5f );
				case TouchControlAnchor.BottomRight:
					return new Vector2( 1.0f, 0.0f );
			}
			
			return Vector2.zero;
		}
Exemplo n.º 3
0
        protected Vector3 OffsetToWorldPosition(TouchControlAnchor anchor, Vector2 offset, TouchUnitType offsetUnitType)
        {
            Vector3 worldOffset;

            if (offsetUnitType == TouchUnitType.Pixels)
            {
                worldOffset = TouchUtility.RoundVector(offset) * TouchManager.PixelToWorld;
            }
            else
            {
                worldOffset = (Vector3)offset * TouchManager.PercentToWorld;
            }
            return(TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + worldOffset);
        }
Exemplo n.º 4
0
 protected Vector3 OffsetToWorldPosition( TouchControlAnchor anchor, Vector2 offset, TouchUnitType offsetUnitType, bool lockAspectRatio )
 {
     Vector3 worldOffset;
     if (offsetUnitType == TouchUnitType.Pixels)
     {
         worldOffset = TouchUtility.RoundVector( offset ) * TouchManager.PixelToWorld;
     }
     else
     {
         if (lockAspectRatio)
         {
             worldOffset = (Vector3) offset * TouchManager.PercentToWorld;
         }
         else
         {
             worldOffset = Vector3.Scale( offset, TouchManager.ViewSize );
         }
     }
     return TouchManager.ViewToWorldPoint( TouchUtility.AnchorToViewPoint( anchor ) ) + worldOffset;
 }
Exemplo n.º 5
0
        protected Vector3 OffsetToWorldPosition(TouchControlAnchor anchor, Vector2 offset, TouchUnitType offsetUnitType, bool lockAspectRatio)
        {
            Vector3 b = (offsetUnitType == TouchUnitType.Pixels) ? ((Vector3)(TouchUtility.RoundVector(offset) * TouchManager.PixelToWorld)) : ((!lockAspectRatio) ? Vector3.Scale(offset, TouchManager.ViewSize) : ((Vector3)offset * TouchManager.PercentToWorld));

            return(TouchManager.ViewToWorldPoint(TouchUtility.AnchorToViewPoint(anchor)) + b);
        }