예제 #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                this.aaResult     = null;
                this.abResult     = null;
                this.AxACollision = null;
                this.AxBCollision = null;
                this.caResult     = null;
                this.cbResult     = null;
                this.ccResult     = null;
                this.CxACollision = null;
                this.CxBCollision = null;
                this.CxCCollision = null;
                this.entity       = null;
                this.Screen       = null;
            }

            disposed = true;

            base.Dispose(disposing);
        }
예제 #2
0
 public Result(AnimatedActor source, AnimatedActor collided, GameTime gameTime, Tuple <T1, T2> boxes, RectangleCollisionResult result)
 {
     Source          = source;
     CollidedEntity  = collided;
     GameTime        = gameTime;
     Boxes           = boxes;
     CollisionResult = result;
 }
예제 #3
0
 /// <summary>
 /// Inicializa uma nova instância da classe BoxCollisionComponent como uma cópia de outro BoxCollisionComponent.
 /// </summary>
 /// <param name="destination">O ator a ser associado esse componente.</param>
 /// <param name="source">A origem para cópia.</param>
 public BoxCollisionComponent(AnimatedActor destination, BoxCollisionComponent source) : base(destination, source)
 {
     AxACollision = source.AxACollision;
     AxBCollision = source.AxBCollision;
     CxACollision = source.CxACollision;
     CxBCollision = source.CxBCollision;
     CxCCollision = source.CxCCollision;
     Screen       = source.Screen;
     Entities     = source.Entities;
 }
예제 #4
0
        private void Check(AnimatedActor e, AnimatedActor o, GameTime gameTime)
        {
            RectangleCollisionResult result = new RectangleCollisionResult();

            //Procura todos os CollisionBox da entidade
            for (int i = 0; i < e.CollisionBoxes.Count; i++)
            {
                CollisionBox ecb = e.CollisionBoxes[i];

                for (int j = 0; j < o.CollisionBoxes.Count; j++)
                {
                    CollisionBox ocb = o.CollisionBoxes[j];

                    if (Collision.BoundsCollision(ecb.Bounds, ocb.Bounds))
                    {
                        result.Intersection = Rectangle.Intersect(ecb.Bounds, ocb.Bounds);
                        result.Subtract     = Collision.Subtract(ecb.Bounds, ocb.Bounds);

                        ccResult.Source          = entity;
                        ccResult.CollidedEntity  = o;
                        ccResult.GameTime        = gameTime;
                        ccResult.Boxes           = new Tuple <CollisionBox, CollisionBox>(ecb, ocb);
                        ccResult.CollisionResult = result;

                        CxCCollision?.Invoke(ccResult);
                    }
                }

                for (int j = 0; j < o.AttackBoxes.Count; j++)
                {
                    AttackBox oab = o.AttackBoxes[j];

                    if (Collision.BoundsCollision(ecb.Bounds, oab.Bounds))
                    {
                        result.Intersection = Rectangle.Intersect(ecb.Bounds, oab.Bounds);
                        result.Subtract     = Collision.Subtract(ecb.Bounds, oab.Bounds);

                        caResult.Source          = entity;
                        caResult.CollidedEntity  = o;
                        caResult.GameTime        = gameTime;
                        caResult.Boxes           = new Tuple <CollisionBox, AttackBox>(ecb, oab);
                        caResult.CollisionResult = result;

                        CxACollision?.Invoke(caResult);
                    }
                }

                if (Collision.BoundsCollision(e.CollisionBoxes[i].Bounds, o.Bounds))
                {
                    result.Intersection = Rectangle.Intersect(ecb.Bounds, o.Bounds);
                    result.Subtract     = Collision.Subtract(ecb.Bounds, o.Bounds);

                    cbResult.Source          = entity;
                    cbResult.CollidedEntity  = o;
                    cbResult.GameTime        = gameTime;
                    cbResult.Boxes           = new Tuple <CollisionBox, Rectangle>(ecb, o.Bounds);
                    cbResult.CollisionResult = result;

                    CxBCollision?.Invoke(cbResult);
                }
            }

            //Procura todos os AttackBox da entidade
            for (int i = 0; i < e.AttackBoxes.Count; i++)
            {
                AttackBox eab = e.AttackBoxes[i];

                for (int j = 0; j < o.CollisionBoxes.Count; j++)
                {
                    CollisionBox ocb = o.CollisionBoxes[j];

                    if (Collision.BoundsCollision(eab.Bounds, ocb.Bounds))
                    {
                        result.Intersection = Rectangle.Intersect(eab.Bounds, ocb.Bounds);
                        result.Subtract     = Collision.Subtract(eab.Bounds, ocb.Bounds);

                        caResult.Source          = entity;
                        caResult.CollidedEntity  = o;
                        caResult.GameTime        = gameTime;
                        caResult.Boxes           = new Tuple <CollisionBox, AttackBox>(ocb, eab);
                        caResult.CollisionResult = result;

                        CxACollision?.Invoke(caResult);
                    }
                }

                for (int j = 0; j < o.AttackBoxes.Count; j++)
                {
                    AttackBox oab = o.AttackBoxes[j];

                    if (Collision.BoundsCollision(eab.Bounds, oab.Bounds))
                    {
                        result.Intersection = Rectangle.Intersect(eab.Bounds, oab.Bounds);
                        result.Subtract     = Collision.Subtract(eab.Bounds, oab.Bounds);

                        aaResult.Source          = entity;
                        aaResult.CollidedEntity  = o;
                        aaResult.GameTime        = gameTime;
                        aaResult.Boxes           = new Tuple <AttackBox, AttackBox>(eab, oab);
                        aaResult.CollisionResult = result;

                        AxACollision?.Invoke(aaResult);
                    }
                }

                if (Collision.BoundsCollision(e.AttackBoxes[i].Bounds, o.Bounds))
                {
                    result.Intersection = Rectangle.Intersect(eab.Bounds, o.Bounds);
                    result.Subtract     = Collision.Subtract(eab.Bounds, o.Bounds);

                    abResult.Source          = entity;
                    abResult.CollidedEntity  = o;
                    abResult.GameTime        = gameTime;
                    abResult.Boxes           = new Tuple <AttackBox, Rectangle>(eab, o.Bounds);
                    abResult.CollisionResult = result;

                    AxBCollision?.Invoke(abResult);
                }
            }
        }
예제 #5
0
        //---------------------------------------//
        //-----         CONSTRUTOR          -----//
        //---------------------------------------//

        /// <summary>
        /// Inicializa uma nova instância de BoxCollisionComponent.
        /// </summary>
        /// <param name="animatedEntity">Define o AnimatedEntity o qual esse componente será associado.</param>
        public BoxCollisionComponent(AnimatedActor animatedEntity) : base(animatedEntity)
        {
            Name   = nameof(BoxCollisionComponent);
            entity = animatedEntity;
        }
예제 #6
0
        //----------------------------------------//
        //-----         CONSTRUTOR           -----//
        //----------------------------------------//

        /// <summary>
        /// Inicializa uma nova instância de GhostComponent.
        /// </summary>
        /// <param name="actor">O ator associado a esse component.</param>
        public GhostComponent(AnimatedActor actor) : base(actor)
        {
            entity = actor;
        }
예제 #7
0
 /// <summary>
 /// Inicializa uma nova instância de GhostComponent como cópia de outra instâcia
 /// </summary>
 /// <param name="destination">O ator a ser associado.</param>
 /// <param name="source">O componente a ser copiado.</param>
 public GhostComponent(AnimatedActor destination, ActorComponent source) : base(destination, source)
 {
     entity = destination;
 }