public Ship(GraphicsDevice GraphDev, int HeightAndWidth) : base(GraphDev, HeightAndWidth, HeightAndWidth) {
			int DrawSize;
			CollisionRegion CollideRegion = new CollisionRegion();

			//Diagonal of square = SqRt(2) * SideLength
			//That is max with of ship rotated
			DrawSize = (int)((float)HeightAndWidth / (float)Math.Sqrt(2));

			//cDrawRegion = new Rectangle();
			cDrawRegion.X = ((HeightAndWidth - DrawSize) / 2) + (DrawSize / 2);
			cDrawRegion.Y = ((HeightAndWidth - DrawSize) / 2) + (DrawSize / 2);
			cDrawRegion.Width = DrawSize;
			cDrawRegion.Height = DrawSize;

			cSpeedX = 0;
			cSpeedY = 0;

			ImageInitialAngle = 0;

			cCollisionList = new List<CollisionRegion>();
			CollideRegion.Origin.X = Left + cDrawRegion.X + (DrawSize / 2);
			CollideRegion.Origin.Y = Top + cDrawRegion.Y + (DrawSize / 2);;
			CollideRegion.Radius = (DrawSize / 2) * 0.9f;

			cCollisionList.Add(CollideRegion);

			cTint = Color.White;

			MouseRotate = false;
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor for the class
        /// </summary>
        /// <param name="GraphDev">Graphics Device this object should use to draw though</param>
        public ConvexPolygon(GraphicsDevice GraphDev)
        {
            //Setup all class variables
            FillShape   = true;
            DrawOutline = true;
            LineWidth   = 1;
            cnRotation  = 0;

            cavBaseVertexList = new List <Vector2>();

            cvScale      = new Vector2(1, 1);
            cvMove       = new Vector2(0, 0);
            cvBaseOffset = new Vector2(0, 0);

            caTexturePos = new List <Vector2>();

            cGraphDev = GraphDev;

            cLineClr       = new Color(0, 0, 0, 0);       //Black and fully transparent
            cFillClr       = new Color(0, 0, 0, 0);       //Black and fully transparent
            cCollisionList = new CollisionRegion {
                Type     = CollideType.ConvexPolygon,
                Vertexes = new List <Vector2>()
            };

            UpdateGaphicsDevice(GraphDev);

            return;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Retrieves a list of collision circles that represent where this object exists on screen
        /// </summary>
        /// <returns>The collision regions.</returns>
        public IEnumerable <CollisionRegion> GetCollisionRegions()
        {
            List <CollisionRegion> RegionList = new List <CollisionRegion>();
            CollisionRegion        NewRegion  = new CollisionRegion()
            {
                Type   = CollideType.Circle,
                Origin = new Vector2(TopLeft.X + (Width / 2), TopLeft.Y + (Height / 2)),
            };

            if (Height > Width)
            {
                NewRegion.Radius = Height / 2;
            }
            else
            {
                NewRegion.Radius = Width / 2;
            }

            //NewRegion.Radius *= 0.9f; //Shrink the region a bit to account for image border

            RegionList.Add(NewRegion);

            return(RegionList);
        }
		/// <summary>
		/// Retrieves a list of collision circles that represent where this object exists on screen
		/// </summary>
		/// <returns>The collision regions.</returns>
		public IEnumerable<CollisionRegion> GetCollisionRegions() {
			List<CollisionRegion> RegionList = new List<CollisionRegion>();
			CollisionRegion NewRegion = new CollisionRegion();

			NewRegion.Origin.X = TopLeft.X + (Width / 2);
			NewRegion.Origin.Y = TopLeft.Y + (Height / 2);

			if (Height > Width) {
				NewRegion.Radius = Height / 2;
			} else {
				NewRegion.Radius = Width / 2;
			}

			//NewRegion.Radius *= 0.9f; //Shrink the region a bit to account for image border

			RegionList.Add(NewRegion);

			return RegionList;
		}