Beispiel #1
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;
        }
Beispiel #2
0
 public static bool Collides(CollisionShape a_cs1, CollisionShape a_cs2)
 {
     return a_cs1.collides(a_cs2);
 }