예제 #1
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            ResetHueVector();

            for (int i = 0; i < _container.Count; i++)
            {
                if (i + 1 >= _container.Count)
                {
                    break;
                }

                Control c0 = _container[i];
                Control c1 = _container[i + 1];

                batcher.DrawLine
                (
                    Texture2DCache.GetTexture(Color.White),
                    c0.ScreenCoordinateX, c0.ScreenCoordinateY,
                    c1.ScreenCoordinateX, c1.ScreenCoordinateY,
                    c0.ScreenCoordinateX + (c1.ScreenCoordinateX - c0.ScreenCoordinateX) / 2, c0.ScreenCoordinateY + (c1.ScreenCoordinateY - c0.ScreenCoordinateY) / 2
                );
            }

            return(true);
        }
예제 #2
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 1, y - 1, _background.Width + 1, _background.Height + 1, ref _hueVector);

            return(base.Draw(batcher, x, y));
        }
예제 #3
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();

            ShaderHueTranslator.GetHueVector(ref _hueVector, Hue, false, Alpha);

            return(batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x, y, Width, Height, ref _hueVector));
        }
예제 #4
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();
            base.Draw(batcher, x, y);
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x, y, Width, Height, ref _hueVector);

            return(true);
        }
예제 #5
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (DrawBackgroundCurrentIndex && MouseIsOver && !string.IsNullOrWhiteSpace(Text))
            {
                ResetHueVector();
                batcher.Draw2D(Texture2DCache.GetTexture(Color.Gray), x, y + 2, Width - 4, Height - 4, ref _hueVector);
            }

            return(base.Draw(batcher, x, y));
        }
예제 #6
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (!string.IsNullOrWhiteSpace(_label.Text) && MouseIsOver)
            {
                ResetHueVector();

                batcher.Draw2D(Texture2DCache.GetTexture(Color.Gray), x + 2, y + 5, Width - 4, Height - 10, ref _hueVector);
            }

            return(base.Draw(batcher, x, y));
        }
예제 #7
0
파일: Line.cs 프로젝트: Juzzver/MobileUO
 public Line(int x, int y, int w, int h, uint color)
 {
     X        = x;
     Y        = y;
     Width    = w;
     Height   = h;
     _texture = Texture2DCache.GetTexture(new Color()
     {
         PackedValue = color
     });
 }
예제 #8
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                base.Draw(batcher, x, y);


                Texture2D color = Texture2DCache.GetTexture(MouseIsOver ? Color.Yellow : ProfileManager.Current.CounterBarHighlightOnAmount &&
                                                            _amount < ProfileManager.Current.CounterBarHighlightAmount && _graphic != 0 ? Color.Red : Color.Gray);

                ResetHueVector();
                batcher.DrawRectangle(color, x, y, Width, Height, ref _hueVector);

                return(true);
            }
예제 #9
0
        public HitBox(int x, int y, int w, int h)
        {
            CanMove          = false;
            AcceptMouseInput = true;
            Alpha            = 0.75f;
            _texture         = Texture2DCache.GetTexture(Color.White);

            X              = x;
            Y              = y;
            Width          = w;
            Height         = h;
            WantUpdateSize = false;
        }
예제 #10
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (!IsVisible || IsDisposed)
            {
                return(false);
            }

            ResetHueVector();
            base.Draw(batcher, x, y);
            ResetHueVector();
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x, y, Width, Height, ref _hueVector);

            return(true);
        }
예제 #11
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                ResetHueVector();
                base.Draw(batcher, x, y);
                batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x, y + 15, Width, Height - 15, ref _hueVector);

                if (_texture.MouseIsOver)
                {
                    _hueVector.Z = 0.7f;
                    batcher.Draw2D(Texture2DCache.GetTexture(Color.Yellow), x + 1, y + 15, Width - 1, Height - 15, ref _hueVector);
                    _hueVector.Z = 0;
                }

                return(true);
            }
