Esempio n. 1
0
 public Movement(Entity entity, IIsometricRenderer world)
 {
     _entity = entity;
     _world = world;
     _currentPosition = new Position3D();
     _moveEvents = new MoveEvents();
 }
        public MapObjectGround(int tileID, Position3D position)
            : base(position)
        {
            ItemID = tileID;
            _normals = new Vector3[4];
            SortThreshold = -1;
            SortTiebreaker = -1;

            // set no draw flag
            _noDraw = (ItemID < 3 || (ItemID >= 0x1AF && ItemID <= 0x1B5));

            // get draw data
            Data.LandData landData = Data.TileData.LandData[ItemID & 0x3FFF];
            if (landData.TextureID <= 0)
            {
                _draw_3DStretched = false;
                _draw_texture = Data.Art.GetLandTexture(ItemID);
                _draw_width = _draw_height = 44;
                _draw_X = 0;
                _draw_Y = (int)(Z * 4);
                _draw_hue = Vector2.Zero;
                _pickType = PickTypes.PickGroundTiles;
                _draw_flip = false;
            }
            else
            {
                _draw_3DStretched = true;
                _draw_texture = Data.Texmaps.GetTexmapTexture(landData.TextureID);
            }

            // set pick type
            _pickType = PickTypes.PickGroundTiles;
        }
        public MapObjectStatic(int staticTileID, int sortInfluence, Position3D position)
            : base(position)
        {
            ItemID = staticTileID;
            SortTiebreaker = sortInfluence;

            _itemData = Data.TileData.ItemData[ItemID & 0x3FFF];

            // Set threshold.
            int background = (_itemData.Background) ? 0 : 1;
            if (!_itemData.Background)
                SortThreshold++;
            if (!(_itemData.Height == 0))
                SortThreshold++;
            if (_itemData.Surface)
                SortThreshold--;

            // get no draw flag
            if (_itemData.Name == "nodraw" || ItemID <= 0)
                _noDraw = true;

            // set up draw variables
            _draw_texture = Data.Art.GetStaticTexture(ItemID);
            _draw_width = _draw_texture.Width;
            _draw_height = _draw_texture.Height;
            _draw_X = (_draw_width >> 1) - 22;
            _draw_Y = (int)(Z * 4) + _draw_height - 44;
            _draw_hue = Vector2.Zero;
            _pickType = PickTypes.PickStatics;
            _draw_flip = false;
        }
Esempio n. 4
0
        public MapObjectText(Position3D position, Entities.Entity ownerEntity, string text, int hue, int fontID)
            : base(position)
        {
            OwnerEntity = ownerEntity;
            Hue = hue;
            FontID = fontID;

            // set up draw data
            _draw_texture = Texture = Data.ASCIIText.GetTextTexture(text, 1);
            _draw_width = _draw_texture.Width;
            _draw_height = _draw_texture.Height;
            _draw_X = (_draw_width >> 1) - 22 - (int)((Position.X_offset - Position.Y_offset) * 22);
            _draw_Y = ((int)Position.Z_offset * 4) + _draw_height - 44 - (int)((Position.X_offset + Position.Y_offset) * 22);
            _draw_hue = Utility.GetHueVector(Hue);
            _pickType = PickTypes.PickObjects;
            _draw_flip = false;
        }
Esempio n. 5
0
        public MapObjectItem(int itemID, Position3D position, int direction, Entity ownerEntity, int hue)
            : base(position)
        {
            ItemID = itemID;
            OwnerEntity = ownerEntity;
            Facing = direction;
            Hue = hue;

            // set up draw data
            _draw_texture = Data.Art.GetStaticTexture(ItemID);
            _draw_width = _draw_texture.Width;
            _draw_height = _draw_texture.Height;
            _draw_X = (_draw_width >> 1) - 22;
            _draw_Y = (int)(Z * 4) + _draw_height - 44;
            _draw_hue = Utility.GetHueVector(Hue);
            _pickType = PickTypes.PickObjects;
            _draw_flip = false;
        }
Esempio n. 6
0
        public MapObjectMobile(Position3D position, int facing, int action, float frame, Entities.Entity ownerEntity)
            : base(position)
        {
            if (_frame >= 1.0f)
                return;

            _layers = new MapObjectMobileLayer[(int)EquipLayer.LastUserValid];

            Facing = facing;
            Action = action;
            _frame = frame;
            OwnerEntity = ownerEntity;

            // set pick type
            _pickType = PickTypes.PickObjects;

            // set up draw data
            _draw_flip = (Facing > 4) ? true : false;
            _draw_IsometricOverlap = true;
        }
