Пример #1
0
 public static void load()
 {
     LevelZombies._models                 = new GameObject().transform;
     LevelZombies.models.name             = "Zombies";
     LevelZombies.models.parent           = Level.spawns;
     LevelZombies.models.tag              = "Logic";
     LevelZombies.models.gameObject.layer = LayerMasks.LOGIC;
     LevelZombies.tables = new List <ZombieTable>();
     if (ReadWrite.fileExists(Level.info.path + "/Spawns/Zombies.dat", false, false))
     {
         Block block = ReadWrite.readBlock(Level.info.path + "/Spawns/Zombies.dat", false, false, 0);
         byte  b     = block.readByte();
         if (b > 3 && b < 5)
         {
             block.readSteamID();
         }
         if (b > 2)
         {
             byte b2 = block.readByte();
             for (byte b3 = 0; b3 < b2; b3 += 1)
             {
                 Color  newColor     = block.readColor();
                 string newName      = block.readString();
                 bool   flag         = block.readBoolean();
                 ushort newHealth    = block.readUInt16();
                 byte   newDamage    = block.readByte();
                 byte   newLootIndex = block.readByte();
                 ushort newLootID;
                 if (b > 6)
                 {
                     newLootID = block.readUInt16();
                 }
                 else
                 {
                     newLootID = 0;
                 }
                 uint newXP;
                 if (b > 7)
                 {
                     newXP = block.readUInt32();
                 }
                 else if (flag)
                 {
                     newXP = 40u;
                 }
                 else
                 {
                     newXP = 3u;
                 }
                 float newRegen = 10f;
                 if (b > 5)
                 {
                     newRegen = block.readSingle();
                 }
                 string newDifficultyGUID = string.Empty;
                 if (b > 8)
                 {
                     newDifficultyGUID = block.readString();
                 }
                 ZombieSlot[] array = new ZombieSlot[4];
                 byte         b4    = block.readByte();
                 for (byte b5 = 0; b5 < b4; b5 += 1)
                 {
                     List <ZombieCloth> list = new List <ZombieCloth>();
                     float newChance         = block.readSingle();
                     byte  b6 = block.readByte();
                     for (byte b7 = 0; b7 < b6; b7 += 1)
                     {
                         ushort num = block.readUInt16();
                         if ((ItemAsset)Assets.find(EAssetType.ITEM, num) != null)
                         {
                             list.Add(new ZombieCloth(num));
                         }
                     }
                     array[(int)b5] = new ZombieSlot(newChance, list);
                 }
                 LevelZombies.tables.Add(new ZombieTable(array, newColor, newName, flag, newHealth, newDamage, newLootIndex, newLootID, newXP, newRegen, newDifficultyGUID));
             }
         }
         else
         {
             byte b8 = block.readByte();
             for (byte b9 = 0; b9 < b8; b9 += 1)
             {
                 Color        newColor2     = block.readColor();
                 string       newName2      = block.readString();
                 byte         newLootIndex2 = block.readByte();
                 ZombieSlot[] array2        = new ZombieSlot[4];
                 byte         b10           = block.readByte();
                 for (byte b11 = 0; b11 < b10; b11 += 1)
                 {
                     List <ZombieCloth> list2 = new List <ZombieCloth>();
                     float newChance2         = block.readSingle();
                     byte  b12 = block.readByte();
                     for (byte b13 = 0; b13 < b12; b13 += 1)
                     {
                         ushort num2 = block.readUInt16();
                         if ((ItemAsset)Assets.find(EAssetType.ITEM, num2) != null)
                         {
                             list2.Add(new ZombieCloth(num2));
                         }
                     }
                     array2[(int)b11] = new ZombieSlot(newChance2, list2);
                 }
                 LevelZombies.tables.Add(new ZombieTable(array2, newColor2, newName2, false, 100, 15, newLootIndex2, 0, 5u, 10f, string.Empty));
             }
         }
     }
     LevelZombies._spawns = new List <ZombieSpawnpoint> [(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE];
     for (byte b14 = 0; b14 < Regions.WORLD_SIZE; b14 += 1)
     {
         for (byte b15 = 0; b15 < Regions.WORLD_SIZE; b15 += 1)
         {
             LevelZombies.spawns[(int)b14, (int)b15] = new List <ZombieSpawnpoint>();
         }
     }
     if (Level.isEditor)
     {
         if (ReadWrite.fileExists(Level.info.path + "/Spawns/Animals.dat", false, false))
         {
             River river = new River(Level.info.path + "/Spawns/Animals.dat", false);
             byte  b16   = river.readByte();
             if (b16 > 0)
             {
                 for (byte b17 = 0; b17 < Regions.WORLD_SIZE; b17 += 1)
                 {
                     for (byte b18 = 0; b18 < Regions.WORLD_SIZE; b18 += 1)
                     {
                         ushort num3 = river.readUInt16();
                         for (ushort num4 = 0; num4 < num3; num4 += 1)
                         {
                             byte    newType  = river.readByte();
                             Vector3 newPoint = river.readSingleVector3();
                             LevelZombies.spawns[(int)b17, (int)b18].Add(new ZombieSpawnpoint(newType, newPoint));
                         }
                     }
                 }
             }
             river.closeRiver();
         }
         else
         {
             for (byte b19 = 0; b19 < Regions.WORLD_SIZE; b19 += 1)
             {
                 for (byte b20 = 0; b20 < Regions.WORLD_SIZE; b20 += 1)
                 {
                     LevelZombies.spawns[(int)b19, (int)b20] = new List <ZombieSpawnpoint>();
                     if (ReadWrite.fileExists(string.Concat(new object[]
                     {
                         Level.info.path,
                         "/Spawns/Animals_",
                         b19,
                         "_",
                         b20,
                         ".dat"
                     }), false, false))
                     {
                         River river2 = new River(string.Concat(new object[]
                         {
                             Level.info.path,
                             "/Spawns/Animals_",
                             b19,
                             "_",
                             b20,
                             ".dat"
                         }), false);
                         byte b21 = river2.readByte();
                         if (b21 > 0)
                         {
                             ushort num5 = river2.readUInt16();
                             for (ushort num6 = 0; num6 < num5; num6 += 1)
                             {
                                 byte    newType2  = river2.readByte();
                                 Vector3 newPoint2 = river2.readSingleVector3();
                                 LevelZombies.spawns[(int)b19, (int)b20].Add(new ZombieSpawnpoint(newType2, newPoint2));
                             }
                             river2.closeRiver();
                         }
                     }
                 }
             }
         }
     }
     else if (Provider.isServer)
     {
         LevelZombies._zombies = new List <ZombieSpawnpoint> [LevelNavigation.bounds.Count];
         for (int i = 0; i < LevelZombies.zombies.Length; i++)
         {
             LevelZombies.zombies[i] = new List <ZombieSpawnpoint>();
         }
         if (ReadWrite.fileExists(Level.info.path + "/Spawns/Animals.dat", false, false))
         {
             River river3 = new River(Level.info.path + "/Spawns/Animals.dat", false);
             byte  b22    = river3.readByte();
             if (b22 > 0)
             {
                 for (byte b23 = 0; b23 < Regions.WORLD_SIZE; b23 += 1)
                 {
                     for (byte b24 = 0; b24 < Regions.WORLD_SIZE; b24 += 1)
                     {
                         ushort num7 = river3.readUInt16();
                         for (ushort num8 = 0; num8 < num7; num8 += 1)
                         {
                             byte    newType3 = river3.readByte();
                             Vector3 vector   = river3.readSingleVector3();
                             byte    b25;
                             if (LevelNavigation.tryGetBounds(vector, out b25) && LevelNavigation.checkNavigation(vector))
                             {
                                 LevelZombies.zombies[(int)b25].Add(new ZombieSpawnpoint(newType3, vector));
                             }
                         }
                     }
                 }
             }
             river3.closeRiver();
         }
         else
         {
             for (byte b26 = 0; b26 < Regions.WORLD_SIZE; b26 += 1)
             {
                 for (byte b27 = 0; b27 < Regions.WORLD_SIZE; b27 += 1)
                 {
                     if (ReadWrite.fileExists(string.Concat(new object[]
                     {
                         Level.info.path,
                         "/Spawns/Animals_",
                         b26,
                         "_",
                         b27,
                         ".dat"
                     }), false, false))
                     {
                         River river4 = new River(string.Concat(new object[]
                         {
                             Level.info.path,
                             "/Spawns/Animals_",
                             b26,
                             "_",
                             b27,
                             ".dat"
                         }), false);
                         byte b28 = river4.readByte();
                         if (b28 > 0)
                         {
                             ushort num9 = river4.readUInt16();
                             for (ushort num10 = 0; num10 < num9; num10 += 1)
                             {
                                 byte    newType4 = river4.readByte();
                                 Vector3 vector2  = river4.readSingleVector3();
                                 byte    b29;
                                 if (LevelNavigation.tryGetBounds(vector2, out b29) && LevelNavigation.checkNavigation(vector2))
                                 {
                                     LevelZombies.zombies[(int)b29].Add(new ZombieSpawnpoint(newType4, vector2));
                                 }
                             }
                             river4.closeRiver();
                         }
                     }
                 }
             }
         }
     }
 }
Пример #2
0
        public static void save()
        {
            Block block = new Block();

            block.writeByte(LevelZombies.SAVEDATA_TABLE_VERSION);
            block.writeByte((byte)LevelZombies.tables.Count);
            byte b = 0;

            while ((int)b < LevelZombies.tables.Count)
            {
                ZombieTable zombieTable = LevelZombies.tables[(int)b];
                block.writeColor(zombieTable.color);
                block.writeString(zombieTable.name);
                block.writeBoolean(zombieTable.isMega);
                block.writeUInt16(zombieTable.health);
                block.writeByte(zombieTable.damage);
                block.writeByte(zombieTable.lootIndex);
                block.writeUInt16(zombieTable.lootID);
                block.writeUInt32(zombieTable.xp);
                block.writeSingle(zombieTable.regen);
                block.writeString(zombieTable.difficultyGUID);
                block.write((byte)zombieTable.slots.Length);
                byte b2 = 0;
                while ((int)b2 < zombieTable.slots.Length)
                {
                    ZombieSlot zombieSlot = zombieTable.slots[(int)b2];
                    block.writeSingle(zombieSlot.chance);
                    block.writeByte((byte)zombieSlot.table.Count);
                    byte b3 = 0;
                    while ((int)b3 < zombieSlot.table.Count)
                    {
                        ZombieCloth zombieCloth = zombieSlot.table[(int)b3];
                        block.writeUInt16(zombieCloth.item);
                        b3 += 1;
                    }
                    b2 += 1;
                }
                b += 1;
            }
            ReadWrite.writeBlock(Level.info.path + "/Spawns/Zombies.dat", false, false, block);
            River river = new River(Level.info.path + "/Spawns/Animals.dat", false);

            river.writeByte(LevelZombies.SAVEDATA_SPAWN_VERSION);
            for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1)
            {
                for (byte b5 = 0; b5 < Regions.WORLD_SIZE; b5 += 1)
                {
                    List <ZombieSpawnpoint> list = LevelZombies.spawns[(int)b4, (int)b5];
                    river.writeUInt16((ushort)list.Count);
                    ushort num = 0;
                    while ((int)num < list.Count)
                    {
                        ZombieSpawnpoint zombieSpawnpoint = list[(int)num];
                        river.writeByte(zombieSpawnpoint.type);
                        river.writeSingleVector3(zombieSpawnpoint.point);
                        num += 1;
                    }
                }
            }
            river.closeRiver();
        }
