コード例 #1
0
        private bool MoveCharacterByMouseInput()
        {
            if ((_rightMousePressed || _continueRunning) && World.InGame) // && !Pathfinder.AutoWalking)
            {
                if (Pathfinder.AutoWalking)
                {
                    Pathfinder.StopAutoWalk();
                }

                int x = ProfileManager.CurrentProfile.GameWindowPosition.X + (ProfileManager.CurrentProfile.GameWindowSize.X >> 1);
                int y = ProfileManager.CurrentProfile.GameWindowPosition.Y + (ProfileManager.CurrentProfile.GameWindowSize.Y >> 1);

                Direction direction = (Direction)GameCursor.GetMouseDirection
                                      (
                    x,
                    y,
                    Mouse.Position.X,
                    Mouse.Position.Y,
                    1
                                      );

                double mouseRange = MathHelper.Hypotenuse(x - Mouse.Position.X, y - Mouse.Position.Y);

                Direction facing = direction;

                if (facing == Direction.North)
                {
                    facing = (Direction)8;
                }

                bool run = mouseRange >= 190;

                if (World.Player.IsDrivingBoat)
                {
                    if (!_boatIsMoving || _boatRun != run || _lastBoatDirection != facing - 1)
                    {
                        _boatRun           = run;
                        _lastBoatDirection = facing - 1;
                        _boatIsMoving      = true;

                        BoatMovingManager.MoveRequest(facing - 1, (byte)(run ? 2 : 1));
                    }
                }
                else
                {
                    World.Player.Walk(facing - 1, run);
                }

                return(true);
            }

            return(false);
        }
コード例 #2
0
ファイル: Tile.cs プロジェクト: broem/ClassicUO
        public List <GameObject> GetItemsBetweenZ(int z0, int z1)
        {
            List <GameObject> items = _itemsAtZ;

            _itemsAtZ.Clear();

            for (int i = 0; i < ObjectsOnTiles.Count; i++)
            {
                if (MathHelper.InRange(ObjectsOnTiles[i].Position.Z, z0, z1))
                {
                    if (ObjectsOnTiles[i] is IDynamicItem)
                    {
                        items.Add(ObjectsOnTiles[i]);
                    }
                }
            }

            return(items);
        }
コード例 #3
0
        public CreateCharSelectionCityGump(byte profession, LoginScene scene) : base(0, 0)
        {
            CanMove = false;
            CanCloseWithRightClick = false;
            CanCloseWithEsc        = false;

            _scene = scene;
            _selectedProfession = profession;

            CityInfo city;

            if (Client.Version >= ClientVersion.CV_70130)
            {
                city = scene.GetCity(0);
            }
            else
            {
                city = scene.GetCity(3);

                if (city == null)
                {
                    city = scene.GetCity(0);
                }
            }

            if (city == null)
            {
                Log.Error(ResGumps.NoCityFound);
                Dispose();

                return;
            }

            uint map = 0;

            if (city.IsNewCity)
            {
                map = city.Map;
            }

            _facetName = new Label("", true, 0x0481, font: 0, style: FontStyle.BlackBorder)
            {
                X = 240,
                Y = 440
            };


            if (Client.Version >= ClientVersion.CV_70130)
            {
                Add(new GumpPic(62, 54, (ushort)(0x15D9 + map), 0));
                Add(new GumpPic(57, 49, 0x15DF, 0));
                _facetName.Text = _cityNames[map];
            }
            else
            {
                Add(new GumpPic(57, 49, 0x1598, 0));
                _facetName.IsVisible = false;
            }

            if (CUOEnviroment.IsOutlands)
            {
                _facetName.IsVisible = false;
            }

            Add(_facetName);


            Add
            (
                new Button((int)Buttons.PreviousScreen, 0x15A1, 0x15A3, 0x15A2)
            {
                X            = 586,
                Y            = 445,
                ButtonAction = ButtonAction.Activate
            }
            );

            Add
            (
                new Button((int)Buttons.Finish, 0x15A4, 0x15A6, 0x15A5)
            {
                X            = 610,
                Y            = 445,
                ButtonAction = ButtonAction.Activate
            }
            );


            _htmlControl = new HtmlControl(452, 60, 175, 367, true, true, ishtml: true, text: city.Description);
            Add(_htmlControl);

            if (CUOEnviroment.IsOutlands)
            {
                _htmlControl.IsVisible = false;
            }

            for (int i = 0; i < scene.Cities.Length; i++)
            {
                CityInfo c = scene.GetCity(i);

                if (c == null)
                {
                    continue;
                }

                int x = 0;
                int y = 0;

                if (c.IsNewCity)
                {
                    uint cityFacet = c.Map;

                    if (cityFacet > 5)
                    {
                        cityFacet = 5;
                    }

                    x = 62 + MathHelper.PercetangeOf(MapLoader.Instance.MapsDefaultSize[cityFacet, 0] - 2048, c.X, 383);
                    y = 54 + MathHelper.PercetangeOf(MapLoader.Instance.MapsDefaultSize[cityFacet, 1], c.Y, 384);
                }
                else if (i < _townButtonsText.Length)
                {
                    x = _townButtonsText[i].X;

                    y = _townButtonsText[i].Y;
                }

                CityControl control = new CityControl(c, x, y, i);
                Add(control);
                _cityControls.Add(control);

                if (CUOEnviroment.IsOutlands)
                {
                    control.IsVisible = false;
                }
            }

            SetCity(city);
        }
