public void Swap(T[] items, int x, int y)
        {
            SwapEvent?.Invoke(this, new Tuple <int, int>(x, y));

            T temp = items[x];

            items[x] = items[y];
            items[y] = temp;
        }
示例#2
0
 protected void Swap(int posA, int posB)
 {
     if (posA < Items.Count && posB < Items.Count)
     {
         SwapEvent?.Invoke(this, new Tuple <T, T>(Items[posA], Items[posB]));
         SwapCount++;
         var temp = Items[posA];
         Items[posA] = Items[posB];
         Items[posB] = temp;
     }
 }
示例#3
0
 protected void Swap(int FirstPosition, int SecondPosition)
 {
     if (FirstPosition < Items.Count && SecondPosition < Items.Count)
     {
         SwapEvent?.Invoke(this, new Tuple <int, int>(FirstPosition, SecondPosition));
         var tmp = Items[FirstPosition];
         Items[FirstPosition]  = Items[SecondPosition];
         Items[SecondPosition] = tmp;
         ++SwapCount;
     }
 }
示例#4
0
        public void Swap(int first, int second)
        {
            if (first < Items.Count && second < Items.Count)
            {
                SwapEvent?.Invoke(this, new Tuple <T, T>(Items[first], Items[second]));
                SwapCount++;

                var temp = Items[first];
                Items[first]  = Items[second];
                Items[second] = temp;
            }
        }
示例#5
0
    public void Swap(int _withIndex)
    {
        EndCurrentEvent();

        SwapEvent swapEvent = new SwapEvent();

        swapEvent.TargetLocation = gameGrid.GetWorldPositionOfIndex(_withIndex);
        swapEvent.SizeCurve      = MasterManager.instance.BlockEvents.SwapScaleAnimCurve;
        swapEvent.Time           = MasterManager.instance.BlockEvents.SwapEventTime;
        currentEvent             = swapEvent;
        currentEvent.Start(this);
    }
 protected void Swap(int index1, int index2)
 {
     if (index1 < Items.Count && index2 < Items.Count)
     {
         SwapEvent?.Invoke(this, new Tuple <T, T>(Items[index1], Items[index2]));
         T temp = Items[index1];
         Items[index1] = Items[index2];
         Items[index2] = temp;
         SwapCount++;
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
 }
        protected void InsertAt(int index1, int index2)
        {
            if (index1 < Items.Count && index2 < Items.Count)
            {
                int step = index1 > index2 ? 1 : -1;
                for (int i = index2; index1 > index2 ? i <index1 : i> index1; i += step)
                {
                    SwapEvent?.Invoke(this, new Tuple <T, T>(Items[i + step], Items[i]));
                    T temp = Items[i + step];
                    Items[i + step] = Items[i];
                    Items[i]        = temp;
                }

                SwapCount++;
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }
        }
示例#8
0
        private void OnSwap(object sender, Tuple <int, int> e)
        {
            _result.SwapsCount++;

            SwapEvent?.Invoke(this, e);
        }