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; }
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; }
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; }
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; }
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; }
public abstract bool Collides(CollisionShape a_cs2);
public override void loadContent() { base.loadContent(); m_collisionShape = new CollisionRectangle(0, 0, m_img.getSize().X, m_img.getSize().Y, m_position); }
public static bool Contains(CollisionShape a_cs1, Vector2 a_cs2) { return a_cs1.contains(a_cs2); }
public static bool Collides(CollisionShape a_cs1, CollisionShape a_cs2) { return a_cs1.collides(a_cs2); }