public void AddConnection(Dot target)
    {
        var isValid = false;

        if (_activeConnections.Count == 0)
        {
            _isLoop       = false;
            _currConnType = target.GetDotType();
            isValid       = true;
        }
        else if (_activeConnections[_activeConnections.Count - 1] == target ||
                 _activeConnections[Mathf.Clamp(_activeConnections.Count - 2, 0, int.MaxValue)] == target)
        {
            // Remove last connection if we passed through last point
            _activeConnections.RemoveAt(_activeConnections.Count - 1);
        }
        else
        {
            isValid = _activeConnections[_activeConnections.Count - 1].IsValidNeighbor(target);
        }

        if (isValid)
        {
            _activeConnections.Add(target);
            DotConnected?.Invoke(target);
        }
        _isLoop = _activeConnections.Count != _activeConnections.Distinct().Count();
    }
Esempio n. 2
0
 public void ClearDotType()
 {
     _isAnimationPlaying = true;
     _dotType            = DotColorType.Clear;
     transform.DOScale(Vector3.zero, 0.2f).onComplete += () =>
     {
         _isAnimationPlaying = false;
     };
 }
Esempio n. 3
0
 private void SetDotType(DotColorType dotType)
 {
     _dotType = dotType;
     if (_dotType != DotColorType.Clear)
     {
         //sets color to all sprites in dot
         foreach (var s in sprites)
         {
             s.color = GameData.DotColors[dotType];
         }
     }
 }