• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Terraria.World类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TEditXNA.Terraria.World的典型用法代码示例。如果您正苦于以下问题:C# World类的具体用法?C# World怎么用?C# World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



World类属于TEditXNA.Terraria命名空间,在下文中一共展示了World类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadWorld

 public static World LoadWorld(string filename)
 {
     var w = new World();
     try
     {
         lock (_fileLock)
         {
             using (var b = new BinaryReader(File.OpenRead(filename)))
             {
                 w.Version = b.ReadUInt32();
                 if (w.Version > 87)
                     LoadV2(b, filename, w);
                 else
                     LoadV1(b, filename, w);
             }
             w.LastSave = File.GetLastWriteTimeUtc(filename);
         }
     }
     catch (Exception err)
     {
         string msg =
             "There was an error reading the world file, do you wish to force it to load anyway?\r\n\r\n" +
             "WARNING: This may have unexpected results including corrupt world files and program crashes.\r\n\r\n" +
             "The error is :\r\n";
         if (MessageBox.Show(msg + err, "World File Error", MessageBoxButton.YesNo, MessageBoxImage.Error) !=
             MessageBoxResult.Yes)
             return null;
     }
     return w;
 }
开发者ID:reaperx420,项目名称:Terraria-Map-Editor,代码行数:30,代码来源:World.cs


示例2: WriteTally

        private static void WriteTally(StreamWriter sb, World world)
        {
            int index = 0;
            int killcount = 0;
            int bannercount = 0;
            int uniquecount = 0;

            foreach (int count in world.KilledMobs)
            {
                if (count > 0)
                {
                    int banners = (int)Math.Floor((double)count / 50f);
                    // sb.WriteProperty(index.ToString(), count.ToString());
                    sb.WriteLine("{0} {1}: {2} ({3} earned)", index, World.TallyNames[index], count, banners);
                    killcount = killcount + count;
                    if (banners > 0)
                        uniquecount = uniquecount + 1;
                    bannercount = bannercount + banners;
                }
                index++;
            }
            sb.Write(Environment.NewLine);
            sb.WriteLine("Total kills counted: {0}", killcount);
            sb.WriteLine("Total banners awarded: {0}", bannercount);
            sb.WriteLine("Total unique banners: {0}", uniquecount);
        }
开发者ID:ppally3,项目名称:Terraria-Map-Editor,代码行数:26,代码来源:KillTally.cs


