//右列表选择框位置调整 add by tianjinpeng 2018/03/09 15:29:54 void choicepos(int index) { if (baglist.numItems == 0) { } else { Vector2 screenPos = baglist.GetChildAt(index).LocalToGlobal(Vector2.zero); Vector2 sPos = new Vector2(screenPos.x - 2, screenPos.y - 1); Vector2 logicScreenPos = storeup.GlobalToLocal(sPos); //choice.position = new Vector2(logicScreenPos.x, logicScreenPos.y); killtweener(choicemove); choicemove = choice.TweenMove(logicScreenPos, 0.1f); } }
public void showAddMonsterEffect(Vector2 originPos, Vector2 toPosInGlobal, MonsterCardComponent item) { lockUI(); MonsterCardComponent copyView = (MonsterCardComponent)UIPackage.CreateObject("UIMain", "MonsterCard").asCom; //GTextField copyView = new GTextField(); copyView.setInfo(item.info); //Vector2 f = _new_item_list.GetChildAt (idx).position; copyView.sortingOrder = 100; copyView.alpha = 0; GRoot.inst.AddChild(copyView); copyView.position = new Vector2(originPos.x - copyView.width / 2, originPos.y - copyView.height / 2); //_main.AddChild (copyView); copyView.TweenFade(1, 0.4f).OnComplete(delegate() { copyView.TweenMove(_main.GlobalToLocal(toPosInGlobal), 0.6f).OnUpdate(delegate(GTweener tweener) { copyView.InvalidateBatchingState(); //float r = (tweener.deltaValue.vec2-tweener.startValue.vec2).magnitude/(tweener.endValue.vec2-tweener.startValue.vec2).magnitude; //r = 1-r*0.6f; //r = r*0.6; //copyView.scale = new Vector2(r,r); }).OnComplete(delegate() { //monsterContianer.GetChildAt(monsterContianer.numChildren-1).visible = true; item.visible = true; unlockUI(); copyView.TweenFade(0, 0.2f).OnComplete(delegate() { //_main.RemoveChild(copyView); GRoot.inst.RemoveChild(copyView); copyView.Dispose(); _enterBattle.visible = true; }); }); }); }
void UpdateDragPosition(Vector2 pos) { if (_coverTurningOp != CoverTurningOp.None) { _dragPoint = GlobalToLocal(pos) - _frontCoverPos; _turningAmount = _dragPoint.x / (2 * _frontCover.width); } else { _dragPoint = _pagesContainer.GlobalToLocal(pos); _turningAmount = _dragPoint.x / (2 * _pageWidth); } if (_draggingCorner == Corner.TR || _draggingCorner == Corner.BR) { _turningAmount = 1 - _turningAmount; } }
public override void ForceRefresh(object userData) { UserDialogParams = userData as DialogParams; if (UserDialogParams == null) { return; } Title = UserDialogParams.Title == null ? Title : UserDialogParams.Title; Mode = UserDialogParams.Mode == 0 ? 2 : UserDialogParams.Mode; Mode = Mathf.Min(Mathf.Max(1, Mode), 2); Title = string.IsNullOrEmpty(Title) ? "" : Title; modeCtl.SetSelectedIndex(Mode - 1); TitleLabel = SubCom.GetChild("title").asTextField; TitleLabel.text = Title; AddButtonClick(); var label = GComponent.GetChild("label"); if (label != null) { label.text = UserDialogParams.Message; } UserData = UserDialogParams.UserData; if (UserData != null && UserData is object[]) { var objs = UserData as object[]; if (objs.Length >= 4) { Vector3 pos = (Vector3)objs[1] + new Vector3(150, 0); //当前的l位置 Vector2 size = (Vector2)objs[2]; //限定范围宽度 Vector2 gPos = (Vector2)objs[3]; //当前所在范围内的 g位置 mOldPos = GComponent.GlobalToLocal(gPos) + new Vector2(150, 0); //当前所在的本地的老位置 ShowPos(pos, size); } } }
public static void AddArrowTalker(GameObject objListener, GameObject objTalker, GComponent frame, float posFrameTop, float posFrameBot, float posFrameLeft, float posFrameRight) { if (objTalker == null) { frame.SetXY(posFrameRight, posFrameBot); var tObj = frame.GetChild("talker"); if (tObj != null) { frame.GetChild("talker").visible = false; } } else if (objListener == null) { frame.SetXY(posFrameRight, posFrameBot); var tObj = frame.GetChild("talker"); if (tObj == null) { tObj = new GGraph(); tObj.name = "talker"; frame.AddChild(tObj); } else { tObj.visible = true; } GGraph graph = tObj.asGraph; // var pAgent = AutoTileMap_Editor.Instance.Agent.transform.position; var pTalk = objTalker.transform.position; Debug.Log("pAgent:" + pTalk.ToString()); var p = AutoTileMap_Editor.Instance.PlayCamera.WorldToScreenPoint(pTalk); Debug.Log("ScreenPoint:" + p.ToString()); var local = frame.GlobalToLocal(p); Debug.Log("local:" + local.ToString()); // Vector2 a = new Vector2(_c.width / 2, _c.height / 2); Vector2 a = new Vector2(80, 5); Vector2 b = new Vector2(a.x, a.y); // local = (local + a) * 0.75f + a; local = Vector2.Lerp(a, local, 0.5f); a.x = a.x - 30; b.x = b.x + 30; var shape = graph.shape; shape.DrawPolygon(new Vector2[] { local, a, b, }, shape.color); } else { var cam = AutoTileMap_Editor.Instance.PlayCamera; var pL = cam.WorldToScreenPoint(objListener.transform.position); var pT = cam.WorldToScreenPoint(objTalker.transform.position); // Debug.Log("Listen:" + pL.ToString()); // Debug.Log("Talk:" + pT.ToString()); Vector2 a = new Vector2(80, 5); if (pT.z > pL.z) { // Top frame.SetXY(pT.x > pL.x ? posFrameRight : posFrameLeft, posFrameTop); a.y = frame.height - 5; } else { // Bot frame.SetXY(pT.x > pL.x ? posFrameRight : posFrameLeft, posFrameBot); } if (posFrameRight <= posFrameLeft) { // a.x = (int)(frame.width / 2); if (pT.x > pL.x) { a.x = frame.width - 80; } } else if (pT.x < pL.x) { a.x = frame.width - 80; } var pTalk = objTalker.transform.position; var p = AutoTileMap_Editor.Instance.PlayCamera.WorldToScreenPoint(pTalk); var local = frame.GlobalToLocal(p); local = Vector2.Lerp(a, local, 0.5f); Vector2 b = new Vector2(a.x, a.y); a.x = a.x - 20; b.x = b.x + 20; var tObj = frame.GetChild("talker"); if (tObj == null) { tObj = new GGraph(); tObj.name = "talker"; frame.AddChild(tObj); } else { tObj.visible = true; } GGraph graph = tObj.asGraph; var shape = graph.shape; shape.DrawPolygon(new Vector2[] { local, a, b, }, shape.color); } }
private void Stage_Begin() { bool isOk = ModelManager.inst.userModel.GetUnlcok(Config.UNLOCK_TIP); if (!isOk) { return; } if (Stage.inst.touchCount > 1) { return; } DisplayObject ds = Stage.inst.touchTarget; if (ds == null || ds.gOwner == null) { return; } object[] n = touchs.Find((object[] obj) => { if (obj [0].ToString() == ds.gOwner.ToString().Replace("FairyGUI.", "")) { if (obj [1] == ds.gOwner) { return(true); } return(false); } else if (obj [0].ToString() == ds.gOwner.parent.ToString() && obj [1] == ds.gOwner.parent) { return(true); } return(false); }); if (n != null) { Vector2 v2 = Stage.inst.touchPosition; v2 = f.GlobalToLocal(v2); ModelManager.inst.alertModel.data = n [2]; ModelManager.inst.alertModel.type = n [0].ToString(); ModelManager.inst.alertModel.isTip = true; if (touch != null && touch.parent != null) { f.RemoveChild(touch.group); } touch = null; touch = new ComTip(); f.AddChild(touch.group); touch.group.x = v2.x; touch.group.y = v2.y; touch.UpdatePos(); float xx = touch.group.x + touch.group.width; float yy = touch.group.y + touch.group.height; if (touch.group.x < 0) { touch.group.x = 0; } if (touch.group.y < 30) { touch.group.y = 30; } float gw = GRoot.inst.width; float gh = GRoot.inst.height; if (xx > gw) { touch.group.x -= xx - gw; } if (yy > gh) { touch.group.y -= yy - gh; } } }
public void SetPosition(Vector3 gPosition, Vector2 size, bool move = true) { mOldPos = View.GlobalToLocal(gPosition) + (move ? new Vector2(100, 0) : Vector2.zero); ShowPos(mOldPos, size, move); }