Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 private void PossibleMove_OnOver(PossibleMove sender)
 {
     possibleMoves.Remove(sender);
 }
Ejemplo n.º 3
0
 internal void RemovePossibleMove(PossibleMove possibleMove, PossibleMove.Role role)
 {
     possibleMoves[role].Remove(possibleMove);
 }
Ejemplo n.º 4
0
 internal void AddPossibleMove(PossibleMove possibleMove, PossibleMove.Role role)
 {
     possibleMoves[role].Add(possibleMove);
 }