예제 #12
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            ResetHueVector();

            if (_var != InfoBarVars.NameNotoriety && ProfileManager.Current.InfoBarHighlightType == 1 && _warningLinesHue != 0x0481)
            {
                ShaderHueTranslator.GetHueVector(ref _hueVector, _warningLinesHue);
                batcher.Draw2D(Texture2DCache.GetTexture(Color.White), _data.ScreenCoordinateX, _data.ScreenCoordinateY, _data.Width, 2, ref _hueVector);
                batcher.Draw2D(Texture2DCache.GetTexture(Color.White), _data.ScreenCoordinateX, _data.ScreenCoordinateY + Parent.Height - 2, _data.Width, 2, ref _hueVector);
            }

            return(true);
        }
예제 #13
0
        public HitBox(int x, int y, int w, int h, string tooltip = null, float alpha = 0.75f)
        {
            CanMove          = false;
            AcceptMouseInput = true;
            Alpha            = alpha;
            _texture         = Texture2DCache.GetTexture(Color.White);

            X              = x;
            Y              = y;
            Width          = w;
            Height         = h;
            WantUpdateSize = false;

            SetTooltip(tooltip);
        }
예제 #14
0
        private void BuildGump()
        {
            Width  = 88;
            Height = 44;

            label = new Label(_macro.Name, true, 1001, Width, 255, FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_CENTER)
            {
                X     = 0,
                Width = Width - 10,
            };
            label.Y = (Height >> 1) - (label.Height >> 1);
            Add(label);

            backgroundTexture = Texture2DCache.GetTexture(new Color(30, 30, 30));
        }
예제 #15
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            if (ShowLock)
            {
                ResetHueVector();

                UOTexture32 lock_texture = GumpsLoader.Instance.GetTexture(0x082C);

                if (lock_texture != null)
                {
                    lock_texture.Ticks = Time.Ticks;

                    if (UIManager.MouseOverControl != null && (UIManager.MouseOverControl == this || UIManager.MouseOverControl.RootParent == this))
                    {
                        _hueVector.X = 34;
                        _hueVector.Y = 1;
                    }

                    batcher.Draw2D(lock_texture, x + (Width - lock_texture.Width), y, ref _hueVector);
                }
            }

            ResetHueVector();

            if (_anchorCandidate != null)
            {
                Point drawLoc = UIManager.AnchorManager.GetCandidateDropLocation(this, _anchorCandidate);

                if (drawLoc != Location)
                {
                    Texture2D previewColor = Texture2DCache.GetTexture(Color.Silver);
                    ResetHueVector();
                    _hueVector.Z = 0.5f;
                    batcher.Draw2D(previewColor, drawLoc.X, drawLoc.Y, Width, Height, ref _hueVector);

                    _hueVector.Z = 0;
                    // double rectangle for thicker "stroke"
                    batcher.DrawRectangle(previewColor, drawLoc.X, drawLoc.Y, Width, Height, ref _hueVector);
                    batcher.DrawRectangle(previewColor, drawLoc.X + 1, drawLoc.Y + 1, Width - 2, Height - 2, ref _hueVector);
                }
            }

            return(true);
        }
예제 #16
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                if (!string.IsNullOrWhiteSpace(_label.Text) && MouseIsOver)
                {
                    ResetHueVector();

                    batcher.Draw2D(Texture2DCache.GetTexture(Color.Gray), x + 2, y + 5, Width - 4, Height - 10, ref _hueVector);
                }

                base.Draw(batcher, x, y);

                if (_entry.Items != null && _entry.Items.Count != 0)
                {
                    _moreMenuLabel.Draw(batcher, x + Width - _moreMenuLabel.Width, y + (Height >> 1) - (_moreMenuLabel.Height >> 1) - 1);
                }

                return(true);
            }
