コード例 #1
0
 private static void onClickedRemoveTableButton(SleekButton button)
 {
     if ((int)EditorSpawns.selectedAnimal < LevelAnimals.tables.Count)
     {
         LevelAnimals.removeTable();
         EditorSpawnsAnimalsUI.updateTables();
         EditorSpawnsAnimalsUI.updateSelection();
         EditorSpawnsAnimalsUI.tableScrollBox.state = new Vector2(0f, float.MaxValue);
     }
 }
コード例 #2
0
 private static void onClickedAddTableButton(SleekButton button)
 {
     if (EditorSpawnsAnimalsUI.tableNameField.text != string.Empty)
     {
         LevelAnimals.addTable(EditorSpawnsAnimalsUI.tableNameField.text);
         EditorSpawnsAnimalsUI.tableNameField.text = string.Empty;
         EditorSpawnsAnimalsUI.updateTables();
         EditorSpawnsAnimalsUI.tableScrollBox.state = new Vector2(0f, float.MaxValue);
     }
 }
コード例 #3
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		public static void save()
		{
			LevelObjects.save();
			LevelLighting.save();
			LevelGround.save();
			LevelRoads.save();
			if (!Level.isVR)
			{
				LevelNavigation.save();
				LevelNodes.save();
				LevelItems.save();
				LevelPlayers.save();
				LevelZombies.save();
				LevelVehicles.save();
				LevelAnimals.save();
				LevelVisibility.save();
			}
			Editor.save();
		}
コード例 #4
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		public IEnumerator init(int id)
		{
			if (!Level.isVR)
			{
				LevelNavigation.load();
			}
			LoadingUI.updateProgress(1f / Level.STEPS);
			yield return null;
			LevelObjects.load();
			LoadingUI.updateProgress(2f / Level.STEPS);
			yield return null;
			LevelLighting.load(Level.size);
			LoadingUI.updateProgress(3f / Level.STEPS);
			yield return null;
			LevelGround.load(Level.size);
			LoadingUI.updateProgress(4f / Level.STEPS);
			yield return null;
			LevelRoads.load();
			LoadingUI.updateProgress(5f / Level.STEPS);
			yield return null;
			if (!Level.isVR)
			{
				LevelNodes.load();
				LoadingUI.updateProgress(6f / Level.STEPS);
				yield return null;
				LevelItems.load();
				LoadingUI.updateProgress(7f / Level.STEPS);
				yield return null;
			}
			LevelPlayers.load();
			LoadingUI.updateProgress(8f / Level.STEPS);
			yield return null;
			if (!Level.isVR)
			{
				LevelZombies.load();
				LoadingUI.updateProgress(9f / Level.STEPS);
				yield return null;
				LevelVehicles.load();
				LoadingUI.updateProgress(10f / Level.STEPS);
				yield return null;
				LevelAnimals.load();
				LoadingUI.updateProgress(11f / Level.STEPS);
				yield return null;
			}
			LevelVisibility.load();
			LoadingUI.updateProgress(12f / Level.STEPS);
			yield return null;
			if (Level.loadingSteps != null)
			{
				Level.loadingSteps();
			}
			yield return null;
			LevelBarricades.load();
			yield return null;
			LevelStructures.load();
			Level._hash = Hash.combine(new byte[][]
			{
				Level.getLevelHash(Level.info.path),
				LevelGround.hash,
				LevelLighting.hash,
				LevelObjects.hash
			});
			Physics.gravity = new Vector3(0f, Level.info.configData.Gravity, 0f);
			yield return null;
			Resources.UnloadUnusedAssets();
			GC.Collect();
			yield return null;
			Level._editing = new GameObject().transform;
			Level.editing.name = "Editing";
			Level.editing.parent = Level.level;
			if (Level.isEditor)
			{
				Level.mapper = ((GameObject)Object.Instantiate(Resources.Load("Edit/Mapper"))).transform;
				Level.mapper.name = "Mapper";
				Level.mapper.parent = Level.editing;
				Level.mapper.position = new Vector3(0f, 1028f, 0f);
				Level.mapper.rotation = Quaternion.Euler(90f, 0f, 0f);
				Level.mapper.GetComponent<Camera>().orthographicSize = (float)(Level.size / 2 - Level.border);
				if (Level.isDevkit)
				{
					GameObject gameObject = Object.Instantiate<GameObject>(Resources.Load<GameObject>("Edit2/Editor"));
					if (gameObject != null)
					{
						gameObject.name = "Editor";
						gameObject.transform.parent = Level.editing;
					}
				}
				else
				{
					Transform transform = ((GameObject)Object.Instantiate(Resources.Load((!Level.isVR) ? "Edit/Editor" : "Edit/VR"))).transform;
					transform.name = "Editor";
					transform.parent = Level.editing;
					transform.tag = "Logic";
					transform.gameObject.layer = LayerMasks.LOGIC;
				}
			}
			yield return null;
			if (Level.onPrePreLevelLoaded != null)
			{
				Level.onPrePreLevelLoaded(id);
			}
			yield return null;
			if (Level.onPreLevelLoaded != null)
			{
				Level.onPreLevelLoaded(id);
			}
			yield return null;
			if (Level.onLevelLoaded != null)
			{
				Level.onLevelLoaded(id);
			}
			yield return null;
			if (Level.onPostLevelLoaded != null)
			{
				Level.onPostLevelLoaded(id);
			}
			yield return null;
			if (!Level.isEditor && Level.info != null && Level.info.hasTriggers)
			{
				Transform transform2 = null;
				string text = Level.info.name.ToLower();
				if (text != null)
				{
					if (!(text == "germany"))
					{
						if (!(text == "pei"))
						{
							if (!(text == "russia"))
							{
								if (text == "tutorial")
								{
									transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Tutorial"))).transform;
								}
							}
							else
							{
								transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Russia"))).transform;
							}
						}
						else
						{
							transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_PEI"))).transform;
						}
					}
					else
					{
						transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Germany"))).transform;
					}
				}
				if (transform2 != null)
				{
					transform2.position = Vector3.zero;
					transform2.rotation = Quaternion.identity;
					transform2.name = "Triggers";
					transform2.parent = Level.clips;
				}
			}
			yield return null;
			Level._isLoaded = true;
			Level.isLoadingContent = false;
			yield break;
		}