Esempio n. 7
0
        public MapObjectCorpse(Position3D position, int direction, Entity ownerEntity, int nHue, int bodyID, float frame)
            : base(0x2006, position, direction, ownerEntity, nHue)
        {
            BodyID = bodyID;
            FrameIndex = (int)(frame * Data.BodyConverter.DeathAnimationFrameCount(bodyID));

            Data.FrameXNA iFrame = getFrame();
            if (iFrame == null)
            {
                _noDraw = true;
                return;
            }
            _draw_texture = iFrame.Texture;
            _draw_width = _draw_texture.Width;
            _draw_height = _draw_texture.Height;
            _draw_X = iFrame.Center.X - 22;
            _draw_Y = iFrame.Center.Y + (int)(Z * 4) + _draw_height - 22;
            _draw_hue = Utility.GetHueVector(Hue);
            _pickType = PickTypes.PickObjects;
            _draw_flip = false;
        }
Esempio n. 8
0
 internal override void Draw(MapTile tile, Position3D position)
 {
     _movement.ClearImmediate();
     tile.AddMapObject(new TileEngine.MapObjectCorpse(position, DrawFacing, this, Hue, _corpseBody, _corpseFrame));
     drawOverheads(tile, new Position3D(_movement.Position.Point_V3));
 }
Esempio n. 9
0
 internal void drawOverheads(TileEngine.MapTile tile, Position3D position)
 {
     // base entities do not draw, but they can have overheads, so we draw those.
     foreach (KeyValuePair<int, Overhead> overhead in _overheads)
     {
         if (!overhead.Value.IsDisposed)
             overhead.Value.Draw(tile, position);
     }
 }
Esempio n. 10
0
        internal override void Draw(MapTile tile, Position3D position)
        {
            if (Ignored)
                return;

            tile.AddMapObject(new TileEngine.MapObjectItem(DisplayItemID, position, DrawFacing, this, Hue));
            drawOverheads(tile, new Position3D(position.Point_V3));
        }
Esempio n. 11
0
 public void Move_Instant(int x, int y, int z, int facing)
 {
     _moveEvents.ResetMoveSequence();
     flushDrawObjects();
     Facing = ((Direction)facing & Direction.FacingMask);
     _goalPosition = _currentPosition = new Position3D(x, y, z);
 }
Esempio n. 12
0
        internal override void Draw(MapTile tile, Position3D position)
        {
            if (IsMoving)
            {
                if (IsRunning)
                    _animation.Animate(MobileAction.Run);
                else
                    _animation.Animate(MobileAction.Walk);
            }
            else
            {
                if (!_animation.IsAnimating)
                    _animation.Animate(MobileAction.Stand);
            }

            MapObjectMobile mobtile = new MapObjectMobile(position, DrawFacing, _animation.ActionIndex, _animation.AnimationFrame, this);
            tile.AddMapObject(mobtile);

            int[] drawLayers = _DrawLayerOrder;
            bool hasOuterTorso = _equipment[(int)EquipLayer.OuterTorso] != null && _equipment[(int)EquipLayer.OuterTorso].AnimationDisplayID != 0;

            for (int i = 0; i < drawLayers.Length; i++)
            {
                // when wearing something on the outer torso the other torso stuff is not drawn
                if (hasOuterTorso && (drawLayers[i] == (int)EquipLayer.InnerTorso || drawLayers[i] == (int)EquipLayer.MiddleTorso))
                {
                    continue;
                }

                if (drawLayers[i] == (int)EquipLayer.Body)
                {
                    mobtile.AddLayer(BodyID, Hue);
                }
                else if (_equipment[drawLayers[i]] != null && _equipment[drawLayers[i]].AnimationDisplayID != 0)
                {
                    mobtile.AddLayer(_equipment[drawLayers[i]].AnimationDisplayID, _equipment[drawLayers[i]].Hue);
                }
            }
            drawOverheads(tile, new Position3D(_movement.Position.Tile_V3));
        }
Esempio n. 13
0
 public MapObject(Position3D position)
 {
     Position = position;
 }
Esempio n. 14
0
 internal override void Draw(MapTile tile, Position3D position)
 {
     // string text = Utility.WrapASCIIText(_font, _text, 200);
     // tile.Add(new TileEngine.MapObjectText(position, _ownerEntity, text, _hue, _font));
 }
