private void ChooseMenu() { SetNewStyle(mainActions[currentChoice].GetComponent<Text>()); if (Input.GetKeyDown(KeyCode.UpArrow)) { SetDefaultStyle(mainActions[currentChoice].GetComponent<Text>()); currentChoice++; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { SetDefaultStyle(mainActions[currentChoice].GetComponent<Text>()); currentChoice--; } if (Input.GetKeyDown(KeyCode.Space)) { switch (mainActions[currentChoice].GetComponent<Text>().text) { case ("Load"): LoadSaves(); panelState = PanelState.Saves; break; default: break; } } CheckOutOFBounds(mainActions); }
/** * Will Set the current State of the Given Button: * if button has been marked as selectable(Defualt): * IDLE: All SupPanels are invisible, INACTIVE, and are not Updated. * SELECTED: All SupPanels are visible, IDLE, and updated Normally. * INACTIVE: All SupPanels are invisible and INACTIVE. * if button has not been marked as selectable: * IDLE: SupPanels States are updated Normally. * SELECTED: SupPanels States are updated Normally. * INACTIVE: All SupPanels are invisible INACTIVE, and not Updated. */ public override void setState(PanelState newState, bool setSubPanels) { //Idle if (newState == PanelState.IDLE) { if (selectable) { base.setState(PanelState.INACTIVE, setSubPanels); setVisibility(false, setSubPanels); setVisibility(true, false); } base.setState(PanelState.IDLE, false); } //Selected else if (newState == PanelState.SELECTED) { if (selectable) { base.setState(PanelState.IDLE, setSubPanels); setVisibility(true, setSubPanels); } base.setState(PanelState.SELECTED, false); } //Inactive else if (newState == PanelState.INACTIVE) { base.setState(PanelState.INACTIVE, setSubPanels); setVisibility(false, setSubPanels); setVisibility(true, false); } }
public CustomPanelInstanceData CreateObjectPanel(CustomPanelType type, string objectReference) { var foundObject = m_dynamicObjectManager.TryFindObject(objectReference); if (foundObject == null) { PanelState state; if (!m_panelStates.TryGetValue(type, out state)) { state = new PanelState(); m_panelStates[type] = state; } var createdCount = state.CreatedPanels.Where(p => p.TargetObjectReference.Equals(objectReference)).Count(); if (createdCount == 0 || type.AllowMultipleInstances) { var panel = new CustomPanelInstanceData(type); panel.SetObjectReference(objectReference); // Who's resolving this, then? if (panel != null) { state.CreatedPanels.Add(panel); panel.Disposed += Panel_Disposed; } return(panel); } else { return(null); } } else { return(CreateObjectPanel(type, foundObject)); } }
public CustomPanelInstanceData CreateObjectPanel(CustomPanelType type, IObjectContainer container) { PanelState state; if (!m_panelStates.TryGetValue(type, out state)) { state = new PanelState(); m_panelStates[type] = state; } var createdCount = state.CreatedPanels.Where(p => Object.ReferenceEquals(p.BoundObjectContainer, container)).Count(); if (createdCount == 0 || type.AllowMultipleInstances) { var panel = new CustomPanelInstanceData(type, container); if (panel != null) { state.CreatedPanels.Add(panel); panel.Disposed += Panel_Disposed; } return(panel); } else { return(null); } }
// ******************************************************************** // ******************************************************************** #region Constructors // ******************************************************************** public LoadingSpinnerPanelData(string _loadingText = "", PanelState _startingState = PanelState.HIDDEN, PanelLimitOverride _limitOverride = PanelLimitOverride.REPLACE) : base(_startingState, _limitOverride) { loadingText = _loadingText; }
// Sets the PanelState and displays the panel accordingly public void SetState(PanelState state) { this.state = state; Color c = new Color(this.icon.color.r, this.icon.color.g, this.icon.color.b, 1); switch (this.state) { case PanelState.Default: this.icon.color = c; c.a = 0; this.panelBorder.color = c; break; case PanelState.Win: this.icon.color = c; this.panelBorder.color = c; break; case PanelState.Lose: this.panelBorder.color = c; c.a = 0.25f; this.icon.color = c; break; } }
public virtual void Show(object parm = null, Callback_0 callback = null) { if (gameObject == null && !string.IsNullOrEmpty(assetPath)) { m_panelState = PanelState.Loading; Object obj = null; if (panelLoad == PanelLoad.Load) { obj = ResourceManager.Instance.LoadAsset(assetPath); OnLoadEnd(obj, parm, callback); return; } else { ResourceManager.Instance.LoadAssetSync(assetPath, o => { obj = o; OnLoadEnd(obj, parm, callback); }); } } if (m_panelState != PanelState.None && m_panelState != PanelState.Loading) { OnShow(parm); m_panelState = PanelState.Showing; if (callback != null) { callback(); } } }
void ChangePanel(PanelState state) { isMessagePanelActive = false; //ランキングー>リザルト if (state == PanelState.result && panelState == PanelState.ranking) { panelState = PanelState.result; //リザルトのアニメーション animator.SetTrigger("ToResult"); result.canScroll = true; ranking.canScroll = false; } //リザルト->ランキング else if (state == PanelState.ranking && panelState == PanelState.result) { panelState = PanelState.ranking; //ランキングのアニメーション animator.SetTrigger("ToRanking"); ranking.canScroll = true; result.canScroll = false; } }
//加载结束 private void OnLoadEnd(Object obj, object parm, Callback_0 callback) { if (m_panelState == PanelState.Destroy)//刚打开就要销毁 { Debug.Log("Destroy on Load End"); } if (obj == null) { GLog.E("Load UI Error:: file: " + name + ", assetPath: " + assetPath); m_panelState = PanelState.Showing; if (callback != null) { callback(); } } else { gameObject = GameObject.Instantiate(obj) as GameObject; transform = gameObject.transform; transform.SetParent(GetParent()); transform.localPosition = Vector3.zero; Init(); Localize(); Resize(); OnShow(parm); m_panelState = PanelState.Showing; if (callback != null) { callback(); } } }
public void OnPointerDown(PointerEventData eventData) { switch (currentPanelState) { case PanelState.idle: if (currentDialogueIndex < dialogueArray.Length - 1) { currentDialogueIndex++; popingTextCoroutine = StartCoroutine(DisPlayDialogue(dialogueArray[currentDialogueIndex])); } else { gameObject.SetActive(false); } break; case PanelState.popingText: StopCoroutine(popingTextCoroutine); dialogueTextUI.text = dialogueArray[currentDialogueIndex]; currentPanelState = PanelState.idle; indicator.SetActive(true); break; } }
void OpenCeShiPanel() { Debug.Log("OpenCeShiPanel..."); JiaoZhunPanelObj.SetActive(false); CeShiPanelObj.SetActive(true); PanelStVal = PanelState.CeShiPanel; CheckOpenCeShiPanel(); }
public uGUIMovingPanel(uGUIManagedPanel panel, PanelState targetState, bool queued, bool instant, bool additional) { this.panel = panel; this.targetState = targetState; this.queued = queued; this.instant = panel.duration == 0 ? true : instant; this.additional = additional; }
public void TogglePanelOff() { panelState = PanelState.panelIn; start = outTarget; currentTarget = inTarget; coroutine = StartCoroutine("Slide"); ToggleOtherMenusOff(); }
public static string ButtonClicked() { string button = "NONE"; if (lastClickTime++ < 10) return button; switch(state) { case PanelState.FOUNDCOLONY: foreach(Button b in colonyButtons) { if (b.WasPressed()) { button = b.Type; prize = int.MaxValue; settlementType = button; ShowQuestionCreateSettlement(); break; } } if (closeButton.WasPressed()) state = PanelState.WAIT; break; case PanelState.AWAITCONFIRM: if (CreateSettlement()) button = closeButton.Type; break; case PanelState.TERRAFORM: string s = selectionBox.CheckButtons(); if (s == "CancelButton") state = PanelState.WAIT; else if (s == "OkButton") { int prize = selectionBox.TotalPrice; int value = selectionBox.Value; PlayerShip.Money -= prize; GameSystemDesigner.ActualPlanet.Terrascore += value; state = PanelState.WAIT; } button = s; break; case PanelState.WAIT: default: foreach (Button b in dishabitedButtons) if (b.WasPressed()) { button = b.Type; LoadNewWindow(button); } if (closeButton.WasPressed()) button = closeButton.Type; break; } if (button != "NONE") lastClickTime = 0; return button; }
public uGUIMovingPanel(uGUIManagedPanel panel, bool show, bool hide, bool queued, bool instant, bool additional) { this.panel = panel; this.queued = queued; this.instant = panel.duration == 0 ? true : instant; this.additional = additional; if (show) targetState = PanelState.Show; if (hide) targetState = PanelState.Hide; }
/// <summary> /// Creates an expandable/collapsable panel /// </summary> /// <param name="graphics">Graphics device</param> /// <param name="size">Size of panel when fully expanded</param> /// <param name="speed">Speed of expansion/collapse</param> /// <param name="position">Position of center of the panel. Panel expands/collapses from/to this point</param> /// <param name="color">Color of the panel</param> public Panel(GraphicsDevice graphics, Vector2 size, Vector2 speed, Vector2 position, Color color) : base(new Texture2D(graphics, (int)size.X, (int)size.Y), position, color) { MaxSize = size; _state = PanelState.Collapsed; _speed = speed; _minScale = new Vector2(1f / size.X, 1f / size.Y); _scale = _minScale; _isVisible = false; //Set texture data _texture.SetData<Color>(Enumerable.Repeat<Color>(Color.White, (int)size.X * (int)size.Y).ToArray<Color>()); SetCenterAsOrigin(); }
public static string ButtonClicked() { string button = "NONE"; if (lastClickTime++ < 10) return button; switch(state) { case PanelState.WAIT: if (GameSystemDesigner.ActualPlanet.PlanetSettlement != null) { foreach (Button b in inhabitedButtons) { if (b.WasPressed()) { button = b.Type; LoadNewWindow(button); } } } if (closeButton.WasPressed()) button = closeButton.Type; break; case PanelState.COMMERCE: if (CommerceUIDesigner.ButtonClicked() == "CloseButton") state = PanelState.WAIT; break; case PanelState.GIFT: string s = selectionBox.CheckButtons(); if (s == "CancelButton") state = PanelState.WAIT; else if (s == "OkButton") { int gift = selectionBox.TotalPrice; if(GameManager.PlayerEmpire != GameManager.ActualSystemOwner) GameRelationManager.CreateGiftEvent(GameManager.PlayerEmpire, GameManager.ActualSystemOwner, gift); PlayerShip.Money -= gift; GameSystemDesigner.ActualPlanet.PlanetSettlement.Money += gift; state = PanelState.WAIT; } break; } if (inhabitedButtons[0].WasPressed()) lastClickTime = 0; return button; }
private void changePlayer() { ClearGUI(); if (currentPlayerTurn == players.Count - 1) { currentBattleState = BattleState.EnemyState; return; } currentPlayerTurn++; GameObject.Find("HeroName").GetComponent<Text>().text = players[currentPlayerTurn].name; currentPanelState = PanelState.Actions; currentMenuChoise = 0; foreach (var act in actions) { act.GetComponent<Text>().enabled = true; } }
private void changeState(PanelState newState) { if (newState == _panelState) { return; } EventHandler<StateEventArgs> handler = StateChanged; if (handler != null) { handler(this, new StateEventArgs(typeof(AchievementPanel.PanelState), newState)); } _panelState = newState; }
static void LoadNewWindow(string button) { switch (button) { case "Commerce": CommerceUIDesigner.LoadWindowComponents(GameSystemDesigner.ActualPlanet); state = PanelState.COMMERCE; break; case "Gift": int prize = 1; int max = PlayerShip.Money / prize; selectionBox.SetValues(max, prize); state = PanelState.GIFT; break; default: state = PanelState.WAIT; break; } }
/// <summary> /// Override for when the panel minimizes. /// </summary> public virtual void Minimize() { var raiseEvent = this.panelState != PanelState.Minimized; this.panelState = PanelState.Minimized; this.IsMaximized = false; // Fire the panel minimized event if (raiseEvent && this.Minimized != null) { this.Minimized(this, EventArgs.Empty); } }
public void Show() { if (state == PanelState.hide) { state = PanelState.showing; } }
private void DoActions() { SetNewStyle(actions[currentMenuChoise].GetComponent<Text>()); if (Input.GetKeyDown(KeyCode.DownArrow)) { SetDefaultStyle(actions[currentMenuChoise].GetComponent<Text>()); currentMenuChoise--; checkOutOfBounds(actions); } else if (Input.GetKeyDown(KeyCode.UpArrow)) { SetDefaultStyle(actions[currentMenuChoise].GetComponent<Text>()); currentMenuChoise++; checkOutOfBounds(actions); } //TEMPORARILY if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } if (Input.GetKeyDown(KeyCode.Space) && actions[currentMenuChoise].name.Equals("Attack")) { var enemyPanel = GameObject.Find("EnemyChoicePanel"); enemyPanel.GetComponent<Image>().enabled = true; currentPanelState = PanelState.Enemies; enemies = GameObject.FindGameObjectsWithTag("Enemy"); enemyNames = new GameObject[enemies.Length]; for (var i = 0; i < enemyNames.Length; i++) { enemyNames[i] = new GameObject(enemies[i].name); enemyNames[i].transform.SetParent(enemyPanel.transform); var text = enemyNames[i].AddComponent<Text>(); text.text = enemies[i].name.Substring(0, enemies[i].name.Length - 1); text.font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf"); text.fontSize = 12; text.color = Color.black; text.fontStyle = FontStyle.Normal; currentMenuChoise = 0; } arrow.transform.localScale = new Vector3(3, 3, 0); arrow.transform.SetParent(enemies[currentMenuChoise].transform); arrow.transform.position = enemies[currentMenuChoise].transform.position + new Vector3(0, 10, 0); } }
static void LoadNewWindow(string button) { switch (button) { case "Terraform": int level = PlayerShip.GetMaxPowerUpLevel(PlayerPowerUp.PowerUpType.TERRAFORMER); if (level <= 0) level = 1; int prize = GameActionsManager.TerraformPlanet(GameSystemDesigner.ActualPlanet, PlayerShip.Money, level); if (PlayerShip.Money < prize || prize == 0) break; int max = PlayerShip.Money / prize; max = MathHelper.Min(max, 32 - GameSystemDesigner.ActualPlanet.Terrascore); selectionBox.SetValues(max, prize); state = PanelState.TERRAFORM; break; case "Found": state = PanelState.FOUNDCOLONY; break; default: break; } }
private void NextTurn() { if (GameObject.FindGameObjectsWithTag("Enemy").Length == 0 || GameObject.FindGameObjectsWithTag("Player").Length == 0) { currentBattleState = BattleState.EndingState; return; } foreach (var act in actions) { act.GetComponent<Text>().enabled = true; } actionsQueue.Clear(); currentBattleState = BattleState.PlayerState; currentPanelState = PanelState.Actions; currentPlayerTurn = 0; currentMenuChoise = 0; GameObject.Find("HeroName").GetComponent<Text>().text = players[currentPlayerTurn].name; }
public void TogglePanelStateInst(string name, PanelState targetState, PanelState toggleState, bool additional = false, bool queued = false, bool instant = false) { uGUIManagedPanel mp = FindPanelInst(name); bool add = false; uGUIMovingPanel currMovingPanel = DeleteAllMovingPanelsExceptCurrent(mp); if (currMovingPanel != null) { if (currMovingPanel.targetState != GetToggleState(currMovingPanel)) { add = true; queued = true; } } else { add = true; } if (add) { movingPanels.Add(new uGUIMovingPanel(mp, targetState, toggleState, queued, instant, additional)); } }
public static void TogglePanelState(string name, PanelState targetState, PanelState toggleState, bool additional = false, bool queued = false, bool instant = false) { uGUIManager.instance.TogglePanelStateInst(name, targetState, toggleState, additional, queued, instant); }
private void ReloadGUI() { arrow.transform.position = new Vector2(0, 0); GameObject.Find("EnemyChoicePanel").GetComponent<Image>().enabled = false; foreach (var obj in enemyNames) { Destroy(obj); } currentPanelState = PanelState.Actions; currentMenuChoise = 0; }
/// <summary> /// Override for when a panel is maximized. /// </summary> public virtual void Maximize() { // Bring the panel to the front Canvas.SetZIndex(this, CurrentZIndex++); bool raiseEvent = this.PanelState != PanelState.Maximized; this.PanelState = PanelState.Maximized; this.IsMaximized = true; // Fire the panel maximized event if (raiseEvent && this.Maximized != null) { this.Maximized(this, EventArgs.Empty); } }
private void Start() { LoadBattle(); //Loading players LoadPlayers(); //Loading misc and interface LoadInfoPanel(); strike = GameObject.Find("strike"); arrow = GameObject.Find("arrow"); actions = GameObject.FindGameObjectsWithTag("Actions").OrderBy(go => go.name).ToArray(); currentPanelState = PanelState.Actions; currentBattleState = BattleState.PlayerState; currentPlayerTurn = 0; currentMenuChoise = 0; GameObject.Find("HeroName").GetComponent<Text>().text = players[currentPlayerTurn].name; //Active style for text choiceColor = new Color(30, 190, 20, 255); choiceStyle = FontStyle.Bold; }
public static void Initialize() { lastClickTime = 0; prize = int.MaxValue; settlementType = ""; state = PanelState.WAIT; CreateColonyButtons(); }
static bool CreateSettlement() { bool result = false; foreach(Button b in ChoiceButtons) { if(b.WasPressed()) { if(b.Type == "YesButton") { Settlement.SettlementType type = Settlement.GetSettlementTypeFromString(settlementType); Settlement capitalSett = GameManager.PlayerCapital.PlanetSettlement; Settlement s = new Settlement(type, prize / 2, capitalSett.Inhabitants / 16, capitalSett.DefensiveArmy, capitalSett.OffensiveArmy, capitalSett.InhaGrowthRate, capitalSett.ScienceLevel, capitalSett.ScienceGrowthRate, capitalSett.CommerceLevel, capitalSett.CommerceGrowthRate, capitalSett.TecnoLevel, capitalSett.TecnoGrowthRate); GameSystemDesigner.ActualPlanet.CreateSettlement(s); GameManager.SetActualSystemOwner(GameManager.PlayerEmpire); PlayerShip.Money -= prize; state = PanelState.WAIT; settlementType = ""; prize = int.MaxValue; return true; } else if(b.Type == "CancelButton") { state = PanelState.WAIT; settlementType = ""; prize = int.MaxValue; return false; } } } return result; }
/// <summary> /// Updates the controls settings. /// </summary> protected override void OnCreateControl() { base.OnCreateControl(); // Set the expanded height of the panel according to the height set in the designer // It can be set to a manual height by replacing "Height" with the number of your choice m_expandedHeight = Height; if (DesignMode) return; // Set the panel status for startup m_animationStep = m_expandedHeight; m_panelState = ExpandedOnStartup ? PanelState.Collapsed : PanelState.Expanded; SwitchStatus(); // Set the animation speed UpdateAnimationSpeed(); }
static void ShowQuestionCreateSettlement() { Settlement.SettlementType type = Settlement.GetSettlementTypeFromString(settlementType); prize = GameActionsManager.GetPrizeToCreateColony(type); if (prize <= PlayerShip.Money) state = PanelState.AWAITCONFIRM; }
/// <summary> /// Collapses the Panel. /// </summary> private void CollapsePanel() { while (AnimationSpeed != AnimationSpeed.None && Height > Header.Height + m_animationStep) { Height -= m_animationStep; Refresh(); } Height = Header.Height; m_headerImage = m_expandImage; m_panelState = PanelState.Collapsed; Refresh(); }
public void Hide() { if (state == PanelState.shown) { state = PanelState.hiding; } }
/// <summary> /// Expands the Panel. /// </summary> private void ExpandPanel() { while (AnimationSpeed != AnimationSpeed.None && Height < m_expandedHeight - m_animationStep) { Height += m_animationStep; Refresh(); } Height = m_expandedHeight; m_headerImage = m_collapseImage; m_panelState = PanelState.Expanded; Refresh(); }
public void Update(float dt) { udtGraph.AddValue(dt); update_time_counter += dt; ups_counter++; if (update_time_counter >= 1) { update_time_counter -= 1; ups = ups_counter; ups_counter = 0; upsGraph.AddValue(ups); } memoryCounter += dt; if (memoryCounter >= 0.5f) { memoryCounter = 0; memory = GC.GetTotalMemory(false); memoryGraph.AddValue(memory); } UpdateBuffer(); foreach (var item in graphs) item.Update(dt); if (state == PanelState.showing) { if(Math.Abs(drawArea.Y - 10) < 0.1f) { drawArea.Y = 10; state = PanelState.shown; } else { drawArea.Y = MathUtils.Lerp(drawArea.Y, 10, dt*8); } } if(state == PanelState.hiding) { if (Math.Abs(drawArea.Y + drawArea.Height + 10) < 0.1f) { drawArea.Y = -drawArea.Height - 10; state = PanelState.hide; } else { drawArea.Y = MathUtils.Lerp(drawArea.Y, -drawArea.Height - 10, dt*8); } } }
public static void Initialize() { lastClickTime = 0; state = PanelState.WAIT; }
/// <summary> /// Override for when the panel restores. /// </summary> public virtual void Restore() { bool raiseEvent = this.PanelState != PanelState.Restored; this.PanelState = PanelState.Restored; this.IsMaximized = false; // Fire the panel minimized event if (raiseEvent && this.Restored != null) { this.Restored(this, EventArgs.Empty); } }
public void SetPanelStateInst(string name, PanelState targetState, bool additional = false, bool queued = false, bool instant = false) { uGUIManagedPanel mp = FindPanelInst(name); if (mp.panelState != targetState) { movingPanels.Add(new uGUIMovingPanel(mp, targetState, queued, instant, additional)); } }