public static void OnCreate_PauseMenu(PauseMenu self, Manager mgr) { if (!GnomanEmpire.Instance.IsGameOver()) { var panel = typeof(PauseMenu) .GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .Single(f => f.FieldType == typeof(Panel)) .GetValue(self) as Panel; var lastBtn = panel.Controls.Last(); Button button = new Button(mgr); button.Init(); button.Width = 200; button.Top = lastBtn.Top + lastBtn.Height + lastBtn.Margins.Bottom + button.Margins.Top - lastBtn.Margins.Top; //yea, lastMarginTop is excluded between save buttons button.Left = (panel.Width - button.Width) / 2; //button.Margins = new Margins(0, 2, 0, 2); button.Text = "Exit (no Save)"; button.Click += new Game.GUI.Controls.EventHandler((sender, args) => { GnomanEmpire.Instance.MoveToMainMenu(); }); panel.Height = button.Top + button.Height; panel.Add(button); } }
public static void Open(MenuButton button) { GameObject prefab = Resources.Load<GameObject>("Prefabs/UIPrefabs/PauseMenu"); GameObject g = Instantiate(prefab); RectTransform tf = g.transform as RectTransform; tf.SetParent(GameObject.Find("/Canvas").transform); panel = g.GetComponent<PauseMenu>(); tf.sizeDelta = new Vector2(); tf.position = new Vector3(tf.rect.width / 2, tf.rect.height / 2, 0); panel.Initialize(button); GameStatus.IsPausing = true; }
/*************************************** Initialization Functions ***************************************/ public override void initialize() { base.initialize(); click = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.CLICK]; enter = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.ENTER]; rightClick = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.RIGHTCLICK]; selectLeft = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.SELECTLEFT]; selectRight = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.SELECTRIGHT]; pauseMenuKey = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.MENU]; collapse = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.COLLAPSE]; uncollapse = (SinglePressBinding)engine.inputComponent[GameInput.ExampleBindings.UNCOLLAPSE]; pauseMenu = new PauseMenu(engine, engine.graphicsComponent.gui, this); pauseMenu.Initialize(); }
public static void Close() { Destroy(panel.gameObject); panel = null; GameStatus.IsPausing = false; }