public void ButtonTeleportFunction(int x, int y) { ViewFieldCell cellScript = _field[x, y]; if (_objectForTeleport == null) { _objectForTeleport = cellScript; cellScript.SetTeleportColor(true); return; } else { _objectForTeleport.SetTeleportColor(false); if (_objectForTeleport != cellScript) { _objectForTeleport.SetTeleportInCell(cellScript.PositionY * Constants.MaxWidthOfField + cellScript.PositionX + 1); _level.profile.SetTeleport(_objectForTeleport.PositionX, _objectForTeleport.PositionY, cellScript.PositionY * Constants.MaxWidthOfField + cellScript.PositionX + 1); _objectForTeleport = null; } else { _objectForTeleport = null; } } }
public void InstantiateField(Level level) { _level = level; _widthOfCell = _cellBase.gameObject.GetComponent <BoxCollider2D>().size.x; _field = new ViewFieldCell[Constants.MaxWidthOfField, Constants.MaxHeightOfField]; _wallVertical = new ViewWallBase[Constants.MaxWidthOfField - 1, Constants.MaxHeightOfField]; _wallHorizontal = new ViewWallBase[Constants.MaxWidthOfField, Constants.MaxHeightOfField - 1]; int countCell = 1; for (int i = 0; i < Constants.MaxWidthOfField; i++) { countCell = i + 1; for (int k = 0; k < Constants.MaxHeightOfField; k++) { GameObject cell = Instantiate(_cellBase.gameObject, _cellBase.gameObject.transform.parent, false) as GameObject; cell.transform.localPosition = _cellBase.transform.localPosition; cell.SetActive(true); cell.GetComponent <RectTransform>().anchoredPosition = (new Vector2(i * (_widthOfCell + paddingBetweenCells) + _cellBase.GetComponent <RectTransform>().anchoredPosition.x, -k * (_widthOfCell + paddingBetweenCells) + _cellBase.GetComponent <RectTransform>().anchoredPosition.y)); ViewFieldCell viewFieldCell = cell.GetComponent <ViewFieldCell>(); viewFieldCell.PositionX = k; viewFieldCell.PositionY = i; viewFieldCell.FieldController = this; viewFieldCell._textNumberCell.text = (countCell).ToString(); countCell += 12; _field[i, k] = viewFieldCell; } } InstantiateWalls(); if (_menuCreator != null) { _menuCreator.SetInfo(_level); } Construct(); }
public void ButtonSugarDropFunction(int x, int y) { ViewFieldCell cellScript = _field[x, y]; if (cellScript.gameObject.activeSelf) { _level.profile.SetSugarDrop(x, y, cellScript.SetSugarDropInCell()); } }
public void ActivateButtonJellyFunction(int x, int y) { ViewFieldCell cellScript = _field[x, y]; if (cellScript.gameObject.activeSelf) { _level.profile.SetJelly(x, y, cellScript.SetJelly(1)); } }
public void ButtonGravityFunction(int x, int y) { ViewFieldCell cellScript = _field[x, y]; if (cellScript.gameObject.activeSelf) { _level.profile.SetGravity(x, y, cellScript.SetGravityInCell()); } }
public void RemoveAllHandlers() { if (_objectForTeleport != null) { _objectForTeleport.SetTeleportColor(false); _objectForTeleport = null; } OnEditField = null; ShowWalls(false); }
public void ButtonColorFunction(int x, int y) { ViewFieldCell cellScript = _field[x, y]; if (cellScript.gameObject.activeSelf) { if (cellScript.ColorOfCell == colorToCell) { _level.profile.SetChip(x, y, 0); cellScript.SetColorInCell(eColors.ColorRandom); } else { _level.profile.SetChip(x, y, Constants.GetIdByEnum(colorToCell)); cellScript.SetColorInCell(colorToCell); } } }