示例3: Save

        public static void Save(World world, string filename, bool resetTime = false)
        {
            try
            {
                OnProgressChanged(world, new ProgressChangedEventArgs(0, "Validating World..."));
                world.Validate();
            }
            catch (ArgumentOutOfRangeException err)
            {
                string msg = string.Format("There is a problem in your world.\r\n" + 
                                           "{0}\r\nThis world will not open in Terraria\r\n" + 
                                           "Would you like to save anyways??\r\n"
                                           , err.ParamName);
                if (MessageBox.Show(msg, "World Error", MessageBoxButton.YesNo, MessageBoxImage.Error) !=
                    MessageBoxResult.Yes)
                    return;
            }
            lock (_fileLock)
            {
                

                if (resetTime)
                {
                    OnProgressChanged(world, new ProgressChangedEventArgs(0, "Resetting Time..."));
                    world.ResetTime();
                }

                if (filename == null)
                    return;

                string temp = filename + ".tmp";
                using (var fs = new FileStream(temp, FileMode.Create))
                {
                    using (var bw = new BinaryWriter(fs))
                    {
                        if (world.Version > 87)
                            SaveV2(world, bw);
                        else
                            SaveV1(world, bw);

                        bw.Close();
                        fs.Close();

                        // make a backup of current file if it exists
                        if (File.Exists(filename))
                        {
                            string backup = filename + ".TEdit";
                            File.Copy(filename, backup, true);
                        }
                        // replace actual file with temp save file
                        File.Copy(temp, filename, true);
                        // delete temp save file
                        File.Delete(temp);
                        OnProgressChanged(null, new ProgressChangedEventArgs(0, "World Save Complete."));
                    }
                }

                world._lastSave = File.GetLastWriteTimeUtc(filename);
            }
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:60,代码来源:World.cs


示例4: Render

        public static WriteableBitmap Render(World w)
        {
            WriteableBitmap bmp = new WriteableBitmap(w.TilesWide / Resolution, w.TilesHigh / Resolution, 96, 96, PixelFormats.Bgra32, null);

            UpdateMinimap(w, ref bmp);

            return bmp;
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:8,代码来源:RenderMiniMap.cs


示例5: AnalyzeWorld

        public static void AnalyzeWorld(World world, string file)
        {
            if (world == null) return;

            using (var writer = new StreamWriter(file, false))
            {
                WriteAnalyzeWorld(writer, world, true);
            }
        }
开发者ID:TEdit,项目名称:Terraria-Map-Editor,代码行数:9,代码来源:WorldAnalysis.cs


示例6: SaveTally

        public static void SaveTally(World world, string file)
        {
            if (world == null) return;

            using (var writer = new StreamWriter(file, false))
            {
                WriteTallyCount(writer, world, true);
            }
        }
开发者ID:ppally3,项目名称:Terraria-Map-Editor,代码行数:9,代码来源:KillTally.cs


示例7: NewWorldView

 public NewWorldView()
 {
     InitializeComponent();
     _newWorld = new World(1200, 4300, "TEdit World");
     _newWorld.Version = World.CompatibleVersion;
     _newWorld.GroundLevel = 350;
     _newWorld.RockLevel = 480;
     _newWorld.ResetTime();
     AddCharNames();
     this.DataContext = NewWorld;
 }
开发者ID:KeviinSkyline,项目名称:Terraria-Map-Editor,代码行数:11,代码来源:NewWorldView.xaml.cs


示例8: SaveV2

        private static void SaveV2(World world, BinaryWriter bw)
        {
            world.Validate();

            // initialize tileframeimportance array if empty
            if (TileFrameImportant == null || TileFrameImportant.Length < TileCount)
            {
                TileFrameImportant = new bool[TileCount];
                for (int i = 0; i < TileCount; i++)
                {
                    if (World.TileProperties.Count > i)
                    {
                        TileFrameImportant[i] = World.TileProperties[i].IsFramed;
                    }
                }
            }

            int[] sectionPointers = new int[SectionCount];

            OnProgressChanged(null, new ProgressChangedEventArgs(0, "Save headers..."));
            sectionPointers[0] = SaveSectionHeader(world, bw);
            sectionPointers[1] = SaveHeaderFlags(world, bw);
            OnProgressChanged(null, new ProgressChangedEventArgs(0, "Save UndoTiles..."));
            sectionPointers[2] = SaveTiles(world.Tiles, world.TilesWide, world.TilesHigh, bw);

            OnProgressChanged(null, new ProgressChangedEventArgs(100, "Save Chests..."));
            sectionPointers[3] = SaveChests(world.Chests, bw);
            OnProgressChanged(null, new ProgressChangedEventArgs(100, "Save Signs..."));
            sectionPointers[4] = SaveSigns(world.Signs, bw);
            OnProgressChanged(null, new ProgressChangedEventArgs(100, "Save NPCs..."));
            sectionPointers[5] = SaveNPCs(world.NPCs, bw);
            OnProgressChanged(null, new ProgressChangedEventArgs(100, "Save Mobs..."));
            sectionPointers[5] = SaveMobs(world.Mobs, bw);
            OnProgressChanged(null, new ProgressChangedEventArgs(100, "Save Tile Entities Section..."));
            sectionPointers[6] = SaveTileEntities(world, bw);
            OnProgressChanged(null, new ProgressChangedEventArgs(100, "Save Footers..."));
            SaveFooter(world, bw);
            UpdateSectionPointers(sectionPointers, bw);
            OnProgressChanged(null, new ProgressChangedEventArgs(100, "Save Complete."));
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:40,代码来源:World.FileV2.cs


示例9: LoadWorld

        public static World LoadWorld(string filename)
        {
            var w = new World();
            uint curVersion = 0;
            try
            {
                lock (_fileLock)
                {
                    using (var b = new BinaryReader(File.OpenRead(filename)))
                    {
                        w.Version = b.ReadUInt32();
                        curVersion = w.Version;
                        if (w.Version > 87)
                            LoadV2(b, filename, w);
                        else
                            LoadV1(b, filename, w);
                    }
                    w.LastSave = File.GetLastWriteTimeUtc(filename);
                }
            }
            catch (Exception err)
            {

                string msg =
                    string.Format("There was an error reading the world file. This is usually caused by a corrupt save file or a world version newer than supported.\r\n\r\n" +
                                  "TEdit v{0}\r\n" +
                                  "TEdit Max World: {1}    Current World: {2}\r\n\r\n" +
                                  "Do you wish to force it to load anyway?\r\n\r\n" +
                                  "WARNING: This may have unexpected results including corrupt world files and program crashes.\r\n\r\n" +
                                   "The error is :\r\n{3}\r\n\r\n{4}\r\n"
                    , TEditXna.App.Version.FileVersion, World.CompatibleVersion, curVersion, err.Message, err);
                if (MessageBox.Show(msg, "World File Error", MessageBoxButton.YesNo, MessageBoxImage.Error) !=
                    MessageBoxResult.Yes)
                    return null;
            }
            return w;
        }
开发者ID:TEdit,项目名称:Terraria-Map-Editor,代码行数:37,代码来源:World.cs


示例10: UpdateMinimap

        public static void UpdateMinimap(World w, ref WriteableBitmap bmp)
        {
            bmp.Lock();
            unsafe
            {
                int pixelCount = bmp.PixelHeight * bmp.PixelWidth;
                var pixels = (int*)bmp.BackBuffer;

                for (int i = 0; i < pixelCount; i++)
                {
                    int x = i % bmp.PixelWidth;
                    int y = i / bmp.PixelWidth;

                    int worldX = x * Resolution;
                    int worldY = y * Resolution;



                    pixels[i] = XnaColorToWindowsInt(PixelMap.GetTileColor(w.Tiles[worldX, worldY], Microsoft.Xna.Framework.Color.Transparent));
                }
            }
            bmp.AddDirtyRect(new Int32Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight));
            bmp.Unlock();
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:24,代码来源:RenderMiniMap.cs


示例11: LoadFooter

        public static void LoadFooter(BinaryReader r, World w)
        {
            if (!r.ReadBoolean())
                throw new FileFormatException("Invalid Footer");

            if (r.ReadString() != w.Title)
                throw new FileFormatException("Invalid Footer");

            if (r.ReadInt32() != w.WorldId)
                throw new FileFormatException("Invalid Footer");
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:11,代码来源:World.FileV2.cs


示例12: LoadMobsData

        public static void LoadMobsData(BinaryReader r, World w)
        {
            int totalMobs = 0;
            bool flag = r.ReadBoolean();
            while (flag)            
            {
                NPC npc = new NPC();
                npc.Name = r.ReadString();                    
                npc.Position = new Vector2(r.ReadSingle(), r.ReadSingle());

                if (NpcIds.ContainsKey(npc.Name))
                    npc.SpriteId = NpcIds[npc.Name];

                w.Mobs.Add(npc);
                totalMobs++;
                flag = r.ReadBoolean();
            }
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:18,代码来源:World.FileV2.cs


示例13: LoadWorld

        public static World LoadWorld(string filename)
        {
            var w = new World();
            try
            {
                lock (_fileLock)
                {
                    using (var b = new BinaryReader(File.OpenRead(filename)))
                    {
                        w.Version = b.ReadUInt32(); //now we care about the version
                        w.Title = b.ReadString();
                        w.WorldId = b.ReadInt32();

                        w.Rand = new Random(w.WorldId);

                        w.LeftWorld = (float)b.ReadInt32();
                        w.RightWorld = (float)b.ReadInt32();
                        w.TopWorld = (float)b.ReadInt32();
                        w.BottomWorld = (float)b.ReadInt32();
                        w.TilesHigh = b.ReadInt32();
                        w.TilesWide = b.ReadInt32();

                        //if (w.TilesHigh > 10000 || w.TilesWide > 10000 || w.TilesHigh <= 0 || w.TilesWide <= 0)
                        //    throw new FileLoadException(string.Format("Invalid File: {0}", filename));

                        if (w.Version >= 63)
                            w.MoonType = (int)b.ReadByte();
                        else
                            w.MoonType = w.Rand.Next(MaxMoons);

                        if (w.Version >= 44)
                        {
                            w.TreeX[0] = b.ReadInt32();
                            w.TreeX[1] = b.ReadInt32();
                            w.TreeX[2] = b.ReadInt32();
                            w.TreeStyle[0] = b.ReadInt32();
                            w.TreeStyle[1] = b.ReadInt32();
                            w.TreeStyle[2] = b.ReadInt32();
                            w.TreeStyle[3] = b.ReadInt32();
                        }
                        if (w.Version >= 60)
                        {
                            w.CaveBackX[0] = b.ReadInt32();
                            w.CaveBackX[1] = b.ReadInt32();
                            w.CaveBackX[2] = b.ReadInt32();
                            w.CaveBackStyle[0] = b.ReadInt32();
                            w.CaveBackStyle[1] = b.ReadInt32();
                            w.CaveBackStyle[2] = b.ReadInt32();
                            w.CaveBackStyle[3] = b.ReadInt32();
                            w.IceBackStyle = b.ReadInt32();
                            if (w.Version >= 61)
                            {
                                w.JungleBackStyle = b.ReadInt32();
                                w.HellBackStyle = b.ReadInt32();
                            }
                        }
                        else
                        {
                            w.CaveBackX[0] = w.TilesWide / 2;
                            w.CaveBackX[1] = w.TilesWide;
                            w.CaveBackX[2] = w.TilesWide;
                            w.CaveBackStyle[0] = 0;
                            w.CaveBackStyle[1] = 1;
                            w.CaveBackStyle[2] = 2;
                            w.CaveBackStyle[3] = 3;
                            w.IceBackStyle = 0;
                            w.JungleBackStyle = 0;
                            w.HellBackStyle = 0;
                        }

                        w.SpawnX = b.ReadInt32();
                        w.SpawnY = b.ReadInt32();
                        w.GroundLevel = (int)b.ReadDouble();
                        w.RockLevel = (int)b.ReadDouble();

                        // read world flags
                        w.Time = b.ReadDouble();
                        w.DayTime = b.ReadBoolean();
                        w.MoonPhase = b.ReadInt32();
                        w.BloodMoon = b.ReadBoolean();

                        if (w.Version >= 70)
                        {
                            w.IsEclipse = b.ReadBoolean();
                        }

                        w.DungeonX = b.ReadInt32();
                        w.DungeonY = b.ReadInt32();

                        if (w.Version >= 56)
                        {
                            w.IsCrimson = b.ReadBoolean();
                        }
                        else
                        {
                            w.IsCrimson = false;
                        }

                        w.DownedBoss1 = b.ReadBoolean();
                        w.DownedBoss2 = b.ReadBoolean();
//.........这里部分代码省略.........
开发者ID:RandomSheep,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:World.cs


示例14: LoadSectionHeader

        public static bool LoadSectionHeader(BinaryReader r, out bool[] tileFrameImportant, out int[] sectionPointers, World w)
        {
            tileFrameImportant = null;
            sectionPointers = null;
            int versionNumber = r.ReadInt32();
            if(versionNumber > 140)
            {
                UInt64 versionTypecheck = r.ReadUInt64();
                if (versionTypecheck != 0x026369676f6c6572ul )
                    throw new FileFormatException("Invalid Header");

                w.FileRevision = r.ReadUInt32();
                UInt64 temp = r.ReadUInt64();//I have no idea what this is for...
                w.IsFavorite = ((temp & 1uL) == 1uL);
            }

            // read file section stream positions
            short fileSectionCount = r.ReadInt16();
            sectionPointers = new int[fileSectionCount];
            for (int i = 0; i < fileSectionCount; i++)
            {
                sectionPointers[i] = r.ReadInt32();
            }

            // Read tile frame importance from bit-packed data
            tileFrameImportant = ReadBitArray(r);

            return true;
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:29,代码来源:World.FileV2.cs


示例15: LoadTileEntities

        public static void LoadTileEntities(BinaryReader r, World w)
        {
            w.TileEntitiesNumber = r.ReadInt32();

            for (int counter = 0; counter < w.TileEntitiesNumber; counter++ )
            {
                TileEntity entity = new TileEntity();
                entity.Type = r.ReadByte();
                entity.Id = r.ReadInt32();
                entity.PosX = r.ReadInt16();
                entity.PosY = r.ReadInt16();
                switch (entity.Type)
                {
                    case 0: //it is a dummy
                        entity.Npc = r.ReadInt16();
                        break;
                    case 1: //it is a item frame
                        entity.ItemNetId = r.ReadInt16();
                        entity.Prefix = r.ReadByte();
                        entity.Stack = r.ReadInt16();
                        break;
                }
                w.TileEntities.Add(entity);
            }
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:25,代码来源:World.FileV2.cs


示例16: LoadWorld

        public static World LoadWorld(string filename)
        {
            var w = new World();
            try
            {
                lock (_fileLock)
                {
                    using (var b = new BinaryReader(File.OpenRead(filename)))
                    {
                        w.Version = b.ReadUInt32(); //now we care about the version
                        uint version = w.Version;
                        w.Title = b.ReadString();
                        w.WorldId = b.ReadInt32();

                        w.Rand = new Random(w.WorldId);

                        w.LeftWorld = (float)b.ReadInt32();
                        w.RightWorld = (float)b.ReadInt32();
                        w.TopWorld = (float)b.ReadInt32();
                        w.BottomWorld = (float)b.ReadInt32();
                        w.TilesHigh = b.ReadInt32();
                        w.TilesWide = b.ReadInt32();

                        //if (w.TilesHigh > 10000 || w.TilesWide > 10000 || w.TilesHigh <= 0 || w.TilesWide <= 0)
                        //    throw new FileLoadException(string.Format("Invalid File: {0}", filename));

                        if (version >= 63)
                            w.MoonType = (int)b.ReadByte();
                        else
                            w.MoonType = w.Rand.Next(MaxMoons);

                        if (version >= 44)
                        {
                            w.TreeX[0] = b.ReadInt32();
                            w.TreeX[1] = b.ReadInt32();
                            w.TreeX[2] = b.ReadInt32();
                            w.TreeStyle[0] = b.ReadInt32();
                            w.TreeStyle[1] = b.ReadInt32();
                            w.TreeStyle[2] = b.ReadInt32();
                            w.TreeStyle[3] = b.ReadInt32();
                        }
                        if (version >= 60)
                        {
                            w.CaveBackX[0] = b.ReadInt32();
                            w.CaveBackX[1] = b.ReadInt32();
                            w.CaveBackX[2] = b.ReadInt32();
                            w.CaveBackStyle[0] = b.ReadInt32();
                            w.CaveBackStyle[1] = b.ReadInt32();
                            w.CaveBackStyle[2] = b.ReadInt32();
                            w.CaveBackStyle[3] = b.ReadInt32();
                            w.IceBackStyle = b.ReadInt32();
                            if (version >= 61)
                            {
                                w.JungleBackStyle = b.ReadInt32();
                                w.HellBackStyle = b.ReadInt32();
                            }
                        }
                        else
                        {
                            w.CaveBackX[0] = w.TilesWide / 2;
                            w.CaveBackX[1] = w.TilesWide;
                            w.CaveBackX[2] = w.TilesWide;
                            w.CaveBackStyle[0] = 0;
                            w.CaveBackStyle[1] = 1;
                            w.CaveBackStyle[2] = 2;
                            w.CaveBackStyle[3] = 3;
                            w.IceBackStyle = 0;
                            w.JungleBackStyle = 0;
                            w.HellBackStyle = 0;
                        }

                        w.SpawnX = b.ReadInt32();
                        w.SpawnY = b.ReadInt32();
                        w.GroundLevel = (int)b.ReadDouble();
                        w.RockLevel = (int)b.ReadDouble();

                        // read world flags
                        w.Time = b.ReadDouble();
                        w.DayTime = b.ReadBoolean();
                        w.MoonPhase = b.ReadInt32();
                        w.BloodMoon = b.ReadBoolean();

                        if (version >= 70)
                        {
                            w.IsEclipse = b.ReadBoolean();
                        }

                        w.DungeonX = b.ReadInt32();
                        w.DungeonY = b.ReadInt32();

                        if (version >= 56)
                        {
                            w.IsCrimson = b.ReadBoolean();
                        }
                        else
                        {
                            w.IsCrimson = false;
                        }

                        w.DownedBoss1 = b.ReadBoolean();
//.........这里部分代码省略.........
开发者ID:Kapow751,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:World.cs


示例17: SaveV1

        private static void SaveV1(World world, BinaryWriter bw)
        {
            bw.Write(CompatibleVersion);
            bw.Write(world.Title);
            bw.Write(world.WorldId);
            bw.Write((int) world.LeftWorld);
            bw.Write((int) world.RightWorld);
            bw.Write((int) world.TopWorld);
            bw.Write((int) world.BottomWorld);
            bw.Write(world.TilesHigh);
            bw.Write(world.TilesWide);

            bw.Write((byte) world.MoonType);
            bw.Write(world.TreeX0);
            bw.Write(world.TreeX1);
            bw.Write(world.TreeX2);
            bw.Write(world.TreeStyle0);
            bw.Write(world.TreeStyle1);
            bw.Write(world.TreeStyle2);
            bw.Write(world.TreeStyle3);
            bw.Write(world.CaveBackX0);
            bw.Write(world.CaveBackX1);
            bw.Write(world.CaveBackX2);
            bw.Write(world.CaveBackStyle0);
            bw.Write(world.CaveBackStyle1);
            bw.Write(world.CaveBackStyle2);
            bw.Write(world.CaveBackStyle3);
            bw.Write(world.IceBackStyle);
            bw.Write(world.JungleBackStyle);
            bw.Write(world.HellBackStyle);

            bw.Write(world.SpawnX);
            bw.Write(world.SpawnY);
            bw.Write(world.GroundLevel);
            bw.Write(world.RockLevel);
            bw.Write(world.Time);
            bw.Write(world.DayTime);
            bw.Write(world.MoonPhase);
            bw.Write(world.BloodMoon);
            bw.Write(world.IsEclipse);
            bw.Write(world.DungeonX);
            bw.Write(world.DungeonY);

            bw.Write(world.IsCrimson);

            bw.Write(world.DownedBoss1);
            bw.Write(world.DownedBoss2);
            bw.Write(world.DownedBoss3);
            bw.Write(world.DownedQueenBee);
            bw.Write(world.DownedMechBoss1);
            bw.Write(world.DownedMechBoss2);
            bw.Write(world.DownedMechBoss3);
            bw.Write(world.DownedMechBossAny);
            bw.Write(world.DownedPlantBoss);
            bw.Write(world.DownedGolemBoss);
            bw.Write(world.SavedGoblin);
            bw.Write(world.SavedWizard);
            bw.Write(world.SavedMech);
            bw.Write(world.DownedGoblins);
            bw.Write(world.DownedClown);
            bw.Write(world.DownedFrost);
            bw.Write(world.DownedPirates);

            bw.Write(world.ShadowOrbSmashed);
            bw.Write(world.SpawnMeteor);
            bw.Write((byte) world.ShadowOrbCount);
            bw.Write(world.AltarCount);
            bw.Write(world.HardMode);
            bw.Write(world.InvasionDelay);
            bw.Write(world.InvasionSize);
            bw.Write(world.InvasionType);
            bw.Write(world.InvasionX);

            bw.Write(world.TempRaining);
            bw.Write(world.TempRainTime);
            bw.Write(world.TempMaxRain);
            bw.Write(world.OreTier1);
            bw.Write(world.OreTier2);
            bw.Write(world.OreTier3);
            bw.Write(world.BgTree);
            bw.Write(world.BgCorruption);
            bw.Write(world.BgJungle);
            bw.Write(world.BgSnow);
            bw.Write(world.BgHallow);
            bw.Write(world.BgCrimson);
            bw.Write(world.BgDesert);
            bw.Write(world.BgOcean);
            bw.Write((int) world.CloudBgActive);
            bw.Write(world.NumClouds);
            bw.Write(world.WindSpeedSet);


            for (int x = 0; x < world.TilesWide; ++x)
            {
                OnProgressChanged(world,
                    new ProgressChangedEventArgs(x.ProgressPercentage(world.TilesWide), "Saving UndoTiles..."));

                int rle = 0;
                for (int y = 0; y < world.TilesHigh; y = y + rle + 1)
                {
//.........这里部分代码省略.........
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:World.FileV1.cs


示例18: LoadHeaderFlags

        public static void LoadHeaderFlags(BinaryReader r, World w, int expectedPosition)
        {
            w.Title = r.ReadString();
            w.WorldId = r.ReadInt32();
            w.LeftWorld = (float)r.ReadInt32();
            w.RightWorld = (float)r.ReadInt32();
            w.TopWorld = (float)r.ReadInt32();
            w.BottomWorld = (float)r.ReadInt32();
            w.TilesHigh = r.ReadInt32();
            w.TilesWide = r.ReadInt32();

            if (w.Version >= 147)
            {
                w.ExpertMode = r.ReadBoolean();
                w.CreationTime = r.ReadInt64();
            }
            else
            {
                w.CreationTime = DateTime.Now.ToBinary();
            }

            w.MoonType = r.ReadByte();
            w.TreeX[0] = r.ReadInt32();
            w.TreeX[1] = r.ReadInt32();
            w.TreeX[2] = r.ReadInt32();
            w.TreeX2 = w.TreeX[2];
            w.TreeX1 = w.TreeX[1];
            w.TreeX0 = w.TreeX[0];
            w.TreeStyle0 = r.ReadInt32();
            w.TreeStyle1 = r.ReadInt32();
            w.TreeStyle2 = r.ReadInt32();
            w.TreeStyle3 = r.ReadInt32();
            w.CaveBackX[0] = r.ReadInt32();
            w.CaveBackX[1] = r.ReadInt32();
            w.CaveBackX[2] = r.ReadInt32();
            w.CaveBackX2 = w.CaveBackX[2];
            w.CaveBackX1 = w.CaveBackX[1];
            w.CaveBackX0 = w.CaveBackX[0];
            w.CaveBackStyle0 = r.ReadInt32();
            w.CaveBackStyle1 = r.ReadInt32();
            w.CaveBackStyle2 = r.ReadInt32();
            w.CaveBackStyle3 = r.ReadInt32();
            w.IceBackStyle = r.ReadInt32();
            w.JungleBackStyle = r.ReadInt32();
            w.HellBackStyle = r.ReadInt32();

            w.SpawnX = r.ReadInt32();
            w.SpawnY = r.ReadInt32();
            w.GroundLevel = r.ReadDouble();
            w.RockLevel = r.ReadDouble();
            w.Time = r.ReadDouble();
            w.DayTime = r.ReadBoolean();
            w.MoonPhase = r.ReadInt32();
            w.BloodMoon = r.ReadBoolean();
            w.IsEclipse = r.ReadBoolean();
            w.DungeonX = r.ReadInt32();
            w.DungeonY = r.ReadInt32();

            w.IsCrimson = r.ReadBoolean();

            w.DownedBoss1 = r.ReadBoolean();
            w.DownedBoss2 = r.ReadBoolean();
            w.DownedBoss3 = r.ReadBoolean();
            w.DownedQueenBee = r.ReadBoolean();
            w.DownedMechBoss1 = r.ReadBoolean();
            w.DownedMechBoss2 = r.ReadBoolean();
            w.DownedMechBoss3 = r.ReadBoolean();
            w.DownedMechBossAny = r.ReadBoolean();
            w.DownedPlantBoss = r.ReadBoolean();
            w.DownedGolemBoss = r.ReadBoolean();
            if (w.Version >= 147) w.DownedSlimeKingBoss = r.ReadBoolean();
            w.SavedGoblin = r.ReadBoolean();
            w.SavedWizard = r.ReadBoolean();
            w.SavedMech = r.ReadBoolean();
            w.DownedGoblins = r.ReadBoolean();
            w.DownedClown = r.ReadBoolean();
            w.DownedFrost = r.ReadBoolean();
            w.DownedPirates = r.ReadBoolean();

            w.ShadowOrbSmashed = r.ReadBoolean();
            w.SpawnMeteor = r.ReadBoolean();
            w.ShadowOrbCount = r.ReadByte();
            w.AltarCount = r.ReadInt32();
            w.HardMode = r.ReadBoolean();
            w.InvasionDelay = r.ReadInt32();
            w.InvasionSize = r.ReadInt32();
            w.InvasionType = r.ReadInt32();
            w.InvasionX = r.ReadDouble();

            if (w.Version >= 147)
            {                 
                 w.SlimeRainTime = r.ReadDouble();
                 w.SundialCooldown = r.ReadByte();
            }

            w.TempRaining = r.ReadBoolean();
            w.TempRainTime = r.ReadInt32();
            w.TempMaxRain = r.ReadSingle();
            w.OreTier1 = r.ReadInt32();
            w.OreTier2 = r.ReadInt32();
//.........这里部分代码省略.........
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:World.FileV2.cs


示例19: SaveFooter

        public static int SaveFooter(World world, BinaryWriter bw)
        {
            bw.Write(true);
            bw.Write(world.Title);
            bw.Write(world.WorldId);

            return (int)bw.BaseStream.Position;
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:8,代码来源:World.FileV2.cs


示例20: LoadV1

        private static void LoadV1(BinaryReader reader, string filename, World w)
        {
            uint version = w.Version;
            w.Title = reader.ReadString();
            w.WorldId = reader.ReadInt32();

            w.Rand = new Random(w.WorldId);

            w.LeftWorld = reader.ReadInt32();
            w.RightWorld = reader.ReadInt32();
            w.TopWorld = reader.ReadInt32();
            w.BottomWorld = reader.ReadInt32();
            w.TilesHigh = reader.ReadInt32();
            w.TilesWide = reader.ReadInt32();

            //if (w.TilesHigh > 10000 || w.TilesWide > 10000 || w.TilesHigh <= 0 || w.TilesWide <= 0)
            //    throw new FileLoadException(string.Format("Invalid File: {0}", filename));


            if (version >= 63)
                w.MoonType = reader.ReadByte();
            else
                w.MoonType = (byte)w.Rand.Next(MaxMoons);


            if (version >= 44)
            {
                w.TreeX0 = reader.ReadInt32();
                w.TreeX1 = reader.ReadInt32();
                w.TreeX2 = reader.ReadInt32();
                w.TreeStyle0 = reader.ReadInt32();
                w.TreeStyle1 = reader.ReadInt32();
                w.TreeStyle2 = reader.ReadInt32();
                w.TreeStyle3 = reader.ReadInt32();
            }
            if (version >= 60)
            {
                w.CaveBackX0 = reader.ReadInt32();
                w.CaveBackX1 = reader.ReadInt32();
                w.CaveBackX2 = reader.ReadInt32();
                w.CaveBackStyle0 = reader.ReadInt32();
                w.CaveBackStyle1 = reader.ReadInt32();
                w.CaveBackStyle2 = reader.ReadInt32();
                w.CaveBackStyle3 = reader.ReadInt32();
                w.IceBackStyle = reader.ReadInt32();
                if (version >= 61)
                {
                    w.JungleBackStyle = reader.ReadInt32();
                    w.HellBackStyle = reader.ReadInt32();
                }
            }
            else
            {
                w.CaveBackX[0] = w.TilesWide/2;
                w.CaveBackX[1] = w.TilesWide;
                w.CaveBackX[2] = w.TilesWide;
                w.CaveBackStyle0 = 0;
                w.CaveBackStyle1 = 1;
                w.CaveBackStyle2 = 2;
                w.CaveBackStyle3 = 3;
                w.IceBackStyle = 0;
                w.JungleBackStyle = 0;
                w.HellBackStyle = 0;
            }

            w.SpawnX = reader.ReadInt32();
            w.SpawnY = reader.ReadInt32();
            w.GroundLevel = (int) reader.ReadDouble();
            w.RockLevel = (int) reader.ReadDouble();

            // read world flags
            w.Time = reader.ReadDouble();
            w.DayTime = reader.ReadBoolean();
            w.MoonPhase = reader.ReadInt32();
            w.BloodMoon = reader.ReadBoolean();

            if (version >= 70)
            {
                w.IsEclipse = reader.ReadBoolean();
            }

            w.DungeonX = reader.ReadInt32();
            w.DungeonY = reader.ReadInt32();

            if (version >= 56)
            {
                w.IsCrimson = reader.ReadBoolean();
            }
            else
            {
                w.IsCrimson = false;
            }

            w.DownedBoss1 = reader.ReadBoolean();
            w.DownedBoss2 = reader.ReadBoolean();
            w.DownedBoss3 = reader.ReadBoolean();

            if (version >= 66)
            {
                w.DownedQueenBee = reader.ReadBoolean();
//.........这里部分代码省略.........
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:World.FileV1.cs



注:本文中的TEditXNA.Terraria.World类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Util.PersistentManager类代码示例发布时间:2022-05-26
下一篇:
C# Terraria.Tile类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap