Esempio n. 1
0
        /// <summary>
        ///     Validates the arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private void ValidateArguments(ProgramArguments args)
        {
            if (!args.Directories.Any())
            {
                args.Directories = args.ConnectionFiles.Select(f => AppDomain.CurrentDomain.BaseDirectory).ToArray();
            }
            else if (args.Directories.Length < args.ConnectionFiles.Length)
            {
                Array.Resize(ref args.Directories, args.ConnectionFiles.Length);

                string p = AppDomain.CurrentDomain.BaseDirectory;

                for (int i = 0; i < args.Directories.Length; i++)
                {
                    if (!string.IsNullOrEmpty(args.Directories[i]))
                    {
                        p = args.Directories[i];
                    }
                    else
                    {
                        args.Directories[i] = p;
                    }
                }
            }
        }
 // Start is called before the first frame update
 void Start()
 {
     //initialized for calling the carddata and deck1definition scripts
     cardData        = cards.GetComponent <CardData>();
     deck1Definition = playerDeck.GetComponent <Deck1Definition>();
     //resizes the cardsLeft array to the ammount of cards in a deck
     //this was done seprately and not when the array was created bc that would be a long line
     Array.Resize(ref cardsLeft, 25);
     deck1Definition.deck1.CopyTo(cardsLeft, 0);
 }
Esempio n. 3
0
            public void Push(T item)
            {
                var capacity = Capacity;

                if (Count == capacity)
                {
                    SysArray.Resize(ref _items, Math.Max(capacity * 2, 4));
                }

                _items[Count] = item;
                Count++;
            }
            public void Push(T item)
            {
                var capacity = Capacity;

                if (Count == capacity)
                {
                    SysArray.Resize(ref _items, Math.Max(capacity * 2, 4));
                }

                Debug.Assert(_items != null);
                _items[Count] = item;
                Count++;
            }
Esempio n. 5
0
 public void ZeroSizeTest()
 {
     using (var map = new MemoryMapStream())
     {
         using (var array = new Array<uint>(map, 0))
         {
             Assert.AreEqual(0, array.Length);
         }
         using (var array = new Array<uint>(map, 100))
         {
             array.Resize(0);
             Assert.AreEqual(0, array.Length);
         }
     }
 }
Esempio n. 6
0
        public void Remove(T item)
        {
            count--;
            var lst = array[count];

            Arr.Resize(ref array, count);
            if (Equals(lst, item))
            {
                return;
            }
            int toRemove = Arr.IndexOf(array, item);

            if (toRemove > -1)
            {
                for (int i = toRemove + 1; i < count; i++)
                {
                    array[i] = array[i - 1];
                }
                array[count - 1] = lst;
            }
        }
 // Update is called once per frame
 void Update()
 {
     //draws cards when it becomes the player's turn
     if (MainHandler.mainHandler.isTurn == true && MainHandler.mainHandler.cardsDrawn == 0)
     {
         i++;
         //creates a random number from 0-24 to call from the deck1[]
         int cardIndex = Mathf.FloorToInt(Random.value * 24);
         //checks if that number is the same as previous to avoid drawing the same card twice
         if (MainHandler.mainHandler.playerDeckNum == 1)
         {
             while (cardsLeft[cardIndex] == "")
             {
                 cardIndex = Mathf.FloorToInt(Random.value * 24);
             }
             //resizes the hand[] to fit all cards drawn
             Array.Resize(ref hand, hand.Length + i);
             hand[i - 1] = cardIndex;
             //deletes the card in the cardsleft[] to keep track of cards drawn
             cardsLeft[cardIndex] = "";
             MainHandler.mainHandler.cardsDrawn++;
         }
     }
 }
Esempio n. 8
0
        public void ResizeTests()
        {
            var randomGenerator = new System.Random(66707770); // make this deterministic 

            using (var map = new MemoryMapStream())
            {
                using (var array = new Array<uint>(map, 1000, 256, 256, 32))
                {
                    var arrayExepected = new uint[1000];

                    for (uint i = 0; i < 1000; i++)
                    {
                        if (randomGenerator.Next(4) >= 2)
                        { // add data.
                            arrayExepected[i] = i;
                            array[i] = i;
                        }
                        else
                        {
                            arrayExepected[i] = int.MaxValue;
                            array[i] = int.MaxValue;
                        }

                        Assert.AreEqual(arrayExepected[i], array[i]);
                    }

                    Array.Resize<uint>(ref arrayExepected, 335);
                    array.Resize(335);

                    Assert.AreEqual(arrayExepected.Length, array.Length);
                    for (int i = 0; i < arrayExepected.Length; i++)
                    {
                        Assert.AreEqual(arrayExepected[i], array[i]);
                    }
                }

                using (var array = new Array<uint>(map, 1000, 256, 256, 32))
                {
                    var arrayExpected = new uint[1000];

                    for (uint i = 0; i < 1000; i++)
                    {
                        if (randomGenerator.Next(4) >= 1)
                        { // add data.
                            arrayExpected[i] = i;
                            array[i] = i;
                        }
                        else
                        {
                            arrayExpected[i] = int.MaxValue;
                            array[i] = int.MaxValue;
                        }

                        Assert.AreEqual(arrayExpected[i], array[i]);
                    }

                    Array.Resize<uint>(ref arrayExpected, 1235);
                    var oldSize = array.Length;
                    array.Resize(1235);

                    Assert.AreEqual(arrayExpected.Length, array.Length);
                    for (int i = 0; i < arrayExpected.Length; i++)
                    {
                        Assert.AreEqual(arrayExpected[i], array[i], 
                            string.Format("Array element not equal at index: {0}. Expected {1}, found {2}",
                                i, array[i], arrayExpected[i]));
                    }
                }
            }
        }
Esempio n. 9
0
 public void Clear()
 {
     count = 0;
     Arr.Resize(ref array, count);
 }
Esempio n. 10
0
 public void Add(T item)
 {
     count++;
     Arr.Resize(ref array, count);
     array[count - 1] = item;
 }