示例#1
0
        public unsafe void LoadStatics(int map)
        {
            IndexMap im = GetIndex(map);

            if (im.MapAddress != 0)
            {
                int bx = X * 8;
                int by = Y * 8;

                if (im.StaticAddress != 0)
                {
                    StaticsBlock *sb = (StaticsBlock *)im.StaticAddress;

                    if (sb != null)
                    {
                        int count = (int)im.StaticCount;

                        for (int i = 0; i < count; i++, sb++)
                        {
                            if (sb->Color != 0 && sb->Color != 0xFFFF)
                            {
                                ushort x   = sb->X;
                                ushort y   = sb->Y;
                                int    pos = y * 8 + x;

                                if (pos >= 64)
                                {
                                    continue;
                                }
                                sbyte z = sb->Z;

                                ushort staticX = (ushort)(bx + x);
                                ushort staticY = (ushort)(by + y);

                                Static staticObject = new Static(sb->Color, sb->Hue, pos)
                                {
                                    Position = new Position(staticX, staticY, z)
                                };

                                if (staticObject.ItemData.IsAnimated)
                                {
                                    World.AddEffect(new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1));
                                }
                                else
                                {
                                    staticObject.AddToTile(Tiles[x, y]);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public unsafe void Load(int map)
        {
            IndexMap im = GetIndex(map);

            if (im.MapAddress != 0)
            {
                MapBlock *block = (MapBlock *)im.MapAddress;
                MapCells *cells = (MapCells *)&block->Cells;
                int       bx    = X * 8;
                int       by    = Y * 8;

                for (int x = 0; x < 8; x++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        int    pos    = y * 8 + x;
                        ushort tileID = (ushort)(cells[pos].TileID & 0x3FFF);
                        sbyte  z      = cells[pos].Z;

                        Land land = new Land(tileID)
                        {
                            Graphic  = tileID,
                            AverageZ = z,
                            MinZ     = z,
                        };

                        ushort tileX = (ushort)(bx + x);
                        ushort tileY = (ushort)(by + y);

                        land.Calculate(tileX, tileY, z);
                        land.Position = new Position(tileX, tileY, z);

                        land.AddToTile(Tiles[x, y]);
                    }
                }

                if (im.StaticAddress != 0)
                {
                    StaticsBlock *sb = (StaticsBlock *)im.StaticAddress;

                    if (sb != null)
                    {
                        int count = (int)im.StaticCount;

                        for (int i = 0; i < count; i++, sb++)
                        {
                            if (sb->Color != 0 && sb->Color != 0xFFFF)
                            {
                                ushort x   = sb->X;
                                ushort y   = sb->Y;
                                int    pos = y * 8 + x;

                                if (pos >= 64)
                                {
                                    continue;
                                }
                                sbyte z = sb->Z;

                                ushort staticX = (ushort)(bx + x);
                                ushort staticY = (ushort)(by + y);

                                Static staticObject = new Static(sb->Color, sb->Hue, pos)
                                {
                                    Position = new Position(staticX, staticY, z)
                                };

                                if (staticObject.ItemData.IsAnimated)
                                {
                                    World.AddEffect(new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1));
                                }
                                else
                                {
                                    staticObject.AddToTile(Tiles[x, y]);
                                }
                            }
                        }
                    }
                }


                //CreateLand();
            }
        }