コード例 #1
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		private void onSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (scene.buildIndex == 3)
			{
				return;
			}
			if (scene.buildIndex == 2 && !Dedicator.isDedicated)
			{
				LoadingUI.loader.AddComponent<AudioListener>();
			}
			LevelLighting.areFXAllowed = true;
			if (scene.buildIndex > Level.SETUP && Level.info != null)
			{
				Level._level = new GameObject().transform;
				Level.level.name = Level.info.name;
				Level.level.tag = "Logic";
				Level.level.gameObject.layer = LayerMasks.LOGIC;
				Level._roots = new GameObject().transform;
				Level.roots.name = "Roots";
				Level.roots.parent = Level.level;
				Level._clips = new GameObject().transform;
				Level.clips.name = "Clips";
				Level.clips.parent = Level.level;
				Level.clips.tag = "Clip";
				Level.clips.gameObject.layer = LayerMasks.CLIP;
				if (Level.info.configData.Use_Legacy_Clip_Borders)
				{
					Transform transform = ((GameObject)Object.Instantiate(Resources.Load("Level/Cap"))).transform;
					transform.position = new Vector3(0f, -4f, 0f);
					transform.localScale = new Vector3((float)(Level.size - Level.border * 2 + Level.CLIP * 2), (float)(Level.size - Level.border * 2 + Level.CLIP * 2), 1f);
					transform.rotation = Quaternion.Euler(-90f, 0f, 0f);
					transform.name = "Cap";
					transform.parent = Level.clips;
					transform = ((GameObject)Object.Instantiate(Resources.Load("Level/Cap"))).transform;
					transform.position = new Vector3(0f, Level.HEIGHT + 4f, 0f);
					transform.localScale = new Vector3((float)(Level.size - Level.border * 2 + Level.CLIP * 2), (float)(Level.size - Level.border * 2 + Level.CLIP * 2), 1f);
					transform.rotation = Quaternion.Euler(90f, 0f, 0f);
					transform.name = "Cap";
					transform.parent = Level.clips;
					transform = ((GameObject)Object.Instantiate(Resources.Load("Level/Cap"))).transform;
					transform.position = new Vector3((float)(Level.size / 2 - Level.border), Level.HEIGHT / 2f, (float)(Level.size / 2 - Level.border));
					transform.localScale = new Vector3((float)(Level.CLIP * 4), (float)(Level.CLIP * 4), 64f);
					transform.rotation = Quaternion.Euler(90f, 0f, 45f);
					transform.name = "Cap";
					transform.parent = Level.clips;
					transform = ((GameObject)Object.Instantiate(Resources.Load("Level/Cap"))).transform;
					transform.position = new Vector3((float)(-Level.size / 2 + Level.border), Level.HEIGHT / 2f, (float)(Level.size / 2 - Level.border));
					transform.localScale = new Vector3((float)(Level.CLIP * 4), (float)(Level.CLIP * 4), 64f);
					transform.rotation = Quaternion.Euler(90f, 0f, 45f);
					transform.name = "Cap";
					transform.parent = Level.clips;
					transform = ((GameObject)Object.Instantiate(Resources.Load("Level/Cap"))).transform;
					transform.position = new Vector3((float)(Level.size / 2 - Level.border), Level.HEIGHT / 2f, (float)(-Level.size / 2 + Level.border));
					transform.localScale = new Vector3((float)(Level.CLIP * 4), (float)(Level.CLIP * 4), 64f);
					transform.rotation = Quaternion.Euler(90f, 0f, 45f);
					transform.name = "Cap";
					transform.parent = Level.clips;
					transform = ((GameObject)Object.Instantiate(Resources.Load("Level/Cap"))).transform;
					transform.position = new Vector3((float)(-Level.size / 2 + Level.border), Level.HEIGHT / 2f, (float)(-Level.size / 2 + Level.border));
					transform.localScale = new Vector3((float)(Level.CLIP * 4), (float)(Level.CLIP * 4), 64f);
					transform.rotation = Quaternion.Euler(90f, 0f, 45f);
					transform.name = "Cap";
					transform.parent = Level.clips;
					Transform transform2 = ((GameObject)Object.Instantiate(Resources.Load((!Level.isEditor) ? "Level/Clip" : "Level/Wall"))).transform;
					transform2.position = new Vector3((float)(Level.size / 2 - Level.border), Level.HEIGHT / 8f, 0f);
					transform2.localScale = new Vector3((float)(Level.size - Level.border * 2), Level.HEIGHT / 4f, 1f);
					transform2.rotation = Quaternion.Euler(0f, -90f, 0f);
					transform2.name = "Clip";
					transform2.parent = Level.clips;
					if (Level.isEditor)
					{
						transform2.GetComponent<Renderer>().material.mainTextureScale = new Vector2((float)(Level.size - Level.border * 2) / 32f, 4f);
					}
					transform2 = ((GameObject)Object.Instantiate(Resources.Load((!Level.isEditor) ? "Level/Clip" : "Level/Wall"))).transform;
					transform2.position = new Vector3((float)(-Level.size / 2 + Level.border), Level.HEIGHT / 8f, 0f);
					transform2.localScale = new Vector3((float)(Level.size - Level.border * 2), Level.HEIGHT / 4f, 1f);
					transform2.rotation = Quaternion.Euler(0f, 90f, 0f);
					transform2.name = "Clip";
					transform2.parent = Level.clips;
					if (Level.isEditor)
					{
						transform2.GetComponent<Renderer>().material.mainTextureScale = new Vector2((float)(Level.size - Level.border * 2) / 32f, 4f);
					}
					transform2 = ((GameObject)Object.Instantiate(Resources.Load((!Level.isEditor) ? "Level/Clip" : "Level/Wall"))).transform;
					transform2.position = new Vector3(0f, Level.HEIGHT / 8f, (float)(Level.size / 2 - Level.border));
					transform2.localScale = new Vector3((float)(Level.size - Level.border * 2), Level.HEIGHT / 4f, 1f);
					transform2.rotation = Quaternion.Euler(0f, 180f, 0f);
					transform2.name = "Clip";
					transform2.parent = Level.clips;
					if (Level.isEditor)
					{
						transform2.GetComponent<Renderer>().material.mainTextureScale = new Vector2((float)(Level.size - Level.border * 2) / 32f, 4f);
					}
					transform2 = ((GameObject)Object.Instantiate(Resources.Load((!Level.isEditor) ? "Level/Clip" : "Level/Wall"))).transform;
					transform2.position = new Vector3(0f, Level.HEIGHT / 8f, (float)(-Level.size / 2 + Level.border));
					transform2.localScale = new Vector3((float)(Level.size - Level.border * 2), Level.HEIGHT / 4f, 1f);
					transform2.rotation = Quaternion.identity;
					transform2.name = "Clip";
					transform2.parent = Level.clips;
					if (Level.isEditor)
					{
						transform2.GetComponent<Renderer>().material.mainTextureScale = new Vector2((float)(Level.size - Level.border * 2) / 32f, 4f);
					}
				}
				Level._effects = new GameObject().transform;
				Level.effects.name = "Effects";
				Level.effects.parent = Level.level;
				Level.effects.tag = "Logic";
				Level.effects.gameObject.layer = LayerMasks.LOGIC;
				Level._spawns = new GameObject().transform;
				Level.spawns.name = "Spawns";
				Level.spawns.parent = Level.level;
				Level.spawns.tag = "Logic";
				Level.spawns.gameObject.layer = LayerMasks.LOGIC;
				base.StartCoroutine("init", scene.buildIndex);
			}
			else
			{
				Level.isLoadingLighting = true;
				Level.isLoadingVehicles = true;
				Level.isLoadingBarricades = true;
				Level.isLoadingStructures = true;
				Level.isLoadingContent = true;
				Level.isLoadingArea = true;
				Level._isLoaded = false;
				if (Level.onLevelLoaded != null)
				{
					Level.onLevelLoaded(scene.buildIndex);
				}
			}
			Resources.UnloadUnusedAssets();
			GC.Collect();
		}
コード例 #2
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;
		}