コード例 #5
0
ファイル: EditorSpawns.cs プロジェクト: sky-xk-nge/Unturned
 private void Update()
 {
     if (!EditorSpawns.isSpawning)
     {
         return;
     }
     if (!EditorInteract.isFlying && GUIUtility.hotControl == 0)
     {
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ANIMAL;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ANIMAL;
             }
         }
         if (EditorInteract.worldHit.transform != null)
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.itemSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.playerSpawn.position    = EditorInteract.worldHit.point;
                 EditorSpawns.playerSpawnAlt.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.zombieSpawn.position = EditorInteract.worldHit.point + Vector3.up;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.vehicleSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.animalSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM || EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.remove.position = EditorInteract.worldHit.point;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.primary) && EditorInteract.worldHit.transform != null)
         {
             Vector3 point = EditorInteract.worldHit.point;
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 if ((int)EditorSpawns.selectedResource < LevelGround.resources.Length)
                 {
                     LevelGround.addSpawn(point, EditorSpawns.selectedResource, false);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 LevelGround.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
                 {
                     LevelItems.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 LevelItems.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 LevelPlayers.addSpawn(point, EditorSpawns.rotation, EditorSpawns.selectedAlt);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 LevelPlayers.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 if ((int)EditorSpawns.selectedZombie < LevelZombies.tables.Count)
                 {
                     LevelZombies.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 LevelZombies.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 LevelVehicles.addSpawn(point, EditorSpawns.rotation);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 LevelVehicles.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 LevelAnimals.addSpawn(point);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 LevelAnimals.removeSpawn(point, (float)EditorSpawns.radius);
             }
         }
     }
 }
コード例 #6
0
ファイル: LevelAnimals.cs プロジェクト: sky-xk-nge/Unturned
 public static ushort getAnimal(AnimalSpawnpoint spawn)
 {
     return(LevelAnimals.getAnimal(spawn.type));
 }
