예제 #1
0
파일: map.cs 프로젝트: brewsterl/cyclops
        /// <summary>
        /// Load the map.
        /// </summary>
        public static Map Load()
        {
            FileHandler handler = new FileHandler();
            //string path = Config.GetDataPath() + "world/" + Config.GetMapName();  TODO: REMOVE
            string path = Config.GetDataPath() + Config.GetWorldDirectory() + Config.GetMapName();
            BinaryReader bReader = new BinaryReader(File.Open(path, FileMode.Open));
            int sizex = bReader.ReadUInt16(); //Height
            int sizey = bReader.ReadUInt16(); //Width
            Map map = new Map(sizex, sizey);

            uint tileCount = bReader.ReadUInt32(); //Tile Count
            for (int i = 0; i < tileCount; i++) {
                ushort x = bReader.ReadUInt16(); //X position
                ushort y = bReader.ReadUInt16(); //Y position
                byte z = bReader.ReadByte(); //Z position
                ushort id = bReader.ReadUInt16(); //Tile ID
                byte itemCount = bReader.ReadByte();

                ushort[] mainTile = new ushort[itemCount + 1]; //Item count + ground
                mainTile[0] = id;
                //map.SetTile(x, y, z, new Tile(Item.CreateItem(id)));

                for (int j = 1; j <= itemCount; j++) {
                    ushort itemID = bReader.ReadUInt16();
                    mainTile[j] = itemID;
                }
                int hashCode = Position.HashCode(x, y);
                map.mainTiles[z].Add(hashCode, mainTile);
            }

            bReader.Close();
            return map;
        }
예제 #2
0
 /// <summary>
 /// Process when a player sends a comment.
 /// </summary>
 /// <param name="player">The player doing the action.</param>
 /// <param name="world">A reference to the gameworld.</param>
 private void ProcessComment(Player player, GameWorld world)
 {
     string comment = netmsg.GetStringZ();
     FileHandler fileHandler = new FileHandler();
     lock (lockStatic) {
         fileHandler.SaveComment(comment, player);
     }
     player.ResetNetMessages();
     player.AddAnonymousChat(ChatAnonymous.WHITE,
         "Your comment has been submitted");
     player.WriteToSocket();
 }