Наследование: Object, IDisposable
Пример #1
0
Файл: mouse.cs Проект: KDE/qyoto
    public void TimerEvent(QTimerEvent e)
    {
        // Don't move too far away
        QLineF lineToCenter = new QLineF(new QPointF(0, 0), MapFromScene(0, 0));
        if (lineToCenter.Length() > 150) {
            double angleToCenter = Math.Acos(lineToCenter.Dx() / lineToCenter.Length());
            if (lineToCenter.Dy() < 0)
                angleToCenter = TwoPi - angleToCenter;
            angleToCenter = NormalizeAngle((Pi - angleToCenter) + Pi / 2);

            if (angleToCenter < Pi && angleToCenter > Pi / 4) {
                // Rotate left
                angle += (angle < -Pi / 2) ? 0.25 : -0.25;
            } else if (angleToCenter >= Pi && angleToCenter < (Pi + Pi / 2 + Pi / 4)) {
                // Rotate right
                angle += (angle < Pi / 2) ? 0.25 : -0.25;
            }
        } else if (Math.Sin(angle) < 0) {
            angle += 0.25;
        } else if (Math.Sin(angle) > 0) {
            angle -= 0.25;
        }

        // Try not to crash with any other mice
        List<QPointF> list = new List<QPointF>();
        list.Add(MapToScene(0, 0));
        list.Add(MapToScene(-30, -50));
        list.Add(MapToScene(30, -50));
        List<IQGraphicsItem> dangerMice = Scene().Items(new QPolygonF(list));
        foreach (QGraphicsItem item in dangerMice) {
            if (item == this)
                continue;

            QLineF lineToMouse = new QLineF(new QPointF(0, 0), MapFromItem(item, 0, 0));
            double angleToMouse = Math.Acos(lineToMouse.Dx() / lineToMouse.Length());
            if (lineToMouse.Length() == 0) {
                angleToMouse = 0;
            }

            if (lineToMouse.Dy() < 0)
                angleToMouse = TwoPi - angleToMouse;
            angleToMouse = NormalizeAngle((Pi - angleToMouse) + Pi / 2);

            if (angleToMouse >= 0 && angleToMouse < Pi / 2) {
                // Rotate right
                angle += 0.5;
            } else if (angleToMouse <= TwoPi && angleToMouse > (TwoPi - Pi / 2)) {
                // Rotate left
                angle -= 0.5;
            }
        }

        // Add some random movement
        if (dangerMice.Count > 1 && (random.Next(10)) == 0) {
            if (random.Next(1) == 1)
                angle += (random.Next(100)) / 500.0;
            else
                angle -= (random.Next(100)) / 500.0;
        }

        speed += (-50 + random.Next(100)) / 100.0;

        double dx = Math.Sin(angle) * 10;
        mouseEyeDirection = (Math.Abs(dx / 5) < 1) ? 0 : dx / 5;

        Rotate(dx);
        SetPos(MapToParent(0, -(3 + Math.Sin(speed) * 3)));
    }
Пример #2
0
 public QGraphicsLineItem AddLine(QLineF line, QPen pen)
 {
     return((QGraphicsLineItem)interceptor.Invoke("addLine##", "addLine(const QLineF&, const QPen&)", typeof(QGraphicsLineItem), typeof(QLineF), line, typeof(QPen), pen));
 }
Пример #3
0
 public double Angle(QLineF l)
 {
     return((double)interceptor.Invoke("angle#", "angle(const QLineF&) const", typeof(double), typeof(QLineF), l));
 }
Пример #4
0
Файл: Qt.cs Проект: KDE/qyoto
 public static QDataStream Read(QDataStream arg1, QLineF arg2)
 {
     return (QDataStream) staticInterceptor.Invoke("operator>>##", "operator>>(QDataStream&, QLineF&)", typeof(QDataStream), typeof(QDataStream), arg1, typeof(QLineF), arg2);
 }
Пример #5
0
Файл: Qt.cs Проект: KDE/qyoto
 public static QDataStream Write(QDataStream arg1, QLineF arg2)
 {
     return (QDataStream) staticInterceptor.Invoke("operator<<##", "operator<<(QDataStream&, const QLineF&)", typeof(QDataStream), typeof(QDataStream), arg1, typeof(QLineF), arg2);
 }
Пример #6
0
 public double AngleTo(QLineF l)
 {
     return (double) interceptor.Invoke("angleTo#", "angleTo(const QLineF&) const", typeof(double), typeof(QLineF), l);
 }
Пример #7
0
 public QGraphicsLineItem AddLine(QLineF line, QPen pen)
 {
     return (QGraphicsLineItem) interceptor.Invoke("addLine##", "addLine(const QLineF&, const QPen&)", typeof(QGraphicsLineItem), typeof(QLineF), line, typeof(QPen), pen);
 }
Пример #8
0
 public void SetLine(QLineF line)
 {
     interceptor.Invoke("setLine#", "setLine(const QLineF&)", typeof(void), typeof(QLineF), line);
 }
