Ejemplo n.º 1
0
        public void Draw(GameTime GameTime, SpriteBatch SpriteBatch)
        {
            DamageFloatingTextList.ForEach((x) =>
            {
                x.SpriteNumericField.Draw(GameTime, SpriteBatch);
#if DEBUG
                DebugLine dL = new DebugLine(Color.Red);
                dL.Update(Cursor.Instance.CurrentFlipbook.Position, x.SpriteNumericField.Position);
                dL.Draw(SpriteBatch);
#endif
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the distance between a circumference and the CollisionBox.
        /// </summary>
        /// <param name="Point"></param>
        /// <param name="Radius"></param>
        public double GetSquaredDistance(Vector2 Point, int Radius)
        {
            /* http://www.migapro.com/circle-and-rotated-rectangle-collision-detection/ */

            float rotation = owner.MobileFlipbook.Rotation;

            // Rotate circle's center point back
            Vector2 rPos = Vector2.Transform(Point - rotatedCornerOffset, Matrix.CreateRotationZ(-rotation))
                           + rotatedBoxCenter;

            // Closest point in the rectangle to the center of circle rotated backwards(unrotated)
            Vector2 closestPosition = Vector2.Zero;

            // Find the unrotated closest x point from center of unrotated circle
            if (rPos.X < rotatedBoxCenter.X)
            {
                closestPosition += new Vector2(rotatedBoxCenter.X, 0);
            }
            else if (rPos.X > rotatedBoxCenter.X + corner[2].X)
            {
                closestPosition += new Vector2(rotatedBoxCenter.X + corner[2].X, 0);
            }
            else
            {
                closestPosition += new Vector2(rPos.X, 0);
            }

            // Find the unrotated closest y point from center of unrotated circle
            if (rPos.Y < rotatedBoxCenter.Y)
            {
                closestPosition += new Vector2(0, rotatedBoxCenter.Y);
            }
            else if (rPos.Y > rotatedBoxCenter.Y + corner[2].Y)
            {
                closestPosition += new Vector2(0, rotatedBoxCenter.Y + corner[2].Y);
            }
            else
            {
                closestPosition += new Vector2(0, rPos.Y);
            }

#if DEBUG
            //Debug Line Update
            Vector2 destination = Vector2.Transform(closestPosition - rotatedBoxCenter, Matrix.CreateRotationZ(rotation)) + rotatedCornerOffset;
            Point += Vector2.Transform(new Vector2(-Radius, 0), Matrix.CreateRotationZ((float)Helper.AngleBetween(Point, destination)));
            debugLine.Update(Point, destination);
#endif

            // Determine collision
            return(Helper.SquaredEuclideanDistance(rPos, closestPosition));// < Radius;
        }
Ejemplo n.º 3
0
        private static void OnUpdate( SharpDevice device )
        {
            // ここでしかdevice手に入らない、まだロードが完全でない
            if ( RefModel != null )
            {
                if ( RefModel.Mesh == null )
                {
                    RefModel.LoadTexture( device );
                }
            }
            //set transformation matrix
            float ratio = ( float )Form.ClientRectangle.Width / Form.ClientRectangle.Height;
            //90° degree with 1 ratio
            Projection = Camera.Projection;
            //Resizing
            if ( device.MustResize )
            {
                device.Resize( );
                OnResizeForm( ratio , device );

            }

            //apply states
            device.UpdateAllStates( );
            PreViewUpdate( device );

            //MATRICES

            //camera

            View = Camera.GetView( );
            //View = Matrix.LookAtLH(new Vector3(0, 30, 70), new Vector3(0, 0, 0), Vector3.UnitY);
            Camera.Update( Mouse , FpsCounter.Delta * 0.001f );
            Mouse.Update( );
            Vector3 from = Camera.Position;
            if ( !float.IsNaN( from.X ) )
            {
                Debug.vdb_label( "campos" );
                Debug.Send( from.DebugStr( ) );
            }

            Matrix world = Matrix.Translation( 0 , 0 , 50 ) * Matrix.RotationY( Environment.TickCount / 1000.0F );

            //light direction
            Vector3 lightDirection = new Vector3( 0.5f , 0 , -1 );
            lightDirection.Normalize( );

            //RENDERING TO DEVICE

            //Set original targets
            device.SetDefaultTargers( );

            //clear color
            device.Clear( Color.Brown );

            //apply shader
            Model.Update( device , View , Projection );
            RefModel?.Update( device , View , Projection );
            Axis.Update( device , View , Projection );

#if DEBUGLINE
            Line.Update(device, View , Projection);
#endif

            PostViewUpdate( device );

            //present
            device.Present( );

        }