예제 #1
0
        public void ResizeBeam(float size)
        {
            float   halfheight = (int)(size / 2f);
            float   halfwidth  = beamThickness / 2f;
            float   angle      = VMath.VectorToAngle(stick);
            Polygon p          = (Polygon)beamNode.body.shape;

            p.SetBox(halfwidth, halfheight, false);
            Vector2R endpos = parent.body.pos + (stick.NormalizeSafe() * halfheight);

            beamNode.body.pos = endpos;
            p.SetOrient(angle);

            Vector2R normal = new Vector2R(-stick.Y, stick.X).NormalizeSafe();

            if (normal == Vector2R.Zero)
            {
                return;
            }
            Color c = Color.Blue;
            int   r = Math.Sign(128 - c.R) * 10;
            int   g = Math.Sign(128 - c.G) * 10;
            int   b = Math.Sign(128 - c.B) * 10;

            for (int i = 0; i < beamThickness; i++)
            {
                Vector2R offset = normal * (i - beamThickness / 2);
                Vector2R start  = parent.body.pos + offset;
                Vector2R end    = start + (stick.NormalizeSafe() * size);
                int      seed   = (int)DelegateManager.Triangle((i + tempColorVal), maxColorVal);
                Color    newcol = new Color(c.R + r * seed, c.G + g * seed, c.B + g * seed); // *0.5f;
                room.Camera.DrawLine(start, end, 1f, newcol, (int)Layers.Under2);
            }
            tempColorVal += colorValSpeed;
        }
예제 #2
0
        public override void AffectOther(Node other)
        {
            Vector2R dir = other.body.pos - parent.body.pos;

            if (link != null)
            {
                if (FollowMode != followMode.FollowNone)
                {
                    TurnTowardsDirection(parent, dir, flee, LerpPercent);
                }
                if (LeadMode != leadMode.LeadNone)
                {
                    TurnTowardsDirection(other, dir, !flee, LerpPercent);
                }
                return;
            }

            float distSquared = dir.LengthSquared();

            if (distSquared > radius * radius)
            {
                return;
            }
            if (FollowMode == followMode.FollowNearest)
            {
                if (distSquared < nearestDistSqrd)
                {
                    nearestDistSqrd = distSquared;
                    nearestNode     = other;
                }
            }
            else if (FollowMode == followMode.FollowAll)
            {
                directions.Add(dir.NormalizeSafe());
            }
            if (LeadMode == leadMode.LeadAll)
            {
                TurnTowardsDirection(other, dir, !flee, LerpPercent);
            }
            else if (LeadMode == leadMode.LeadNearest)
            {
                if (distSquared < nearestDistSqrd)
                {
                    nearestDistSqrd = distSquared;
                    nearestNode     = other;
                }
            }
        }