private void RewardShape(int chainLength, MatchShape shape) { if (!shapeRewards.ContainsKey(shape)) { return; } Tool tool = shapeRewards[shape]; if (availableToolUses[tool] < 0) { return; } if (chainLength < requiredChainLength[tool]) { return; } switch (toolData.RewardStrategy) { case RewardStrategy.NAtOncePerLength: while (requiredChainLength[tool] <= chainLength) { availableToolUses[tool] += requiredChainLength[tool]; ++requiredChainLength[tool]; } break; case RewardStrategy.PermanentUnlock: availableToolUses[tool] = -1; break; default: ++availableToolUses[tool]; ++awardedToolsForCurrentChainLength[tool]; int availableToolUsesForChainLength = GetAvailableToolUsesForChainLength(requiredChainLength[tool]); if (availableToolUsesForChainLength >= 0 && awardedToolsForCurrentChainLength[tool] >= availableToolUsesForChainLength) { ++requiredChainLength[tool]; awardedToolsForCurrentChainLength[tool] = 0; } break; } }
//figure the match shape, top, bot, left, right and intersecting tiles void FigureOtherMatchData() { int? repeatingX = null, repeatingY = null; Tile topTile = null, botTile = null, leftTile = null, rightTile = null; GridPosition lastGridPos = GridPosition.zero; for (int i = 0; i < Tiles.Count; i++) { Tile t = Tiles[i]; if (topTile == null && botTile == null && leftTile == null && rightTile == null) { topTile = botTile = leftTile = rightTile = t; } if (t.gridPos.x > rightTile.gridPos.x) { rightTile = t; } if (t.gridPos.x < leftTile.gridPos.x) { leftTile = t; } if (t.gridPos.y < topTile.gridPos.y) { topTile = t; } if (t.gridPos.y > botTile.gridPos.y) { botTile = t; } if (i > 0) { if (t.gridPos.x == lastGridPos.x) { repeatingX = t.gridPos.x; } if (t.gridPos.y == lastGridPos.y) { repeatingY = t.gridPos.y; } } lastGridPos = t.gridPos; } if (repeatingX != null && repeatingY != null) { IntersectingTile = Tiles[0].board.Tiles[repeatingX ?? int.MinValue][repeatingY ?? int.MinValue]; MatchShape = MatchShape.L_OR_T; } else if (repeatingX != null) { leftTile = rightTile = null; MatchShape = MatchShape.V_LINE; } else { topTile = botTile = null; MatchShape = MatchShape.H_LINE; } this.TopTile = topTile; this.BotTile = botTile; this.LeftTile = leftTile; this.RightTile = rightTile; }