void OnInitialize() { UITextList uiTextList = _textListCollider.GetComponent <UITextList>(); _textLabel.lineWidth = Mathf.FloorToInt(uiTextList.maxWidth); string versionNumString = string.Format(Localization.instance.Get("IDS_SETTING_ABOUT"), AppVersion.GetCurrentVersionString()); string versionAppString = string.Format(Localization.instance.Get("IDS_SETTING_ABOUT2"), AppVersion.GetCurrentBuildString()); _textLabel.text = versionNumString + "\n" + Localization.instance.Get("IDS_SETTING_CREDITS") + "\n" + versionAppString + "(" + FCDownloadManager.Instance.CurrentAssetBundleTag + ")"; _textHeight = _textLabel.relativeSize.y * _textLabel.transform.localScale.y; _textListCollider.size = new Vector3(_textListCollider.size.x, _textHeight, _textListCollider.size.z); _textListCollider.center = new Vector3(_textListCollider.center.x, -_textHeight / 2.0f, _textListCollider.center.z); _springPanel = _draggablePanel.gameObject.GetComponent <SpringPanel>(); _textListPanelTrans = _draggablePanel.gameObject.transform; _boardHeight2D = _draggablePanel.gameObject.GetComponent <UIPanel>().clipRange.w / 2.0f; _draggablePanel.ResetPosition(); _draggablePanel.MoveRelative(new Vector3(0, -_boardHeight2D, 0)); _isPressing = false; _isStarting = true; StartCoroutine("WaitAWhile"); }
public void AddText(string txt) { if (textList.Count == 0) { UILabel label = msg.GetComponent <UILabel>(); label.text = txt; label.MakePixelPerfect(); AddLabel(label); msg.name = "0"; } else if (textList.Count >= MaxLine) { UILabel label = textList[0]; textList.Remove(label); Vector3 pos = msg.transform.localPosition; UILabel temp = msg.GetComponent <UILabel>(); pos.y -= temp.height; label.transform.localPosition = pos; label.text = txt; label.MakePixelPerfect(); AddLabel(label); msg = label.gameObject; } else { GameObject obj = GameObject.Instantiate(msg) as GameObject; obj.transform.parent = msg.transform.parent; obj.name = (int.Parse(msg.name) + 1).ToString(); Vector3 pos = msg.transform.localPosition; UILabel label = msg.GetComponent <UILabel>(); pos.y -= label.height; obj.transform.localPosition = pos; label = obj.GetComponent <UILabel>(); label.text = txt; label.MakePixelPerfect(); AddLabel(label); msg = obj; } UIDraggablePanel panel = GetComponent <UIDraggablePanel>(); float size = panel.bounds.size.y; if (size > 300) { Vector3 pos = panel.transform.localPosition; Vector3 pos1 = msg.transform.localPosition; pos.y = (Mathf.Abs(pos1.y) - 152 - pos.y); panel.MoveRelative(pos); } }
public void ChooseTattoo(TattooData td) { _selectedTD = td; float x = recipeGrid.cellHeight * (td.ord + td.level - 1); UIRecipeItem recipeItem = _recipeItemList.Find(delegate(UIRecipeItem rcp) { return(!rcp.IsSummaryLine && rcp.ttData.tattooID == td.tattooID); }); this.SetFocus(recipeItem); //select it! UIDraggablePanel panel = recipeGrid.transform.parent.GetComponent <UIDraggablePanel>(); panel.ResetPosition(); panel.MoveRelative(x * Vector3.up); }
public static Bounds FocusClipPanelOnPosition(Vector3 worldPosition, UIPanel clipPanel, UIDraggablePanel dragPanel, float normalizedRange, float minBrowserPosition) { Bounds browserBounds; if (!IsClipPanelPositionVisible(worldPosition, clipPanel, normalizedRange, out browserBounds)) { Vector3 targetPosition = browserBounds.center; targetPosition.y = targetPosition.y + (browserBounds.size.y / 2); targetPosition = clipPanel.transform.InverseTransformPoint(browserBounds.center); //move the background by the amount of space it would take to reach the object Vector3 relativeDifference = targetPosition - clipPanel.transform.InverseTransformPoint(worldPosition); relativeDifference.z = 0f; relativeDifference.x = 0f; //should we really do this...? dragPanel.MoveRelative(relativeDifference, true, minBrowserPosition); dragPanel.UpdateScrollbars(true, true); //Debug.Log("world position " + worldPosition.ToString() + " was NOT visible in clip panel " + clipPanel.name + ", moving " + relativeDifference.y.ToString()); } return(browserBounds); }
void Update() { if (m_moveRelativeVec != Vector3.zero) { if (m_CurDragPanel == null) { return; } NGUITools.SetActive(m_CurDragPanel.gameObject, true); UIDraggablePanel moveDragPanel = m_CurDragPanel.GetComponent <UIDraggablePanel>(); if (moveDragPanel != null) { //moveDragPanel.currentMomentum = m_moveRelativeVec; moveDragPanel.MoveRelative(m_moveRelativeVec); } m_moveRelativeVec = Vector3.zero; } }
public void RepositionEx(bool isX = false) { if (_ParentPanel != null) { Transform tmpTrans = _ParentPanel.GetComponent <Transform>(); if (tmpTrans != null) { Vector3 deta = _InitPosition - tmpTrans.localPosition; Vector3 move = Vector3.zero; //暂时默认没有同时移动x跟y的拖动 if (isX) { move = new Vector3(deta.x, 0, 0); } else { move = new Vector3(0, deta.y, 0); } _ParentPanel.DisableSpring(); _ParentPanel.MoveRelative(move); } } }
public void OnShowRankMenu() { gameObject.SetActive(true); m_CharmFlowerBt.SetActive(GlobalData.IsOpenCharmRankFlag); m_CharmEggBt.SetActive(GlobalData.IsOpenCharmRankFlag); UIDraggablePanel panelDragble = m_MenuPanel.GetComponent <UIDraggablePanel>(); if (panelDragble != null) { //Transform tmpTrans = panelDragble.GetComponent<Transform>(); Transform panelDragTrans = m_MenuPanel.GetComponent <Transform>(); if (panelDragTrans != null) { Vector3 deta = m_MenuPanelPos - panelDragTrans.localPosition; Vector3 move = Vector3.zero; move = new Vector3(0, deta.y, 0); panelDragble.DisableSpring(); panelDragble.MoveRelative(move); } } //m_UIGrid.repositionNow = true; }
public void Run() { //sdUICharacter.Instance.HideMask(); needShowPoint = false; sdUICharacter.Instance.MsgClickCancel(); int num = 0; string[] param = opParam.ToString().Split(';'); if ((opType & (int)GuideOperationType.None) > 0) { } if ((opType & (int)GuideOperationType.ShowArrow) > 0) { if (param.Length > num) { string objName = param[num]; GameObject obj = GameObject.Find(objName); sdUICharacter.Instance.ShowArrow(obj); ++num; } } if ((opType & (int)GuideOperationType.ShowPoint) > 0) { if (param.Length > num) { ShowPoint(param[num]); ++num; } } if ((opType & (int)GuideOperationType.ShowWord) > 0) { if (param.Length > num) { string word = param[num]; if (sdGameLevel.instance == null) { return; } sdMovieDialogue dlg = sdGameLevel.instance.gameObject.GetComponent <sdMovieDialogue>(); if (dlg == null) { dlg = sdGameLevel.instance.gameObject.AddComponent <sdMovieDialogue>(); } if (dlg != null) { dlg.SetMovieInfo(int.Parse(word), true, true, Vector3.one, Vector3.zero); sdGameLevel.instance.guideDialogueEnd += OnFinish; ++num; } } } if ((opType & (int)GuideOperationType.ShowEffect) > 0) { if (param.Length > num) { string word = param[num]; string[] wordlist = word.Split('|'); GameObject item = GameObject.Find(wordlist[0]); ResLoadParams p = new ResLoadParams(); p.info = "effect"; p.userdata0 = item; sdResourceMgr.Instance.LoadResource(wordlist[1], LoadEffect, p); ++num; } } if ((opType & (int)GuideOperationType.HideObj) > 0) { if (param.Length > num) { string objName = param[num]; GameObject obj = GameObject.Find(objName); if (obj != null) { obj.SetActive(false); if (!sdGuideMgr.Instance.hideList.Contains(objName)) { sdGuideMgr.Instance.hideList.Add(objName, obj); } else { sdGuideMgr.Instance.hideList[objName] = obj; } } ++num; } } if ((opType & (int)GuideOperationType.ShowObj) > 0) { if (param.Length > num) { string objName = param[num]; if (sdGuideMgr.Instance.hideList[objName] != null) { GameObject obj = sdGuideMgr.Instance.hideList[objName] as GameObject; obj.SetActive(true); } ++num; } } if ((opType & (int)GuideOperationType.PointEquip) > 0) { if (param.Length > num) { sdUICharacter.Instance.tipCanEquip = true; if (sdGameLevel.instance == null || sdGameLevel.instance.mainChar == null) { return; } string tid = ""; string[] wordlist = param[num].Split('|'); if (wordlist.Length == 1) { Hashtable needEquip = new Hashtable(); Hashtable itemTable = sdGameItemMgr.Instance.GetAllItem((int)PanelType.Panel_Bag, -1); foreach (DictionaryEntry itemInfo in itemTable) { sdGameItem item = itemInfo.Value as sdGameItem; if (item.equipPos < 0) { continue; } if (!item.CanEquip(sdGameLevel.instance.mainChar)) { continue; } if (needEquip.ContainsKey(item.equipPos)) { sdGameItem maxItem = needEquip[item.equipPos] as sdGameItem; int maxScore = sdConfDataMgr.Instance().GetItemScore(maxItem.instanceID); int curScore = sdConfDataMgr.Instance().GetItemScore(item.instanceID); if (curScore > maxScore) { needEquip[item.equipPos] = item; } } else { needEquip.Add(item.equipPos, item); } } foreach (DictionaryEntry itemInfo in needEquip) { sdGameItem item = itemInfo.Value as sdGameItem; sdGameItem compareItem = sdGameItemMgr.Instance.getEquipItemByPos(item.equipPos); if (compareItem == null) { tid = item.templateID.ToString(); break; } int score = sdConfDataMgr.Instance().GetItemScore(item.instanceID); int compareScore = sdConfDataMgr.Instance().GetItemScore(compareItem.instanceID); if (score > compareScore) { tid = item.templateID.ToString(); break; } } } else { int job = int.Parse(sdGameLevel.instance.mainChar.GetProperty()["Job"].ToString()); if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Warrior) { tid = wordlist[0]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Magic) { tid = wordlist[1]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Rogue) { tid = wordlist[2]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Minister) { tid = wordlist[3]; } } Hashtable info = sdConfDataMgr.Instance().GetItemById(tid); sdSlotMgr.Instance.GotoEquip(int.Parse(info["Character"].ToString())); Hashtable table = sdSlotMgr.Instance.GetIconList(PanelType.Panel_Bag); foreach (DictionaryEntry item in table) { sdSlotIcon icon = item.Value as sdSlotIcon; if (icon.tempId == tid) { icon.gameObject.name = "guide_item"; ShowPoint(icon.gameObject.name + "|1"); } } ++num; } } if ((opType & (int)GuideOperationType.JumpMap) > 0) { Debug.Log(string.Format("guide:{0}", id)); sdUICharacter.JumpToWorldMap(); } if ((opType & (int)GuideOperationType.SmallWord) > 0) { if (param.Length > num) { string word = param[num]; if (sdGameLevel.instance == null) { return; } sdGuideDialogue dlg = sdGameLevel.instance.gameObject.GetComponent <sdGuideDialogue>(); if (dlg == null) { dlg = sdGameLevel.instance.gameObject.AddComponent <sdGuideDialogue>(); } if (dlg != null) { string[] wordlist = word.Split('|'); Vector3 pos = Vector3.zero; if (wordlist.Length >= 3) { string posStr = wordlist[2]; string[] posList = posStr.Split('@'); pos.y = int.Parse(posList[1]); pos.x = int.Parse(posList[0]); } dlg.SetMovieInfo(int.Parse(wordlist[1]), new Vector3(1f, 1f, 1f), pos); //sdGameLevel.instance.mainCamera.GetComponent<sdGameCamera>().zoomEnd += OnFinish; ++num; } } } if ((opType & (int)GuideOperationType.Spec) > 0) { if (param.Length > num) { string tid = param[num]; if (tid == "2") { EventDelegate finish = new EventDelegate(OnFinish); sdUICharacter.Instance.ShowGuideRoll(finish); } else if (tid == "3") { if (sdGameLevel.instance != null) { sdGameLevel.instance.AutoMode = true; sdGameLevel.instance.FullAutoMode = false; } } else if (tid == "4") { sdUICharacter.Instance.tipCanEquip = false; } ++num; } } if ((opType & (int)GuideOperationType.OpenFrame) > 0) { GameObject panel = GameObject.Find("Sys1"); if (panel != null) { GameObject btn = GameObject.Find("Btn_Push"); UISprite sp = btn.transform.FindChild("Background").GetComponent <UISprite>(); sdRoleWndButton.sysPanelPos = panel.transform.localPosition.x; panel.transform.localPosition = new Vector3(640.0f - 120.0f * panel.transform.localScale.x, panel.transform.localPosition.y, panel.transform.localPosition.z); sp.spriteName = "btn_c"; } } if ((opType & (int)GuideOperationType.PointItemUp) > 0) { if (param.Length > num) { if (sdGameLevel.instance == null || sdGameLevel.instance.mainChar == null) { return; } sdUICharacter.Instance.tipCanEquip = true; string tid = ""; string[] wordlist = param[num].Split('|'); int job = int.Parse(sdGameLevel.instance.mainChar.GetProperty()["Job"].ToString()); if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Warrior) { tid = wordlist[0]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Magic) { tid = wordlist[1]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Rogue) { tid = wordlist[2]; } else if (job == (int)HeaderProto.ERoleJob.ROLE_JOB_Minister) { tid = wordlist[3]; } Hashtable iconList = sdSlotMgr.Instance.GetIconList(PanelType.Panel_ItemSelect); foreach (DictionaryEntry item in iconList) { sdSlotIcon icon = item.Value as sdSlotIcon; if (icon.tempId == tid) { UIDraggablePanel panel = icon.GetComponentInParent <UIDraggablePanel>(); Vector3 pos = Vector3.zero; pos.y = -icon.transform.localPosition.y; panel.MoveRelative(pos); panel.UpdateScrollbars(true); icon.gameObject.name = "guide_item"; ShowPoint(icon.gameObject.name + "|1"); break; } } ++num; } } if ((opType & (int)GuideOperationType.LockTown) > 0) { sdUICharacter.Instance.bLockTown = true; } WaitForEvetnt(); }
void OnPanelDrag(Vector2 offset) { if (!bCheck) { return; } if (topCheckTrans == null || bottomCheckTrans == null) { return; } if (offset.y < 0) { float bottomMarkRelatePos = transform.InverseTransformPoint(bottomMarkTrans.position).y; //Debug.LogWarning("bottom pos: " + bottomMarkRelatePos); if (bottomMarkRelatePos > bottomItemOffsetForPanel) { RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().OnClickPrePage(); int index = 10 + RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().addItemCount; if (index == 10) { return; } SetBottomTargetItem(RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().m_gridFoodItemList[index - 1].gameObject); Bounds checkBounds = NGUIMath.CalculateRelativeWidgetBounds(transform, bottomTargetTrans); float targetPos = checkBounds.center.y - checkBounds.extents.y; bCheck = false; dragPanel.MoveRelative(new Vector2(0, bottomItemOffsetForPanel - targetPos)); dragPanel.RestrictWithinBounds(true); bCheck = true; } } else if (offset.y > 0) { float TopMarkRelatePos = transform.InverseTransformPoint(TopMarkTrans.position).y; if (TopMarkRelatePos < topItemOffsetForPanel) { RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().OnClickNextPage(); int index = 6 - RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().addItemCount; //Debug.Log("countttttttttt" + index); if (index == 6) { return; } SetTopTargetItem(RestaurantController.Instance().m_FoodWindow.GetComponent <RestaurantFoodWindow>().m_gridFoodItemList[index - 1].gameObject); Bounds checkBounds = NGUIMath.CalculateRelativeWidgetBounds(transform, topTargetTrans); float targetPos = checkBounds.center.y + checkBounds.extents.y; bCheck = false; dragPanel.MoveRelative(new Vector2(0, topItemOffsetForPanel - targetPos)); dragPanel.RestrictWithinBounds(true); bCheck = true; } } }
public void Notify(int panelType) { if (armorBtn == null) { armorBtn = GameObject.Find("tab_armor"); } if (weaponBtn == null) { weaponBtn = GameObject.Find("tab_weapon"); } if (shipinBtn == null) { shipinBtn = GameObject.Find("tab_shipin"); } if ((panelType & (int)PanelType.Panel_Bag) > 0) { if (copyItem != null && Instance.m_PanelList.Count != 0 && Instance.m_PanelList.ContainsKey(PanelType.Panel_Bag)) { float bagScrollValue = 0f; UIDraggablePanel panel = copyItem.transform.parent.GetComponent <UIDraggablePanel>(); if (panel != null) { if (isFirst) { bagScrollValue = 0; isFirst = false; } else { bagScrollValue = panel.verticalScrollBar.value; } panel.ResetPosition(); } Hashtable itemTable = sdGameItemMgr.Instance.GetAllItem(1, itemFilter); Hashtable list = Instance.m_PanelList[PanelType.Panel_Bag]; if (itemTable.Count > list.Count) { if (copyItem == null) { Debug.LogWarning("NoCopyItem"); } copyItem.SetActive(true); for (int i = list.Count; i < itemTable.Count; ++i) { GameObject tempItem = GameObject.Instantiate(copyItem) as GameObject; tempItem.transform.parent = copyItem.transform.parent; Vector3 pos = copyItem.transform.localPosition; pos.y -= i * 100; tempItem.transform.localPosition = pos; tempItem.transform.localScale = copyItem.transform.localScale; sdSlotIcon icon = tempItem.GetComponent <sdSlotIcon>(); if (icon != null) { icon.index = i; RegisterSlot(icon); } } } else if (itemTable.Count < list.Count) { foreach (DictionaryEntry item in list) { sdSlotIcon icon = item.Value as sdSlotIcon; if (icon != null && icon.index >= itemTable.Count) { if (icon.index == 0) { copyItem.SetActive(false); } else { icon.gameObject.SetActive(false); } } } } else { copyItem.SetActive(true); } if (panel != null) { panel.ResetPosition(); } IDictionaryEnumerator iter = list.GetEnumerator(); ArrayList itemList = new ArrayList(itemTable.Values); if (itemList != null) { itemList.Sort(); bool needRepos = false; if (itemLocation != HeaderProto.ERoleItemEquipSlot.RoleItemEquipSlot_Equip_Max) { needRepos = true; } foreach (sdGameItem info in itemList) { iter.MoveNext(); if (iter == null) { break; } //sdGameItem info = (sdGameItem)item.Value; if (info.bagIndex != (int)PanelType.Panel_Bag) { continue; } //if (info.slotIndex != num) continue; Hashtable table = new Hashtable(); sdSlotIcon icon = (sdSlotIcon)iter.Value; table.Add("uuid", info.instanceID); table.Add("ID", info.templateID); table.Add("count", info.count); icon.SetInfo(info.instanceID.ToString(), table); icon.gameObject.SetActive(true); if (needRepos && sdConfDataMgr.Instance().IsItemRightType(itemLocation, info.equipPos)) { UIDraggablePanel drag = icon.transform.parent.GetComponent <UIDraggablePanel>(); if (drag != null) { //drag.disableDragIfFits = false; drag.MoveRelative(-icon.transform.localPosition); drag.UpdateScrollbars(true); bagScrollValue = drag.verticalScrollBar.value; needRepos = false; itemLocation = HeaderProto.ERoleItemEquipSlot.RoleItemEquipSlot_Equip_Max; //drag.disableDragIfFits = true; sdRadioButton btn = null; if (itemFilter == (int)ItemFilter.Weapon) { btn = weaponBtn.GetComponent <sdRadioButton>(); } else if (itemFilter == (int)ItemFilter.Armor) { btn = armorBtn.GetComponent <sdRadioButton>(); } else if (itemFilter == (int)ItemFilter.Shipin) { btn = shipinBtn.GetComponent <sdRadioButton>(); } if (btn != null) { sdUICharacter.Instance.ActiceRadioBtn(btn); btn.Active(true); } } } else { if (itemFilter == lastFilter) { if (panel != null) { panel.verticalScrollBar.value = bagScrollValue; } } } } } lastFilter = itemFilter; } } if ((panelType & (int)PanelType.Panel_Equip) > 0) { if (Instance.m_PanelList.Count > 0 && Instance.m_PanelList.ContainsKey(PanelType.Panel_Equip)) { Hashtable list = Instance.m_PanelList[PanelType.Panel_Equip]; IDictionaryEnumerator iter = list.GetEnumerator(); Hashtable itemTable = sdGameItemMgr.Instance.GetAllItem(2, -1); if (itemTable != null) { while (iter.MoveNext()) { sdSlotIcon icon = (sdSlotIcon)iter.Value; if (icon == null) { continue; } bool findFlag = false; foreach (DictionaryEntry item in itemTable) { sdGameItem info = (sdGameItem)item.Value; if (info.bagIndex != (int)PanelType.Panel_Equip) { continue; } Hashtable tempItem = sdConfDataMgr.Instance().GetItemById(info.templateID.ToString()); if (tempItem != null) { int itemPos = int.Parse(tempItem["Character"].ToString()); if (itemPos == icon.index) { findFlag = true; } } if (findFlag) { Hashtable table = new Hashtable(); table.Add("uuid", info.instanceID); table.Add("ID", info.templateID); table.Add("count", info.count); icon.SetInfo(info.instanceID.ToString(), table); break; } } if (!findFlag) { icon.SetInfo("", null); } } } } } }