/// <summary> /// Returns the list of gems in the row /// </summary> /// <param name="gem">The gem in the row we wish to select</param> /// <returns>List of row gems</returns> private List<OrbGem> GetGemRow(OrbGem gem) { return this.orbs.FindAll(x => x.Loc.y == gem.Loc.y); }
/// <summary> /// Returns the list of gems in the column /// </summary> /// <param name="gem">The gem in the column we wish to select</param> /// <returns>List of column gems</returns> private List<OrbGem> GetGemColumn(OrbGem gem) { return this.orbs.FindAll(x => x.Loc.x == gem.Loc.x); }
/// <summary> /// Highlights the appropriate list on the board based on the type of board ability and the current gem placement /// </summary> /// <param name="gem"></param> public void SetupTarget(OrbGem gem) { switch (this._currentBoardAbility.BoardAbilityTarget) { case BoardAbilityData.BoardTargetType.Grid: this.HighlightList(this.GetGemGrid(gem, this._currentBoardAbility.BoardGridSizeX, this._currentBoardAbility.BoardGridSizeY)); break; case BoardAbilityData.BoardTargetType.Row: this.HighlightList(this.GetGemRow(gem)); break; case BoardAbilityData.BoardTargetType.Column: this.HighlightList(this.GetGemColumn(gem)); break; case BoardAbilityData.BoardTargetType.Selection: this.HighlightList(this.GetGemGrid(gem, 1, 1)); break; default: UnityEngine.Debug.LogError("Error: Attempted to set up a target board without an appropriate target type"); break; } }
/// <summary> /// Returns the list of gems in a grid /// </summary> /// <param name="gem">The upper left corner of the grid</param> /// <param name="gridX">Amount the grid extends in the X direction</param> /// <param name="gridY">Amount the grid extends in the Y direction</param> /// <returns>List of grid gems</returns> private List<OrbGem> GetGemGrid(OrbGem gem, int gridX, int gridY) { return this.orbs.FindAll(x => x.Loc.x < gem.Loc.x + gridX && x.Loc.x >= gem.Loc.x && x.Loc.y < gem.Loc.y + gridY && x.Loc.y >= gem.Loc.y); }
/// <summary> /// Swaps one orb with another on the board /// </summary> /// <param name="a">The first orb gem we are swapping</param> /// <param name="b">The second orb gem we are swapping</param> /// <param name="manualSwap">Designates if this is a player-initiated move, or a board move</param> public void DoSwapOrb(OrbGem a, OrbGem b) { OrbPoint p1 = a.Loc; OrbPoint p2 = b.Loc; Cell cell = cells[p1.x, p1.y]; cells[p1.x, p1.y] = cells[p2.x, p2.y]; cells[p2.x, p2.y] = cell; a.Loc = p2; b.Loc = p1; }