Exemplo n.º 1
0
    public virtual IMapBlock getBlock(short x, short y, short z)
    {
        global::System.IntPtr cPtr = mcworld_client_corePINVOKE.IMap_getBlock(swigCPtr, x, y, z);
        IMapBlock             ret  = (cPtr == global::System.IntPtr.Zero) ? null : new IMapBlock(cPtr, false);

        return(ret);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Changes Coordinates
        /// </summary>
        /// <param name="x">x coord</param>
        /// <param name="y">y coord</param>
        public void GetCoordinates(uint x, uint y)
        {
            if (_block == null || (x / 8 != _x / 8 || y / 8 != _y / 8))
            {
                if (_block != null)
                {
                    _block.Dispose();
                }
                _block = _map[_map.FindBlockId(x, y)];
            }
            _y = y;
            _x = x;
            var tile = _block[_x % 8, y % 8];

            _land      = tile.Land.TileId;
            _altitude  = tile.Land.Altitude;
            _list      = tile.ItemsList;
            _listIndex = 0;
        }
Exemplo n.º 3
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(IMapBlock obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            int blockCount = reader.ReadInt32();

            for (int i = 0; i < blockCount; i++)
            {
                MapBlockType type = (MapBlockType)reader.ReadInt32();

                if (!Enum.IsDefined(typeof(MapBlockType), type))
                {
                    throw new InvalidMapBlockTypeException((int)type);
                }

                int  offset    = reader.ReadInt32();
                long nextBlock = stream.Position;

                stream.Seek(offset, SeekOrigin.Begin);

                if (type == MapBlockType.MapInformation)
                {
                    MapPosition  = new IntVector2(reader.ReadInt32(), reader.ReadInt32());
                    ZonePosition = new IntVector2(reader.ReadInt32(), reader.ReadInt32());
                    World        = reader.ReadMatrix();
                    Name         = reader.ReadString();
                }
                else if (type == MapBlockType.WaterPatch)
                {
                    WaterPatches = new MapWaterPatches();
                    WaterPatches.Read(reader);
                }
                else
                {
                    if (type == MapBlockType.WaterPlane)
                    {
                        WaterSize = reader.ReadSingle();
                    }

                    int  entryCount = reader.ReadInt32();
                    Type classType  = type.GetAttributeValue <MapBlockTypeAttribute, Type>(x => x.Type);

                    for (int j = 0; j < entryCount; j++)
                    {
                        IMapBlock block = (IMapBlock)Activator.CreateInstance(classType);
                        block.Read(reader);

                        switch (type)
                        {
                        case MapBlockType.Object:
                            Objects.Add((MapObject)block);
                            break;

                        case MapBlockType.NPC:
                            NPCs.Add((MapNPC)block);
                            break;

                        case MapBlockType.Building:
                            Buildings.Add((MapBuilding)block);
                            break;

                        case MapBlockType.Sound:
                            Sounds.Add((MapSound)block);
                            break;

                        case MapBlockType.Effect:
                            Effects.Add((MapEffect)block);
                            break;

                        case MapBlockType.Animation:
                            Animations.Add((MapAnimation)block);
                            break;

                        case MapBlockType.MonsterSpawn:
                            MonsterSpawns.Add((MapMonsterSpawn)block);
                            break;

                        case MapBlockType.WaterPlane:
                            WaterPlanes.Add((MapWaterPlane)block);
                            break;

                        case MapBlockType.WarpPoint:
                            WarpPoints.Add((MapWarpPoint)block);
                            break;

                        case MapBlockType.CollisionObject:
                            CollisionObjects.Add((MapCollisionObject)block);
                            break;

                        case MapBlockType.EventObject:
                            EventObjects.Add((MapEventObject)block);
                            break;
                        }
                    }
                }


                if (i < blockCount - 1)
                {
                    stream.Seek(nextBlock, SeekOrigin.Begin);
                }
            }
        }