private void OnSpecialTypeChanged(GemController sender, GemSpecialType specialType) { if (SpecialTypeImages.ContainsKey(specialType)) { specialImage.Source = SpecialTypeImages[specialType]; } }
private void OnSpecialTypeChanged(GemController sender, GemSpecialType specialType) { this.specialType = specialType; foreach (GemComponent gemComponent in gemComponents) { gemComponent.SetGemSpecialType(specialType); } }
private void DoSpecialSwipe(GemController gem, GemController neighbor) { if (gem == null || neighbor == null) { Logger.Instance.Error("DoSpecialSwipe(): gem or neighbor is null"); return; } if (neighbor.SpecialType == GemSpecialType.HitType && gem.SpecialType == GemSpecialType.HitType) { BreakByType(GemType.All); } else if (gem.SpecialType == GemSpecialType.HitType) { if (neighbor.SpecialType != GemSpecialType.Regular) { SetSpecialTypeByType(neighbor.SpecialType, neighbor.CurrentGemType); } BreakByType(neighbor.CurrentGemType); MatchGem(gem); } else if (neighbor.SpecialType == GemSpecialType.HitType) { if (gem.SpecialType != GemSpecialType.Regular) { SetSpecialTypeByType(gem.SpecialType, gem.CurrentGemType); } BreakByType(gem.CurrentGemType); MatchGem(neighbor); } else { GemSpecialType newSpecialType = GemSpecialType.Regular; if (neighbor.SpecialType == gem.SpecialType) { switch (neighbor.SpecialType) { case GemSpecialType.Bomb: newSpecialType = GemSpecialType.DoubleBomb; break; case GemSpecialType.Horizontal: case GemSpecialType.Vertical: newSpecialType = GemSpecialType.Horizontal | GemSpecialType.Vertical; break; } } else { newSpecialType = neighbor.SpecialType | gem.SpecialType; } neighbor.SpecialType = newSpecialType; gem.SpecialType = GemSpecialType.Regular; MatchGem(gem); MatchGem(neighbor); } }
public void CheckMatchedMatches() { if (matchedMatches.Count > 0) { foreach (PossibleMatch pm in matchedMatches) { if (pm.IsOver) { continue; } Logger.Instance.Message(pm.ToString() + " was matched"); List <GemController> matchedGems = new List <GemController>(pm.MatchedGems); if (matchedGems.Count > 3 && !pm.IsContainer) { GemSpecialType type = GemSpecialType.Regular; if (matchedGems.Count > 4 && (pm.MatchDirection == Line.Horizontal || pm.MatchDirection == Line.Vertical)) { type = GemSpecialType.HitType; } else if (pm.MatchDirection == Line.Cross) { type = GemSpecialType.Bomb; } else if (pm.MatchDirection == Line.Vertical) { type = GemSpecialType.Horizontal; } else if (pm.MatchDirection == Line.Horizontal) { type = GemSpecialType.Vertical; } GemController gem = pm.MatchInitiator; if (gem == null) { gem = matchedGems[Randomizer.Range(0, matchedGems.Count)]; } gem.SpecialType = type; matchedGems.Remove(gem); } foreach (GemController gem in matchedGems) { MatchGem(gem); } pm.Over(); } matchedMatches.Clear(); } if (dissapearedGems.Count > 0) { RefillColums(); } }
public override void SetGemSpecialType(GemSpecialType specialType) { if (spriteRenderer == null) { Debug.LogError("SpriteRenderer of " + gameObject.name + " is null"); } GemSpecialSprite gemSpecialSprite = gemSpecialSprites.FirstOrDefault(g => g.specialType == specialType); if (gemSpecialSprite == null) { Debug.LogError("Failed to find sprite of type " + specialType); return; } spriteRenderer.sprite = gemSpecialSprite.sprite; }
private void SetSpecialTypeByType(GemSpecialType specialType, GemType type) { if (null == gems) { Logger.Instance.Error("SetSpecialTypeByType(): gems not inited"); } for (int x = 0; x < columnCount; x++) { for (int y = 0; y < rowCount; y++) { if (null != gems[x][y] && gems[x][y].CurrentGemType.HasSameFlags(type)) { gems[x][y].SpecialType = specialType; } } } }
private void OnSpecialGemMatch(GemController sender, GemSpecialType type) { Logger.Instance.Message("Special " + sender.ToString() + " matched"); List <GemController> hitGems = new List <GemController>(); int bombsize = type == GemSpecialType.DoubleBomb ? 5 : 3; switch (type) { case GemSpecialType.Horizontal: hitGems.AddRange(GetGemsByRowIndex(sender.Position.y)); break; case GemSpecialType.Vertical: hitGems.AddRange(GetGemsByColumnIndex(sender.Position.x)); break; case GemSpecialType.Vertical | GemSpecialType.Horizontal: hitGems.AddRange(GetGemsByRowIndex(sender.Position.y)); hitGems.AddRange(GetGemsByColumnIndex(sender.Position.x)); break; case GemSpecialType.Vertical | GemSpecialType.Bomb: if (sender.Position.x - 1 >= 0) { hitGems.AddRange(GetGemsByColumnIndex(sender.Position.x - 1)); } hitGems.AddRange(GetGemsByColumnIndex(sender.Position.x)); if (sender.Position.x + 1 < columnCount) { hitGems.AddRange(GetGemsByColumnIndex(sender.Position.x + 1)); } break; case GemSpecialType.Horizontal | GemSpecialType.Bomb: if (sender.Position.y - 1 >= 0) { hitGems.AddRange(GetGemsByRowIndex(sender.Position.y - 1)); } hitGems.AddRange(GetGemsByRowIndex(sender.Position.y)); if (sender.Position.y + 1 < rowCount) { hitGems.AddRange(GetGemsByRowIndex(sender.Position.y + 1)); } break; case GemSpecialType.DoubleBomb: case GemSpecialType.Bomb: for (int x = sender.Position.x - (bombsize / 2); x <= sender.Position.x + (bombsize / 2); x++) { for (int y = sender.Position.y - (bombsize / 2); y <= sender.Position.y + (bombsize / 2); y++) { if (y < 0 || x < 0 || y >= rowCount || x >= columnCount) { continue; } GemController gem = gems[x][y]; if (gem == null) { continue; } hitGems.Add(gem); } } break; case GemSpecialType.HitType: break; default: Logger.Instance.Error("unknown special type " + type + " of " + sender.ToString()); break; } foreach (GemController gem in hitGems) { if (gem == sender) { continue; } MatchGem(gem); } }
public virtual void SetGemSpecialType(GemSpecialType specialType) { }