예제 #17
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            //batcher.SetBlendState(_checkerBlend.Value);
            //batcher.SetStencil(_checkerStencil.Value);

            //batcher.Draw2D(TransparentTexture, new Rectangle(position.X, position.Y, Width, Height), Vector3.Zero /*ShaderHuesTraslator.GetHueVector(0, false, 0.5f, false)*/);

            //batcher.SetBlendState(null);
            //batcher.SetStencil(null);

            //return true;

            ResetHueVector();
            _hueVector.Z = 0.5f;
            //batcher.SetStencil(_checkerStencil.Value);
            batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x, y, Width, Height, ref _hueVector);
            //batcher.SetStencil(null);
            return(true);
        }
예제 #18
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            if (_anchorCandidate != null)
            {
                Point drawLoc = UIManager.AnchorManager.GetCandidateDropLocation(this, _anchorCandidate);

                if (drawLoc != Location)
                {
                    Texture2D previewColor = Texture2DCache.GetTexture(Color.Silver);
                    ResetHueVector();
                    _hueVector.Z = 0.5f;
                    batcher.Draw2D(previewColor, drawLoc.X, drawLoc.Y, Width, Height, ref _hueVector);

                    _hueVector.Z = 0;
                    // double rectangle for thicker "stroke"
                    batcher.DrawRectangle(previewColor, drawLoc.X, drawLoc.Y, Width, Height, ref _hueVector);
                    batcher.DrawRectangle(previewColor, drawLoc.X + 1, drawLoc.Y + 1, Width - 2, Height - 2, ref _hueVector);
                }
            }

            return(true);
        }
예제 #19
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (SerialHelper.IsValid(Serial) && World.OPL.TryGetRevision(Serial, out uint revision) && _hash != revision)
            {
                _hash = revision;
                Text  = ReadProperties(Serial, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Time.Ticks)
            {
                return(false);
            }


            byte   font  = 1;
            float  alpha = 0.3f;
            ushort hue   = 0xFFFF;
            float  zoom  = 1;

            if (ProfileManager.Current != null)
            {
                font  = ProfileManager.Current.TooltipFont;
                alpha = 1f - ProfileManager.Current.TooltipBackgroundOpacity / 100f;

                if (float.IsNaN(alpha))
                {
                    alpha = 1f;
                }

                hue  = ProfileManager.Current.TooltipTextHue;
                zoom = ProfileManager.Current.TooltipDisplayZoom / 100f;
            }

            FontsLoader.Instance.SetUseHTML(true);
            FontsLoader.Instance.RecalculateWidthByInfo = true;

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create(null, font: font, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true, hue: hue);
            }

            if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    int width = FontsLoader.Instance.GetWidthUnicode(font, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FontsLoader.Instance.GetWidthExUnicode(font, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Font = font;
                _renderedText.Hue  = hue;
                _renderedText.Text = _textHTML;
            }

            FontsLoader.Instance.RecalculateWidthByInfo = false;
            FontsLoader.Instance.SetUseHTML(false);

            if (_renderedText.Texture == null)
            {
                return(false);
            }

            int z_width  = _renderedText.Width + 8;
            int z_height = _renderedText.Height + 8;

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Client.Game.Window.ClientBounds.Width - z_width)
            {
                x = Client.Game.Window.ClientBounds.Width - z_width;
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Client.Game.Window.ClientBounds.Height - z_height)
            {
                y = Client.Game.Window.ClientBounds.Height - z_height;
            }


            Vector3 hue_vec = Vector3.Zero;

            ShaderHueTranslator.GetHueVector(ref hue_vec, 0, false, alpha);
            batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x - 4, y - 2, z_width * zoom, z_height * zoom, ref hue_vec);
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 4, y - 2, (int)(z_width * zoom), (int)(z_height * zoom), ref hue_vec);

            hue_vec.X = 0;
            hue_vec.Y = 0;
            hue_vec.Z = 0;

            return(batcher.Draw2D
                   (
                       _renderedText.Texture,
                       x + 3, y + 3, z_width * zoom, z_height * zoom,
                       0, 0, z_width, z_height, ref hue_vec
                   ));
        }
