/// <summary> /// 激活一个AbstractCell /// </summary> /// <returns></returns> private AbstractCell activeACell() { AbstractCell c = null; if (_catchList.Count > 0) { c = _catchList[_catchList.Count - 1]; _catchList.RemoveAt(_catchList.Count - 1); _activeList.Add(c); } else { GameObject go = Instantiate(prefab); go.GetComponent <RectTransform>().sizeDelta = new Vector2(cellX, cellY); go.transform.SetParent(_content); go.transform.localScale = Vector3.one; go.GetComponent <RectTransform>().anchoredPosition = Vector2.zero; c = go.GetComponent <AbstractCell>(); _activeList.Add(c); } c.gameObject.SetActive(true); return(c); }
public Form1() { InitializeComponent(); MySpreadsheet = new MySpreadsheet(50, 26); MySpreadsheet.CellPropertyChanged += new PropertyChangedEventHandler(SpreadSheetPropertyChanged); //Move the following into data-grid initialization //Populates the data grid with columns 'A' through 'Z' for (char col = 'A'; col <= 'Z'; ++col) { dataGridView1.Columns.Add("Column" + col, col.ToString()); } //Creates 50 rows in the datagridview and numbers each row dataGridView1.Rows.Add(50); foreach (DataGridViewRow row in dataGridView1.Rows) { row.HeaderCell.Value = (row.Index + 1).ToString(); } //Fires when an event occurs which requires updating the UI cells, hacky use of PropertyChangedEventArgs parameter //used to pass the row and column of the cell which needs to be updated void SpreadSheetPropertyChanged(object sender, PropertyChangedEventArgs e) { AbstractCell cell = (AbstractCell)sender; int row = cell.RowIndex; int column = cell.ColumnIndex; dataGridView1[column, row].Value = MySpreadsheet.getCell(row, column).EvaluatedValue; } }
public void Move(AbstractCell square) { CurrentCell?.RemoveCharacter(); CurrentCell = square; SelfObject.transform.position = CurrentCell.ObjectPosition; CurrentCell.AcceptCharacter(this); TurnEnd(); }
public override void CreateCells(int[,] intSquareArray) { Cells = new AbstractCell[intSquareArray.GetLength(0), intSquareArray.GetLength(1)]; for (int y = 0; y < Cells.GetLength(1); y++) { for (int x = 0; x < Cells.GetLength(0); x++) { if (intSquareArray[x, y] == 0) { Cells[x, y] = new PlainCell(this, new IntVector2(x, y)); Cells[x, y].AcceptObject(new WallObject(Cells[x, y])); } if (intSquareArray[x, y] == 1) { Cells[x, y] = new PlainCell(this, new IntVector2(x, y), PrefabsManager.Instance.PlainCell); Cells[x, y].InRoom = true; } if (intSquareArray[x, y] == 2) { Cells[x, y] = new PlainCell(this, new IntVector2(x, y), PrefabsManager.Instance.PlainCell); } } } }
/// <summary> /// 刷新数据 /// </summary> /// <param name="index">刷新数据的其实标识点</param> /// <param name="ignore">当重新赋值时,data的长度小于可显示的长度,这是要刷新一下数据,因为索引值不会变</param> private void refreshData(int index, bool ignore = false) { if ((_previousTopIndex == index || index < 0) && !ignore) { return; } _previousTopIndex = index; catchAllCell(); for (int i = 0; i < _pageCountY; i++) { for (int j = 0; j < countX; j++) { int num = (index + i) * countX + j; if (num >= _dataList.Length) { break; } AbstractCell c = activeACell(); c.rectTransform.anchoredPosition = getCellPos(index + i, j); c.data = _dataList[num]; } } }
public GoalObject(AbstractCell cell) : base(cell) { }
public StairsObject(AbstractCell cell) : base(cell) { }
public ItemBoxObject(AbstractCell cell) : base(cell) { }
public WallObject(AbstractCell cell) : base(cell) { }
public AbstractObject(AbstractCell cell) { CurrentCell = cell; }
/// <summary> /// 缓存一个AbstractCell /// </summary> /// <param name="c"></param> private void catchACell(AbstractCell c) { _catchList.Add(c); _activeList.Remove(c); c.gameObject.SetActive(false); }