コード例 #7
0
 // Token: 0x0600270A RID: 9994 RVA: 0x000E805C File Offset: 0x000E645C
 private void onLevelLoaded(int level)
 {
     if (level > Level.SETUP)
     {
         this.seq = 0u;
         AnimalManager._animals        = new List <Animal>();
         AnimalManager._packs          = null;
         AnimalManager.updates         = 0;
         AnimalManager.tickIndex       = 0;
         AnimalManager._tickingAnimals = new List <Animal>();
         if (Provider.isServer)
         {
             AnimalManager._packs = new List <PackInfo>();
             if (LevelAnimals.spawns.Count > 0)
             {
                 for (int i = 0; i < LevelAnimals.spawns.Count; i++)
                 {
                     AnimalSpawnpoint animalSpawnpoint = LevelAnimals.spawns[i];
                     int num = -1;
                     for (int j = AnimalManager.packs.Count - 1; j >= 0; j--)
                     {
                         List <AnimalSpawnpoint> spawns = AnimalManager.packs[j].spawns;
                         for (int k = 0; k < spawns.Count; k++)
                         {
                             AnimalSpawnpoint animalSpawnpoint2 = spawns[k];
                             if ((animalSpawnpoint2.point - animalSpawnpoint.point).sqrMagnitude < 256f)
                             {
                                 if (num == -1)
                                 {
                                     spawns.Add(animalSpawnpoint);
                                 }
                                 else
                                 {
                                     List <AnimalSpawnpoint> spawns2 = AnimalManager.packs[num].spawns;
                                     for (int l = 0; l < spawns2.Count; l++)
                                     {
                                         spawns.Add(spawns2[l]);
                                     }
                                     AnimalManager.packs.RemoveAtFast(num);
                                 }
                                 num = j;
                                 break;
                             }
                         }
                     }
                     if (num == -1)
                     {
                         PackInfo packInfo = new PackInfo();
                         packInfo.spawns.Add(animalSpawnpoint);
                         AnimalManager.packs.Add(packInfo);
                     }
                 }
                 List <AnimalManager.ValidAnimalSpawnsInfo> list = new List <AnimalManager.ValidAnimalSpawnsInfo>();
                 for (int m = 0; m < AnimalManager.packs.Count; m++)
                 {
                     PackInfo packInfo2            = AnimalManager.packs[m];
                     List <AnimalSpawnpoint> list2 = new List <AnimalSpawnpoint>();
                     for (int n = 0; n < packInfo2.spawns.Count; n++)
                     {
                         list2.Add(packInfo2.spawns[n]);
                     }
                     list.Add(new AnimalManager.ValidAnimalSpawnsInfo
                     {
                         spawns = list2,
                         pack   = packInfo2
                     });
                 }
                 while ((long)AnimalManager.animals.Count < (long)((ulong)AnimalManager.maxInstances) && list.Count > 0)
                 {
                     int index = UnityEngine.Random.Range(0, list.Count);
                     AnimalManager.ValidAnimalSpawnsInfo validAnimalSpawnsInfo = list[index];
                     int index2 = UnityEngine.Random.Range(0, validAnimalSpawnsInfo.spawns.Count);
                     AnimalSpawnpoint animalSpawnpoint3 = validAnimalSpawnsInfo.spawns[index2];
                     validAnimalSpawnsInfo.spawns.RemoveAt(index2);
                     if (validAnimalSpawnsInfo.spawns.Count == 0)
                     {
                         list.RemoveAt(index);
                     }
                     Vector3 point = animalSpawnpoint3.point;
                     point.y += 0.1f;
                     ushort id;
                     if (validAnimalSpawnsInfo.pack.animals.Count > 0)
                     {
                         id = validAnimalSpawnsInfo.pack.animals[0].id;
                     }
                     else
                     {
                         id = LevelAnimals.getAnimal(animalSpawnpoint3);
                     }
                     Animal animal = this.addAnimal(id, point, UnityEngine.Random.Range(0f, 360f), false);
                     if (animal != null)
                     {
                         animal.pack = validAnimalSpawnsInfo.pack;
                         validAnimalSpawnsInfo.pack.animals.Add(animal);
                     }
                 }
                 for (int num2 = AnimalManager.packs.Count - 1; num2 >= 0; num2--)
                 {
                     PackInfo packInfo3 = AnimalManager.packs[num2];
                     if (packInfo3.animals.Count <= 0)
                     {
                         AnimalManager.packs.RemoveAt(num2);
                     }
                 }
             }
         }
     }
 }