예제 #20
0
 protected override void OnMouseExit(int x, int y)
 {
     label.Hue         = 1001;
     backgroundTexture = Texture2DCache.GetTexture(new Color(30, 30, 30));
     base.OnMouseExit(x, y);
 }
예제 #21
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (SerialHelper.IsValid(_serial) && World.OPL.TryGetRevision(_serial, out uint revision) && _hash != revision)
            {
                _hash = revision;
                Text  = ReadProperties(_serial, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Time.Ticks)
            {
                return(false);
            }

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create(string.Empty, font: 1, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true);
            }
            else if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    FontsLoader.Instance.SetUseHTML(true);
                    FontsLoader.Instance.RecalculateWidthByInfo = true;

                    int width = FontsLoader.Instance.GetWidthUnicode(1, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FontsLoader.Instance.GetWidthExUnicode(1, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;

                    FontsLoader.Instance.RecalculateWidthByInfo = false;
                    FontsLoader.Instance.SetUseHTML(false);
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Text = _textHTML;
            }

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8))
            {
                x = Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8);
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8))
            {
                y = Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8);
            }

            Vector3 hue = Vector3.Zero;

            ShaderHuesTraslator.GetHueVector(ref hue, 0, false, 0.3f, true);

            batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);

            return(_renderedText.Draw(batcher, x + 3, y));
        }
예제 #22
0
 protected override void OnMouseEnter(int x, int y)
 {
     label.Hue         = 53;
     backgroundTexture = Texture2DCache.GetTexture(Color.DimGray);
     base.OnMouseEnter(x, y);
 }
