Beispiel #1
0
        internal void calcPos(Counter <OrderedPair <Node> > pairCounter)
        {
            if (!isCycle())
            {
                mVecPair = mPair.map <Vec>(delegate(OrderedPair <Node> pair)
                {
                    Vec delta = pair.mSecond.mPos - pair.mFirst.mPos;
                    Vec vec   = delta.norm();

                    double shift = (mShift - (pairCounter.get(mPair.getOrderedPair()) - 1) * 0.5f) * W;
                    Vec pFirst   = pair.mFirst.mPos + vec.rotate() * shift + vec * Node.mSize / 2;
                    Vec pSecond  = pair.mSecond.mPos + vec.rotate() * shift - vec * Node.mSize / 2;
                    return(new OrderedPair <Vec>(pFirst, pSecond));
                });
            }
            else
            {
                Vec pos = mPair.mFirst.mPos + Vec.getDir(mShift, 3, W);
                mVecPair = new SwapPair <Vec>(pos, pos, false);
            }
        }
Beispiel #2
0
        internal void paint(Drawer drawer, bool selected)
        {
            Color color = Color.Black;

            if (mPair.mFirst.hasFishka())
            {
                color = mPair.mFirst.getFishka().mPlayer.mColor;
            }

            if (mAlive)
            {
                Pen pen = new Pen(color);
                if (selected)
                {
                    pen = new Pen(color, 3);
                }

                if (!isCycle())
                {
                    Vec delta2 = mVecPair.mSecond - mVecPair.mFirst;
                    Vec vec2   = delta2.norm();
                    Vec p1     = mVecPair.mSecond - vec2 * W + vec2.rotate() * W / 2;
                    Vec p2     = mVecPair.mSecond - vec2 * W - vec2.rotate() * W / 2;

                    drawer.drawLine(pen, mVecPair.mFirst, mVecPair.mSecond);
                    drawer.drawLine(pen, p1, mVecPair.mSecond);
                    drawer.drawLine(pen, p2, mVecPair.mSecond);
                    drawer.drawEllipse(pen, getCenter(), W / 3);
                }
                else
                {
                    drawer.drawEllipse(pen, mVecPair.mFirst, W);
                }
            }
            else
            {
                if (mDeadProc < 1)
                {
                    if (isCycle())
                    {
                        drawer.drawExplose(new Pen(color, 1), mVecPair.mFirst, W / 2, mDeadProc);
                    }
                    else
                    {
                        const int    PART   = 10;
                        const double PART_1 = 1.0 / PART;

                        for (int i = 0; i < PART; i++)
                        {
                            Vec delta2 = mVecPair.mSecond - mVecPair.mFirst;
                            Vec vec2   = delta2.norm();
                            Vec p1     = mVecPair.mFirst + vec2 * W;
                            Vec p2     = mVecPair.mSecond - vec2 * W;

                            double a = i * PART_1 + mDeadProc * PART_1 / 2;
                            double b = (i + 1) * PART_1 - mDeadProc * PART_1 / 2;

                            drawer.drawLine(new Pen(color, 1), p1.interpolate(p2, a), p1.interpolate(p2, b));
                        }
                    }
                }
            }
        }