示例#1
0
 public override bool collides(CollisionShape a_cs)
 {
     if (a_cs is CollisionRectangle)
     {
         CollisionRectangle a_cr = (CollisionRectangle)a_cs;
         foreach(Vector2 v in a_cr.getFivePoints())
         {
             if (contains(v))
             {
                 return true;
             }
         }
         foreach(Vector2 v in getFourPoints())
         {
             if (a_cr.contains(v))
             {
                 return true;
             }
         }
     }
     else if (a_cs is CollisionLine)
     {
         return collidesWithLineSegment(((CollisionLine)a_cs).getPosition().getGlobalCartesian(), ((CollisionLine)a_cs).getEndPosition().getGlobalCartesian());
     }
     return false;
 }
示例#2
0
 public override bool collides(CollisionShape a_cs)
 {
     if (a_cs is CollisionRectangle)
     {
         return a_cs.collidesWithLineSegment(m_position.getGlobalCartesian(), m_endPosition.getGlobalCartesian());
     }
     else if (a_cs is CollisionLine)
     {
         return collidesWithLineSegment(((CollisionLine)a_cs).getPosition().getGlobalCartesian(), ((CollisionLine)a_cs).getEndPosition().getGlobalCartesian());
     }
     return false;
 }
示例#3
0
        public override bool Collides(CollisionShape a_cs)
        {
            if (a_cs is CollisionRectangle)
            {
                CollisionRectangle t_cr = (CollisionRectangle)a_cs;

                return (m_xOffset + m_position.getGlobalX() < t_cr.m_xOffset + t_cr.m_position.getGlobalX() + t_cr.m_width &&
                    m_xOffset + m_position.getGlobalX() + m_width > t_cr.m_xOffset + t_cr.m_position.getGlobalX() &&
                    m_yOffset + m_position.getGlobalY() < t_cr.m_yOffset + t_cr.m_position.getGlobalY() + t_cr.m_height &&
                    m_yOffset + m_position.getGlobalY() + m_height > t_cr.m_yOffset + t_cr.m_position.getGlobalY());
            }
            else if (a_cs is CollisionTriangle)
            {
                return a_cs.Collides(this);
            }
            return false;
        }
示例#4
0
        public override bool collides(CollisionShape a_cs)
        {
            if (a_cs is CollisionRectangle)
            {
                CollisionRectangle t_cr = (CollisionRectangle)a_cs;

                return (m_xOffset + m_position.getGlobalX() < t_cr.m_xOffset + t_cr.m_position.getGlobalX() + t_cr.m_width &&
                    m_xOffset + m_position.getGlobalX() + m_width > t_cr.m_xOffset + t_cr.m_position.getGlobalX() &&
                    m_yOffset + m_position.getGlobalY() < t_cr.m_yOffset + t_cr.m_position.getGlobalY() + t_cr.m_height &&
                    m_yOffset + m_position.getGlobalY() + m_height > t_cr.m_yOffset + t_cr.m_position.getGlobalY());
            }
            else if (a_cs is CollisionTriangle)
            {
                return a_cs.collides(this);
            }
            else if (a_cs is CollisionLine)
            {
                return collidesWithLineSegment(((CollisionLine)a_cs).getPosition().getGlobalCartesian(), ((CollisionLine)a_cs).getEndPosition().getGlobalCartesian());
            }
            return false;
        }
示例#5
0
 public override bool Collides(CollisionShape a_cs)
 {
     if (a_cs is CollisionRectangle)
     {
         CollisionRectangle a_cr = (CollisionRectangle)a_cs;
         foreach(Vector2 v in a_cr.getFivePoints())
         {
             if (contains(v))
             {
                 return true;
             }
         }
         foreach(Vector2 v in getFourPoints())
         {
             if (a_cr.contains(v))
             {
                 return true;
             }
         }
     }
     return false;
 }
示例#6
0
 public abstract bool Collides(CollisionShape a_cs2);
示例#7
0
文件: Entity.cs 项目: Yuma-Shi/GLhf
 public override void loadContent()
 {
     base.loadContent();
     m_collisionShape = new CollisionRectangle(0, 0, m_img.getSize().X, m_img.getSize().Y, m_position);
 }
示例#8
0
 public static bool Contains(CollisionShape a_cs1, Vector2 a_cs2)
 {
     return a_cs1.contains(a_cs2);
 }
示例#9
0
 public static bool Collides(CollisionShape a_cs1, CollisionShape a_cs2)
 {
     return a_cs1.collides(a_cs2);
 }