Exemple #1
0
        /// <summary>
        ///   Lock on the bubble dictionary is held already
        /// </summary>
        /// <param name="widgetNode"></param>
        /// <param name="now"></param>
        private void UpdateNode(AttachedWidget widgetNode, long now)
        {
            const float MaxFadeRange        = 40 * Client.OneMeter;
            const float MinFadeRange        = 20 * Client.OneMeter;
            const float MaxFadeRangeSquared = MaxFadeRange * MaxFadeRange;
            const float MinFadeRangeSquared = MinFadeRange * MinFadeRange;

            Axiom.MathLib.Vector3 ray =
                widgetNode.Node.DerivedPosition - client.Camera.DerivedPosition;

            // Don't show if they are too far away
            if (ray.LengthSquared > MaxFadeRangeSquared)
            {
                widgetNode.Visible = false;
                return;
            }

            BubbleTextNode bubbleNode = (BubbleTextNode)widgetNode;

            if (bubbleNode.IsExpired(now))
            {
                widgetNode.Visible = false;
                return;
            }

            Vector3 widgetOffset = new Vector3(0, 0.3f * Client.OneMeter, 0);
            Point   pixelOffset  = new Point(0, -50);

            // if (!SetWidgetPosition(widgetNode, widgetOffset, pixelOffset))
            if (!SetWidgetPosition(widgetNode, Vector3.Zero, pixelOffset))
            {
                return;
            }

            if (ray.LengthSquared < MinFadeRangeSquared)
            {
                widgetNode.Widget.Alpha = 1.0f;
            }
            else
            {
                widgetNode.Widget.Alpha = 1.0f - (ray.Length - MinFadeRange) / (MaxFadeRange - MinFadeRange);
            }
            if (this.Visible)
            {
                widgetNode.Visible = true;
            }
        }
Exemple #2
0
        protected bool SetWidgetPosition(AttachedWidget widgetNode,
                                         Vector3 widgetOffset, Point pixelOffset)
        {
            Vector3 widgetPosition = widgetNode.Node.DerivedPosition + widgetOffset;
            float   screenX, screenY, screenZ;

            if (!client.GetScreenPosition(widgetPosition, out screenX, out screenY, out screenZ))
            {
                widgetNode.Visible = false;
                return(false);
            }
            screenX = screenX * window.Width + pixelOffset.x;
            screenY = screenY * window.Height + pixelOffset.y;
            if ((screenX > window.Width) || (screenX < 0.0f) ||
                (screenY > window.Height) || (screenY < 0.0f))
            {
                widgetNode.Visible = false;
                return(false);
            }
            widgetNode.SetPosition(screenX, screenY, screenZ);
            return(true);
        }
 protected bool SetWidgetPosition(AttachedWidget widgetNode, Vector3 widgetOffset)
 {
     Point zero = new Point(0, 0);
     return SetWidgetPosition(widgetNode, widgetOffset, zero);
 }
        protected bool SetWidgetPosition(AttachedWidget widgetNode,
										 Vector3 widgetOffset, Point pixelOffset)
        {
            Vector3 widgetPosition = widgetNode.Node.DerivedPosition + widgetOffset;
            float screenX, screenY, screenZ;
            if (!client.GetScreenPosition(widgetPosition, out screenX, out screenY, out screenZ)) {
                widgetNode.Visible = false;
                return false;
            }
            screenX = screenX * window.Width + pixelOffset.x;
            screenY = screenY * window.Height + pixelOffset.y;
            if ((screenX > window.Width) || (screenX < 0.0f) ||
                (screenY > window.Height) || (screenY < 0.0f)) {
                widgetNode.Visible = false;
                return false;
            }
            widgetNode.SetPosition(screenX, screenY, screenZ);
            return true;
        }
        /// <summary>
        ///   Lock on the name dictionary is held already
        /// </summary>
        /// <param name="widgetNode"></param>
        /// <param name="now"></param>
        private void UpdateNode(AttachedWidget widgetNode, long now)
        {
            const float MaxFadeRange = 40 * Client.OneMeter;
            const float MinFadeRange = 20 * Client.OneMeter;
            const float MaxFadeRangeSquared = MaxFadeRange * MaxFadeRange;
            const float MinFadeRangeSquared = MinFadeRange * MinFadeRange;

            ColorEx[] SelectedColors = new ColorEx[4];
            SelectedColors[0] = new ColorEx(1, 0, 1.0f, 1.0f);
            SelectedColors[1] = new ColorEx(1, 0, 0.9f, 0.9f);
            SelectedColors[2] = new ColorEx(1, 0, 0.8f, 0.8f);
            SelectedColors[3] = new ColorEx(1, 0, 0.7f, 0.7f);

            ColorEx StandardColor = new ColorEx(1, 0, 0.9f, 0.9f);

            Axiom.MathLib.Vector3 ray =
                widgetNode.Node.DerivedPosition - client.Camera.DerivedPosition;

            if (!IsTargeted(widgetNode.Oid)) {
                // Don't show if they are too far away or if they are the player,
                // unless they are selected
                if (widgetNode.Oid == client.PlayerId || ray.LengthSquared > MaxFadeRangeSquared) {
                    widgetNode.Visible = false;
                    return;
                }
            }

            // Put the name widget about one foot above the mob's head
            if (!SetWidgetPosition(widgetNode, Vector3.Zero))
            // if (!SetWidgetPosition(widgetNode, new Vector3(0, 0.3f * Client.OneMeter, 0)))
                return;

            if (ray.LengthSquared < MinFadeRangeSquared || IsTargeted(widgetNode.Oid))
                widgetNode.Widget.Alpha = 1.0f;
            else
                widgetNode.Widget.Alpha = 1.0f - (ray.Length - MinFadeRange) / (MaxFadeRange - MinFadeRange);
            #if OLD_CODE
            ZOrderedStaticText textWidget = (ZOrderedStaticText)widgetNode.Widget;
            if (IsTargeted(widgetNode.Oid)) {
                const int Period = 500;
                // Blink the name with a 500ms period.
                float tmp = now % Period;
                tmp /= Period;
                int i = (int)Math.Min(3, 4 * Math.Sin(Math.PI * tmp));
                textWidget.SetTextColor(SelectedColors[i]);
            } else
                textWidget.SetTextColor(StandardColor);
            #endif
            if (this.Visible)
                widgetNode.Visible = true;
        }
        /// <summary>
        ///   Lock on the bubble dictionary is held already
        /// </summary>
        /// <param name="widgetNode"></param>
        /// <param name="now"></param>
        private void UpdateNode(AttachedWidget widgetNode, long now)
        {
            const float MaxFadeRange = 40 * Client.OneMeter;
            const float MinFadeRange = 20 * Client.OneMeter;
            const float MaxFadeRangeSquared = MaxFadeRange * MaxFadeRange;
            const float MinFadeRangeSquared = MinFadeRange * MinFadeRange;

            Axiom.MathLib.Vector3 ray =
                widgetNode.Node.DerivedPosition - client.Camera.DerivedPosition;

            // Don't show if they are too far away
            if (ray.LengthSquared > MaxFadeRangeSquared) {
                widgetNode.Visible = false;
                return;
            }

            BubbleTextNode bubbleNode = (BubbleTextNode)widgetNode;
            if (bubbleNode.IsExpired(now)) {
                widgetNode.Visible = false;
                return;
            }

            Vector3 widgetOffset = new Vector3(0, 0.3f * Client.OneMeter, 0);
            Point pixelOffset = new Point(0, -50);

            // if (!SetWidgetPosition(widgetNode, widgetOffset, pixelOffset))
            if (!SetWidgetPosition(widgetNode, Vector3.Zero, pixelOffset))
                return;

            if (ray.LengthSquared < MinFadeRangeSquared)
                widgetNode.Widget.Alpha = 1.0f;
            else
                widgetNode.Widget.Alpha = 1.0f - (ray.Length - MinFadeRange) / (MaxFadeRange - MinFadeRange);
            if (this.Visible)
                widgetNode.Visible = true;
        }
