/// <summary> /// Add a new object to the cinema /// </summary> /// <param name="x">The x position to add it in</param> /// <param name="y">The y position to add it in</param> public void AddNewObject(int x, int y) { popupController.confirmMovePanel.SetActive(false); popupController.moveButtons.SetActive(false); Vector3 pos = new Vector3(x, y * 0.8f, 0); //float xCorrection = 0; //float yCorrection = 0; if (itemToAddID == 0) { //xCorrection = 4.6f; //yCorrection = 6.05f; int newID = ShopController.theScreens.Count; ScreenObject aScreen = new ScreenObject(newID + 1, 0); aScreen.SetPosition(x, y); aScreen.Upgrade(); ShopController.theScreens.Add(aScreen); //pos.x += xCorrection; //pos.y += yCorrection; pos.y += 0.8f; // gap at bottom GameObject screenThing = shopController.AddScreen(ShopController.theScreens[newID], pos, height); // check staff position CheckStaffPosition(screenThing); for (int i = 0; i < staffMembers.Count; i++) { staffMembers[i].GetTransform().Translate(new Vector3(0, 0, -1)); } } else { if (itemToAddID == 7) { foodArea = new FoodArea(); foodArea.hasHotFood = true; // give them 1 thing to start with foodQueue = new CustomerQueue(70, x + 3, ((y + 4) * 0.8f) - 1, 1); } OtherObject oo = new OtherObject(x, y, itemToAddID, ShopController.otherObjects.Count + 1); ShopController.otherObjects.Add(oo); GameObject theObject = shopController.AddObject(pos, ShopController.otherObjects.Count, height, itemToAddID, true); // check staff position CheckStaffPosition(theObject); for (int i = 0; i < staffMembers.Count; i++) { staffMembers[i].GetTransform().Translate(new Vector3(0, 0, -1)); } SpriteRenderer[] subImages = theObject.GetComponentsInChildren<SpriteRenderer>(); if (itemToAddID == 7) { try { subImages[1].enabled = foodArea.hasHotFood; subImages[2].enabled = foodArea.hasPopcorn; subImages[3].enabled = foodArea.hasIceCream; subImages[4].enabled = true; subImages[5].enabled = true; int baseOrder = subImages[0].sortingOrder; subImages[0].sortingOrder = baseOrder - 2; subImages[1].sortingOrder = baseOrder + 1; subImages[2].sortingOrder = baseOrder + 1; subImages[3].sortingOrder = baseOrder + 1; subImages[4].sortingOrder = baseOrder + 1; subImages[5].sortingOrder = baseOrder - 5; OtherObjectScript.CreateStaffSlot(2, theObject.transform.position + new Vector3(3, 7.95f, 0)); NewShowTimes(); } catch (Exception) { } } } itemToAddID = -1; SetTiles(2, theTileManager.toMoveX, theTileManager.toMoveY, theTileManager.fullWidth, theTileManager.fullHeight); ChangeColour(carpetColour, theTileManager.toMoveX, theTileManager.toMoveY, theTileManager.fullWidth, theTileManager.fullHeight); CheckForPath(); theTileManager.ResetStatusVariables(); statusCode = 0; //GameObject[] staff = GameObject.FindGameObjectsWithTag("Staff"); //for (int i = 0; i < staff.Length; i++) //{ // SpriteRenderer[] srs = staff[i].GetComponentsInChildren<SpriteRenderer>(); // for (int j = 0; j < 6; j++) // { // srs[j].enabled = true; // } // srs[5].enabled = false; // // sort z position // staff[i].transform.position = new Vector3(staff[i].transform.position.x, staff[i].transform.position.y, -1); //} ReShowStaffAndBuildings(); GameObject foodPlace = GameObject.FindGameObjectWithTag("Food Area"); if (foodPlace != null) { SpriteRenderer[] foodAreaRenderers = foodPlace.GetComponentsInChildren<SpriteRenderer>(); foreach (SpriteRenderer sr in foodAreaRenderers) { sr.color = new Color(1, 1, 1, 1); } } objectSelected = ""; tagSelected = ""; upgradeLevelSelected = 0; }