public void TumbleRow(float direction, GridController gridController, int prevSize) { if (prevSize >= size) { gridController.attemptedTumble.Add(this); iVec2 targetCellPosition; if (direction > 0) { Debug.Log("Tumble left."); this.selected = false; targetCellPosition = new iVec2(this.cell.position.x - 1, this.cell.position.y); } else { Debug.Log("Tumble right."); this.selected = false; targetCellPosition = new iVec2(this.cell.position.x + 1, this.cell.position.y); } Cell targetCell = gridController.GetCellAtPosition(targetCellPosition); if (targetCell) { targetCell.tile.TumbleRow(direction, gridController, size); } } }
public void TumbleColumn(float direction, GridController gridController, int prevSize) { //if (prevSize == size && size != 6) if (prevSize >= size && size != 6 && size != 7) { iVec2 targetCellPosition; Cell targetCell; gridController.attemptedTumble.Add(this); if (direction > 0) { Debug.Log("Tumble up."); grid.lastSwipeDirection = 1; this.selected = false; targetCellPosition = new iVec2(this.cell.position.x, this.cell.position.y + 1); } else { Debug.Log("Tumble down."); grid.lastSwipeDirection = -1; this.selected = false; targetCellPosition = new iVec2(this.cell.position.x, this.cell.position.y - 1); } targetCell = gridController.GetCellAtPosition(targetCellPosition); if (targetCell) { targetCell.tile.TumbleColumn(direction, gridController, size); } } SpecialTumbleActions(gridController); }
protected override void SetData() { _x_size = 6; //columns _y_size = 8; //size _turnsAllowed = 30; _amountOfGoals = 2; _hasSpecialTileSetup = true; iceCells = new iVec2[32]; int i = 0; for (i = 0; i < 8; i++) { iceCells[i] = new iVec2(0, i); } for (i = 8; i < 16; i++) { iceCells[i] = new iVec2(1, i - 8); } for (i = 16; i < 24; i++) { iceCells[i] = new iVec2(4, i - 16); } for (i = 24; i < 32; i++) { iceCells[i] = new iVec2(5, i - 24); } }
public Cell GetCellAtPosition(iVec2 pos) { Cell returnCell = null; if ((pos.x < config.x_size && pos.x >= 0) && (pos.y < config.y_size && pos.y >= 0)) { List <Cell> cellColumn = cellColumns[pos.x]; returnCell = cellColumn[pos.y]; } return(returnCell); }
public void DestroyTileBeneath() { iVec2 targetCellPosition; targetCellPosition = new iVec2(this.position.x, this.position.y - 1); Cell targetCell = _grid.GetCellAtPosition(targetCellPosition); if (targetCell) { targetCell.tile.Destroy(1); } }
public void InitCell(iVec2 position, GridController grid, bool isIce) { _originalMaterial = gameObject.GetComponent <MeshRenderer>().material; _position = position; _tile = null; _grid = grid; _isIce = isIce; if (isIce) { gameObject.GetComponent <MeshRenderer>().material = iceMaterial; } }
protected override void Awake() { base.Awake(); /*for (int i = 0; i < goals.Length; i++) * { * goals[i] = ScriptableObject.CreateInstance<Goal>(); * }*/ iceCells = new iVec2[32]; /*goals[0] = ScriptableObject.CreateInstance<AnyTileSimultaneous_Goal>(); * goals[0].requiredAmount = 3; * goals[0].amountSimultaneous = 8; * goals[0].UpdateText(); */ /*goals[1] = ScriptableObject.CreateInstance<YellowTileSimultaneous_Goal>(); * goals[1].requiredAmount = 3; * goals[1].amountSimultaneous = 4; * goals[1].UpdateText(); * * goals[2] = ScriptableObject.CreateInstance<AnyTileSimultaneous_Goal>(); * goals[2].requiredAmount = 6; * goals[2].amountSimultaneous = 5; * goals[2].UpdateText();*/ //goals[0] = ScriptableObject.CreateInstance<MergeBlackTiles_Goal>(); //goals[0].requiredAmount = 8; //goals[0].UpdateText(); /*goals[0] = ScriptableObject.CreateInstance<BringDownCagedWhite_Goal>(); * goals[0].requiredAmount = 4; * goals[0].UpdateText();*/ goals[0] = ScriptableObject.CreateInstance <SuperRow_Goal>(); goals[0].requiredAmount = 4; goals[0].UpdateText(); goals[1] = ScriptableObject.CreateInstance <RemoveIce_Goal>(); goals[1].requiredAmount = 24; goals[1].UpdateText(); }
public void Swap(float direction, GridController gridController) { iVec2 targetCellPosition; if (direction > 0) { Debug.Log("Swap left."); this.selected = false; targetCellPosition = new iVec2(this.cell.position.x - 1, this.cell.position.y); } else { Debug.Log("Swap right."); this.selected = false; targetCellPosition = new iVec2(this.cell.position.x + 1, this.cell.position.y); } Cell targetCell = gridController.GetCellAtPosition(targetCellPosition); if (targetCell) { BaseTile targetTileSwap = targetCell.tile; Cell thisCell = this.cell; if (this.size == 7 && targetTileSwap.size == 7) { gridController.BlackTileMerged(); targetTileSwap.Destroy(1); Destroy(1); } else { targetCell.tile = this; thisCell.tile = targetTileSwap; this.SetCell(targetTileSwap.cell); targetTileSwap.SetCell(thisCell); } RootController.Instance.GameManager().turnsUsed++; gridController.MoveUpWhiteTiles(); } }
Cell GenerateCell(iVec2 pos, GameObject columnObject) { GameObject cell = Instantiate(cellTemplate); Cell cellScript = cell.GetComponent <Cell>(); cell.transform.SetParent(columnObject.transform); cell.transform.localPosition = new Vector3(pos.x, pos.y, 0); cell.transform.localScale = new Vector3(1f, 1f, 1f); cell.transform.localRotation = new Quaternion(0, 0, 0, 0); cell.name = pos.x + " | " + pos.y; cell.tag = ConvertRowNumberToTag(pos.y); bool isIce = false; if (pos.y == 0 || pos.y == 1 || pos.y == 2 || pos.y == 3) { isIce = true; } cellScript.InitCell(pos, this, isIce); return(cellScript); }
public void JumpUp(GridController gridController) { iVec2 targetCellPosition = new iVec2(this.cell.position.x, this.cell.position.y + 1); Cell targetCell = gridController.GetCellAtPosition(targetCellPosition); if (targetCell) { if (this.cell.transform.tag != "CellRow0" || !canBeDestroyed) { BaseTile targetTileSwap = targetCell.tile; Cell thisCell = this.cell; targetCell.tile = this; thisCell.tile = targetTileSwap; this.SetCell(targetTileSwap.cell); targetTileSwap.SetCell(thisCell); canBeDestroyed = true; } } }