Пример #1
0
        // Calls in update if mouse just up
        public virtual void OnMouseDown(InputManager.MouseButton button, Vector2 position)
        {
            Vector2 circlePosition = Circle.GetPosition(position, CurrentTurn);
            if (CurrentField.InField(circlePosition)) {
                Circle c = CurrentField[(int)circlePosition.X, (int)circlePosition.Y];

                currentLine = new Line(Circle.GetCenterPosition(c), position);
            }
        }
Пример #2
0
        public virtual void OnMouseUp(InputManager.MouseButton button, Vector2 position)
        {
            if (currentLine != null) {
                Vector2 begin = Circle.GetPosition(currentLine.begin, CurrentTurn);
                Vector2 end = Circle.GetPosition(currentLine.end, CurrentTurn);
                if (CurrentField.InField(end) && Connect(begin, end)) {
                    if (Circle.CheckWon()) {
                        LinesGame.CurrentState = new ClosingState(CurrentTurn);
                    } else {
                        NextTurn();
                    }
                } else {
                    OldLines.Add(currentLine);
                }

                currentLine = null;
            }
        }