public void SetDataOk(string displayText, Action OkImplementation, EPanelSize dSize = EPanelSize.MediumPortrait, bool reset = false, UIType uiType = UIType.NormalView) { if (reset) { ResetFormat(); } DescriptionPanel.Activate(); ImageOnlyPanel.Deactivate(); Description.SetText(displayText); OnClickOk = OkImplementation; OnClickYes = null; OnClickNo = null; OnClickClose = null; if (YesButton != null) { YesButton.Deactivate(); } if (NoButton != null) { NoButton.Deactivate(); } if (OKButton != null) { OKButton.Activate(); } if (CloseButton != null) { CloseButton.Deactivate(); } Description.Activate(); ImageAnnouncement.Deactivate(); AdjustDialogSize(dSize); switch (uiType) { case UIType.StackedView: { ViewController.ActivateWithStackView(this); } break; case UIType.NormalView: { ViewController.ActivateWithNormalView(this); } break; case UIType.BaseView: { Debug.LogWarning("base type is not supported"); } break; } }
void AdjustDialogSize(EPanelSize dSize) { var desc = dSize.GetDescription().Split('|', (char)StringSplitOptions.RemoveEmptyEntries); var sizeVec = new Vector2(desc[0].ToInt(), desc[1].ToInt()); //can change to percentage based, if problems occured ContainerPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, GetCanvas.GetComponent <RectTransform>().sizeDelta.x *(sizeVec.x / 100)); ContainerPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, GetCanvas.GetComponent <RectTransform>().sizeDelta.y *(sizeVec.y / 100)); }
public virtual void AskForConsent(bool storedValue, Action <bool> onConsent) { if (_isInitialized) { return; } #region UI Correction EPanelSize panelSize = EPanelSize.MediumLandscape; Debug.Log("Current Resolution: " + Screen.width + " : " + Screen.height); if (Screen.height > Screen.width) { panelSize = EPanelSize.LargePortrait; } else if (Screen.currentResolution.height < Screen.currentResolution.width) { panelSize = EPanelSize.MediumLandscape; } #endregion if (!storedValue) { UIPopupBox.Instance.SetDataYesNo("We request your permission to show ads, \nPlease Accept.", () => { _consentForShowingAds = true; onConsent.SafeInvoke(true); Initialize(); }, () => { _consentForShowingAds = false; onConsent.SafeInvoke(false); }, shouldUseAcceptAndDecline: true, dSize: panelSize); } else //initialize if consent already given { _consentForShowingAds = true; Initialize(); } }
/// <summary> /// Sets a new level /// </summary> /// <param name="NextComponent">The ID of the next component to be targetted</param> public void NewLevel(int NextComponent) { // Increment level number LevelNumber += 1; // Show level ui if (NextComponent == 0) { _LevelUI.ShowingLevelUI = true; } // First delete the old stuff // Delete the gates Destroy(Gates.GateParent); // Delete the panels if (PanelsRoot != null) { Destroy(PanelsRoot); } // Setup things // Get the component details Ship.ShipComponent Component = PlayerShip.AllComponents[NextComponent]; // Setup inputs and outputs _Gates.InputCount = Component.InputCount; _Gates.OutputCount = Component.OutputCount; _Gates.Initialise(); PanelSize = Component.BoardSize; // Set labels and descriptions for (int i = 0; i < Component.InputLabels.Count; i++) { _Gates.InputConnections[i].Label = Component.InputLabels[i]; _Gates.InputConnections[i].Description = Component.InputDescriptions[i]; } // Set labels and descriptions (outputs) for (int i = 0; i < Component.OutputLabels.Count; i++) { _Gates.OutputConnections[i].Label = Component.OutputLabels[i]; _Gates.OutputConnections[i].Description = Component.OutputDescriptions[i]; } // Tell the ship PlayerShip.CurrentComponentId = NextComponent; // Create a new ship if the current one is set to null if (EnemyShip == null) { SpawnEnemy(); } // Now setup the panels // Tidy up a bit PanelsRoot = new GameObject(); PanelsRoot.transform.position = new Vector3(0, 0, 5); PanelsRoot.name = "Panel Root Object"; // Initialise the BG Panel Objects list BGPanelObjs = new List <GameObject>(); // First spawn in the background panels BGPanelObjs.Add(Instantiate(PanelBackground)); BGPanelObjs.Add(Instantiate(PanelBackground, new Vector2(-0.64f, 0), new Quaternion(0, 0, 0, 0))); BGPanelObjs.Add(Instantiate(PanelBackground, new Vector2(0.64f, 0), new Quaternion(0, 0, 0, 0))); for (int i = 0; i < BGPanelObjs.Count; i++) { BGPanelObjs[i].transform.parent = PanelsRoot.transform; } // Then the panel, switch, various other things that depend on panel size // Use a switch statement and kill many stones with one bird ;) switch (PanelSize) { case EPanelSize.Large: // Create the foreground panel FGPanelObj = Instantiate(LargePanel); FGPanelObj.name = "large panel"; FGPanelObj.transform.parent = PanelsRoot.transform; // Create the switch SwitchObj = Instantiate(SwitchPrefab, LargeSwitchPos, new Quaternion(0, 0, 0, 0)); SwitchObj.name = "panel switch"; SwitchObj.transform.parent = PanelsRoot.transform; // Setup the player's base positions for inputs+outputs ThePlayer.SourceBasePos = Camera.main.WorldToScreenPoint(new Vector2(-0.24f, 0.19f)); ThePlayer.OutBasePos = Camera.main.WorldToScreenPoint(new Vector2(0.22f, 0.19f)); Camera.main.orthographicSize = 0.3f; // Flip the base positions' y-coordinates ThePlayer.SourceBasePos.y = Screen.height - ThePlayer.SourceBasePos.y; ThePlayer.OutBasePos.y = Screen.height - ThePlayer.OutBasePos.y; break; case EPanelSize.Medium: // Create the foreground panel FGPanelObj = Instantiate(MediumPanel); FGPanelObj.name = "medium panel"; FGPanelObj.transform.parent = PanelsRoot.transform; // Create the switch SwitchObj = Instantiate(SwitchPrefab, MediumSwitchPos, new Quaternion(0, 0, 0, 0)); SwitchObj.name = "panel switch"; SwitchObj.transform.parent = PanelsRoot.transform; ThePlayer.SourceBasePos = Camera.main.WorldToScreenPoint(new Vector2(-0.24f, 0.1f)); ThePlayer.OutBasePos = Camera.main.WorldToScreenPoint(new Vector2(0.22f, 0.1f)); Camera.main.orthographicSize = 0.24f; ThePlayer.SourceBasePos.y = Screen.height - ThePlayer.SourceBasePos.y; ThePlayer.OutBasePos.y = Screen.height - ThePlayer.OutBasePos.y; break; case EPanelSize.Small: // Create the foreground panel FGPanelObj = Instantiate(SmallPanel); FGPanelObj.name = "small panel"; FGPanelObj.transform.parent = PanelsRoot.transform; // Create the switch SwitchObj = Instantiate(SwitchPrefab, SmallSwitchPos, new Quaternion(0, 0, 0, 0)); SwitchObj.name = "panel switch"; SwitchObj.transform.parent = PanelsRoot.transform; // Setup the player's base positions for inputs+outputs ThePlayer.SourceBasePos = Camera.main.WorldToScreenPoint(new Vector2(-0.15f, 0.1f)); ThePlayer.OutBasePos = Camera.main.WorldToScreenPoint(new Vector2(0.15f, 0.1f)); Camera.main.orthographicSize = 0.24f; // Flip the base positions' y-coordinates ThePlayer.SourceBasePos.y = Screen.height - ThePlayer.SourceBasePos.y; ThePlayer.OutBasePos.y = Screen.height - ThePlayer.OutBasePos.y; break; } }
public void SetDataImageAnnouncement(Sprite toDisplay, Action closeImplementation, EPanelSize dSize = EPanelSize.MediumLandscape, UIType uiType = UIType.NormalView) { if (toDisplay == null) { return; } DescriptionPanel.Deactivate(); ImageOnlyPanel.Activate(); ImageOnlyAnnouncement.sprite = toDisplay; OnClickClose = closeImplementation; OnClickOk = null; OnClickYes = null; OnClickNo = null; if (YesButton != null) { YesButton.Deactivate(); } if (NoButton != null) { NoButton.Deactivate(); } if (OKButton != null) { OKButton.Deactivate(); } if (CloseButton != null) { CloseButton.Activate(); } AdjustDialogSize(dSize); switch (uiType) { case UIType.StackedView: { ViewController.ActivateWithStackView(this); } break; case UIType.NormalView: { ViewController.ActivateWithNormalView(this); } break; case UIType.BaseView: { Debug.LogWarning("base type is not supported"); } break; } }
public void SetDataYesNo(string displayText, Action yesImplementation, Action noImplementation, EPanelSize dSize = EPanelSize.MediumPortrait, bool reset = false, bool shouldUseAcceptAndDecline = false, UIType uiType = UIType.NormalView) { if (reset) { ResetFormat(); } DescriptionPanel.Activate(); ImageOnlyPanel.Deactivate(); Description.SetText(displayText); OnClickYes = yesImplementation; OnClickNo = noImplementation; OnClickOk = null; OnClickClose = null; if (YesButton != null) { if (shouldUseAcceptAndDecline) { YesButton.GetComponentInChildren <Text>().SetText("Accept"); } YesButton.Activate(); } if (NoButton != null) { if (shouldUseAcceptAndDecline) { NoButton.GetComponentInChildren <Text>().SetText("Decline"); } NoButton.Activate(); } if (OKButton != null) { OKButton.Deactivate(); } if (CloseButton != null) { CloseButton.Deactivate(); } Description.Activate(); ImageAnnouncement.Deactivate(); AdjustDialogSize(dSize); switch (uiType) { case UIType.StackedView: { ViewController.ActivateWithStackView(this); } break; case UIType.NormalView: { ViewController.ActivateWithNormalView(this); } break; case UIType.BaseView: { Debug.LogWarning("base type is not supported"); } break; } }