private void OnPossibleMoveFound(GemController sender, GemController[] participants, GemController key, Line direction) { foreach (PossibleMove pm in PossibleMoves) { if (pm.GetHashCode() == MatchUtils.CalculateHash(new int[] { key.Position.x, key.Position.y, sender.Position.x, sender.Position.y })) { return; } } List <GemController> participantsList = new List <GemController>(); foreach (GemController participant in participants) { PossibleMatch participantPossibleMatch = participant.GetPossibleMatchByDirection(direction); if (participantPossibleMatch != null && !participantPossibleMatch.IsMatch()) { participantsList.AddRange(participantPossibleMatch.MatchedGems); } else { participantsList.Add(participant); } } PossibleMove possibleMove = new PossibleMove(participantsList, key, sender.Position, direction); possibleMove.OnOver += PossibleMove_OnOver; possibleMoves.Add(possibleMove); if (OnPossibleMoveCreate != null) { OnPossibleMoveCreate(possibleMove); } }
private void PossibleMove_OnOver(PossibleMove sender) { possibleMoves.Remove(sender); }
internal void RemovePossibleMove(PossibleMove possibleMove, PossibleMove.Role role) { possibleMoves[role].Remove(possibleMove); }
internal void AddPossibleMove(PossibleMove possibleMove, PossibleMove.Role role) { possibleMoves[role].Add(possibleMove); }