Ejemplo n.º 1
0
        public void ConnectTo(ConnectionNode endNode)
        {
            AutoComplete();

            EndNode = endNode;

            if (startNode is InputNode)
            {
                (startNode as InputNode).ConnectedCable     = this;
                (startNode as InputNode).OnPositionChanged += OnPointsChanged;
            }
            if (startNode is OutputNode)
            {
                (startNode as OutputNode).ConnectedCables.Add(this);
                (startNode as OutputNode).OnPositionChanged += OnPointsChanged;
            }
            if (endNode is InputNode)
            {
                (endNode as InputNode).ConnectedCable     = this;
                (endNode as InputNode).OnPositionChanged += OnPointsChanged;
            }
            if (endNode is OutputNode)
            {
                (endNode as OutputNode).ConnectedCables.Add(this);
                (endNode as OutputNode).OnPositionChanged += OnPointsChanged;
            }

            IsCompleted = true;

            OnPointsChanged?.Invoke();
        }
Ejemplo n.º 2
0
        /// <summary>Adds X (<paramref name="value"/>) points to this PointSystem's Current Points.</summary>
        /// <remarks>
        /// If, after the calculation, the amount
        /// of points is less then MaxPoints, then it triggers OnPointsIncreased and OnPointsChanged events. However if, after the calculation, the amount
        /// of points is greater or equal to MaxPoints, then it triggers OnPointsIncreased, OnPointsChanged and OnPointsMax events.
        ///</remarks>
        /// <param name="value">value to be summed to this PointSystem's Current Points.</param>
        public void AddPoints(int value)
        {
            if (value > 0)
            {
                int aux = currentPoints + value;// Propriedade auxiliar para não precisar repetir função
                if (aux >= maxPoints)
                {
                    currentPoints = maxPoints;
                    OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                        CurrentPointsEventArgs = currentPoints
                    };
                    OnPointsMax?.Invoke(this, EventArgsData);

                    OnPointsIncreased?.Invoke(this, EventArgsData);
                    OnPointsChanged?.Invoke(this, EventArgsData);
                }
                else
                {
                    currentPoints = aux;
                    OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                        CurrentPointsEventArgs = currentPoints
                    };
                    OnPointsIncreased?.Invoke(this, EventArgsData);
                    OnPointsChanged?.Invoke(this, EventArgsData);
                }
            }
            else
            {
                Debug.LogError("value can't be negative nor zero!");
            }
        }
Ejemplo n.º 3
0
        /// <summary>Removes X (<paramref name="value"/>) points from this PointSystem's Current Points (always use positive values, the calculation is made within the function).</summary>
        /// <remarks>
        /// If, after the calculation, the amount
        /// of points is greater then 0, then it triggers OnPointsDecreased and OnPointsChanged events. However if, after the calculation, the amount
        /// of points is less or equal to 0 then it triggers OnPointsDecreased, OnPointsChanged and OnPointsZero events.
        ///</remarks>
        /// <param name="value">value to be subtracted from this PointSystem 's Current Points.</param>
        public void RemovePoints(int value)
        {
            if (value > 0)
            {
                int aux = currentPoints - value;

                if (aux > 0)
                {
                    currentPoints = aux;
                    OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                        CurrentPointsEventArgs = currentPoints
                    };
                    OnPointsDecreased?.Invoke(this, EventArgsData);
                    OnPointsChanged?.Invoke(this, EventArgsData);
                }

                else
                {
                    currentPoints = 0;
                    OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                        CurrentPointsEventArgs = currentPoints
                    };
                    OnPointsDecreased?.Invoke(this, EventArgsData);
                    OnPointsChanged?.Invoke(this, EventArgsData);
                    OnPointsZero?.Invoke(this, EventArgsData);
                }
            }
            else
            {
                Debug.LogError("value can't be negative nor zero!");
            }
        }
Ejemplo n.º 4
0
    private IEnumerator SetPoints()
    {
        yield return(0);

        points = PlayerPrefs.GetInt("InGamePoints") | 0;
        OnPointsChanged.Invoke(points);
    }
Ejemplo n.º 5
0
 public void Clear()
 {
     lock (this) {
         points.Clear();
     }
     OnPointsChanged?.Invoke();
 }
Ejemplo n.º 6
0
        public void AddSegment(Point point)
        {
            Points.Add(MainWindow.Self.Round(point, 0.5));

            Segments.Add(new CableSegment(this, Segments.Count));

            OnPointsChanged?.Invoke();
        }
Ejemplo n.º 7
0
        public void MovePoint(int index, Vector vector)
        {
            if (index > 0 && index < Points.Count + 1)
            {
                Points[index - 1] += vector;
            }

            OnPointsChanged?.Invoke();
        }
Ejemplo n.º 8
0
 public void AddPoint(Point point)
 {
     lock (this) {
         points.AddLast(point);
         while (points.Count > 0 && (points.Count > Limit || (DropOldestCondition?.Invoke(points.First.Value) ?? false)))
         {
             points.RemoveFirst();
         }
     }
     OnPointsChanged?.Invoke();
 }
