Example #1
0
 public CollisionTestSettings(Type entityType, CollisionBoxType myBoxType, CollisionBoxType otherBoxType, float maxZDistance = 10)
 {
     this.requiredType      = entityType;
     this.collisionBoxType1 = myBoxType;
     this.collisionBoxType2 = otherBoxType;
     this.requiredFlags     = PhysicsFlags.None;
     this.maxZDistance      = maxZDistance;
 }
Example #2
0
 public CollisionTestSettings(Type entityType, Rectangle2F myBox, Rectangle2F otherBox, float maxZDistance = 10)
 {
     this.requiredType      = entityType;
     this.collisionBox1     = myBox;
     this.collisionBox2     = otherBox;
     this.collisionBoxType1 = CollisionBoxType.Custom;
     this.collisionBoxType2 = CollisionBoxType.Custom;
     this.requiredFlags     = PhysicsFlags.None;
     this.maxZDistance      = maxZDistance;
 }
Example #3
0
 public void SetFlags(PhysicsFlags flagsToSet, bool enabled)
 {
     if (enabled)
     {
         flags |= flagsToSet;
     }
     else
     {
         flags &= ~flagsToSet;
     }
 }
Example #4
0
        private Point2I ledgeTileLocation;                                      // The tile location of the ledge we are currently passing over, or (-1, -1) if not passing over ledge.


        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------

        // By default, physics are disabled.
        public PhysicsComponent(Entity entity)
        {
            this.isEnabled                = false;
            this.flags                    = PhysicsFlags.None;
            this.entity                   = entity;
            this.velocity                 = Vector2F.Zero;
            this.zVelocity                = 0.0f;
            this.previousVelocity         = Vector2F.Zero;
            this.previousZVelocity        = 0.0f;
            this.gravity                  = GameSettings.DEFAULT_GRAVITY;
            this.maxFallSpeed             = GameSettings.DEFAULT_MAX_FALL_SPEED;
            this.collisionBox             = new Rectangle2F(-1, -1, 2, 2);
            this.softCollisionBox         = new Rectangle2F(-1, -1, 2, 2);
            this.topTile                  = null;
            this.isColliding              = false;
            this.autoDodgeDistance        = 6;
            this.autoDodgeSpeed           = 1.0f;
            this.hasLanded                = false;
            this.reboundVelocity          = Vector2F.Zero;
            this.ledgeAltitude            = 0;
            this.ledgeTileLocation        = new Point2I(-1, -1);
            this.roomEdgeCollisionBoxType = CollisionBoxType.Hard;

            this.crushMaxGapSize = 0;
            this.edgeClipAmount  = 1;

            this.collisionInfo         = new CollisionInfo[Directions.Count];
            this.previousCollisionInfo = new CollisionInfo[Directions.Count];
            for (int i = 0; i < Directions.Count; i++)
            {
                collisionInfo[i].Clear();
                previousCollisionInfo[i].Clear();
            }

            this.MovementCollisions = new bool[4];
            this.ClipCollisionInfo  = new CollisionInfoNew[4];
            for (int i = 0; i < 4; i++)
            {
                ClipCollisionInfo[i] = new CollisionInfoNew();
            }
        }
        private float zVelocity; // Z-Velocity in pixels per frame.

        #endregion Fields

        #region Constructors

        //-----------------------------------------------------------------------------
        // Constructors
        //-----------------------------------------------------------------------------
        // By default, physics are disabled.
        public PhysicsComponent(Entity entity)
        {
            this.isEnabled			= false;
            this.flags				= PhysicsFlags.None;
            this.entity				= entity;
            this.velocity			= Vector2F.Zero;
            this.zVelocity			= 0.0f;
            this.gravity			= GameSettings.DEFAULT_GRAVITY;
            this.maxFallSpeed		= GameSettings.DEFAULT_MAX_FALL_SPEED;
            this.collisionBox		= new Rectangle2F(-4, -10, 8, 9);		// TEMPORARY: this is the player collision box.
            this.softCollisionBox	= new Rectangle2F(-6, -14, 12, 13);	// TEMPORARY: this is the player collision box.
            this.topTileFlags		= TileFlags.None;
            this.allTileFlags		= TileFlags.None;
            this.isColliding		= false;
            this.autoDodgeDistance	= 6;

            this.hasLanded			= false;

            this.collisionInfo = new CollisionInfo[Directions.Count];
            for (int i = 0; i < Directions.Count; i++)
                collisionInfo[i].Clear();
        }
 public CollisionTestSettings(Type entityType, Rectangle2F myBox, Rectangle2F otherBox, float maxZDistance = 10)
 {
     this.requiredType		= entityType;
     this.collisionBox1		= myBox;
     this.collisionBox2		= otherBox;
     this.collisionBoxType1	= CollisionBoxType.Custom;
     this.collisionBoxType2	= CollisionBoxType.Custom;
     this.requiredFlags		= PhysicsFlags.None;
     this.maxZDistance		= maxZDistance;
 }
 public CollisionTestSettings(Type entityType, CollisionBoxType myBoxType, CollisionBoxType otherBoxType, float maxZDistance = 10)
 {
     this.requiredType		= entityType;
     this.collisionBoxType1	= myBoxType;
     this.collisionBoxType2	= otherBoxType;
     this.requiredFlags		= PhysicsFlags.None;
     this.maxZDistance		= maxZDistance;
 }
Example #8
0
 public void EnablePhysics(PhysicsFlags flags = PhysicsFlags.None)
 {
     physics.IsEnabled = true;
     physics.Flags |= flags;
 }
Example #9
0
 public void EnablePhysics(PhysicsFlags flags = PhysicsFlags.None)
 {
     physics.IsEnabled = true;
     physics.Flags    |= flags;
 }
Example #10
0
 public void SetFlags(PhysicsFlags flagsToSet, bool enabled)
 {
     if (enabled)
         flags |= flagsToSet;
     else
         flags &= ~flagsToSet;
 }
Example #11
0
 //-----------------------------------------------------------------------------
 // Flags
 //-----------------------------------------------------------------------------
 public bool HasFlags(PhysicsFlags flags)
 {
     return ((this.flags & flags) == flags);
 }
Example #12
0
        //-----------------------------------------------------------------------------
        // Flags
        //-----------------------------------------------------------------------------

        public bool HasFlags(PhysicsFlags flags)
        {
            return((this.flags & flags) == flags);
        }