Esempio n. 15
0
        internal override void Draw(MapTile tile, Position3D position)
        {
            if (_unloadedTiles.Count == 0)
                return;

            List<Point2D> drawnTiles = new List<Point2D>();

            foreach (Point2D p in _unloadedTiles)
            {
                int x = tile.X + p.X - _components.Center.X;
                int y = tile.Y + p.Y - _components.Center.Y;

                MapTile t = World.Map.GetMapTile(x, y, false);
                if (t != null)
                {
                    drawnTiles.Add(p);

                    if (!_hasCustomTiles)
                    {
                        if (p.X < _components.Width && p.Y < _components.Height)
                        {
                            foreach (StaticTile s in _components.Tiles[p.X][p.Y])
                            {
                                t.AddMapObject(new MapObjectStatic(s.ID, 0, new Position3D(x, y, s.Z)));
                            }
                        }
                    }
                    else
                    {
                        foreach (StaticTile s in _customHouseTiles)
                        {
                            if ((s.X == p.X) && (s.Y == p.Y))
                            {
                                t.AddMapObject(new MapObjectStatic(s.ID, 0, new Position3D(s.X, s.Y, s.Z)));
                            }
                        }
                    }
                }
            }

            foreach (Point2D p in drawnTiles)
            {
                _unloadedTiles.Remove(p);
            }
        }
Esempio n. 16
0
        public void Update(GameTime gameTime)
        {
            flushDrawObjects();
            // Are we moving? (if our current location != our destination, then we are moving)
            if (IsMoving)
            {
                MoveSequence += ((float)(gameTime.ElapsedGameTime.TotalMilliseconds) / TimeToCompleteMove(Facing).Milliseconds);

                if (MoveSequence < 1f)
                {
                    _currentPosition.Offset_V3 = (_goalPosition.Tile_V3 - _currentPosition.Tile_V3) * MoveSequence;
                }
                else
                {
                    _currentPosition = _goalPosition;
                    MoveSequence = 0f;
                }
            }
            else
            {
                MoveEvent moveEvent;
                int sequence;
                while ((moveEvent = _moveEvents.GetMoveEvent(out sequence)) != null)
                {
                    if (_entity.IsClientEntity)
                        UltimaClient.Send(new MoveRequestPacket((byte)moveEvent.Facing, (byte)sequence, moveEvent.Fastwalk));
                    Facing = (Direction)moveEvent.Facing;
                    Position3D p = new Position3D(
                        moveEvent.X, moveEvent.Y, moveEvent.Z);
                    if (p != _currentPosition)
                    {
                        _goalPosition = p;
                        return;
                    }
                }

            }
        }
Esempio n. 17
0
        private Direction getNextFacing(Position3D current, Position3D goal)
        {
            Direction facing;

            if (goal.X < current.X)
            {
                if (goal.Y < current.Y)
                    facing = Direction.Up;
                else if (goal.Y > current.Y)
                    facing = Direction.Left;
                else
                    facing = Direction.West;
            }
            else if (goal.X > current.X)
            {
                if (goal.Y < current.Y)
                    facing = Direction.Right;
                else if (goal.Y > current.Y)
                    facing = Direction.Down;
                else
                    facing = Direction.East;
            }
            else
            {
                if (goal.Y < current.Y)
                    facing = Direction.North;
                else if (goal.Y > current.Y)
                    facing = Direction.South;
                else
                {
                    // We should never reach this.
                    facing = Facing & Direction.FacingMask;
                }
            }

            return facing;
        }
Esempio n. 18
0
 internal virtual void Draw(MapTile tile, Position3D position)
 {
 }
Esempio n. 19
0
        private Position3D getNextTile(Position3D current, Position3D goal, out Direction facing)
        {
            facing = getNextFacing(current, goal);
            Vector3 nextTile = MovementCheck.OffsetTile(current.Tile_V3, facing);

            int nextAltitude;
            bool moveIsOkay = MovementCheck.CheckMovement((Mobile)_entity, _world.Map, current.Tile_V3, facing, out nextAltitude);
            nextTile.Z = nextAltitude;
            if (moveIsOkay)
            {
                if (IsRunning)
                    facing |= Direction.Running;
                return new Position3D(nextTile);
            }
            else
            {
                return null;
            }
        }
Esempio n. 20
0
 public MapObjectPrerendered(Position3D position)
     : base(position)
 {
     _objects.Add(this);
 }
Esempio n. 21
0
 internal override void Draw(MapTile tile, Position3D position)
 {
     tile.FlushObjectsBySerial(Serial);
     int hue = _isHued ? _hue : 0;
     tile.AddMapObject(new TileEngine.MapObjectDynamic(this, position, _baseItemID, (int)(_frameSequence * _frameLength), hue, _useGumpArtInsteadOfTileArt));
 }