Exemple #7
0
        /// <summary>
        ///   Lock on the name dictionary is held already
        /// </summary>
        /// <param name="widgetNode"></param>
        /// <param name="now"></param>
        private void UpdateNode(AttachedWidget widgetNode, long now)
        {
            const float MaxFadeRange        = 40 * Client.OneMeter;
            const float MinFadeRange        = 20 * Client.OneMeter;
            const float MaxFadeRangeSquared = MaxFadeRange * MaxFadeRange;
            const float MinFadeRangeSquared = MinFadeRange * MinFadeRange;

            ColorEx[] SelectedColors = new ColorEx[4];
            SelectedColors[0] = new ColorEx(1, 0, 1.0f, 1.0f);
            SelectedColors[1] = new ColorEx(1, 0, 0.9f, 0.9f);
            SelectedColors[2] = new ColorEx(1, 0, 0.8f, 0.8f);
            SelectedColors[3] = new ColorEx(1, 0, 0.7f, 0.7f);

            ColorEx StandardColor = new ColorEx(1, 0, 0.9f, 0.9f);

            Axiom.MathLib.Vector3 ray =
                widgetNode.Node.DerivedPosition - client.Camera.DerivedPosition;

            if (!IsTargeted(widgetNode.Oid))
            {
                // Don't show if they are too far away or if they are the player,
                // unless they are selected
                if (widgetNode.Oid == client.PlayerId || ray.LengthSquared > MaxFadeRangeSquared)
                {
                    widgetNode.Visible = false;
                    return;
                }
            }

            // Put the name widget about one foot above the mob's head
            if (!SetWidgetPosition(widgetNode, Vector3.Zero))
            {
                // if (!SetWidgetPosition(widgetNode, new Vector3(0, 0.3f * Client.OneMeter, 0)))
                return;
            }

            if (ray.LengthSquared < MinFadeRangeSquared || IsTargeted(widgetNode.Oid))
            {
                widgetNode.Widget.Alpha = 1.0f;
            }
            else
            {
                widgetNode.Widget.Alpha = 1.0f - (ray.Length - MinFadeRange) / (MaxFadeRange - MinFadeRange);
            }
#if OLD_CODE
            ZOrderedStaticText textWidget = (ZOrderedStaticText)widgetNode.Widget;
            if (IsTargeted(widgetNode.Oid))
            {
                const int Period = 500;
                // Blink the name with a 500ms period.
                float tmp = now % Period;
                tmp /= Period;
                int i = (int)Math.Min(3, 4 * Math.Sin(Math.PI * tmp));
                textWidget.SetTextColor(SelectedColors[i]);
            }
            else
            {
                textWidget.SetTextColor(StandardColor);
            }
#endif
            if (this.Visible)
            {
                widgetNode.Visible = true;
            }
        }
Exemple #8
0
        protected bool SetWidgetPosition(AttachedWidget widgetNode, Vector3 widgetOffset)
        {
            Point zero = new Point(0, 0);

            return(SetWidgetPosition(widgetNode, widgetOffset, zero));
        }