private void UpdateLinkAnchorAndShape(DragItem item, PointD locationFrom, PointD locationTo) { if (item == null) { return; } if (this.EdgePointType == EdgePointVMType.Start) { item.Thumb.Margin = new System.Windows.Thickness(locationFrom.X, locationFrom.Y, 0, 0); } else if (this.EdgePointType == EdgePointVMType.End) { item.Thumb.Margin = new System.Windows.Thickness(locationTo.X, locationTo.Y, 0, 0); } else { //... } FixedGeometryPoints fixedPoints = FixedGeometryPoints.Source; if (this.EdgePointType == EdgePointVMType.End) { fixedPoints = FixedGeometryPoints.Target; } else if (this.EdgePointType == EdgePointVMType.Normal) { fixedPoints = FixedGeometryPoints.None; } item.Path.Data = selectedItemVM.CalcPathGeometry(locationFrom, locationTo, fixedPoints, selectedItemVM.RoutingMode); }
public virtual void OnDrop(DragItem source) { IDockView child; if (source.RelativeObj is BaseFloatWindow) { child = (source.RelativeObj as BaseFloatWindow).Child; (source.RelativeObj as BaseFloatWindow).DetachChild(child); } else { child = source.RelativeObj as IDockView; } DockManager.FormatChildSize(child as ILayoutSize, new Size(ActualWidth, ActualHeight)); DockManager.ChangeDockMode(child, (Model as ILayoutGroup).Mode); DockManager.ChangeSide(child, Model.Side); //取消AttachObj信息 DockManager.ClearAttachObj(child); var group = Model as LayoutGroup; switch (DropMode) { case DropMode.Header: case DropMode.Center: if (DropMode == DropMode.Center) { _index = 0; } _AttachDockView(child as UIElement, group); break; } }
private void audiosListBox_DragEnter(object sender, DragEventArgs e) { ListBox lst = sender as ListBox; if (!e.Data.GetDataPresent(typeof(DragItem))) { e.Effects = DragDropEffects.None; } else if ((e.AllowedEffects & DragDropEffects.Move) == 0) { e.Effects = DragDropEffects.None; } else { DragItem drag_item = (DragItem)e.Data.GetData(typeof(DragItem)); if (drag_item.Client != lst) { e.Effects = DragDropEffects.None; } else { e.Effects = DragDropEffects.Move; } } }
private void zalupa_MouseDown(object sender, MouseButtonEventArgs e) { ListBox lst = sender as ListBox; int index = -1; for (int i = 0; i < audiosListBox.Items.Count; i++) { var lbi = audiosListBox.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem; if (lbi == null) { continue; } if (IsMouseOverTarget(lbi, e.GetPosition((IInputElement)lbi))) { index = i; break; } } lst.SelectedIndex = index; if (index < 0) { return; } DragItem drag_item = new DragItem(lst, index, lst.Items[index]); DragDrop.DoDragDrop(lst, drag_item, DragDropEffects.Move); }
public void OnDrop(PointerEventData eventData) { if (_dragItem == null) { return; } if (_dropItem != null) { if (_dragItem != null && itemReplacable) { _dropItem.dragSlot = _dragItem.dragSlot; } else { _dropItem.dragSlot = null; } } _dropItem = _dragItem; _dropItem.DropSlot(this); #if PLAYMAKER if (targetFSM != null) { FsmEventTarget fsmEventTarget = new FsmEventTarget(); fsmEventTarget.target = FsmEventTarget.EventTarget.FSMComponent; fsmEventTarget.fsmComponent = targetFSM; targetFSM.Fsm.Event(fsmEventTarget, eventName); } #endif OnDropItem.Invoke(); }
public void OnBeginDrag(PointerEventData eventData) { Slot = null; dragItem = this;// типа синглтон startPosition = transform.position; startParent = transform.parent; transform.SetParent(dragLayer); #region // в канвасах работает так - если ты находишься выше // (даже если не являешься родителем а всеголишь брат) // то и обьект находиться твой выше // т.е. твой луч врезается в тебя (если убрать блок рейкаст) // то ты становишься прозрачным. // а если ты навсегда оставляешь его прозрачным то // тебя не смогут найти другие обьекты. // в дальшейшем могут быть проблемы // если на тебя будут падать другие обьекты #endregion _canvasGroup.blocksRaycasts = false; _canvasGroup.alpha = 0.6f; }
public override void Dispose() { _target = null; _source = null; _activeRect = null; base.Dispose(); }
void Start() { _dManager = this.gameObject.AddComponent <DragManager> (); this.gameObject.AddComponent <EasyInput> (); DragItem item = GameObject.Instantiate(_phototype); item._id = 0; item._index = 0; item.transform.SetParent(this.transform); item.gameObject.SetActive(true); _dManager._list.Add(item); DragItem item2 = GameObject.Instantiate(_phototype); item2._id = 1; item2._index = 1; item2.transform.SetParent(this.transform); item2.gameObject.SetActive(true); _dManager._list.Add(item2); DragItem item3 = GameObject.Instantiate(_phototype); item3._id = 2; item3._index = 2; item3.transform.SetParent(this.transform); item3.gameObject.SetActive(true); _dManager._list.Add(item3); _dManager.reset(-1); }
/// <summary> /// 显示供选择的数据池 /// </summary> /// <param name="selectPoolDic"></param> private void ShowSelectPoolRoot(Dictionary <int, string> numIconDic) { GameObject stageObj = transform.Find("StagePanel/stage_" + GameData.Instance.GameStage + "/DragItemsPanel").gameObject; int num = stageObj.transform.childCount; for (int i = 1; i <= num; i++) { DragItem sc = stageObj.transform.Find("DragItem_" + i).GetComponent <DragItem>(); sc.Apply(numIconDic[i]); } /* for (int i = 1; i <= numIconDic.Count; i++) * { * GameObject go = Instantiate(DragItemTemplate); * go.name = "DragItem_" + i; * go.SetActive(true); * go.transform.parent = selectPoolWidget.transform; * go.transform.localScale = Vector3.one; * // go.transform.localPosition = Vector3.zero + new Vector3(0,200,0); * * DragItem sc = go.GetComponent<DragItem>(); * sc.Apply(numIconDic[i]); * * dragItemList.Add(go); * } * //设置grid的显示列数 * selectPoolWidget.transform.GetComponent<UIGrid>().maxPerLine = GameData.Instance.showColumn; * selectPoolWidget.transform.GetComponent<UIGrid>().Reposition(); * selectPoolWidget.transform.GetComponent<UIGrid>().repositionNow = true;*/ }
public void OnEndDrag(PointerEventData eventData) { dragItem = null; canvasGroup.blocksRaycasts = true; if (slot == null) { transform.SetParent(startParrent); transform.position = startPosition; } else { transform.SetParent(slot); transform.localPosition = Vector3.zero; countorOfOdersForGrouping = ordersForGrouping != null ? ordersForGrouping.Length : 0; foreach (var cell in ordersForGrouping) { if (cell.transform.childCount == 0) { countorOfOdersForGrouping--; } } if (countorOfOdersForGrouping == 0) { ShowButtonGo?.Invoke(true); } else { ShowButtonGo?.Invoke(false); } } slot = null; }
public void NextPhase(string _phase) { if (_phase.StartsWith("InSauce")) { activeItem = activeItemHolder.GetChild(0).GetComponent <DragItem>(); activeItem.TargetPoint = new Transform[] { EatPos }; } else if (_phase == "DSEat") { if (SoundManager.Instance != null) { SoundManager.Instance.StopAndPlay_Sound(SoundManager.Instance.EatSound); } Destroy(activeItem.gameObject); //dodaj PARTICLES activeItem = null; dimSumLeft--; Debug.Log("DSEat " + dimSumLeft); DragItem.OneItemEnabledNo = 1; if (dimSumLeft == 0) { Debug.Log("KRAJ"); if (SoundManager.Instance != null) { SoundManager.Instance.StopAndPlay_Sound(SoundManager.Instance.ActionCompleted); } gameTimer.StopTimer(); bEnableEat = false; StartCoroutine("LevelCompleted"); } } }
private void Start() { DragItem.ResetActionShowButtonGo(); DragItem.ShowButtonGo += ShowBattonGo; animator = GetComponent <Animator>(); go.SetActive(false); }
private int InsertOntoView(View view, DragItem item) { var positionEntered = GetListPositionForView(view); var correctedPosition = positionEntered; // If the view already has a translation, we need to adjust the position // If the view has a positive translation, that means that the current position // is actually one index down then where it started. // If the view has a negative translation, that means it actually moved // up previous now we will need to move it down. if (view.TranslationY > 0) { correctedPosition += 1; } else if (view.TranslationY < 0) { correctedPosition -= 1; } // If the current index of the dragging item is bigger than the target // That means the dragging item is moving up, and the target view should // move down, and vice-versa var translationCoef = item.Index > correctedPosition ? 1 : -1; // We translate the item as much as the height of the drag item (up or down) var translationTarget = view.TranslationY + (translationCoef * item.View.Height); ObjectAnimator anim = ObjectAnimator.OfFloat(view, "TranslationY", view.TranslationY, translationTarget); anim.SetDuration(100); anim.Start(); return(correctedPosition); }
private void CreateSoulDrag() { DragItem drag = null; drag = ui.Soul.gameObject.AddComponent <DragItem>(); drag.DragIcon = ui.Soul; drag.ToolTipEvent += OnShowSuitTipHandler; }
public void touchStart(DragItem item, float x){ Touch touch = new Touch(); touch.x = x; touch.item = item; fsm_.post ("drag", touch); }
internal BaseDropPanel(IDragTarget target, DragItem source) { _target = target; _source = source; //绘制停靠的区域 _activeRect = new ActiveRectDropVisual(DragManager.NONE); AddChild(_activeRect); }
private void OnEnable() { if (slotType == SlotType.SHOP) { DragItem itemDragUI = itemUI.GetComponent <DragItem>(); Destroy(itemDragUI); } }
private void OnTriggerExit2D(Collider2D collision) { if (dragItem != null && dragItem == collision.GetComponent <DragItem>()) { dragItem = null; InventoryManager.Instance.HideDragItemText(); } }
private void AddStack(ItemStack stack) { Slot freeSlot = slots.FirstOrDefault(x => !x.isBlock); DragItem dragItem = Instantiate(ResourcesLoader.LoadPref("ItemIcon")).GetComponent <DragItem>(); dragItem.InitItem(stack); dragItem.SetSlot(freeSlot); }
public void Action(DragItem dragItem) { var stack = dragItem.currentItemStack; if (state == TypeAction.Drop) { uiStore.storeComponent.DropStack(stack); } if (state == TypeAction.Split) { uiStore.storeComponent.Split(stack); } }
public void OnBeginDrag(PointerEventData eventData) { slot = null; dragItem = this; startPosition = transform.position; startParrent = transform.parent; transform.SetParent(dragLayer); canvasGroup.blocksRaycasts = false; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.GetComponent <DragItem>() && collision.GetComponent <DragItem>().item.Item != null) { dragItem = collision.GetComponent <DragItem>(); InventoryManager.Instance.ShowDragItemText(dragItem.item.Item.name, dragItem.transform.position); } }
public override void OnDrop(DragItem source) { if (DropMode == DropMode.Left || DropMode == DropMode.Right || DropMode == DropMode.Top || DropMode == DropMode.Bottom) { IDockView child; if (source.RelativeObj is BaseFloatWindow) { child = (source.RelativeObj as BaseFloatWindow).Child; (source.RelativeObj as BaseFloatWindow).DetachChild(child); } else { child = source.RelativeObj as IDockView; } DockManager.ChangeDockMode(child, (Model as ILayoutGroup).Mode); //must to changside DockManager.ChangeSide(child, Model.Side); LayoutGroupPanel panel; if (DockViewParent == null) { var wnd = Parent as BaseFloatWindow; wnd.DetachChild(this); panel = new LayoutGroupPanel(Model.Side) { Direction = (DropMode == DropMode.Left || DropMode == DropMode.Right) ? Direction.Horizontal : Direction.Vertical, DesiredWidth = wnd.ActualWidth, DesiredHeight = wnd.ActualHeight, IsAnchorPanel = true }; wnd.DockManager = DockManager; wnd.AttachChild(panel, AttachMode.None, 0); panel._AttachChild(this, 0); } else { panel = DockViewParent as LayoutGroupPanel; } AttachTo(panel, child, DropMode); } else { base.OnDrop(source); } if (source.RelativeObj is BaseFloatWindow) { (source.RelativeObj as BaseFloatWindow).Close(); } }
public void OnEndDrag(PointerEventData eventData) { dragItem = null; canvasGroup.blocksRaycasts = true; if (slot == null) { transform.SetParent(startParrent); transform.position = startPosition; } slot = null; }
internal RootDropPanel(IDragTarget target, DragItem source) : base(target, source) { //绘制左边的拖放区域 AddChild(new UnitDropVisual(DragManager.LEFT)); //绘制顶部的拖放区域 AddChild(new UnitDropVisual(DragManager.TOP)); //绘制右边的拖放区域 AddChild(new UnitDropVisual(DragManager.RIGHT)); //绘制底部的拖放区域 AddChild(new UnitDropVisual(DragManager.BOTTOM)); }
public virtual bool BlockSlot(DragItem dragItem) { if(isBlock) { blockedItem.currentItemStack.AddStack(dragItem.currentItemStack); return false; } else { blockedItem = dragItem; block = true; storeController.storeComponent.AddNewStack(dragItem.currentItemStack); return true; } }
public void OnBeginDrag(PointerEventData data) { OldParent = transform.parent; OldPos = transform.localPosition; FindObjectOfType <InventoryUI>().OnDrag(this); GetComponent <Image>().raycastTarget = false; transform.parent = GetComponentInParent <Canvas>().transform; CurrentDragged = this; }
void PerformNavigationStart(Vector3 position) { if (GestureManager.Instance.focusedGameObject_ != null) { DragItem item = GestureManager.Instance.focusedGameObject_.GetComponent <DragItem>(); if (item != null) { dManager_.touchStart(item, position.x); } } // audioSource.Play(); }
protected virtual void ConfigUI() { iconAtlas = UIAtlasManager.GetInstance().GetUIAtlas("SkillAtlas"); icon = NGUITools.AddChild <UISprite>(gameObject); icon.atlas = iconAtlas; icon.spriteName = "lock"; icon.depth = 100; icon.MakePixelPerfect(); drag = gameObject.AddComponent <DragItem>(); drag.DragType = DRAG_TYPE; }
private State getInput(){ State state = new State (); state.addAction ("drag", delegate(FSMEvent evt) { Touch touch = (Touch)(evt.obj); curr_ = touch.item; //begin_ = touch.x; return "drag"; }); return state; }
public void XYLMatchSwitch(string nam) { if (GameObject.Find("Canvas/BottomCollectBtns/CenterMaterialPart/" + "XY") != null) { this.dragItem = GameObject.Find("Canvas/BottomCollectBtns/CenterMaterialPart/" + "XY").GetComponent <DragItem>(); } else { this.transform.GetChild(0).gameObject.SetActive(false); return; } this.XYClick = this.dragItem.collectBtnClick; //XYL单独处理 if (nam.Equals("XY")) { this.XYClick.material = Material.XY; this.XYClick.materialPanelIndex = 0; this.XYClick.factor = 4; } if (nam.Equals("XYL")) { this.XYClick.material = Material.XYL; this.XYClick.materialPanelIndex = 7; this.XYClick.factor = 40; if (MatchingBarManager.Instance.partDictionary.ContainsKey(Material.XYL.ToString())) { GameObject temp; if (MatchingBarManager.Instance.partDictionary.TryGetValue(Material.XYL.ToString(), out temp)) { if (Int32.Parse(temp.transform.GetChild(0).GetComponent <Text>().text) >= 80) { Debug.Log("到达上限了,不要再加工了"); this.inUse = false; this.XYClick.materialPanelIndex = 0; if (tempXYLCollect != null) { this.tempXYLCollect.materialPanelIndex = 0; } this.transform.GetChild(0).gameObject.SetActive(false); return; } } } } if (TextCountManager.Instance.CheckPartTextCount(XYClick)) { this.transform.GetChild(0).gameObject.SetActive(false); return; } this.GetComponent <MatchingBar>().CreateMatchingMaterial(XYClick, this, this.dragItem); this.transform.GetChild(0).gameObject.SetActive(false); }
private void SlicePic() { sliceContent.gameObject.SetActive(true); showImage.gameObject.SetActive(false); Texture2D slicePic_t2d = showImage.sprite.texture; if (slicePic_t2d == null) { return; } if (listTextures.Count > 0) { foreach (Texture2D t1 in listTextures) { DestroyImmediate(t1); } } listTextures = new List <Texture2D> (); listTextures.Clear(); returnAllChild(sliceContent.transform); listItem = new List <DragItem> (); listItem.Clear(); int difficultDegree = MainUIController.Instance.DifficultDegree; float _w = slicePic_t2d.width; float _h = slicePic_t2d.height; int _offsetW = (int)(_w / difficultDegree); int _offsetH = (int)(_h / difficultDegree); gridLayout.cellSize = showImage.rectTransform.rect.size / difficultDegree; gridLayout.constraintCount = difficultDegree; for (int i = 0; i < difficultDegree; i++) //高度 行 { for (int j = 0; j < difficultDegree; j++) //宽度 列 { Texture2D _temp = new Texture2D(_offsetW, _offsetH, TextureFormat.RGB24, false); DragItem _item = getItemDrag().GetComponent <DragItem>(); _item.transform.SetParent(sliceContent.transform, false); int n = (i * difficultDegree + j); _item.name = n + "_itme"; _temp.SetPixels(slicePic_t2d.GetPixels(j * _offsetW, i * _offsetH, _offsetW, _offsetH)); _temp.Apply(); listTextures.Add(_temp); listItem.Add(_item); } } fillImageForItems(); tips.text = "拖拽移动..."; }
private bool ItemCanDrop(DragItem DragItem) { if (DragItem == null) return false; if (transform.childCount != 0) { if (DragItem.GetComponent<Item>().Data.Type != ItemSlotType.Consumable) { return false; } else { if (transform.GetChild(0).GetComponent<Item>().Data.Name == DragItem.gameObject.GetComponent<Item>().Data.Name) { int Num1, Num2, Num3; Num1 = transform.GetChild(0).GetComponent<Item>().Data.Amount; Num2 = DragItem.gameObject.GetComponent<Item>().Data.Amount; Num3 = Num1 + Num2; if (Num3 > InventoryControl.SlotCapcity) { Num1 = InventoryControl.SlotCapcity; Num2 = Num3 - InventoryControl.SlotCapcity; transform.GetChild(0).GetComponentInChildren<Text>().text = Num1.ToString(); DragItem.GetComponentInChildren<Text>().text = Num2.ToString(); return false; } else { DragItem.GetComponentInChildren<Text>().text = Num3.ToString(); Destroy(transform.GetChild(0).gameObject); return true; } } else { return false; } } } else return true; }
private void clbShipDetail_MouseDown(object sender, MouseEventArgs e) { if (e.Button != System.Windows.Forms.MouseButtons.Left) return; int dragIndex = clbShipDetail.IndexFromPoint(e.Location); if (dragIndex == -1) return; var dragItem = new DragItem(clbShipDetail,dragIndex); clbShipDetail.DoDragDrop(dragItem, DragDropEffects.All); }
private void UpdateLinkAnchorAndShape(DragItem item, PointD locationFrom, PointD locationTo) { if (item == null) return; if (this.EdgePointType == EdgePointVMType.Start) item.Thumb.Margin = new System.Windows.Thickness(locationFrom.X, locationFrom.Y, 0, 0); else if (this.EdgePointType == EdgePointVMType.End) item.Thumb.Margin = new System.Windows.Thickness(locationTo.X, locationTo.Y, 0, 0); else { //... } FixedGeometryPoints fixedPoints = FixedGeometryPoints.Source; if (this.EdgePointType == EdgePointVMType.End) fixedPoints = FixedGeometryPoints.Target; else if (this.EdgePointType == EdgePointVMType.Normal) fixedPoints = FixedGeometryPoints.None; item.Path.Data = selectedItemVM.CalcPathGeometry(locationFrom, locationTo, fixedPoints, selectedItemVM.RoutingMode); }
private void AddLinkAnchorAndShape(PointD locationFrom, PointD locationTo) { DragItem dragItem = new DragItem(); Rectangle r = new Rectangle(); r.Stroke = new SolidColorBrush(Colors.Black); r.StrokeThickness = 1.0; r.Width = this.ActualWidth; r.Height = this.ActualHeight; if (this.EdgePointType == EdgePointVMType.Start) r.Margin = new System.Windows.Thickness(locationFrom.X, locationFrom.Y, 0, 0); else if (this.EdgePointType == EdgePointVMType.End) r.Margin = new System.Windows.Thickness(locationTo.X, locationTo.Y, 0, 0); else { //... } dragItem.Thumb = r; FixedGeometryPoints fixedPoints = FixedGeometryPoints.Source; if (this.EdgePointType == EdgePointVMType.End) fixedPoints = FixedGeometryPoints.Target; else if (this.EdgePointType == EdgePointVMType.Normal) fixedPoints = FixedGeometryPoints.None; Path path = new Path(); path.Data = selectedItemVM.CalcPathGeometry(locationFrom, locationTo, fixedPoints, selectedItemVM.RoutingMode); path.Stroke = new SolidColorBrush(Colors.Black); path.StrokeThickness = 1.0; dragItem.Path = path; dragCanvas.Children.Add(dragItem); }
public void CancelDelete() { CheckDele.ResetItem(); CheckDele = null; gameObject.SetActive(false); }
public override bool BlockSlot(DragItem dragItem) { Action(dragItem); return false; }
public void Delete() { CheckDele.DeleteItem(); CheckDele = null; gameObject.SetActive(false); }
public void OpenDelItemPanel(DragItem Item) { gameObject.SetActive(true); CheckDele = Item; }