public void Reset() { if (SelectedOne != null) { SelectedOne.Select(); SelectedOne = null; } CurrentItems = CurrentItems.FindAll(t => !t.IsRemoved); currentPositions = CurrentItems.Select(t => t.position).ToList(); var rst = Utils.RandomSort(CurrentItems); CurrentItems.Clear(); foreach (var item in rst) { CurrentItems.Add(item); } positionItemDic.Clear(); for (int i = 0; i < CurrentItems.Count; i++) { CurrentItems[i].position = currentPositions[i]; positionItemDic.Add(CurrentItems[i].position, CurrentItems[i]); } EventCenter.Instance.Broad(Actions.RefreshItem, null); }
private bool CanRemove(int id) { if (SelectedOne != null) { if (id == SelectedOne.Id) { SelectedOne.Select(); SelectedOne = null; return(false); } else if (SelectedOne.TypeId == AllItemInfo[id].TypeId) { List <Vector2> a = new List <Vector2>(); if (JudgeRemove(SelectedOne, AllItemInfo[id], a)) { AllItemInfo[id].Remove(); SelectedOne.Remove(); SelectedOne = null; ShowLine(a); return(true); } else { SelectedOne.Select(); SelectedOne = AllItemInfo[id]; SelectedOne.Select(); } } else { SelectedOne.Select(); SelectedOne = AllItemInfo[id]; SelectedOne.Select(); } } return(false); }