Пример #1
0
        /// <summary>
        /// Adds to the list.
        /// </summary>
        /// <param name="item">Item</param>
        public void Add(Items item)
        {
            Node temp    = new Node(item);
            Node current = head;

            while (current.GetNext() != null)
            {
                current = current.GetNext();
            }
            current.SetNext(temp);
            listCount++;
        }
Пример #2
0
        /// <summary>
        /// Adds item to the list by specific index.
        /// </summary>
        /// <param name="item">Item</param>
        /// <param name="index">Index</param>
        public void Add(Items item, int index)
        {
            Node temp    = new Node(item);
            Node current = head;

            for (int i = 1; i < index && current.GetNext() != null; i++)
            {
                current.GetNext();
            }
            temp.SetNext(current.GetNext());
            current.SetNext(temp);
            listCount++;
        }
Пример #3
0
        /// <summary>
        /// Returns color of item.
        /// </summary>
        /// <param name="index">index</param>
        /// <returns>ConsoleColor</returns>
        public RLColor GetColor(int index)
        {
            Node current = head.GetNext();

            for (int i = 1; i < index; i++)
            {
                if (current.GetNext() == null)
                {
                    return(RLColor.White);
                }
                current = current.GetNext();
                break;
            }
            return(current.GetColor());
        }
Пример #4
0
        /// <summary>
        /// Gets item by index???
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public Items GetSingleItem(int index)
        {
            Node current = head.GetNext();

            for (int i = 1; i < index; i++)
            {
                if (current.GetNext() == null)
                {
                    return(null);
                }
                current = current.GetNext();
                break;
            }
            return(current.GetItems());
        }
Пример #5
0
        /// <summary>
        /// Gets index by name of the item. (unused)
        /// </summary>
        /// <param name="name">Search</param>
        /// <param name="index">Index</param>
        /// <returns></returns>
        public int GetIndexAtName(string name, int index)
        {
            int thing = 0;

            if (index <= 0)
            {
                return(0);
            }
            Node   current = head.GetNext();
            string temp;

            for (int i = 0; i < index; i++)
            {
                temp = current.GetName();
                if (temp == name)
                {
                    //Console.WriteLine("Found");
                    thing = i;
                    break;
                }
                else
                {
                }
                current = current.GetNext();
            }
            return(thing);
        }
Пример #6
0
        /// <summary>
        /// Returns item at index.
        /// </summary>
        /// <param name="index">Index</param>
        /// <returns></returns>
        public Items Get(int index)
        {
            if (index <= 0)
            {
                return(null);
            }

            Node current = head.GetNext();

            for (int i = 1; i < index; i++)
            {
                if (current.GetNext() == null)
                {
                    return(null);
                }
                current = current.GetNext();
            }
            return(current.GetItems());
        }
Пример #7
0
        /// <summary>
        /// Returns string representation of the list.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            Node   current = head.GetNext();
            string output  = "Inventory:\n";

            while (current != null)
            {
                output += $"[{current.GetName()}]";
                current = current.GetNext();
            }
            return(output);
        }
Пример #8
0
        /// <summary>
        /// Returns an array of all items.
        /// </summary>
        /// <returns>Items Array</returns>
        public Items[] GetAllItemsFuckingCunt()
        {
            Items[] tempItemsArray = new Items[Size()];
            Node    current        = head.GetNext();
            int     count          = 0;

            while (current != null)
            {
                tempItemsArray[count] = current.GetItems();
                current = current.GetNext();
                count++;
            }
            return(tempItemsArray);
        }