コード例 #1
0
        private static bool pickBackgroundImage(string path)
        {
            if (!Directory.Exists(path))
            {
                LoadingUI.loadBackgroundImage(null);
                return(false);
            }
            string[] files  = Directory.GetFiles(path, "*.png");
            string[] files2 = Directory.GetFiles(path, "*.jpg");
            string[] array  = new string[files.Length + files2.Length];
            int      num    = 0;

            for (int i = 0; i < files.Length; i++)
            {
                array[num] = files[i];
                num++;
            }
            for (int j = 0; j < files2.Length; j++)
            {
                array[num] = files2[j];
                num++;
            }
            if (array.Length == 0)
            {
                LoadingUI.loadBackgroundImage(null);
            }
            else
            {
                int    num2  = Random.Range(0, array.Length);
                string path2 = array[num2];
                LoadingUI.loadBackgroundImage(path2);
            }
            return(true);
        }
コード例 #2
0
ファイル: MenuUI.cs プロジェクト: sky-xk-nge/Unturned
 public void build()
 {
     if (MenuUI.window != null)
     {
         MenuUI.window.build();
     }
     LoadingUI.rebuild();
 }
コード例 #3
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		public static void load(LevelInfo newInfo)
		{
			Level._isEditor = false;
			Level._isDevkit = false;
			Level.isExiting = false;
			Level._info = newInfo;
			LoadingUI.updateScene();
			SceneManager.LoadScene("Game");
			if (!Dedicator.isDedicated)
			{
				string text = Level.info.name.ToLower();
				if (text != null)
				{
					if (!(text == "germany"))
					{
						if (!(text == "hawaii"))
						{
							if (!(text == "pei"))
							{
								if (!(text == "russia"))
								{
									if (!(text == "yukon"))
									{
										if (text == "washington")
										{
											Provider.provider.achievementsService.setAchievement("Washington");
										}
									}
									else
									{
										Provider.provider.achievementsService.setAchievement("Yukon");
									}
								}
								else
								{
									Provider.provider.achievementsService.setAchievement("Russia");
								}
							}
							else
							{
								Provider.provider.achievementsService.setAchievement("PEI");
							}
						}
						else
						{
							Provider.provider.achievementsService.setAchievement("Hawaii");
						}
					}
					else
					{
						Provider.provider.achievementsService.setAchievement("Peaks");
					}
				}
			}
			Provider.updateRichPresence();
			DevkitTransactionManager.resetTransactions();
		}
コード例 #4
0
 private void Start()
 {
     if (!Dedicator.isDedicated)
     {
         MenuSettings.load();
         GraphicsSettings.resize();
         LoadingUI.updateScene();
     }
 }
コード例 #5
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		public static void edit(LevelInfo newInfo, bool Devkit)
		{
			Level._isEditor = true;
			Level._isDevkit = Devkit;
			Level.isExiting = false;
			Level._info = newInfo;
			LoadingUI.updateScene();
			SceneManager.LoadScene("Game");
			Provider.updateRichPresence();
			DevkitTransactionManager.resetTransactions();
		}
コード例 #6
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		public static void exit()
		{
			if (Level.onLevelExited != null)
			{
				Level.onLevelExited();
			}
			if (!Level.isEditor && Player.player != null && PlayerUI.window != null && Level.info != null && PlayerUI.window.totalTime > 60f)
			{
				int fpsMin = PlayerUI.window.fpsMin;
				int fpsMax = PlayerUI.window.fpsMax;
				int num = (int)((float)PlayerUI.window.totalFrames / PlayerUI.window.totalTime);
				string value = (!Level.info.canAnalyticsTrack) ? "Workshop" : Level.info.name;
				Dictionary<string, object> dictionary = new Dictionary<string, object>
				{
					{
						"FPS_Min",
						fpsMin
					},
					{
						"FPS_Max",
						fpsMax
					},
					{
						"FPS_Avg",
						num
					},
					{
						"Map",
						value
					},
					{
						"Network",
						Provider.clients.Count > 1
					}
				};
				Analytics.CustomEvent("Perf", dictionary);
			}
			Level._isEditor = false;
			Level._isDevkit = false;
			Level.isExiting = true;
			Level._info = null;
			LoadingUI.updateScene();
			SceneManager.LoadScene("Menu");
			Provider.updateRichPresence();
			DevkitTransactionManager.resetTransactions();
		}
コード例 #7
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;
		}
