/// <summary> /// 添加一个UI /// </summary> /// <param name="ui"></param> public void AddUI(BaseUI ui) { if (ui != null) { mDicUI[ui.UIName] = ui; } }
/// <summary> /// 添加一个界面到缓存字典中 /// </summary> /// <param name="viewName">界面名字</param> /// <param name="view">界面</param> public void AddViewToDic(string viewName, BaseUI view) { if (mDicView.ContainsKey(viewName)) { mDicView[viewName] = view; } else { mDicView.Add(viewName,view); } }
/// <summary> /// 显示一个UI界面 如果不存在就创建 /// </summary> /// <param name="uiName">ui名称</param> /// <param name="type">要绑定的脚本</param> /// <param name="listener">如果界面不存在则会有界面加载完成后的回调</param> /// <param name="param">要传入的参数</param> public void ShowUI(string uiName, Type type, ILoadUIListener listener, object param = null, bool createCanCall = false) { BaseUI ui = null; mDicUI.TryGetValue(uiName, out ui); if (ui == null) { cmdList.Add(Command.CreateAndShowCmd(uiName, type, listener, param, createCanCall)); } else { cmdList.Add(Command.ShowCmd(uiName, listener, param, createCanCall)); } }
bool UICollision.IsCollisionMouse(BaseUI ui, float x, float y) { var c = ui as Components.CircleComponent; float distance = (float)Math.Sqrt(Math.Pow(c.X + c.Radius - x, 2) + Math.Pow(c.Y + c.Radius - y, 2)); if (distance <= c.Radius) { return(true); } else { return(false); } }
/// <summary> /// 显示一个界面 /// </summary> /// <param name="cmd"></param> private void _ShowUI(Command cmd) { BaseUI u = null; mDicUI.TryGetValue(cmd.uiName, out u); if (u != null) { if (cmd.listener != null) { cmd.listener.Finish(u); } u.Show(); } }
private void PortDropDownWindow_OnUpdateEvent(BaseUI sender, GameTime gameTime) { var sf = (StandardForm)sender; if (Math.Abs(sf.Location.Y - sf.LerpLocation.Y) > 1) { sf.Location = new Vector2(sf.Location.X - ((sf.Location.X - sf.LerpLocation.X) * .02f), sf.Location.Y - ((sf.Location.Y - sf.LerpLocation.Y) * .02f)); } if (sf.Transparency > 20) { sf.Transparency -= 1; } }
private void SelectedShipyardButton_OnUpdateEvent(BaseUI sender, GameTime gameTime) { var b = (Button)sender; if (Math.Abs(b.Location.Y - b.LerpLocation.Y) > 1) { b.Location = new Vector2(b.Location.X - ((b.Location.X - b.LerpLocation.X) * .08f), b.Location.Y - ((b.Location.Y - b.LerpLocation.Y) * .08f)); } if (b.Transparency > 20) { b.Transparency -= 1; } }
//UIの削除関数 public void DestroyUI(string UI_name) { if (!instanceMap.ContainsKey(UI_name)) { return; } tempCallObj.Remove(UI_name); BaseUI will_desUI = instanceMap[UI_name]; //避難させておく instanceMap.Remove(UI_name); Destroy(will_desUI.gameObject); }
private void portCashDisplay_OnUpdateEvent(BaseUI sender, GameTime gameTime) { var lbl = (Label)sender; lbl.Text = lbl.Text = GetConcatinatedString("Ship: " + _shipManager.PlayerShip.shipName, "Money: " + _shipManager.currentCash, lbl.Font, lbl.Owner.Size.Width - RightHandMargin, RightHandMargin); //"Money: " + ShipManager.currentCash; lbl.Location = new Vector2( (int)lbl.Owner.Location.X + lbl.Owner.Size.Width - RightHandMargin - (_debugTextManager.GetFont().MeasureString(lbl.Text).X), lbl.Location.Y); }
static int OnDestroy(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); BaseUI obj = (BaseUI)ToLua.CheckObject <BaseUI>(L, 1); obj.OnDestroy(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void Hide <T>() where T : BaseUI, new() { BaseUI panel = null; foreach (var item in panelList) { if (item is T) { panel = item; break; } } panel?.Hide(); }
public override void Init() { mMainUI = new MainUI(); mDoubleFightUI = new DoubleFightUI(); mSingleBalletUI = new SingleBattleUI(); base.Init(); mTargetUI = mMainUI; mMainUI.Init(); mDoubleFightUI.Init(); mSingleBalletUI.Init(); mWhichScene = WhichScene.MainTitle; mCurrentUI = mMainUI; }
/// <summary> /// 显示一个界面 /// </summary> /// <param name="cmd"></param> private void _ShowUI(Command cmd) { BaseUI ui = null; mDicUI.TryGetValue(cmd.uiName, out ui); if (ui != null) { if (cmd.listener != null) { cmd.listener.FiniSh(ui); } ui.Show(cmd.param); } }
public BaseUI CloseUI(UIType type, params object[] data) { BaseUI ui = null; if (_uiPool.TryGetValue((int)type, out ui)) { ui.OnClose(data); } else { Debug.LogError("Close: can not find ui " + type); } return(ui); }
// Update is called every frame, if the MonoBehaviour is enabled. void Update() { if (cmdList.Count > 0) { Command tempCmd = null; tempCmd = cmdList[0]; if (tempCmd == null) { cmdList.RemoveAt(0); } else { switch (tempCmd.cmdType) { case Command.CmdType.CreateAndShow: _Create(tempCmd); break; case Command.CmdType.Create: _Create(tempCmd); break; case Command.CmdType.Destroy: _DestroyUI(tempCmd); break; case Command.CmdType.Hide: _HideUI(tempCmd); break; case Command.CmdType.Show: BaseUI ui = null; mDicUI.TryGetValue(tempCmd.uiName, out ui); if (ui == null) { cmdList.RemoveAt(0); cmdList.Insert(0, Command.CreateAndShowCmd(tempCmd.uiName, tempCmd.type, tempCmd.listener, tempCmd.param, tempCmd.createCanCall)); return; } _ShowUI(tempCmd); break; } cmdList.RemoveAt(0); } } }
private IEnumerator <int> AsyncLoadData() { UIInfoData _uiInfoData = null; UnityEngine.Object _prefabObj = null; GameObject _uiObject = null; GameObject _uiParent = null; if (stackOpenUIs != null && stackOpenUIs.Count > 0) { do { _uiInfoData = stackOpenUIs.Pop(); _uiParent = _uiInfoData.Parent; _prefabObj = Resources.Load(_uiInfoData.Path); if (_prefabObj != null) { //_uiObject = NGUITools.AddChild(Game.Instance.mainUICamera.gameObject, _prefabObj as GameObject); _uiObject = MonoBehaviour.Instantiate(_prefabObj) as GameObject; if (null != UIRootObj) { if (null == _uiParent) { _uiObject.transform.SetParent(UIRootObj.transform); _uiObject.transform.localScale = Vector3.one; _uiObject.GetComponent <Canvas>().worldCamera = UICamera; } else { _uiObject.transform.parent = _uiParent.transform; _uiObject.transform.localScale = Vector3.one; } } BaseUI _baseUI = _uiObject.GetComponent <BaseUI>(); if (null == _baseUI) { _baseUI = _uiObject.AddComponent(_uiInfoData.ScriptType) as BaseUI; } if (null != _baseUI) { _baseUI.SetUIWhenOpening(_uiInfoData.UIParams); } dicOpenUIs.Add(_uiInfoData.UIType, _uiObject); } } while(stackOpenUIs.Count > 0); } yield return(0); }
public static void AnimateColor(BaseUI content, Color from, Color to, Duration dur) { LinearGradientBrush brush = new LinearGradientBrush(); GradientStop stop2 = new GradientStop(from, 0); GradientStop stop1 = new GradientStop(to, 0); try { content.UnregisterName("stop1"); content.UnregisterName("stop2"); } catch { } content.RegisterName("stop1", stop1); content.RegisterName("stop2", stop2); brush.GradientStops.Add(stop1); brush.GradientStops.Add(stop2); content.BackgroundShape.Fill = brush; DoubleAnimation offsetAnimation = new DoubleAnimation(); offsetAnimation.From = 0.0; offsetAnimation.To = 1.0; offsetAnimation.Duration = dur; DoubleAnimation offsetAnimation2 = new DoubleAnimation(); offsetAnimation2.From = 0.1; offsetAnimation2.To = 1.0; offsetAnimation2.Duration = dur; Storyboard st = new Storyboard(); Storyboard.SetTargetName(offsetAnimation, "stop1"); Storyboard.SetTargetProperty(offsetAnimation, new PropertyPath(GradientStop.OffsetProperty)); Storyboard.SetTargetName(offsetAnimation2, "stop2"); Storyboard.SetTargetProperty(offsetAnimation2, new PropertyPath(GradientStop.OffsetProperty)); st.Children.Add(offsetAnimation); st.Children.Add(offsetAnimation2); st.Begin(content); }
private void debugButton_OnUpdateEvent(BaseUI sender, GameTime gameTime) { var b = (Button)sender; if (b.Timer == 0) { b.SetBackgroundMaterial(_textureManager.Button_GalaxyIcon); b.Timer -= 1; } else if (b.Timer > 0) { b.Timer -= 1; } b.Location = new Vector2((b.Owner.Location.X) + 1 * b.BackgroundMaterial.Width, b.Owner.Location.Y + 4); }
public void SetSceneUI(BaseUI UIPrefab) { var currentScene = SceneManager.GetActiveScene(); var ExistingUIObjects = GameObject.FindObjectsOfType <BaseUI>(); foreach (var ExistingUIObject in ExistingUIObjects) { Destroy(ExistingUIObject.gameObject); } if (UIPrefab != null) { _sceneUI = MonoBehaviour.Instantiate(UIPrefab); } }
private void _CreateWind(CommandData cmd) { BaseUI wind = GetWindow(cmd.uiName); if (wind == null) { wind = cmd.createFun(); mUIArray.Add(cmd.uiName, wind); } if (cmd.isCallBack && cmd.callback != null) { cmd.callback(wind); } _ShowWindow(cmd); }
public void OpenUI(BaseUI ui) { if (uilist.Contains(ui)) { for (int i = 0; i < uilist.Count; i++) { if (uilist[i] != ui) { uilist[i].Hide(); } } ui.Show(); currentUI = ui; } }
public static void addCommonBg(BaseUI baseUI, CommonBgType type = CommonBgType.AnimBG_Star) { GameObject bg = ResMgr.Instance.load("UI/" + type.ToString()) as GameObject; if (bg != null) { bg.transform.SetParent(baseUI.CacheTrans); bg.transform.localPosition = Vector3.zero; bg.transform.localScale = Vector3.one; bg.transform.SetSiblingIndex(0); UIEventTrigger listener = bg.AddComponent <UIEventTrigger>(); listener.setClickHandler(baseUI.closeSelfUI); } }
public BaseUI ShowUI(string UIName) { Transform outUIWnd = null; //如果已经打开了 则只需要显示在前面就行了 if (_CurShowUI.TryGetValue(UIName, out outUIWnd)) { outUIWnd.gameObject.SetActive(true); outUIWnd.SetAsLastSibling(); return(outUIWnd.GetComponent <BaseUI>()); } BaseUI UIScr = null; //没有打开 重新加载 GameObject uiGameObj = LoadUI(UIName); if (uiGameObj == null) { return(null); } //检查脚本有没有加 UIScr = uiGameObj.GetComponent <BaseUI>(); if (UIScr == null) { Debug.Log("UI NotAddScript"); return(null); } HideCurMutex(); switch (UIScr.Type) { case UIType.Low: uiGameObj.transform.SetParent(_LowQue, false); break; case UIType.Normal: uiGameObj.transform.SetParent(_NormQue, false); //_BG.gameObject.active = true; break; } //ShowOPForUI(UIScr); _CurShowUI.Add(UIName, uiGameObj.transform); _GCUIDict.Remove(UIName); return(UIScr); }
public IEnumerator CloseWindow(BaseUI baseui) { if (currentUI.UIID == baseui.UIID) { yield return(baseui.ClosingAnim()); baseui.CloseCompleted(); baseui.OnClose(); if (uiwindowQueue.Count > 0) { BaseUI ui = uiwindowQueue[0]; uiwindowQueue.RemoveAt(0); yield return(ShowWindow(ui)); } } }
public void UIChange(WhichScene whichScene) { IsChanging = true; if (whichScene == WhichScene.DoubleBattle) { mTargetUI = mDoubleFightUI; } else if (whichScene == WhichScene.SingleFight) { mTargetUI = mSingleBalletUI; } else if (whichScene == WhichScene.MainTitle) { mTargetUI = mMainUI; } }
public BaseUI Add(UIList ui, bool state = true) { if (_uiDic.ContainsKey(ui)) { return(_uiDic[ui]); } BaseUI baseUI = Helper.Instantiate <BaseUI>(path + ui.ToString(), transform.position, Quaternion.identity, true, transform); if (baseUI != null) { baseUI.gameObject.SetActive(state); _uiDic.Add(ui, baseUI); } return(baseUI); }
//互斥窗口处理 隐藏当前已经打开的窗口 public void HideCurMutex() { //没有打开后需要隐藏的窗口 if (_NormQue.childCount < 1) { return; } //获取之前最后一个窗口 BaseUI ShowingWnd = GetCurUI(); //对上一个已打开窗口处理 若互斥则隐藏 if (ShowingWnd != null && ShowingWnd.Type == UIType.Mutex) { ShowingWnd.Hide(); } }
private bool ReleaseUI(BaseUI ui) { bool ret = false; if (ui == false) { return(ret); } List <BaseUI> uiList = GetCacheUI(typeof(BaseUI)); if (uiList != null) { ret = uiList.Remove(ui); } return(ret); }
void Start() { lineRend = GetComponent <LineRenderer>(); DrawDistanceZoneInitial(new Vector3(maxDistance, 0, 0)); armiesOut = new List <GameObject>(); structuresControlled = new List <GameObject>(); //Prepare BaseUI script baseUI = GetComponent <BaseUI>(); personalResources = 0; timeCounter = Time.time; this.GetComponent <SpriteRenderer>().sprite = territoryPrefabs[owner]; }
//关掉窗口后 处理上一个窗口 若隐藏则打开 public void ReShowUI() { if (_NormQue.childCount < 1) { return; } BaseUI ShowingWnd = GetCurUI(); if (ShowingWnd == null || ShowingWnd.Type != UIType.Mutex) { return; } else { ShowOPForUI(ShowingWnd); } }
/// <summary> /// 创建UI的实体部分 /// </summary> /// <param name="cmd">命令</param> private void _Create(Command cmd) { BaseUI ui = null; mDicUI.TryGetValue(cmd.uiName, out ui); if (ui != null) { if (cmd.listener != null) { cmd.listener.FiniSh(ui); } } else { ResMgr.Instance.Load(cmd.uiName, new LoadResFinish(cmd), typeof(GameObject), true); } }
private void ShowChatLogFrame() { this.m_chatLogFrame = UnityEngine.Object.Instantiate <ChatLogFrame>(this.m_Prefabs.m_ChatLogFrame); bool flag = base.transform.localScale == BaseUI.Get().m_Bones.m_QuickChatVirtualKeyboard.localScale; if ((((UniversalInputManager.Get().IsTouchMode() && W8Touch.s_isWindows8OrGreater) || W8Touch.Get().IsVirtualKeyboardVisible()) && flag) || flag) { this.DefaultChatTransform(); } this.m_chatLogFrame.transform.parent = base.transform; this.m_chatLogFrame.transform.position = this.m_Bones.m_ChatLog.position; if ((((UniversalInputManager.Get().IsTouchMode() && W8Touch.s_isWindows8OrGreater) || W8Touch.Get().IsVirtualKeyboardVisible()) && flag) || flag) { this.TransformChatForKeyboard(); } ChatMgr.Get().OnChatLogFrameShown(); }
/// <summary> /// 移除一个UI /// </summary> /// <param name="ui"></param> public void RemoveUI(BaseUI ui) { if (ui != null && mDicUI.ContainsKey(ui.UIName)) { mDicUI.Remove(ui.UIName); } }
public void Succeed(BaseUI baseUi) { throw new NotImplementedException(); }
public void FiniSh(BaseUI ui) { }