public BoxStack CreateStackPlaceholder(int ignoreIndex) { GameObject newPlaceholderStack = new GameObject("Placeholder Stack"); BoxStack newStack = newPlaceholderStack.AddComponent <BoxStack>(); if (boxList.Count > 0) { newPlaceholderStack.transform.position = boxList[0].transform.position; for (int i = 0; i < boxList.Count; i++) { int temp = i; Box currentBox = boxList[temp]; StorageBox parentProduct = (StorageBox)currentBox.product; boxList[i].product.PlayCloseAnimation(); if (i != ignoreIndex) { Box newBox = Instantiate(boxList[i]); parentProduct.box = newBox.gameObject; newBox.product = parentProduct; //newBoxObject.product.PlayCloseAnimation(); if (newBox.GetComponent <Placeholder>() == null) { newBox.gameObject.AddComponent <Placeholder>(); } newStack.AddBox(newBox); } } } newStack.SortStack(newStack.transform.position, true, false); return(newStack); }
public BoxStack CreateBoxStack() { GameObject newBoxStackGO = new GameObject("BoxStack"); newBoxStackGO.transform.position = transform.position; BoxStack newBoxStack = newBoxStackGO.AddComponent <BoxStack>(); newBoxStack.AddBox(this); return(newBoxStack); }
public static BoxStack CreatePlaceholderStack(BoxStack stack) { Database database = GameObject.Find("Database").GetComponent <Database>(); GameObject newBoxStackGO = new GameObject("BoxStack_Placeholder"); BoxStack newBoxStack = newBoxStackGO.AddComponent <BoxStack>(); int counter = 0; foreach (Box box in stack.boxList) { GameObject placeholderBox = Instantiate(database.GetStoreObject(box.product.objectID, 1).gameObject_); // Placeholder box is same id but with subid 1 if (counter == 0) { newBoxStack.transform.position = placeholderBox.transform.position; placeholderBox.transform.localPosition = new Vector3(0, 0, 0); counter++; } newBoxStack.AddBox(placeholderBox.GetComponent <Box>()); } //newBoxStack.SortStack(stack.transform.position, true); return(newBoxStack); }
public BoxStack GetStack() { // Called to create placeholder, fills the boxStack list GameObject newBoxStackGO = new GameObject("BoxStack"); BoxStack newBoxStack = newBoxStackGO.AddComponent <BoxStack>(); newBoxStack.stackIndex = boxStacks.Count; for (int i = 0; i < BOXSTACKSIZE; i++) { Box newBox = GetBox(); if (newBox != null) { if (i == 0) { newBoxStackGO.transform.position = newBox.transform.position; } newBoxStack.AddBox(newBox); } } boxStacks.Add(newBoxStack); return(newBoxStack); }
public BoxStack CreateStackPlaceholder_IncreasedSize(Box newBox) { List <Box> tempBoxList = new List <Box>(); foreach (Box box in boxList) { tempBoxList.Add(box); } tempBoxList.Add(newBox); tempBoxList.Sort(SortBoxes); GameObject newPlaceholderStack = new GameObject("Placeholder Stack"); BoxStack newStack = newPlaceholderStack.AddComponent <BoxStack>(); if (tempBoxList.Count > 0) { newPlaceholderStack.transform.position = tempBoxList[0].transform.position; for (int i = 0; i < tempBoxList.Count; i++) { int temp = i; Box currentBox = tempBoxList[temp]; StorageBox parentProduct = (StorageBox)currentBox.product; Box newBoxObject = Instantiate(tempBoxList[i]); parentProduct.box = newBoxObject.gameObject; newBoxObject.product = parentProduct; newBoxObject.gameObject.SetActive(true); //newBoxObject.product.PlayCloseAnimation(); if (newBox.GetComponent <Placeholder>() == null) { newBox.gameObject.AddComponent <Placeholder>(); } newStack.AddBox(newBoxObject); } } newStack.SortStack(newStack.transform.position, true, false); Destroy(newBox.gameObject); // destory box that was originally sent return(newStack); }