コード例 #4
0
        public static bool IsPointInCorpse(Item corpse, int xx, int yy)
        {
            if (corpse == null || World.CorpseManager.Exists(corpse.Serial, 0))
            {
                return(false);
            }

            byte dir    = (byte)((byte)corpse.Layer & 0x7F & 7);
            bool mirror = false;

            AnimationsLoader.Instance.GetAnimDirection(ref dir, ref mirror);
            AnimationsLoader.Instance.Direction = dir;
            byte animIndex = (byte)corpse.AnimIndex;

            for (int i = -1; i < Constants.USED_LAYER_COUNT; i++)
            {
                Layer layer = i == -1 ? Layer.Mount : LayerOrder.UsedLayers[dir, i];

                ushort graphic;
                ushort color = 0;

                if (layer == Layer.Invalid)
                {
                    graphic = corpse.GetGraphicForAnimation();
                    AnimationsLoader.Instance.AnimGroup = AnimationsLoader.Instance.GetDieGroupIndex(graphic, corpse.UsedLayer);
                }
                else if (corpse.HasEquipment && MathHelper.InRange(corpse.Amount, 0x0190, 0x0193) ||
                         MathHelper.InRange(corpse.Amount, 0x00B7, 0x00BA) ||
                         MathHelper.InRange(corpse.Amount, 0x025D, 0x0260) ||
                         MathHelper.InRange(corpse.Amount, 0x029A, 0x029B) ||
                         MathHelper.InRange(corpse.Amount, 0x02B6, 0x02B7) ||
                         corpse.Amount == 0x03DB || corpse.Amount == 0x03DF || corpse.Amount == 0x03E2 || corpse.Amount == 0x02E8 || corpse.Amount == 0x02E9)
                {
                    Item itemEquip = corpse.Equipment[(int)layer];

                    if (itemEquip == null)
                    {
                        continue;
                    }

                    graphic = itemEquip.ItemData.AnimID;

                    if (AnimationsLoader.Instance.EquipConversions.TryGetValue(corpse.Amount, out Dictionary <ushort, EquipConvData> map))
                    {
                        if (map.TryGetValue(graphic, out EquipConvData data))
                        {
                            graphic = data.Graphic;
                        }
                    }
                }
                else
                {
                    continue;
                }


                byte animGroup = AnimationsLoader.Instance.AnimGroup;

                AnimationGroup gr = layer == Layer.Invalid
                                        ? AnimationsLoader.Instance.GetCorpseAnimationGroup(ref graphic, ref animGroup, ref color)
                                        : AnimationsLoader.Instance.GetBodyAnimationGroup(ref graphic, ref animGroup, ref color);

                AnimationDirection direction = gr.Direction[AnimationsLoader.Instance.Direction];

                if (direction == null || ((direction.FrameCount == 0 || direction.Frames == null) && !AnimationsLoader.Instance.LoadDirectionGroup(ref direction)))
                {
                    continue;
                }

                int fc = direction.FrameCount;

                if (fc > 0 && animIndex >= fc)
                {
                    animIndex = (byte)(fc - 1);
                }

                if (animIndex < direction.FrameCount)
                {
                    AnimationFrameTexture frame = direction.Frames[animIndex];

                    if (frame == null || frame.IsDisposed)
                    {
                        continue;
                    }

                    int       drawCenterY = frame.CenterY;
                    const int drawX       = -22;
                    int       drawY       = drawCenterY - 22;
                    drawY -= 3;
                    int x = drawX + frame.CenterX;
                    int y = -drawY - (frame.Height + frame.CenterY) + drawCenterY;

                    if (mirror)
                    {
                        x = xx + x + 44 - TranslatedMousePositionByViewport.X;
                    }
                    else
                    {
                        x = TranslatedMousePositionByViewport.X - xx + x;
                    }

                    y = TranslatedMousePositionByViewport.Y - yy + y;

                    if (frame.Contains(x, y))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #5
0
        private bool DrawCorpse(UltimaBatcher2D batcher, int posX, int posY, Vector3 hueVec, float depth)
        {
            if (IsDestroyed || World.CorpseManager.Exists(Serial, 0))
            {
                return(false);
            }

            posX += 22;
            posY += 22;

            byte direction = (byte)((byte)Layer & 0x7F & 7);

            AnimationsLoader.Instance.GetAnimDirection(ref direction, ref IsFlipped);

            byte   animIndex = (byte)AnimIndex;
            ushort graphic   = GetGraphicForAnimation();

            AnimationsLoader.Instance.ConvertBodyIfNeeded(ref graphic);
            byte group = AnimationsLoader.Instance.GetDieGroupIndex(graphic, UsedLayer);

            bool ishuman = MathHelper.InRange(Amount, 0x0190, 0x0193) || MathHelper.InRange(Amount, 0x00B7, 0x00BA) || MathHelper.InRange(Amount, 0x025D, 0x0260) || MathHelper.InRange(Amount, 0x029A, 0x029B) || MathHelper.InRange(Amount, 0x02B6, 0x02B7) || Amount == 0x03DB || Amount == 0x03DF || Amount == 0x03E2 || Amount == 0x02E8 || Amount == 0x02E9;

            DrawLayer
            (
                batcher,
                posX,
                posY,
                this,
                Layer.Invalid,
                animIndex,
                ishuman,
                Hue,
                IsFlipped,
                hueVec.Z,
                group,
                direction,
                hueVec,
                depth
            );

            for (int i = 0; i < Constants.USED_LAYER_COUNT; i++)
            {
                Layer layer = LayerOrder.UsedLayers[direction, i];

                DrawLayer
                (
                    batcher,
                    posX,
                    posY,
                    this,
                    layer,
                    animIndex,
                    ishuman,
                    0,
                    IsFlipped,
                    hueVec.Z,
                    group,
                    direction,
                    hueVec,
                    depth
                );
            }

            return(true);
        }