private void ObserveCells(CellHandler cell) { cell.ChangeButtonInteractable(true); cell.ChangeAvailableMarker(true); observedCells.Add(cell); cell.CellButton.OnClickAsObservable().Subscribe(_ => OnClickedCellButton(cell)); }
private void CreateCell(int column, int row) { CellHandler cell = ObjectCreator.CreateInObject(this.gameObject, cellPrefab).GetComponent <CellHandler>(); cell.SetCell(column, row, CellType.Default); cells[column, row] = cell; }
IEnumerator GenerateGrid(int columnCount) { grid.m_Column = columnCount; cellArray = new GameObject[columnCount*columnCount, columnCount*columnCount]; yield return new WaitForEndOfFrame (); for (var i = 0; i < columnCount; i++) { for(var j = 0; j < columnCount; j++) { cellArray[i,j] = (GameObject)Instantiate(cell, new Vector3(1, 1, 1), Quaternion.identity); cellArray[i,j].transform.SetParent(grid.transform); cellArray[i,j].transform.localScale = new Vector3(1, 1, 1); cellArray[i,j].name = "Cell[" + i + "][" + j + "]"; cellList.Add (cellArray[i,j]); cellHandler = cellArray[i,j].GetComponent<CellHandler> (); cellHandler.CoordX = i; cellHandler.CoordY = j; // Add color: var rand = Random.Range (0,2); if (rand == 1) { cellHandler.cellStatus = CellHandler.Status.On; cellArray[i,j].GetComponent<CanvasRenderer> ().SetColor (new Color32 (135, 204, 196, 255)); } else { cellHandler.cellStatus = CellHandler.Status.Off; cellArray[i,j].GetComponent<CanvasRenderer>().SetColor (new Color32 (128, 128, 128, 128)); } } } }
// Use this for initialization void Start() { buttonText = GetComponentInChildren<Text>(); cellHandler = GameObject.Find("Cells").GetComponent<CellHandler>(); if (buttonText == null) Debug.LogError("Button Text is NUll"); else if (cellHandler == null) Debug.LogError("cellHandler is null"); }
private void OnClickedCellButton(CellHandler cell) { RemoveAllBtnAction(); playerAction.NextColumn = cell.Column; playerAction.NextRow = cell.Row; playerAction.Action = PieceAction.Move; MessageBroker.Default.Publish(playerAction); }
public static Cell GetCellForAnimal(Animal animal) { firstHandler = new OccamyCellHandler(); secondHandler = new ManticoreCellHandler(); lastHandler = new GhoulCellHandler(); firstHandler.Successor = secondHandler; secondHandler.Successor = lastHandler; return(firstHandler.GetCell(animal)); }
public void ForEach(CellHandler foo) { if (children != null) { foreach (Cell child in children) { child.ForEach(foo); } } if (true) { foo(this); } }
private FolderHelper m_FolderHelper; // 操作数据库的对象 public MainPage() { InitializeComponent(); m_FolderHelper = new FolderHelper(); m_Extensions = new ObservableCollection <string>(); ddlstExtension.ItemsSource = m_Extensions; m_Extensions.Add("ALL"); CellHandler cellHandler = new CellHandler(); flxFiles.CellFactory = cellHandler; flxFolder.CellFactory = cellHandler; cellHandler.MyRowHeader = CreateRowHeader; }
public List <string> GetAllCells() { var cells = new List <string>(); CellHandler handler = delegate(HexCube cube, Cell cell) { if (!cell.IsEmpty()) { HexAxial axial = cube.ToAxial(); cells.Add(string.Format(@"{0};{1}:{2}", axial.Q, axial.R, cell)); } }; IterateCells(handler); return(cells); }
private void RenderHexagonOutlines(Graphics device) { CellHandler handler = delegate(HexCube cube, Cell cell) { PointF centerOfHex = cube.HexToPixel(); var pos = new PointF { X = (centerOfHex.X + _halfMapWidth), Y = (centerOfHex.Y + _halfMapHeight) }; var pen = new Pen(Color.Black, 1); PointF[] corners = Hexagon.GetCorners(pos); device.DrawLines(pen, corners); }; IterateCells(handler); }
private void IterateCells(CellHandler handler) { for (int cellZ = -_size; cellZ <= _size; cellZ++) { for (int cellY = -_size; cellY <= _size; cellY++) { for (int cellX = -_size; cellX <= _size; cellX++) { var cube = new HexCube(cellX, cellY, cellZ); Cell cell = GetCell(cube); if (cell != null) { handler(cube, cell); } } } } }
private void RenderHexagonImages(Graphics device, ImageList[] images) { CellHandler handler = delegate(HexCube cube, Cell cell) { for (int i = 1; i <= Layers.NumberOfLayers; i++) { CellData data = cell.GetCellData(i); if (data.TerrainId >= 0) { PointF centerOfHex = cube.HexToPixel(); var pos = new PointF { X = (centerOfHex.X + _halfMapWidth) - Constants.HALF_HEX_WIDTH, Y = (centerOfHex.Y + _halfMapHeight) - Constants.HALF_HEX_HEIGHT }; int paletteId = data.PaletteId; device.DrawImage(images[paletteId].Images[data.TerrainId], pos); } } }; IterateCells(handler); }
public void Show(CellHandler clickedCell) { gameObject.SetActive(true); this.clickedCell = clickedCell; input.Select(); }
private void CheckIfCellIsRevealed(CellHandler cellAction, Position pos) { if (this.gameBoard.IsCellRevealed(pos)) { this.PrintUsedCellMessage("This cell has already been revealed! Please enter new cell coordinates!"); } else if (this.gameBoard.CheckIfFlagCell(pos)) { this.PrintUsedCellMessage("You've already placed flag at these coordinates! Please enter new cell coordinates!"); } else { cellAction(pos); this.userIteractor.DrawBoard(this.gameBoard.Board); } }
private void ProcessCoordinates(Position coordinates) { if (this.gameBoard.CheckIfHasMine(coordinates) && !this.gameBoard.CheckIfFlagCell(coordinates)) { // Memento logic if (this.remainingLives > 0) { bool reverting = this.AskUserToRevert(); if (reverting == true) { this.gameBoard.RestoreMemento(this.currentBoardState.Memento); return; } } this.ShowEndGameMessage(); this.gameBoard.ResetBoard(); this.ResetLives(); this.userIteractor.DrawBoard(this.gameBoard.Board); } else if (this.gameBoard.CheckIfHasMine(coordinates) && this.gameBoard.CheckIfFlagCell(coordinates)) { this.PrintUsedCellMessage("You've already placed flag at these coordinates! Please enter new cell coordinates!"); } else { var cellHandler = new CellHandler(this.gameBoard.RevealBlock); this.CheckIfCellIsRevealed(cellHandler, coordinates); this.currentBoardState.Memento = this.gameBoard.SaveMemento(); } if (this.gameBoard.CheckIfGameIsWon()) { this.ShowGameWonMessage(); } }
private void ProcessFlagCommand(Position coordinates) { var cellHandler = new CellHandler(this.gameBoard.PlaceFlag); this.CheckIfCellIsRevealed(cellHandler, coordinates); }
void Start() { cellHandler = (CellHandler)GameObject.Find("Cells").GetComponent("CellHandler"); }
internal void PushAddedCellHandler(CellHandler handler) { _addedCellHandlers.Push(handler); }
public void ShowPanel(CellHandler clickedCell) { Panel.Show(clickedCell); }
public void render(GameObject rendererObj) { if(!isRendered()) { renderedGameObject = rendererObj; renderedGameObject.name = "Cell"; handler = renderedGameObject.GetComponent<CellHandler> (); handler.Init (); if(WorldRenderer.WRENDERER.debugUIModeIsActive()) { activateUI(); } } }
public void unrender() { deactivateUI (); handler = null; renderedGameObject = null; }
// Use this for initialization void Start() { singleton = this; //Try to load any save if (Save.LoadData()) { readyForInput = true; } else { Restart(); } }
void Start() { cellHandler = GetComponentInParent <CellHandler>(); }
public void CreateInventoryOnEditor() { if (cells == null) { cells = new List <CellHandler>(); } Vector2 _offset = new Vector2(-(inventorySize.x * cellSize.x - cellSize.x) / 2.0f, -(inventorySize.y * cellSize.y - cellSize.y) / 2.0f); bool _colorToggle = true; for (int i = 0; i < inventorySize.x; i++) //Create cells inside inventory { if (inventorySize.y % 2 == 0) { _colorToggle = !_colorToggle; } for (int j = 0; j < inventorySize.y; j++) { CellHandler _ch = Instantiate(cellPf, Vector2.zero, Quaternion.identity, transform).GetComponent <CellHandler>(); _ch.transform.localPosition = new Vector3(_offset.x + i * cellSize.x, _offset.y + j * cellSize.y); //Set position int _cID = cells.Count; //Cell ID List <int> _neighbours = new List <int>(); //Neighbours //Up if ((_cID + 1) % inventorySize.y != 0 && _cID + 1 < inventorySize.x * inventorySize.y) { _neighbours.Add(_cID + 1); } else { _neighbours.Add(-1); } //Right if (_cID + 1 < inventorySize.x * inventorySize.y && _cID + inventorySize.y < inventorySize.x * inventorySize.y) { _neighbours.Add(_cID + inventorySize.y); } else { _neighbours.Add(-1); } //Down if (_cID % inventorySize.y != 0 && _cID > 0) { _neighbours.Add(_cID - 1); } else { _neighbours.Add(-1); } //Left if (_cID - 1 >= 0 && _cID - inventorySize.y >= 0) { _neighbours.Add(_cID - inventorySize.y); } else { _neighbours.Add(-1); } _ch.SetupCellLogic(_cID, ref _neighbours, _colorToggle ? Color.white : Color.grey); _colorToggle = !_colorToggle; cells.Add(_ch); } } EditorSceneManager.MarkSceneDirty(this.gameObject.scene); EditorUtility.SetDirty(this.gameObject); }