示例#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();
        }
示例#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!");
            }
        }
示例#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!");
            }
        }
示例#4
0
    private IEnumerator SetPoints()
    {
        yield return(0);

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

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

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

            OnPointsChanged?.Invoke();
        }
示例#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();
 }
示例#9
0
 public void SetPoints(List <Point> list)
 {
     lock (this) {
         points.Clear();
         foreach (var p in list)
         {
             points.AddLast(p);
         }
     }
     OnPointsChanged?.Invoke();
 }
示例#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);
        }
示例#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]);
        }
示例#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();
        }
示例#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();
            }
        }
示例#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();
        }
示例#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!");
     }
 }
示例#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();
        }
示例#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;
        }
示例#18
0
 public void AddPoints(int amount)
 {
     points += amount;
     OnPointsChanged.Invoke(points);
     // return points;
 }
示例#19
0
 public void AddPoints(int pointsToAdd)
 {
     _points += pointsToAdd;
     OnPointsChanged.Invoke(_points);
 }
示例#20
0
 private void OnPointsChangedEvent()
 {
     OnPointsChanged?.Invoke(points);
 }
示例#21
0
 public void Move(Vector vector)
 {
     Parent.MovePoint(Index, vector);
     OnPointsChanged?.Invoke();
 }
示例#22
0
    public void IncreasePoints(int value = 1)
    {
        points += value;

        OnPointsChanged?.Invoke(value);
    }