コード例 #1
0
        public void Teleport(int xOffset, int yOffset, int zOffset, Map map)
        {
            for (int i = 0; i < IncludedEntities.Count; i++)
            {
                if (Contains(IncludedEntities[i].Location))
                {
                    Point3D loc = new Point3D(IncludedEntities[i].X + xOffset, IncludedEntities[i].Y + yOffset, IncludedEntities[i].Z + zOffset);

                    if (IncludedEntities[i] is Item && IncludedEntities[i].Z == (this.Z + 1))
                    {
                        ((Item)IncludedEntities[i]).MoveToWorld(loc, map);
                    }
                    else if (IncludedEntities[i] is Mobile && IncludedEntities[i].Z == (this.Z + 1))
                    {
                        ((Mobile)IncludedEntities[i]).MoveToWorld(loc, map);
                    }
                }
            }

            if (Owner != null && Contains(Owner) && Owner.Z == (this.Z + 1))
            {
                Owner.MoveToWorld(new Point3D(Owner.X + xOffset, Owner.Y + yOffset, Owner.Z + zOffset), Owner.Map);
            }

            Point3D locationPoint = new Point3D(X + xOffset, Y + yOffset, Z + zOffset);

            Location = locationPoint;
            Map      = map;

            if (Shadow != null && !Shadow.Deleted)
            {
                object top = Map.GetTopSurface(locationPoint);
                int    z   = Map.GetAverageZ(locationPoint.X, locationPoint.Y);

                if (top is LandTile)
                {
                    z = ((LandTile)top).Z + ((LandTile)top).Height;
                }
                else if (top is StaticTile)
                {
                    z = ((StaticTile)top).Z + ((StaticTile)top).Height;
                }
                else if (top is Item)
                {
                    z = ((Item)top).GetWorldTop().Z;
                }

                Shadow.MoveToWorld(new Point3D(locationPoint, z), map);
            }
        }
コード例 #2
0
 public SmallRoyalBlueCarpet() : base()
 {
     Shadow = new Shadow(0x223, 0x224, 0x225, 0x226);
 }
コード例 #3
0
 public SmallRedCarpet() : base()
 {
     Shadow = new Shadow(0x21D, 0x21E, 0x21F, 0x220);
 }
コード例 #4
0
        public bool SetFacing(Direction facing)
        {
            if (Parent != null || Map == null)
            {
                return(false);
            }

            if (Map != Map.Internal)
            {
                switch (facing)
                {
                case Direction.North: if (!CanFit(Location, Map, NorthId, facing, false))
                    {
                        return(false);
                    }
                    break;

                case Direction.East: if (!CanFit(Location, Map, EastId, facing, false))
                    {
                        return(false);
                    }
                    break;

                case Direction.South: if (!CanFit(Location, Map, SouthId, facing, false))
                    {
                        return(false);
                    }
                    break;

                case Direction.West: if (!CanFit(Location, Map, WestId, facing, false))
                    {
                        return(false);
                    }
                    break;
                }
            }

            Map.OnLeave(this);

            Direction old = Facing;

            _facing = facing;

            MultiComponentList mcl    = Components;
            List <IEntity>     toMove = new List <IEntity>();
            IPooledEnumerable  eable  = Map.GetObjectsInBounds(new Rectangle2D((X + mcl.Min.X), (Y + mcl.Min.Y), mcl.Width, mcl.Height));

            foreach (object obj in eable)
            {
                if (obj is Item && Contains((Item)obj))
                {
                    Item i = obj as Item;

                    if (i != this && i.Z >= Z)
                    {
                        toMove.Add(i);
                    }
                }
                else if (obj is Mobile && Contains((Mobile)obj))
                {
                    toMove.Add((Mobile)obj);
                    ((Mobile)obj).Direction = (Direction)((int)((Mobile)obj).Direction - (int)old + (int)facing);
                }
            }

            eable.Free();

            int count = (int)(Facing - old) & 0x7;

            count /= 2;

            for (int i = 0; i < toMove.Count; i++)
            {
                IEntity ent = toMove[i];

                if (ent is Item)
                {
                    ((Item)ent).Location = Rotate(ent.Location, count);
                }
                else if (ent is Mobile)
                {
                    ((Mobile)ent).Location = Rotate(ent.Location, count);
                }
            }

            switch (Facing)
            {
            case Direction.North: ItemID = NorthId; break;

            case Direction.East: ItemID = EastId; break;

            case Direction.South: ItemID = SouthId; break;

            case Direction.West: ItemID = WestId; break;
            }

            if (Shadow != null && !Shadow.Deleted)
            {
                Shadow.OnRotate(old, Facing);
            }

            Map.OnEnter(this);
            return(true);
        }