예제 #23
0
        public void Draw(UltimaBatcher2D batcher, float scale)
        {
            if (!IsEnabled)
            {
                return;
            }

            const int BAR_WIDTH       = 28;
            const int BAR_HEIGHT      = 3;
            const int BAR_WIDTH_HALF  = BAR_WIDTH >> 1;
            const int BAR_HEIGHT_HALF = BAR_HEIGHT >> 1;

            int screenX = ProfileManager.Current.GameWindowPosition.X;
            int screenY = ProfileManager.Current.GameWindowPosition.Y;
            int screenW = ProfileManager.Current.GameWindowSize.X;
            int screenH = ProfileManager.Current.GameWindowSize.Y;



            Color color;

            int mode = ProfileManager.Current.MobileHPType;

            if (mode < 0)
            {
                return;
            }

            int showWhen = ProfileManager.Current.MobileHPShowWhen;

            foreach (Mobile mobile in World.Mobiles)
            {
                //if (World.Party.Contains(mobile) && mobile.Tile == null)
                //    continue;

                int current = mobile.Hits;
                int max     = mobile.HitsMax;

                if (showWhen == 1 && current == max)
                {
                    continue;
                }

                int x = screenX + mobile.RealScreenPosition.X;
                int y = screenY + mobile.RealScreenPosition.Y;

                x += (int)mobile.Offset.X + 22;
                y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22;

                x  = (int)(x / scale);
                y  = (int)(y / scale);
                x -= (int)(screenX / scale);
                y -= (int)(screenY / scale);
                x += screenX;
                y += screenY;

                x += 5;
                y += 5;

                x -= BAR_WIDTH_HALF;
                y -= BAR_HEIGHT_HALF;

                if (mode != 1 && !mobile.IsDead)
                {
                    if ((showWhen == 2 && current != max) || showWhen <= 1)
                    {
                        int xx = x;
                        int yy = y;

                        if (mobile.IsGargoyle && mobile.IsFlying)
                        {
                            yy -= (int)(22 / scale);
                        }
                        else if (!mobile.IsMounted)
                        {
                            yy += (int)(22 / scale);
                        }


                        AnimationsLoader.Instance.GetAnimationDimensions(mobile.AnimIndex,
                                                                         mobile.GetGraphicForAnimation(),
                                                                         /*(byte) m.GetDirectionForAnimation()*/ 0,
                                                                         /*Mobile.GetGroupForAnimation(m, isParent:true)*/ 0,
                                                                         mobile.IsMounted,
                                                                         /*(byte) m.AnimIndex*/ 0,
                                                                         out int centerX,
                                                                         out int centerY,
                                                                         out int width,
                                                                         out int height);


                        yy -= (int)((height + centerY + 28) / scale);


                        int ww = mobile.HitsMax;

                        if (ww > 0)
                        {
                            ww = mobile.Hits * 100 / ww;

                            if (ww > 100)
                            {
                                ww = 100;
                            }
                            else if (ww < 1)
                            {
                                ww = 0;
                            }

                            mobile.UpdateHits((byte)ww);
                        }

                        if (mobile.HitsPercentage != 0)
                        {
                            xx -= (mobile.HitsTexture.Width >> 1) + 3;
                            xx += 22;
                            yy -= mobile.HitsTexture.Height / 1;
                            if (mobile.ObjectHandlesOpened)
                            {
                                yy -= 22;
                            }

                            if (!(xx < screenX || xx > screenX + screenW - mobile.HitsTexture.Width || yy < screenY || yy > screenY + screenH))
                            {
                                mobile.HitsTexture.Draw(batcher, xx, yy);
                            }
                        }
                    }
                }

                if (x < screenX || x > screenX + screenW - BAR_WIDTH)
                {
                    continue;
                }

                if (y < screenY || y > screenY + screenH - BAR_HEIGHT)
                {
                    continue;
                }

                if (mode >= 1 && TargetManager.LastTarget != mobile)
                {
                    if (max > 0)
                    {
                        max = current * 100 / max;

                        if (max > 100)
                        {
                            max = 100;
                        }

                        if (max > 1)
                        {
                            max = BAR_WIDTH * max / 100;
                        }
                    }

                    batcher.Draw2D(_edge, x - 1, y - 1, BAR_WIDTH + 2, BAR_HEIGHT + 2, ref _vectorHue);
                    batcher.Draw2D(_back, x, y, BAR_WIDTH, BAR_HEIGHT, ref _vectorHue);

                    if (mobile.IsParalyzed)
                    {
                        color = Color.AliceBlue;
                    }
                    else if (mobile.IsYellowHits)
                    {
                        color = Color.Orange;
                    }
                    else if (mobile.IsPoisoned)
                    {
                        color = Color.LimeGreen;
                    }
                    else
                    {
                        color = Color.CornflowerBlue;
                    }

                    batcher.Draw2D(Texture2DCache.GetTexture(color), x, y, max, BAR_HEIGHT, ref _vectorHue);
                }
            }
        }