Ejemplo n.º 9
0
 public void SetPoints(List <Point> list)
 {
     lock (this) {
         points.Clear();
         foreach (var p in list)
         {
             points.AddLast(p);
         }
     }
     OnPointsChanged?.Invoke();
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Set CurrentPoints variable to 0
        /// </summary>
        /// <remarks>Triggers the OnPointsChanged and OnPointsZero events</remarks>
        public void ResetPoints()
        {
            currentPoints = 0;

            OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
                CurrentPointsEventArgs = currentPoints
            };

            OnPointsChanged?.Invoke(this, EventArgsData);
            OnPointsZero?.Invoke(this, EventArgsData);
        }
Ejemplo n.º 11
0
        /// <inheritdoc/>
        public void AddPoints(int guildId, short points)
        {
            if (!GuildPoints.ContainsKey(guildId))
            {
                GuildPoints[guildId] = points;
            }
            else
            {
                GuildPoints[guildId] += points;
            }

            OnPointsChanged?.Invoke(guildId, GuildPoints[guildId]);
        }
Ejemplo n.º 12
0
        public void AddSegment(int index, Point point)
        {
            Points.Insert(index - 1, MainWindow.Self.Round(point, 0.5));

            Segments.Insert(index, new CableSegment(this, index));

            for (int i = index + 1; i < Segments.Count; i++)
            {
                Segments[i].Index++;
            }

            OnPointsChanged?.Invoke();
        }
Ejemplo n.º 13
0
        public void RemoveSegment(int index)
        {
            if (index > 0 && index <= Points.Count)
            {
                Points.RemoveAt(index - 1);

                Segments.RemoveAt(index);

                for (int i = index; i < Segments.Count; i++)
                {
                    Segments[i].Index--;
                }

                OnPointsChanged?.Invoke();
            }
        }
Ejemplo n.º 14
0
        public void AddSegment(Point point)
        {
            if (startNode != null)
            {
                startNode.OnPositionChanged += OnPointsChanged;
            }
            if (endNode != null)
            {
                endNode.OnPositionChanged += OnPointsChanged;
            }

            Points.Add(MainWindow.Self.Round(point, 0.5));

            Segments.Add(new CableSegment(this, Segments.Count));

            OnPointsChanged?.Invoke();
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Set currentPoints in the PointsSystem instance
 /// </summary>
 public void SetCurrentPoints(int currentpoints)
 {
     if (currentpoints > 0 && currentpoints <= maxPoints)
     {
         OnPointsDataEventArgs EventArgsData = new OnPointsDataEventArgs {
             CurrentPointsEventArgs = currentPoints
         };
         if (currentpoints == maxPoints)
         {
             OnPointsMax?.Invoke(this, EventArgsData);
         }
         currentPoints = currentpoints;
         OnPointsChanged?.Invoke(this, EventArgsData);
     }
     else
     {
         Debug.LogError("value can't be negative, zero nor greater then MaxPoints!");
     }
 }
Ejemplo n.º 16
0
        public void AddSegment(int index, Point point)
        {
            if (startNode != null)
            {
                startNode.OnPositionChanged += OnPointsChanged;
            }
            if (endNode != null)
            {
                endNode.OnPositionChanged += OnPointsChanged;
            }

            Points.Insert(index - 1, MainWindow.Self.Round(point, 0.5));

            Segments.Insert(index, new CableSegment(this, index));

            for (int i = index + 1; i < Segments.Count; i++)
            {
                Segments[i].Index++;
            }

            OnPointsChanged?.Invoke();
        }
Ejemplo n.º 17
0
        private void MainWindow_MouseMove(object sender, MouseEventArgs e)
        {
            if (currentMode == ManipulateMode.All)
            {
                Cursor = Cursors.Arrow;
            }
            CustomPoint over = GetPointAt(e.GetPosition(this));

            if (over != null)
            {
                Cursor = Cursors.SizeAll;
            }

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (selectedPoint != null)
                {
                    Cursor = Cursors.SizeAll;
                    HandleMovement(e.GetPosition(this));
                    InvalidateVisual();
                    OnPointsChanged?.Invoke();

                    UpdateRawPoints();
                }
                else
                {
                    double deltaX = e.GetPosition(this).X - prevMouseX;
                    double deltaY = e.GetPosition(this).Y - prevMouseY;
                    Cursor = Cursors.Hand;
                    translateTransform.X += deltaX;
                    translateTransform.Y -= deltaY;
                    InvalidateVisual();
                }
            }
            prevMouseX = e.GetPosition(this).X;
            prevMouseY = e.GetPosition(this).Y;
        }
Ejemplo n.º 18
0
 public void AddPoints(int amount)
 {
     points += amount;
     OnPointsChanged.Invoke(points);
     // return points;
 }
Ejemplo n.º 19
0
 public void AddPoints(int pointsToAdd)
 {
     _points += pointsToAdd;
     OnPointsChanged.Invoke(_points);
 }
Ejemplo n.º 20
0
 private void OnPointsChangedEvent()
 {
     OnPointsChanged?.Invoke(points);
 }
Ejemplo n.º 21
0
 public void Move(Vector vector)
 {
     Parent.MovePoint(Index, vector);
     OnPointsChanged?.Invoke();
 }
Ejemplo n.º 22
0
    public void IncreasePoints(int value = 1)
    {
        points += value;

        OnPointsChanged?.Invoke(value);
    }