private void CellViewSelected(EnhancedScrollerCellView cellView) { if (cellView != null) { var selectedDataIndex = (cellView as TeamCellView).DataIndex; for (var i = 0; i < _data.Count; i++) { if (i == selectedDataIndex) { if (!_data[i].Created) { selectTeamPopup.GetComponent <CanvasGroup>().alpha = 0; selectTeamPopup.GetComponent <CanvasGroup>().interactable = false; selectTeamPopup.GetComponent <CanvasGroup> ().blocksRaycasts = false; selectMonsterPopup.GetComponent <CanvasGroup>().alpha = 1; selectMonsterPopup.GetComponent <CanvasGroup>().interactable = true; selectMonsterPopup.GetComponent <CanvasGroup>().blocksRaycasts = true; editBtn.GetComponent <Selectable>().interactable = false; } else if (_data[i].Created) { editBtn.GetComponent <Selectable>().interactable = true; } } _data[i].Selected = (selectedDataIndex == i); } } }
public List <Data> _data; //轻量级数组 public void OnEnter() { _data = new List <Data>(); // tell the scroller that this script will be its delegate cellViewPrefab = transform.Find("FollowingPanel").GetComponent <EnhancedScrollerCellView>(); scroller.Delegate = this; }
private void OnCellViewVisibilityChanged(EnhancedScrollerCellView cellview) { if (cellview.dataIndex == currentIndexItem) { this.PostEvent((int)EventID.ItemScrollSelect, cellview as ItemScroll); } }
/// <summary> /// This function handles the cell view's button click event /// </summary> /// <param name="cellView">The cell view that had the button clicked</param> private void CellViewSelected(EnhancedScrollerCellView cellView) { if (cellView == null) { // nothing was selected selectedImage.gameObject.SetActive(false); selectedImageText.text = "None"; } else { // get the selected data index of the cell view var selectedDataIndex = (cellView as InventoryCellView).DataIndex; // loop through each item in the data list and turn // on or off the selection state. This is done so that // any previous selection states are removed and new // ones are added. for (var i = 0; i < _data.Count; i++) { _data[i].Selected = (selectedDataIndex == i); } selectedImage.gameObject.SetActive(true); selectedImage.sprite = Resources.Load <Sprite>(_data[selectedDataIndex].spritePath + "_v"); selectedImageText.text = _data[selectedDataIndex].itemName; } }
private void CellViewInstantiated(EnhancedScroller enhancedScroller, EnhancedScrollerCellView cellview) { NoteUiItem item = cellview as NoteUiItem; item.OnClick += ItemClickHandler; item.OnLongClick += ItemLongClickHandler; item.OnSelect += ItemSelectHandler; }
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex) { cellViewPrefab = Resources.Load <GameObject>(path).GetComponent <ItemCell>(); ItemCell cellView = scroller.GetCellView(cellViewPrefab) as ItemCell; cellView.SetData(_data[dataIndex]); cellView.gameObject.SetActive(true); return(cellView); }
public virtual void CellViewVisibilityChanged(EnhancedScrollerCellView cellView) { CellViewBase view = cellView as CellViewBase; if (cellView.active) { view.RefreshCellView(); } }
// 新規セルビュー追加時デリゲート private void CellViewInstantiated(EnhancedScroller scroller, EnhancedScrollerCellView cellView) { List <UIPart> parts = new List <UIPart> { new BallItemPart(cellView as BallItemCellView) }; // 即時追加 UIController.Instance.AttachParts(TargetLayer, parts); }
private void Awake() { GameObject prefab = AssetManager.Instance.GetAsset <GameObject>("ui_prefab", "LogCell"); cellPrefab = prefab.GetComponent <EnhancedScrollerCellView>(); Text text = prefab.transform.Find("Text").GetComponent <Text>(); textGenerationSettings = text.GetGenerationSettings(new Vector2(700, 0)); cacheTextGenerator = text.cachedTextGenerator; scroller = GetComponent <EnhancedScroller>(); scroller.Delegate = this; }
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex) { Debug.Log(dataIndex); cellViewPrefab = Resources.Load <EnhancedScrollerCellView>(path); // it will create a new cell. FollowerCell cellView = scroller.GetCellView(cellViewPrefab) as FollowerCell; cellView.name = "Cell " + dataIndex.ToString(); cellView.SetData(_data[dataIndex]);// cellView.gameObject.SetActive(true); return(cellView); }
public override void CellViewVisibilityChanged(EnhancedScrollerCellView cellView) { base.CellViewVisibilityChanged(cellView); if (cellView.dataIndex == curShowTuChe) { role.gameObject.SetActive(cellView.active); if (cellView.active == true) { SetRole(cellView.transform); } } }
/// <summary> /// Gets the cell view that should be used for the data index. Your implementation /// of this function should request a new cell from the scroller so that it can /// properly recycle old cells. /// </summary> /// <param name="scroller"></param> /// <param name="dataIndex"></param> /// <param name="cellIndex"></param> /// <returns></returns> public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex) { EnhancedScrollerCellView cellView = scroller.GetCellView(cellPrefab); cellView.dataIndex = dataIndex; if (itemRendererHandler != null) { itemRendererHandler(cellView, dataSource != null && dataSource.Count > dataIndex ? dataSource [dataIndex] : null); } return(cellView); }
/// <summary> /// This handler will be called any time a cell view is shown or hidden /// </summary> /// <param name="cellView">The cell view that was shown or hidden</param> private void CellViewVisibilityChanged(EnhancedScrollerCellView cellView) { // cast the cell view to our custom view CellView view = cellView as CellView; // if the cell is active, we set its data, // otherwise we will clear the image back to // its default state if (cellView.active) { view.SetData(_data[cellView.dataIndex]); } else { view.ClearImage(); } }
private void CellViewSelected(EnhancedScrollerCellView cellView) { if (cellView == null) { } else { // get the selected data index of the cell view var selectedData = (cellView as LevelEntryView).Data; Debug.Log("cell view selected : " + selectedData.levelNum + " Selected: " + selectedData.Selected); //double click to edit level if (selectedData.Selected) { GotoEditingMode(); } _levelList.SelectSingleLevel(selectedData); } }
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex) { EnhancedScrollerCellView cellView = null; //有设置Prefab直接生成 if (cellViewPrefab != null) { cellView = scroller.GetCellView(cellViewPrefab); cellView.name = "Cell_" + cellIndex + "_" + dataIndex; } //如果Prefab为空,需要在Lua处理Prefab加载逻辑 if (cellDataSetter != null) { cellView = cellDataSetter(scroller, dataIndex, cellIndex, cellView); } return(cellView); }
// 新規セルビュー追加時デリゲート private void CellViewInstantiated(EnhancedScroller scroller, EnhancedScrollerCellView cellView) { BallItemCellView ballItemCell = cellView as BallItemCellView; if (ballItemCell == null) { return; } List <UIPart> parts = new List <UIPart> { new BallItemButtonPart(ballItemCell, ballItemCell.textButton), new BallItemButtonPart(ballItemCell, ballItemCell.fixedIntegerButton), new BallItemButtonPart(ballItemCell, ballItemCell.dataIntegerButton) }; // 即時追加 UIController.Instance.AttachParts(TargetLayer, parts); }
// 新規セルビュー追加時デリゲート private void CellViewInstantiated(EnhancedScroller scroller, EnhancedScrollerCellView cellView) { UIPart part = null; switch (cellView.cellIdentifier) { case "ShopCellView": part = new ShopPart(cellView as ShopCellView); break; case "BallCellView": part = new BallPart(cellView as BallCellView, m_HomeScrollerView); break; case "BattleCellView": part = new BattlePart(cellView as BattleCellView); break; case "SocialCellView": part = new SocialPart(cellView as SocialCellView); break; case "EventCellView": part = new EventPart(cellView as EventCellView); break; default: Debug.LogError($"CellViewInstantiated Error cellIdentifier:{cellView.cellIdentifier}"); return; } List <UIPart> parts = new List <UIPart> { part }; // 即時追加 UIController.Instance.AttachParts(this, parts); }
// 新規セルビュー追加時デリゲート private void CellViewInstantiated(EnhancedScroller scroller, EnhancedScrollerCellView cellView) { UIPart part = null; switch (cellView.cellIdentifier) { case "MixedListCellView": part = new MixedListPart(cellView as MixedListCellView); break; case "MixedLineCellView": part = new MixedLinePart(cellView as MixedLineCellView, m_LaboScrollerView); break; case "PreviewCellView": part = new PreviewPart(cellView as PreviewCellView); break; case "ElementLineCellView": part = new ElementLinePart(cellView as ElementLineCellView, m_LaboScrollerView, m_MixedBallTabBase.m_MixedBallTabView); break; case "ElementListCellView": part = new ElementListPart(cellView as ElementListCellView); break; default: Debug.LogError($"CellViewInstantiated Error cellIdentifier:{cellView.cellIdentifier}"); return; } List <UIPart> parts = new List <UIPart> { part }; // 即時追加 UIController.Instance.AttachParts(this, parts); }
/// <summary> /// This is the handler of each snapping in the scroller. The /// cell index will only be different from the data index if looping is on. /// </summary> /// <param name="scroller">The EnhancedScroller that fired the event</param> /// <param name="cellIndex">The index of the cell that snapped on</param> /// <param name="dataIndex">The data index of the cell that snapped on</param> private void ScrollerSnapped(EnhancedScroller scroller, int cellIndex, int dataIndex, EnhancedScrollerCellView cellView) { // if we are not playing, ignore this event if (GameState != GameStateEnum.Playing) { return; } // increment the snap count. We will need three total snaps to tally the score _snapCount++; // set the slot of the snapped scroller for use in tallying the score _snappedDataIndices[_snapCount - 1] = dataIndex; if (_snapCount == _slotControllers.Length) { // if we've reached the final snap count, then tally the score TallyScore(); // reenable the lever pullLeverButton.interactable = true; } if (Credits == 0) { // if we are out of credits after tallying the score, go to a game over state GameState = GameStateEnum.GameOver; } }
private void CellViewSelected(EnhancedScrollerCellView cellView) { Debug.Log("===============断点02=========="); }
private void CellViewInstantiated(EnhancedScroller enhancedScroller, EnhancedScrollerCellView cellview) { DetailedReminderUiItem item = cellview as DetailedReminderUiItem; item.onReminderItemClicked = OnReminderItemClicked; }
private void CellViewSelected(EnhancedScrollerCellView cellView) { if (cellView != null) { var selectedDataIndex = (cellView as InventoryCellView).DataIndex; // loop through each item in the data list and turn // on or off the selection state. This is done so that // any previous selection states are removed and new // ones are added. for (var i = 0; i < _data.Count; i++) { if (selectedDataIndex == i) { if (!_data[i].Selected) { if (stack.Count < 4) { stack.Push(selectedDataIndex); hashtableMonster.Add(selectedDataIndex, _data[i].monsterName); _data[i].Selected = (selectedDataIndex == i); break; } else if (4 == stack.Count) { hashtableMonster.Remove(stack.Peek()); _data[stack.Pop()].Selected = false; _data[i].Selected = true; stack.Push(i); hashtableMonster.Add(i, _data[i].monsterName); break; } } else { if (stack.Peek() == i) { hashtableMonster.Remove(stack.Peek()); _data[stack.Pop()].Selected = false; break; } else { Queue tempQueue = new Queue(); while (stack.Peek() != i) { tempQueue.Enqueue(stack.Pop()); } hashtableMonster.Remove(stack.Peek()); _data[stack.Pop()].Selected = false; while (tempQueue.Count > 0) { stack.Push((int)tempQueue.Dequeue()); } break; } } } } } }
private void ScrollerSnapped(EnhancedScroller enhancedScroller, int cellindex, int dataindex, EnhancedScrollerCellView cellview) { // Debug.Log($"ScrollerSnapped. DataIndex: {dataindex}, cellIndex: {cellview}"); }
void HandleCellViewWillRecycleDelegate(EnhancedScrollerCellView cellView) { }
/// <summary> /// Tells the cell view that it is about to be recycled /// </summary> /// <param name="cellView">Cell view.</param> private void CellViewWillRecycle(EnhancedScrollerCellView cellView) { (cellView as CellView).WillRecycle(); }
private void ScrollerScrolled(EnhancedScroller enhancedScroller, Vector2 val, float scrollposition) { int currentActiveCellIndex = scroller.GetClosestCellIndex(); // Debug.Log($"ScrollerScrolled. _lastActiveCellIndex: {_lastActiveCellIndex}, currentActiveCellIndex: {currentActiveCellIndex}, total data count: {_data.Count}"); // check is start and end cell items indexes are in a range of 7 days and value not equals to previously cached value if (_lastActiveCellIndex != currentActiveCellIndex && currentActiveCellIndex > -1 && currentActiveCellIndex < _data.Count) { _lastActiveCellIndex = currentActiveCellIndex; EnhancedScrollerCellView activeCell = scroller.GetClosestCellView(); if (activeCell != null) { // set focus of cells only for daily view in CSU mode if (appMode == AppMode.CSU) { if (activeCell != null) { _lastActiveCellView?.SetFocus(false); _lastActiveCellView = (activeCell as DayScrollItemView); // Debug.Log( // $"active cell data: {_lastActiveCellView.graphData.data}, date: {_lastActiveCellView.graphData.date}, value: {_lastActiveCellView.graphData.interpolatedScore}"); _lastActiveCellView.SetFocus(true); } } } } QuestionBasedTrackerData data = _data[_lastActiveCellIndex].data; // for CSU if (_trackerType == TrackerManager.TrackerType.CSU) { // Debug.Log("data: " + data); // hide by default _photoHint.UpdateValue(null); if (data != null) { // if there are some photos int numOfPhotos = (data as CSUData).GetPhotosCount(); // Debug.Log("Photos count: " + numOfPhotos); if (numOfPhotos > 0) { _photoHint.UpdateValue(numOfPhotos.ToString()); } } _CSUViewController.UpdateData(data as CSUData); } // if using the graph (3 of 4 trackers) else { // move graph camera together with a slider _graphController.UpdateCameraView(val.x); // set score _scoreHint.UpdateValue(data == null ? string.Empty : data.GetScore().ToString()); } // cache last scroll position to restore last position on screen Hide >> Show or tracker type change if (_scrollLastPositions.ContainsKey(_trackerType)) { _scrollLastPositions[_trackerType] = val.x; } else { _scrollLastPositions.Add(_trackerType, val.x); } // check notes if (_lastActiveCellIndex > -1) { List <NoteData> notes = NotesManager.GetNoteData(_data[_lastActiveCellIndex].date); if (notes.Count > 0) { _notesHint.UpdateValue(notes.Count.ToString()); } else { _notesHint.UpdateValue(null); } } else { _notesHint.UpdateValue(null); } }
private void CellViewInstantiated(EnhancedScroller enhancedScroller, EnhancedScrollerCellView cellview) { ReminderUiItem item = cellview as ReminderUiItem; item.OnToggled += ItemOnToggled; }