예제 #24
0
            internal void DrawSelection(UltimaBatcher2D batcher, int x, int y, int starty, int endy)
            {
                ResetHueVector();
                _hueVector.Z = 0.5f;

                int selectStart = Math.Min(Stb.SelectStart, Stb.SelectEnd);
                int selectEnd   = Math.Max(Stb.SelectStart, Stb.SelectEnd);

                if (selectStart < selectEnd)
                {
                    MultilinesFontInfo info = _rendererText.GetInfo();

                    int drawY = 1;
                    int start = 0;

                    while (info != null && selectStart < selectEnd)
                    {
                        // ok we are inside the selection
                        if (selectStart >= start && selectStart < start + info.CharCount)
                        {
                            int startSelectionIndex = selectStart - start;

                            // calculate offset x
                            int drawX = 0;
                            for (int i = 0; i < startSelectionIndex; i++)
                            {
                                drawX += _rendererText.GetCharWidth(info.Data[i].Item);
                            }

                            // selection is gone. Bye bye
                            if (selectEnd >= start && selectEnd < start + info.CharCount)
                            {
                                int count = selectEnd - selectStart;

                                int endX = 0;

                                // calculate width
                                for (int k = 0; k < count; k++)
                                {
                                    endX += _rendererText.GetCharWidth(info.Data[startSelectionIndex + k].Item);
                                }

                                if (drawY >= starty && drawY <= endy)
                                {
                                    batcher.Draw2D(
                                        Texture2DCache.GetTexture(SELECTION_COLOR),
                                        x + drawX,
                                        y + drawY - starty,
                                        endX,
                                        info.MaxHeight + 1,
                                        ref _hueVector);
                                }

                                break;
                            }


                            // do the whole line
                            if (drawY >= starty && drawY <= endy)
                            {
                                batcher.Draw2D(
                                    Texture2DCache.GetTexture(SELECTION_COLOR),
                                    x + drawX,
                                    y + drawY - starty,
                                    info.Width - drawX,
                                    info.MaxHeight + 1,
                                    ref _hueVector);
                            }

                            // first selection is gone. M
                            selectStart = start + info.CharCount;
                        }

                        start += info.CharCount;
                        drawY += info.MaxHeight;
                        info   = info.Next;
                    }
                }
            }
