private int FindObjDatePosition(ClothesDetails objDetails, string str) { //tempList can only be as long or smaller than clothesList for (int i = 0; i < clothesList.Count; i++) { if (str == "Date - Oldest to Newest") { //checks if run out of space if (tempList.Count == i) { return(-1); } //compares the position's date against the current items date if (System.DateTime.Compare(objDetails.getDT(), tempList[i].GetComponent <ClothesDetails>().getDT()) <= 0) { return(i); } } if (str == "Date - Newest to Oldest") { if (tempList.Count == i) { return(-1); } if (System.DateTime.Compare(objDetails.getDT(), tempList[i].GetComponent <ClothesDetails>().getDT()) >= 0) { return(i); } } } return(-1); }
public bool isTheSameAs(ClothesDetails newItem) { if (!ItemName.text.Equals(newItem.getName())) { //Debug.Log("new Item" + newItem.name + " has a different name to " + this.name); return(false); } if (price != newItem.getPrice()) { //Debug.Log("new Item" + newItem.name + " has a different price to " + this.name); return(false); } if (!ItemColour.text.Equals(newItem.getColour())) { //Debug.Log("new Item" + newItem.name + " has a different colour to " + this.name); return(false); } string size = "Medium"; if (newItem.gameObject.transform.parent.gameObject.GetComponentInParent <ClothesDisplay>() != null) { size = newItem.gameObject.transform.parent.gameObject.GetComponentInParent <ClothesDisplay>().sizeField; if (size == "Default") { size = "Medium"; } } if (!ItemSize.text.Equals(size)) { //Debug.Log("new Item" + newItem.name + " has a different size to " + this.name); return(false); } //Debug.Log("new Item" + newItem.name + " is identical to " + this.name); return(true); }
private void Awake() { if (!player) { player = GameObject.FindGameObjectWithTag("Player"); } holdingObject = false; displayActive = false; details = this.GetComponent <ClothesDetails>(); myDestination = GameObject.Find("GrabDestination").GetComponent <Transform>(); }
public void addItem(ClothesDetails newItem) { Debug.Log("Adding Item named " + newItem.getName()); //Check if this item is already in the basket foreach (BasketEntry b in basketEntries) { if (b.isTheSameAs(newItem)) { b.increaseQuantity(); return; } } GameObject newEntry = Instantiate(basketEntry, new Vector3(0, 0, 0), basketMenu.transform.rotation, entryContainer); Debug.Log(basketEntries.Count); newEntry.transform.localPosition = new Vector3(2, 75 + (-30 * basketEntries.Count), 0); newEntry.GetComponent <BasketEntry>().importDetails(newItem); basketEntries.Add(newEntry.GetComponent <BasketEntry>()); }
public void importDetails(ClothesDetails details) { ItemName.text = details.getName(); ItemColour.text = details.getColour(); if (details.gameObject.transform.parent.gameObject.GetComponentInParent <ClothesDisplay>() != null) { ItemSize.text = details.gameObject.transform.parent.gameObject.GetComponentInParent <ClothesDisplay>().sizeField; if (details.gameObject.transform.parent.gameObject.GetComponentInParent <ClothesDisplay>().sizeField == "Default") { ItemSize.text = "Medium"; } } else { ItemSize.text = "Medium"; } ItemQuantity.text = quantityValue.ToString(); price = details.getPrice(); ItemCost.text = "£" + (price).ToString(); }
// Start is called before the first frame update void Start() { parent = transform.parent.GetComponent <ClothesDetails>(); itemNameText.text = parent.getName(); dateText.text = parent.day + "/" + parent.month + "/" + parent.year; priceText.text = "£" + parent.getPrice().ToString(); string tempSizeText = ""; foreach (string size in parent.getSize()) { if (tempSizeText.Length == 0) { tempSizeText += size.Substring(0, 1); } else { tempSizeText += "/" + size.Substring(0, 1); } } sizeText.text = tempSizeText; colourText.text = parent.getColour(); }
private int FindIndex(ClothesDetails cd, string str) { ClothesDetails term2; foreach (GameObject GO in tempList) { term2 = GO.GetComponent <ClothesDetails>(); if (str == "Price - Highest to Lowest") { if (cd.getPrice() >= term2.getPrice()) { return(tempList.IndexOf(GO)); } } else if (str == "Price - Lowest to Highest") { if (cd.getPrice() <= term2.getPrice()) { return(tempList.IndexOf(GO)); } } } return(-1); }