コード例 #8
0
        public static void updateScene()
        {
            if (!Dedicator.isDedicated)
            {
                if (LoadingUI.backgroundImage == null)
                {
                    return;
                }
                if (LoadingUI.loadingImage == null)
                {
                    return;
                }
                LoadingUI.updateProgress(0f);
                Local local = Localization.read("/Menu/MenuTips.dat");
                byte  b;
                do
                {
                    b = (byte)Random.Range(1, (int)(LoadingUI.TIP_COUNT + 1));
                }while (b == (byte)LoadingUI.tip);
                LoadingUI.tip = (ELoadingTip)b;
                string text;
                if (OptionsSettings.streamer && Provider.streamerNames != null && Provider.streamerNames.Count > 0 && Provider.streamerNames[0] == "Nelson AI")
                {
                    text = local.format("Streamer");
                }
                else
                {
                    switch (LoadingUI.tip)
                    {
                    case ELoadingTip.HOTKEY:
                        text = local.format("Hotkey");
                        break;

                    case ELoadingTip.EQUIP:
                        text = local.format("Equip", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.other)
                        });
                        break;

                    case ELoadingTip.DROP:
                        text = local.format("Drop", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.other)
                        });
                        break;

                    case ELoadingTip.SIRENS:
                        text = local.format("Sirens", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.other)
                        });
                        break;

                    case ELoadingTip.TRANSFORM:
                        text = local.format("Transform");
                        break;

                    case ELoadingTip.QUALITY:
                        text = local.format("Quality");
                        break;

                    case ELoadingTip.UMBRELLA:
                        text = local.format("Umbrella");
                        break;

                    case ELoadingTip.HEAL:
                        text = local.format("Heal");
                        break;

                    case ELoadingTip.ROTATE:
                        text = local.format("Rotate");
                        break;

                    case ELoadingTip.BASE:
                        text = local.format("Base");
                        break;

                    case ELoadingTip.DEQUIP:
                        text = local.format("Dequip", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.dequip)
                        });
                        break;

                    case ELoadingTip.NIGHTVISION:
                        text = local.format("Nightvision", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.vision)
                        });
                        break;

                    case ELoadingTip.TRANSFER:
                        text = local.format("Transfer", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.other)
                        });
                        break;

                    case ELoadingTip.SURFACE:
                        text = local.format("Surface", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.jump)
                        });
                        break;

                    case ELoadingTip.ARREST:
                        text = local.format("Arrest", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.leanLeft),
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.leanRight)
                        });
                        break;

                    case ELoadingTip.SAFEZONE:
                        text = local.format("Safezone");
                        break;

                    case ELoadingTip.CLAIM:
                        text = local.format("Claim");
                        break;

                    case ELoadingTip.GROUP:
                        text = local.format("Group");
                        break;

                    case ELoadingTip.MAP:
                        text = local.format("Map", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.map)
                        });
                        break;

                    case ELoadingTip.BEACON:
                        text = local.format("Beacon");
                        break;

                    case ELoadingTip.HORN:
                        text = local.format("Horn", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.primary)
                        });
                        break;

                    case ELoadingTip.LIGHTS:
                        text = local.format("Lights", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.secondary)
                        });
                        break;

                    case ELoadingTip.SNAP:
                        text = local.format("Snap", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.snap)
                        });
                        break;

                    case ELoadingTip.UPGRADE:
                        text = local.format("Upgrade", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.other)
                        });
                        break;

                    case ELoadingTip.GRAB:
                        text = local.format("Grab", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.other)
                        });
                        break;

                    case ELoadingTip.SKYCRANE:
                        text = local.format("Skycrane", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.other)
                        });
                        break;

                    case ELoadingTip.SEAT:
                        text = local.format("Seat");
                        break;

                    case ELoadingTip.RARITY:
                        text = local.format("Rarity");
                        break;

                    case ELoadingTip.ORIENTATION:
                        text = local.format("Orientation", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.rotate)
                        });
                        break;

                    case ELoadingTip.RED:
                        text = local.format("Red");
                        break;

                    case ELoadingTip.STEADY:
                        text = local.format("Steady", new object[]
                        {
                            MenuConfigurationControlsUI.getKeyCodeText(ControlsSettings.sprint)
                        });
                        break;

                    default:
                        text = "#" + LoadingUI.tip.ToString();
                        break;
                    }
                }
                LoadingUI.tipBox.text = ItemTool.filterRarityRichText(local.format("Tip", new object[]
                {
                    text
                }));
                if (Level.info != null)
                {
                    if (!LoadingUI.pickBackgroundImage(Level.info.path + "/Screenshots") && !LoadingUI.loadBackgroundImage(Level.info.path + "/Level.png"))
                    {
                        LoadingUI.pickBackgroundImage(ReadWrite.PATH + "/Screenshots");
                    }
                    Local local2 = Localization.tryRead(Level.info.path, false);
                    if (local2 != null)
                    {
                        if (Provider.isConnected)
                        {
                            string text2;
                            if (Provider.isServer)
                            {
                                text2 = LoadingUI.localization.format("Offline");
                            }
                            else
                            {
                                if (Provider.currentServerInfo.IsVACSecure)
                                {
                                    text2 = LoadingUI.localization.format("VAC_Secure");
                                }
                                else
                                {
                                    text2 = LoadingUI.localization.format("VAC_Insecure");
                                }
                                if (Provider.currentServerInfo.IsBattlEyeSecure)
                                {
                                    text2 = text2 + " + " + LoadingUI.localization.format("BattlEye_Secure");
                                }
                                else
                                {
                                    text2 = text2 + " + " + LoadingUI.localization.format("BattlEye_Insecure");
                                }
                            }
                            LoadingUI.loadingLabel.text = local2.format("Loading_Server", new object[]
                            {
                                (!OptionsSettings.streamer) ? Provider.currentServerInfo.name : LoadingUI.localization.format("Streamer"),
                                text2
                            });
                            if (Provider.mode == EGameMode.EASY)
                            {
                                LoadingUI.loadingImage.backgroundColor = Palette.COLOR_G;
                                LoadingUI.loadingImage.foregroundColor = Palette.COLOR_G;
                            }
                            else if (Provider.mode == EGameMode.HARD)
                            {
                                LoadingUI.loadingImage.backgroundColor = Palette.COLOR_R;
                                LoadingUI.loadingImage.foregroundColor = Palette.COLOR_R;
                            }
                            else
                            {
                                LoadingUI.loadingImage.backgroundColor = Color.white;
                                LoadingUI.loadingImage.foregroundColor = Color.white;
                            }
                        }
                        else
                        {
                            LoadingUI.loadingLabel.text            = local2.format("Loading_Editor");
                            LoadingUI.loadingImage.backgroundColor = Color.white;
                            LoadingUI.loadingImage.foregroundColor = Color.white;
                        }
                    }
                    else
                    {
                        LoadingUI.loadingLabel.text            = string.Empty;
                        LoadingUI.loadingImage.backgroundColor = Color.white;
                        LoadingUI.loadingImage.foregroundColor = Color.white;
                    }
                    if (Level.info.configData.Creators.Length > 0 || Level.info.configData.Collaborators.Length > 0 || Level.info.configData.Thanks.Length > 0)
                    {
                        int    num   = 0;
                        string text3 = string.Empty;
                        if (Level.info.configData.Creators.Length > 0)
                        {
                            text3 += LoadingUI.localization.format("Creators");
                            num   += 15;
                            for (int i = 0; i < Level.info.configData.Creators.Length; i++)
                            {
                                text3 = text3 + "\n" + Level.info.configData.Creators[i];
                                num  += 15;
                            }
                        }
                        if (Level.info.configData.Collaborators.Length > 0)
                        {
                            if (text3.Length > 0)
                            {
                                text3 += "\n\n";
                                num   += 30;
                            }
                            text3 += LoadingUI.localization.format("Collaborators");
                            num   += 15;
                            for (int j = 0; j < Level.info.configData.Collaborators.Length; j++)
                            {
                                text3 = text3 + "\n" + Level.info.configData.Collaborators[j];
                                num  += 15;
                            }
                        }
                        if (Level.info.configData.Thanks.Length > 0)
                        {
                            if (text3.Length > 0)
                            {
                                text3 += "\n\n";
                                num   += 30;
                            }
                            text3 += LoadingUI.localization.format("Thanks");
                            num   += 15;
                            for (int k = 0; k < Level.info.configData.Thanks.Length; k++)
                            {
                                text3 = text3 + "\n" + Level.info.configData.Thanks[k];
                                num  += 15;
                            }
                        }
                        LoadingUI.creditsBox.positionOffset_Y = -num / 2;
                        LoadingUI.creditsBox.sizeOffset_Y     = num;
                        LoadingUI.creditsBox.text             = text3;
                        LoadingUI.creditsBox.isVisible        = true;
                    }
                    else
                    {
                        LoadingUI.creditsBox.isVisible = false;
                    }
                }
                else
                {
                    LoadingUI.pickBackgroundImage(ReadWrite.PATH + "/Screenshots");
                    LoadingUI.loadingLabel.text            = LoadingUI.localization.format("Loading");
                    LoadingUI.loadingImage.backgroundColor = Color.white;
                    LoadingUI.loadingImage.foregroundColor = Color.white;
                    LoadingUI.creditsBox.isVisible         = false;
                }
                LoadingUI.loadingBox.sizeOffset_X = -20;
                LoadingUI.cancelButton.isVisible  = false;
            }
        }