Пример #3
0
 public static void updateSelection()
 {
     if ((int)EditorSpawns.selectedZombie < LevelZombies.tables.Count)
     {
         ZombieTable zombieTable = LevelZombies.tables[(int)EditorSpawns.selectedZombie];
         EditorSpawnsZombiesUI.selectedBox.text         = zombieTable.name;
         EditorSpawnsZombiesUI.tableNameField.text      = zombieTable.name;
         EditorSpawnsZombiesUI.tableColorPicker.state   = zombieTable.color;
         EditorSpawnsZombiesUI.megaToggle.state         = zombieTable.isMega;
         EditorSpawnsZombiesUI.healthField.state        = zombieTable.health;
         EditorSpawnsZombiesUI.damageField.state        = zombieTable.damage;
         EditorSpawnsZombiesUI.lootIndexField.state     = zombieTable.lootIndex;
         EditorSpawnsZombiesUI.lootIDField.state        = zombieTable.lootID;
         EditorSpawnsZombiesUI.xpField.state            = zombieTable.xp;
         EditorSpawnsZombiesUI.regenField.state         = zombieTable.regen;
         EditorSpawnsZombiesUI.difficultyGUIDField.text = zombieTable.difficultyGUID;
         if (EditorSpawnsZombiesUI.slotButtons != null)
         {
             for (int i = 0; i < EditorSpawnsZombiesUI.slotButtons.Length; i++)
             {
                 EditorSpawnsZombiesUI.spawnsScrollBox.remove(EditorSpawnsZombiesUI.slotButtons[i]);
             }
         }
         EditorSpawnsZombiesUI.slotButtons = new SleekButton[zombieTable.slots.Length];
         for (int j = 0; j < EditorSpawnsZombiesUI.slotButtons.Length; j++)
         {
             ZombieSlot  zombieSlot  = zombieTable.slots[j];
             SleekButton sleekButton = new SleekButton();
             sleekButton.positionOffset_X = 240;
             sleekButton.positionOffset_Y = 460 + j * 70;
             sleekButton.sizeOffset_X     = 200;
             sleekButton.sizeOffset_Y     = 30;
             sleekButton.text             = EditorSpawnsZombiesUI.localization.format("Slot_" + j);
             SleekButton sleekButton2 = sleekButton;
             if (EditorSpawnsZombiesUI.< > f__mg$cache1 == null)
             {
                 EditorSpawnsZombiesUI.< > f__mg$cache1 = new ClickedButton(EditorSpawnsZombiesUI.onClickedSlotButton);
             }
             sleekButton2.onClickedButton = EditorSpawnsZombiesUI.< > f__mg$cache1;
             EditorSpawnsZombiesUI.spawnsScrollBox.add(sleekButton);
             SleekSlider sleekSlider = new SleekSlider();
             sleekSlider.positionOffset_Y = 40;
             sleekSlider.sizeOffset_X     = 200;
             sleekSlider.sizeOffset_Y     = 20;
             sleekSlider.orientation      = ESleekOrientation.HORIZONTAL;
             sleekSlider.state            = zombieSlot.chance;
             sleekSlider.addLabel(Mathf.RoundToInt(zombieSlot.chance * 100f) + "%", ESleekSide.LEFT);
             SleekSlider sleekSlider2 = sleekSlider;
             if (EditorSpawnsZombiesUI.< > f__mg$cache2 == null)
             {
                 EditorSpawnsZombiesUI.< > f__mg$cache2 = new Dragged(EditorSpawnsZombiesUI.onDraggedChanceSlider);
             }
             sleekSlider2.onDragged = EditorSpawnsZombiesUI.< > f__mg$cache2;
             sleekButton.add(sleekSlider);
             EditorSpawnsZombiesUI.slotButtons[j] = sleekButton;
         }
         if (EditorSpawnsZombiesUI.clothButtons != null)
         {
             for (int k = 0; k < EditorSpawnsZombiesUI.clothButtons.Length; k++)
             {
                 EditorSpawnsZombiesUI.spawnsScrollBox.remove(EditorSpawnsZombiesUI.clothButtons[k]);
             }
         }
         if ((int)EditorSpawnsZombiesUI.selectedSlot < zombieTable.slots.Length)
         {
             EditorSpawnsZombiesUI.clothButtons = new SleekButton[zombieTable.slots[(int)EditorSpawnsZombiesUI.selectedSlot].table.Count];
             for (int l = 0; l < EditorSpawnsZombiesUI.clothButtons.Length; l++)
             {
                 SleekButton sleekButton3 = new SleekButton();
                 sleekButton3.positionOffset_X = 240;
                 sleekButton3.positionOffset_Y = 460 + EditorSpawnsZombiesUI.slotButtons.Length * 70 + l * 40;
                 sleekButton3.sizeOffset_X     = 200;
                 sleekButton3.sizeOffset_Y     = 30;
                 ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, zombieTable.slots[(int)EditorSpawnsZombiesUI.selectedSlot].table[l].item);
                 string    str       = "?";
                 if (itemAsset != null)
                 {
                     if (string.IsNullOrEmpty(itemAsset.itemName))
                     {
                         str = itemAsset.name;
                     }
                     else
                     {
                         str = itemAsset.itemName;
                     }
                 }
                 sleekButton3.text = zombieTable.slots[(int)EditorSpawnsZombiesUI.selectedSlot].table[l].item.ToString() + " " + str;
                 SleekButton sleekButton4 = sleekButton3;
                 if (EditorSpawnsZombiesUI.< > f__mg$cache3 == null)
                 {
                     EditorSpawnsZombiesUI.< > f__mg$cache3 = new ClickedButton(EditorSpawnsZombiesUI.onClickItemButton);
                 }
                 sleekButton4.onClickedButton = EditorSpawnsZombiesUI.< > f__mg$cache3;
                 EditorSpawnsZombiesUI.spawnsScrollBox.add(sleekButton3);
                 EditorSpawnsZombiesUI.clothButtons[l] = sleekButton3;
             }
         }
         else
         {
             EditorSpawnsZombiesUI.clothButtons = new SleekButton[0];
         }
         EditorSpawnsZombiesUI.itemIDField.positionOffset_Y      = 460 + EditorSpawnsZombiesUI.slotButtons.Length * 70 + EditorSpawnsZombiesUI.clothButtons.Length * 40;
         EditorSpawnsZombiesUI.addItemButton.positionOffset_Y    = 460 + EditorSpawnsZombiesUI.slotButtons.Length * 70 + EditorSpawnsZombiesUI.clothButtons.Length * 40 + 40;
         EditorSpawnsZombiesUI.removeItemButton.positionOffset_Y = 460 + EditorSpawnsZombiesUI.slotButtons.Length * 70 + EditorSpawnsZombiesUI.clothButtons.Length * 40 + 40;
         EditorSpawnsZombiesUI.spawnsScrollBox.area = new Rect(0f, 0f, 5f, (float)(460 + EditorSpawnsZombiesUI.slotButtons.Length * 70 + EditorSpawnsZombiesUI.clothButtons.Length * 40 + 70));
     }
     else
     {
         EditorSpawnsZombiesUI.selectedBox.text         = string.Empty;
         EditorSpawnsZombiesUI.tableNameField.text      = string.Empty;
         EditorSpawnsZombiesUI.tableColorPicker.state   = Color.white;
         EditorSpawnsZombiesUI.megaToggle.state         = false;
         EditorSpawnsZombiesUI.healthField.state        = 0;
         EditorSpawnsZombiesUI.damageField.state        = 0;
         EditorSpawnsZombiesUI.lootIndexField.state     = 0;
         EditorSpawnsZombiesUI.lootIDField.state        = 0;
         EditorSpawnsZombiesUI.xpField.state            = 0u;
         EditorSpawnsZombiesUI.regenField.state         = 0f;
         EditorSpawnsZombiesUI.difficultyGUIDField.text = string.Empty;
         if (EditorSpawnsZombiesUI.slotButtons != null)
         {
             for (int m = 0; m < EditorSpawnsZombiesUI.slotButtons.Length; m++)
             {
                 EditorSpawnsZombiesUI.spawnsScrollBox.remove(EditorSpawnsZombiesUI.slotButtons[m]);
             }
         }
         EditorSpawnsZombiesUI.slotButtons = null;
         if (EditorSpawnsZombiesUI.clothButtons != null)
         {
             for (int n = 0; n < EditorSpawnsZombiesUI.clothButtons.Length; n++)
             {
                 EditorSpawnsZombiesUI.spawnsScrollBox.remove(EditorSpawnsZombiesUI.clothButtons[n]);
             }
         }
         EditorSpawnsZombiesUI.clothButtons = null;
         EditorSpawnsZombiesUI.itemIDField.positionOffset_Y      = 460;
         EditorSpawnsZombiesUI.addItemButton.positionOffset_Y    = 500;
         EditorSpawnsZombiesUI.removeItemButton.positionOffset_Y = 500;
         EditorSpawnsZombiesUI.spawnsScrollBox.area = new Rect(0f, 0f, 5f, 530f);
     }
 }