예제 #25
0
        public void Draw(UltimaBatcher2D batcher, int x, int y)
        {
            bool removeEffects = false;

            if (Timer < Time.Ticks)
            {
                if (CurrentCount == 0)
                {
                    return;
                }

                removeEffects = true;
            }
            else if (Type == 0xFF || Type == 0xFE)
            {
                return;
            }

            uint passed = Time.Ticks - LastTick;

            if (passed > 7000)
            {
                LastTick = Time.Ticks;
                passed   = 25;
            }

            bool windChanged = false;

            if (WindTimer < Time.Ticks)
            {
                if (WindTimer == 0)
                {
                    windChanged = true;
                }

                WindTimer = Time.Ticks + (uint)(RandomHelper.GetValue(7, 13) * 1000);

                sbyte lastWind = Wind;

                Wind = (sbyte)RandomHelper.GetValue(0, 4);

                if (RandomHelper.GetValue(0, 2) != 0)
                {
                    Wind *= -1;
                }

                if (Wind < 0 && lastWind > 0)
                {
                    Wind = 0;
                }
                else if (Wind > 0 && lastWind < 0)
                {
                    Wind = 0;
                }

                if (lastWind != Wind)
                {
                    windChanged = true;
                }
            }

            //switch ((WEATHER_TYPE) Type)
            //{
            //    case WEATHER_TYPE.WT_RAIN:
            //    case WEATHER_TYPE.WT_FIERCE_STORM:
            //        // TODO: set color
            //        break;
            //    case WEATHER_TYPE.WT_SNOW:
            //    case WEATHER_TYPE.WT_STORM:
            //        // TODO: set color
            //        break;
            //    default:
            //        break;
            //}

            //Point winpos = ProfileManager.Current.GameWindowPosition;
            Point winsize = ProfileManager.Current.GameWindowSize;

            for (int i = 0; i < _effects.Count; i++)
            {
                var effect = _effects[i];

                if (effect.X < x || effect.X > x + winsize.X ||
                    effect.Y < y || effect.Y > y + winsize.Y)
                {
                    if (removeEffects)
                    {
                        _effects.RemoveAt(i--);

                        if (CurrentCount > 0)
                        {
                            CurrentCount--;
                        }
                        else
                        {
                            CurrentCount = 0;
                        }

                        continue;
                    }

                    effect.X = x + RandomHelper.GetValue(0, winsize.X);
                    effect.Y = y + RandomHelper.GetValue(0, winsize.Y);
                }


                switch ((WEATHER_TYPE)Type)
                {
                case WEATHER_TYPE.WT_RAIN:
                    float scaleRation = effect.ScaleRatio;
                    effect.SpeedX = -4.5f - scaleRation;
                    effect.SpeedY = 5.0f + scaleRation;
                    break;

                case WEATHER_TYPE.WT_FIERCE_STORM:
                    effect.SpeedX = Wind;
                    effect.SpeedY = 6.0f;
                    break;

                case WEATHER_TYPE.WT_SNOW:
                case WEATHER_TYPE.WT_STORM:

                    if (Type == (byte)WEATHER_TYPE.WT_SNOW)
                    {
                        effect.SpeedX = Wind;
                        effect.SpeedY = 1.0f;
                    }
                    else
                    {
                        effect.SpeedX = Wind * 1.5f;
                        effect.SpeedY = 1.5f;
                    }

                    if (windChanged)
                    {
                        effect.SpeedAngle     = MathHelper.ToDegrees((float)Math.Atan2(effect.SpeedX, effect.SpeedY));
                        effect.SpeedMagnitude =
                            (float)Math.Sqrt(Math.Pow(effect.SpeedX, 2) + Math.Pow(effect.SpeedY, 2));
                    }

                    float speed_angle     = effect.SpeedAngle;
                    float speed_magnitude = effect.SpeedMagnitude;

                    speed_magnitude += effect.ScaleRatio;

                    speed_angle += SinOscillate(0.4f, 20, Time.Ticks + effect.ID);

                    var rad = MathHelper.ToRadians(speed_angle);
                    effect.SpeedX = speed_magnitude * (float)Math.Sin(rad);
                    effect.SpeedY = speed_magnitude * (float)Math.Cos(rad);

                    break;
                }

                float speedOffset = passed / SimulationRation;

                switch ((WEATHER_TYPE)Type)
                {
                case WEATHER_TYPE.WT_RAIN:
                case WEATHER_TYPE.WT_FIERCE_STORM:

                    int oldX = (int)effect.X;
                    int oldY = (int)effect.Y;

                    float ofsx = effect.SpeedX * speedOffset;
                    float ofsy = effect.SpeedY * speedOffset;

                    effect.X += ofsx;
                    effect.Y += ofsy;

                    const float MAX_OFFSET_XY = 5.0f;

                    if (ofsx >= MAX_OFFSET_XY)
                    {
                        oldX = (int)(effect.X - MAX_OFFSET_XY);
                    }
                    else if (ofsx <= -MAX_OFFSET_XY)
                    {
                        oldX = (int)(effect.X + MAX_OFFSET_XY);
                    }

                    if (ofsy >= MAX_OFFSET_XY)
                    {
                        oldY = (int)(effect.Y - MAX_OFFSET_XY);
                    }
                    else if (oldY <= -MAX_OFFSET_XY)
                    {
                        oldY = (int)(effect.Y + MAX_OFFSET_XY);
                    }

                    int startX = x + oldX;
                    int startY = y + oldY;
                    int endX   = x + (int)effect.X;
                    int endY   = y + (int)effect.Y;

                    batcher.DrawLine(Texture2DCache.GetTexture(Color.Gray), startX, startY, endX, endY, startX + (endX - startX) / 2, startY + (endY - startY) / 2);
                    break;

                case WEATHER_TYPE.WT_SNOW:
                case WEATHER_TYPE.WT_STORM:

                    effect.X += effect.SpeedX * speedOffset;
                    effect.Y += effect.SpeedY * speedOffset;

                    batcher.Draw2D(Texture2DCache.GetTexture(Color.White),
                                   x + (int)effect.X, y + (int)effect.Y, 2, 2, ref _hueVector);

                    break;
                }
            }

            LastTick = Time.Ticks;
        }
예제 #26
0
 static HealthLinesManager()
 {
     _edge = Texture2DCache.GetTexture(Color.Black);
     _back = Texture2DCache.GetTexture(Color.Red);
 }