public void DestoryApp(int index, bool anim) { appList.RemoveAt(index); IconController iconController = pageChildList [index].GetComponent <IconController> (); pageChildList.RemoveAt(index); iconController.DestorySelt(anim); }
void DestoryFirstEmptyOnDropPageAndResetDropInfo() { List <App> appList = launcherController.appList; List <GameObject> iconList = launcherController.pageChildList; GameObject dragIcon = swapInfo.dragIcon; IconController iconController = dragIcon.GetComponent <IconController> (); // launcherController.Log (TAG, "DestoryFirstEmptyOnDropPageAndResetDropInfo swapInfo.firstEmptyIconLocationOnDropPage:"+swapInfo.firstEmptyIconLocationOnDropPage); swapInfo.dropLocation = swapInfo.firstEmptyIconLocationOnDropPage; iconMovingInfo.dropIndex = swapInfo.firstEmptyIconIndexOnDropPage; appList.RemoveAt(swapInfo.firstEmptyIconIndexOnDropPage); iconList.RemoveAt(swapInfo.firstEmptyIconIndexOnDropPage); appList.Insert(swapInfo.firstEmptyIconIndexOnDropPage, swapInfo.dragModel); iconList.Insert(swapInfo.firstEmptyIconIndexOnDropPage, swapInfo.dragIcon); IconController firstPlaceholder = swapInfo.firstEmptyIconIconOnDropPage.GetComponent <IconController> (); firstPlaceholder.DestorySelt(true); }
//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); } } }