Beispiel #1
0
        /// <summary>
        /// Sets the position relative to screen bound.
        /// </summary>
        /// <param name="bound">Bound.</param>
        /// <param name="offset">Offset.</param>
        public void SetPositionRelativeToScreen(ScreenBound bound, Vector2 offset)
        {
            PositionMode = PositionType.ScreenRelative;

            Bound             = bound;
            ScreenBoundOffset = offset;

            if (screenService != null)
            {
                switch (bound)
                {
                case ScreenBound.TopLeft:
                    m_Position = offset;
                    break;

                case ScreenBound.TopRight:
                    m_Position = Vector2.Add(offset, new Vector2(screenService.GameWindowSize.X, 0));
                    break;

                case ScreenBound.BottomRight:
                    m_Position = Vector2.Add(offset, screenService.GameWindowSize);
                    break;

                case ScreenBound.BottomLeft:
                    m_Position = Vector2.Add(offset, new Vector2(0, screenService.GameWindowSize.Y));
                    break;
                }
            }
        }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #3
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (other.CompareTag("ScreenBounds"))
     {
         ScreenBound screenBound = other.GetComponent <ScreenBound>();
         if (screenBound != null)
         {
             rb.velocity = screenBound.PushInDirection(rb);
         }
     }
 }
Beispiel #4
0
        void ScreenBoundCollide( ScreenBound bound )
        {
            _previousCollision = bound;

            switch( bound )
            {
                case ScreenBound.Left:
                    ViewModel.AngleMin = 270;
                    ViewModel.AngleMax = 90;
                    break;
                case ScreenBound.Top:
                    ViewModel.AngleMin = 0;
                    ViewModel.AngleMax = 180;
                    break;
                case ScreenBound.Right:
                    ViewModel.AngleMin = 90;
                    ViewModel.AngleMax = 270;
                    break;
                case ScreenBound.Bottom:
                    ViewModel.AngleMin = 180;
                    ViewModel.AngleMax = 360;
                    break;
                default:
                    ViewModel.AngleMin = 0;
                    ViewModel.AngleMax = 360;
                    break;
            }

            if( bound != ScreenBound.None )
            {
                StopTranslation();
                StartRotation();
            }
        }
Beispiel #5
0
		/// <summary>
		/// Sets the position relative to screen bound.
		/// </summary>
		/// <param name="bound">Bound.</param>
		/// <param name="offset">Offset.</param>
		public void SetPositionRelativeToScreen(ScreenBound bound, Vector2 offset) 
		{
			PositionMode = PositionType.ScreenRelative;

			Bound = bound;
			ScreenBoundOffset = offset;

			if (screenService != null) {
				switch(bound) {
					case ScreenBound.TopLeft:
						m_Position = offset;
						break;
					case ScreenBound.TopRight:
						m_Position = Vector2.Add(offset,new Vector2(screenService.GameWindowSize.X,0));
						break;
					case ScreenBound.BottomRight:
						m_Position = Vector2.Add(offset,screenService.GameWindowSize);
						break;
					case ScreenBound.BottomLeft:
						m_Position = Vector2.Add(offset,new Vector2(0,screenService.GameWindowSize.Y));
						break;
				}
			}
		}