private void GenerateStation() { Verlet.VerletPhysicsManager.Clear(); _dead = false; _breakableComponents = new List <BreakableComponent>(); _timelimit = _timeLimits[Mathf.Clamp(_currentLevel, 0, _timeLimits.Count - 1)]; if (_currentLevel >= 2) { _panelConfiguration = Instantiate(_panelConfigurations[Random.Range(2, _panelConfigurations.Count)], _baseStation.transform); } else { _panelConfiguration = Instantiate( _panelConfigurations[Mathf.Clamp(_currentLevel, 0, _panelConfigurations.Count - 1)], _baseStation.transform); } _panelConfiguration.LargePanels.ForEach(x => { CreateRandomBreakables(_panelConfiguration, PanelSize.LARGE, x); }); _panelConfiguration.MediumPanels.ForEach(x => { CreateRandomBreakables(_panelConfiguration, PanelSize.MEDIUM, x); }); _panelConfiguration.SmallPanels.ForEach(x => { CreateRandomBreakables(_panelConfiguration, PanelSize.SMALL, x); }); _panelConfiguration.MediumLandscapePanels.ForEach(x => { CreateRandomBreakables(_panelConfiguration, PanelSize.MEDIUM_LANDSCAPE, x); }); _startTime = Time.time; }
public override void OnInspectorGUI() { DrawDefaultInspector(); PanelConfiguration script = (PanelConfiguration)target; // Check if Size is updated EditorGUI.BeginChangeCheck(); script.Size = EditorGUILayout.IntField("Size", script.Size); // Update the Size of the array accordingly if (EditorGUI.EndChangeCheck()) { script.Scores = new int[script.Size]; script.Description = new string[script.Size]; serializedObject.Update(); } Show(serializedObject.FindProperty("Description"), false); Show(serializedObject.FindProperty("Scores"), false); serializedObject.ApplyModifiedProperties(); script.Test = EditorGUILayout.Toggle("Test scene", script.Test); }
private void CreateRandomBreakables(PanelConfiguration panelConfig, PanelSize size, GameObject parentPanel) { GameObject prefab = null; Bounds bounds = parentPanel.GetComponentInChildren <Renderer>().bounds; switch (size) { case PanelSize.LARGE: { int spaces = 4; while (spaces > 0) { int random = _currentLevel == 1 ? 8 : UnityEngine.Random.Range(0, 10); if (random <= 8 && spaces == 4) { prefab = _breakableContainer.GetRandomLargeBreakable(); InstantiatePanel(prefab, parentPanel.transform.parent.gameObject, parentPanel.transform.localPosition, parentPanel.transform.rotation); spaces -= 4; } else if (random > 6 && random < 9 && spaces % 2 == 0) { prefab = _breakableContainer.GetRandomMediumBreakable(); Vector3 offset = new Vector3(bounds.size.x / 4.0f, 0.0f, 0.0f); offset = spaces == 4 ? offset * -1.0f : offset; InstantiatePanel(prefab, parentPanel.transform.parent.gameObject, parentPanel.transform.localPosition - offset, parentPanel.transform.rotation); spaces -= 2; } else { prefab = _breakableContainer.GetRandomSmallBreakable(); float yMultiplied = parentPanel.transform.rotation == Quaternion.identity ? 4.0f : 2.0f; Vector3 offset = new Vector3(bounds.size.x / 4.0f, bounds.size.y / yMultiplied, 0.0f); offset.x = spaces > 2 ? offset.x * -1.0f : offset.x; offset.y = spaces % 2 == 0 ? offset.y * -1.0f : offset.y; GameObject smallPanel = InstantiatePanel(prefab, parentPanel.transform.parent.gameObject, parentPanel.transform.localPosition - offset, parentPanel.transform.rotation); smallPanel.name = spaces.ToString(); spaces -= 1; } } } break; case PanelSize.MEDIUM: { int spaces = 2; while (spaces > 0) { int random = _currentLevel == 2 ? 8 : UnityEngine.Random.Range(0, 10); if (random >= 3 && spaces == 2) { prefab = _breakableContainer.GetRandomMediumBreakable(); InstantiatePanel(prefab, parentPanel.transform.parent.gameObject, parentPanel.transform.localPosition, parentPanel.transform.rotation); spaces -= 2; } else { prefab = _breakableContainer.GetRandomSmallBreakable(); float yMultiplied = parentPanel.transform.rotation == Quaternion.identity ? 4.0f : 2.0f; Vector3 offset = new Vector3(0.0f, bounds.size.y / yMultiplied, 0.0f); offset.y = spaces % 2 == 0 ? offset.y * -1.0f : offset.y; InstantiatePanel(prefab, parentPanel.transform.parent.gameObject, parentPanel.transform.localPosition + offset, parentPanel.transform.rotation); spaces -= 1; } } } break; case PanelSize.SMALL: { prefab = _breakableContainer.GetRandomSmallBreakable(); InstantiatePanel(prefab, parentPanel.transform.parent.gameObject, parentPanel.transform.localPosition, parentPanel.transform.rotation); } break; case PanelSize.MEDIUM_LANDSCAPE: { prefab = _breakableContainer.GetRandomMediumLandscapeBreakable(); InstantiatePanel(prefab, parentPanel.transform.parent.gameObject, parentPanel.transform.localPosition, parentPanel.transform.rotation); } break; } Destroy(parentPanel); }
public static AppConfiguration FromString(string value) { var config = new AppConfiguration(); if (string.IsNullOrEmpty(value)) { return(config); // Return defaults } var values = value.Split(new[] { Environment.NewLine }, StringSplitOptions.None); var version = values[0] == "v1" ? 1 : int.Parse(values[0]); var valueIndex = 1; config.SharedWindowConfig.OnResumeDisplayLogon = bool.Parse(values[valueIndex++]); if (version > 1) { config.SharedWindowConfig.StartupDelaySec = uint.Parse(values[valueIndex++]); } config.SharedPanelConfig.NavigationEnabledByUtc = DateTime.Parse(values[valueIndex++]); var uriCount = int.Parse(values[valueIndex++]); for (int i = 0; i < uriCount; i++) { var safeUri = new Uri(Encoding.Unicode.GetString(Convert.FromBase64String(values[valueIndex++])), UriKind.Absolute); config.SharedPanelConfig.AddSafeUris(new[] { safeUri }); } int windowCount = int.Parse(values[valueIndex++]); if (windowCount != AppConfiguration.SupportedWindowCount) { throw new InvalidOperationException($"Expected {AppConfiguration.SupportedWindowCount} windows, but found {windowCount}"); } var windows = new WindowConfiguration[windowCount]; for (int i = 0; i < windowCount; i++) { var topVerticalSplitter = double.Parse(values[valueIndex++]); var bottomVerticalSplitter = double.Parse(values[valueIndex++]); var horizontalSplitter = double.Parse(values[valueIndex++]); int paneCount = int.Parse(values[valueIndex++]); if (paneCount != 4) { throw new InvalidOperationException($"Expected 4 panes, but found {paneCount}"); } var panes = new PanelConfiguration[paneCount]; for (int j = 0; j < panes.Length; j++) { var uri = Encoding.Unicode.GetString(Convert.FromBase64String(values[valueIndex++])); var refreshFreq = int.Parse(values[valueIndex++]); var scale = int.Parse(values[valueIndex++]); var scaleMaximized = int.Parse(values[valueIndex++]); panes[j] = new PanelConfiguration(uri: uri, refreshFreq: refreshFreq, scale: scale, scaleMaximized: scaleMaximized); } windows[i] = new WindowConfiguration( topVerticalSplitter: topVerticalSplitter, bottomVerticalSplitter: bottomVerticalSplitter, horizontalSplitter: horizontalSplitter, panes: panes); } config.Windows.Clear(); config.Windows.AddRange(windows); return(config); }