Пример #1
0
 private void Dot_OnSelected(object sender, DotEventArgs dotEventArgs)
 {
     if (!HasMoveStarted)
     {
         StartMove(dotEventArgs.CurrentDot);
     }
 }
Пример #2
0
        protected virtual void OnEntered(DotEventArgs e)
        {
            var handler = Entered;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Пример #3
0
 private void Dot_OnDeselected(object sender, DotEventArgs dotEventArgs)
 {
     if (!HasMoveStarted)
     {
         return;
     }
     CheckMove();
     LinePainter.Instance.StopPainting();
 }
Пример #4
0
        private void Dot_OnEntered(object sender, DotEventArgs dotEventArgs)
        {
            if (!HasMoveStarted)
            {
                return;
            }

            // The dot you just entered
            var currentDot = dotEventArgs.CurrentDot;

            switch (currentDot.DotType)
            {
            case DotTypes.None:
                Debug.LogError("Invalid Dot Type");
                break;

            case DotTypes.Normal:
                if (IsValid((NormalDot)currentDot))
                {
                    if ((_selectedDots.Count >= 2) && IsDeselecting(currentDot))
                    {
                        _selectedDots[_lastSelectedDotNumber].Animator.FinishAnimations();
                        _selectedDots.RemoveAt(_lastSelectedDotNumber);
                        _lastSelectedDotNumber--;
                        LinePainter.Instance.RemoveLastPosition();
                        OnDotDeselected();
                    }
                    else
                    {
                        _isSquareAnnounced = IsSquare();
                        if ((!IsSquare() && _selectedDots.Contains(currentDot)) ||
                            !_selectedDots.Contains(currentDot))
                        {
                            currentDot.Select();
                            _selectedDots.Add(currentDot);
                            _lastSelectedDotNumber++;
                            LinePainter.Instance.AddPosition(currentDot.transform.position);
                            OnDotSelected();
                        }
                        if (IsSquare() && !_isSquareAnnounced)
                        {
                            _isSquareAnnounced = true;
                            OnSquareSelected();
                        }
                    }
                }
                break;

            default:
                throw new InvalidEnumArgumentException();
            }
        }