Пример #9
0
 public virtual void DrawLines(QLineF lines, int lineCount)
 {
     interceptor.Invoke("drawLines#$", "drawLines(const QLineF*, int)", typeof(void), typeof(QLineF), lines, typeof(int), lineCount);
 }
Пример #10
0
 public QGraphicsLineItem(QLineF line, IQGraphicsItem parent) : this((Type)null)
 {
     CreateProxy();
     interceptor.Invoke("QGraphicsLineItem##", "QGraphicsLineItem(const QLineF&, QGraphicsItem*)", typeof(void), typeof(QLineF), line, typeof(IQGraphicsItem), parent);
 }
Пример #11
0
 public QGraphicsLineItem(QLineF line) : this((Type)null)
 {
     CreateProxy();
     interceptor.Invoke("QGraphicsLineItem#", "QGraphicsLineItem(const QLineF&)", typeof(void), typeof(QLineF), line);
 }
Пример #12
0
 public QVariant(QLineF line)
     : this((Type) null)
 {
     CreateProxy();
     interceptor.Invoke("QVariant#", "QVariant(const QLineF&)", typeof(void), typeof(QLineF), line);
 }
Пример #13
0
 public QLineF Map(QLineF l)
 {
     return((QLineF)interceptor.Invoke("map#", "map(const QLineF&) const", typeof(QLineF), typeof(QLineF), l));
 }
Пример #14
0
 public QGraphicsLineItem AddLine(QLineF line)
 {
     return((QGraphicsLineItem)interceptor.Invoke("addLine#", "addLine(const QLineF&)", typeof(QGraphicsLineItem), typeof(QLineF), line));
 }
Пример #15
0
 public void DrawLine(QLineF line)
 {
     interceptor.Invoke("drawLine#", "drawLine(const QLineF&)", typeof(void), typeof(QLineF), line);
 }
Пример #16
0
 public QLineF Map(QLineF l)
 {
     return (QLineF) interceptor.Invoke("map#", "map(const QLineF&) const", typeof(QLineF), typeof(QLineF), l);
 }
Пример #17
0
 public void DrawLines(QLineF lines, int lineCount)
 {
     interceptor.Invoke("drawLines#$", "drawLines(const QLineF*, int)", typeof(void), typeof(QLineF), lines, typeof(int), lineCount);
 }
Пример #18
0
 public void SetLine(QLineF line)
 {
     interceptor.Invoke("setLine#", "setLine(const QLineF&)", typeof(void), typeof(QLineF), line);
 }
Пример #19
0
 public QLineF.IntersectType Intersect(QLineF l, QPointF intersectionPoint)
 {
     return (QLineF.IntersectType) interceptor.Invoke("intersect##", "intersect(const QLineF&, QPointF*) const", typeof(QLineF.IntersectType), typeof(QLineF), l, typeof(QPointF), intersectionPoint);
 }
Пример #20
0
 public QGraphicsLineItem(QLineF line, IQGraphicsItem parent)
     : this((Type) null)
 {
     CreateProxy();
     interceptor.Invoke("QGraphicsLineItem##", "QGraphicsLineItem(const QLineF&, QGraphicsItem*)", typeof(void), typeof(QLineF), line, typeof(IQGraphicsItem), parent);
 }
Пример #21
0
 public QGraphicsLineItem AddLine(QLineF line)
 {
     return (QGraphicsLineItem) interceptor.Invoke("addLine#", "addLine(const QLineF&)", typeof(QGraphicsLineItem), typeof(QLineF), line);
 }
Пример #22
0
 public QGraphicsLineItem(QLineF line)
     : this((Type) null)
 {
     CreateProxy();
     interceptor.Invoke("QGraphicsLineItem#", "QGraphicsLineItem(const QLineF&)", typeof(void), typeof(QLineF), line);
 }
Пример #23
0
Файл: Qt.cs Проект: KDE/qyoto
 public static QDBusArgument Read(QDBusArgument a, QLineF line)
 {
     return (QDBusArgument) staticInterceptor.Invoke("operator>>##", "operator>>(const QDBusArgument&, QLineF&)", typeof(QDBusArgument), typeof(QDBusArgument), a, typeof(QLineF), line);
 }
Пример #24
0
 public QLineF.IntersectType Intersect(QLineF l, QPointF intersectionPoint)
 {
     return((QLineF.IntersectType)interceptor.Invoke("intersect##", "intersect(const QLineF&, QPointF*) const", typeof(QLineF.IntersectType), typeof(QLineF), l, typeof(QPointF), intersectionPoint));
 }
Пример #25
0
Файл: Qt.cs Проект: KDE/qyoto
 public static QDBusArgument Write(QDBusArgument a, QLineF line)
 {
     return (QDBusArgument) staticInterceptor.Invoke("operator<<##", "operator<<(QDBusArgument&, const QLineF&)", typeof(QDBusArgument), typeof(QDBusArgument), a, typeof(QLineF), line);
 }
Пример #26
0
 public QVariant(QLineF line) : this((Type)null)
 {
     CreateProxy();
     interceptor.Invoke("QVariant#", "QVariant(const QLineF&)", typeof(void), typeof(QLineF), line);
 }