示例#1
0
 private bool IsValidDot(Dot hitDot)
 {
     return
         (hitDot.Color == MatchingColor &&
          hitDot.Coordinate.IsNeighbor(LastDotHit.Coordinate) &&
          (hitDot == PreviousChainHead || !LastDotHit.IsConnectedTo(hitDot)) &&
          LastDotHit.CanAddAnotherChain());
 }
示例#2
0
    void TryAddDot(Dot hitDot)
    {
        // Don't interact with any dot that is currently moving
        if (hitDot.GridBox.IsUpdatingCoordinate)
        {
            return;
        }

        // If set is empty, add it
        if (dotsInteracting.Count == 0)
        {
            dotsInteracting.Add(hitDot);
            MatchingColor = hitDot.Color;
            DrawCursorChain(hitDot);
        }
        else if (IsValidDot(hitDot))
        {
            // If same dot as previous hit, undo chain
            if (hitDot == PreviousChainHead)
            {
                PreviousChainHead.RemoveChain(LastDotHit);
                dotsInteracting.RemoveAt(LastIndexOfDotsInteracting);
            }
            // Add Chain
            else
            {
                Chain newChain = CreateChain();
                if (newChain != null)
                {
                    newChain.Initialize(LastDotHit);
                    newChain.ConnectTo(hitDot);
                    LastDotHit.AddChain(newChain);
                }

                dotsInteracting.Add(hitDot);
            }
            DrawCursorChain(hitDot);
        }
    }