/// <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++; }
/// <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++; }
/// <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()); }
/// <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()); }
/// <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); }
/// <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()); }
/// <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); }
/// <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); }