コード例 #1
0
        public void CallCollision(ICollider col1, ICollider col2)                                         //calls the OnCollision method of the colliders if they are the right type (it cheks if they are the right type)
        {
            if (col1.collisionType != CollisionType.Simple && col1.collisionType != CollisionType.Simple) //makes sure col1 is not simple or simple wall (simple means dont call OnCollision)
            {
                col1.OnCollision();
            }

            if (col2.collisionType != CollisionType.Simple && col2.collisionType != CollisionType.Simple)  //makes sure col2 is not simple or simple wall (simple means dont call OnCollision)
            {
                col2.OnCollision();
            }
        }
コード例 #2
0
        public bool Intersects(ICollider other)
        {
            if (Polygon2.Intersects(
                    PhysicsCollider, other.PhysicsCollider,
                    Particle.Position, other.Particle.Position,
                    false))
            {
                // event 1
                CollisionEvent args = new CollisionEvent();
                args.Colliding = true;
                args.Entity1   = Owner.Owner;
                args.Entity2   = other.Owner.Owner;

                OnCollision(this, args);
                other.OnCollision(this, args);

                return(true);
            }
            else
            {
                return(false);
            }
        }