//icon 后移,遇到page末尾是空位就干掉空位并停止后移 public void IconBackward(int beginIndex, int endIndex, bool anim) { List <GameObject> iconList = pageChildList; Log(TAG, "IconBackward beginIndex:" + beginIndex + " endIndex:" + endIndex + " iconList size:" + iconList.Count); for (int i = beginIndex; i <= endIndex; i++) { GameObject icon = iconList [i]; IconController iconController = icon.GetComponent <IconController> (); App app = appList [i]; if (app.isPlaceholder && i % launcherModel.pageItemNum == (launcherModel.pageItemNum - 1)) { //page end iconList.RemoveAt(i); appList.RemoveAt(i); iconController.DestorySelt(anim); return; } if (i + 1 < iconList.Count) { GameObject nextIcon = iconList [i + 1]; Location toLocation = nextIcon.GetComponent <IconController> ().originLocation; Log(TAG, "IconBackward index:" + i + " originLocation:" + iconController.originLocation + " toLocation:" + toLocation); iconController.MoveToLocation(toLocation); } else { //create a new page Log(TAG, "IconBackward create a new page"); CreateNewPageAndFill(); GameObject nextIcon = iconList [i + 1]; Location toLocation = nextIcon.GetComponent <IconController> ().originLocation; iconController.MoveToLocation(toLocation); DestoryApp(appList.Count - launcherModel.pageItemNum, false); } } }
//icon 前移 public void IconAdvance(int toIndex, int beginIndex, int endIndex, bool anim) { List <GameObject> iconList = pageChildList; Location toLocation = iconList [toIndex].GetComponent <IconController> ().originLocation; for (int i = beginIndex; i <= endIndex; i++) { GameObject icon = iconList [i]; IconController iconController = icon.GetComponent <IconController> (); Location iconLocation = iconController.originLocation; if (iconController.regressLocation == null) { iconController.MoveToLocation(toLocation); } else { iconController.LocationRegress(); } toLocation = iconLocation; } }
void SamePageSwap(int drag, int drop) { List <GameObject> pageChildList = launcherController.pageChildList; List <App> appList = launcherController.appList; drop = AdjustSamePageDropIndex(drop); // Log(TAG, "ChildExChange: dragIndex:"+iconMovingInfo.dragIndex+" dropIndex:"+iconMovingInfo.dropIndex); GameObject childDrag = pageChildList [drag]; GameObject childDrop = pageChildList [drop]; Location dropPos3D = childDrop.GetComponent <IconController> ().originLocation; int moveNum = drop - drag; int absMoveNum = Mathf.Abs(moveNum); int nextIndex = drag; Location toLocation = pageChildList [drag].GetComponent <IconController>().originLocation; for (int i = 0; i < absMoveNum; i++) { nextIndex = moveNum > 0 ? nextIndex + 1 : nextIndex - 1; GameObject child = pageChildList [nextIndex]; IconController childControl = child.GetComponent <IconController> (); Location nextLocation = childControl.originLocation; childControl.MoveToLocation(toLocation); // Log (TAG, "nextPos icon:"+nextIndex+" oriLocation:"+nextLocation+" to Location:"+toLocation); toLocation = nextLocation; } childDrag.GetComponent <IconController> ().SetOriLocation(dropPos3D); App app = appList[drag]; appList.RemoveAt(drag); pageChildList.RemoveAt(drag); appList.Insert(drop, app); pageChildList.Insert(drop, childDrag); iconMovingInfo.dragIndex = iconMovingInfo.dropIndex; // Log(TAG, "CurrentPageSwap: childDrag:"+childDrag.GetComponent<IconController> ().originLocation+" childDrop:"+childDrop.GetComponent<IconController> ().originLocation); }