/// <summary> /// Hiring a new staff member (after the appearance has been selected) /// </summary> /// <param name="name">The staff members name</param> /// <param name="hID">The ID of the hair sprite to use</param> /// <param name="eID">The ID of the extras sprite to use</param> public void AddStaffMember(String name, int hID, int eID) { int id = staffMembers.Count; StaffMember sm = new StaffMember(id, name, staffPrefab, currDay, 0, AppearanceScript.hairStyle); Color[] cols = new Color[3]; cols[0] = AppearanceScript.colours[0]; cols[1] = AppearanceScript.colours[1]; cols[2] = AppearanceScript.colours[2]; sm.SetColours(cols, hID, eID); Sprite hairSprite, extrasSprite; hairSprite = AppearanceScript.hairStyle; extrasSprite = AppearanceScript.extraOption; sm.SetSprites(hairSprite, extrasSprite); staffMembers.Add(sm); int x = 35 + (2 * (id % 6)); int y = (2 * (id / 6)); CreateStaff(sm, x, y); Transform t = staffMembers[staffMembers.Count - 1].GetTransform(); t.FindChild("hiddenPointer").GetComponent<SpriteRenderer>().enabled = false; Color c = AppearanceScript.colours[0]; Color toPass = new Color(c.r, c.g, c.b, 1); for (int i = 0; i < staffMembers.Count; i++) { staffMembers[i].UniformChanged(toPass); } }
// Use this for initialization void Start() { options = new Options(); ConfirmationScript[] sdsdfd = GameObject.FindObjectsOfType<ConfirmationScript>(); ticketQueue = new CustomerQueue(11, 38.5f, 6.8f, 0); #region Find Objects theTileManager = GameObject.Find("TileManagement").GetComponent<TileManager>(); GameObject custStatus = GameObject.Find("Customer Status"); movementScript.customerStatus = custStatus; GameObject[] tmpArray = GameObject.FindGameObjectsWithTag("Floor Tile"); steps = GameObject.Find("Steps"); mouseDrag.staffAttributePanel = GameObject.Find("Staff Attributes"); #endregion Customer.tiles = floorTiles; #region Hide Objects on Start custStatus.SetActive(false); shopController.redCarpet.SetActive(false); mouseDrag.staffAttributePanel.SetActive(false); #endregion #region Add Delegate references mouseDrag.getStaffJobById += GetStaffJobById; mouseDrag.changeStaffJob += UpdateStaffJob; movementScript.addToQueueTickets += AddToQueueTickets; movementScript.getQueueTicketsSize += GetTicketQueueSize; movementScript.addToQueueFood += AddToQueueFood; movementScript.getQueueFoodSize += GetFoodQueueSize; #endregion #region Facebook stuff GameObject pnlNoFriends = GameObject.Find("pnlNoFriends"); try { string fbUserID = FBScript.current.id; if (fbUserID.Length > 0) { cmdFriends.SetActive(true); facebookProfile = new FacebookFriend(); facebookProfile.name = FBScript.current.firstname + " " + FBScript.current.surname; facebookProfile.id = FBScript.current.id; facebookProfile.friends = FBScript.current.friendList; if (facebookProfile.friends.Count > 0) { pnlNoFriends.SetActive(false); } else { pnlNoFriends.SetActive(true); } for (int i = 0; i < facebookProfile.friends.Count; i++) { GameObject go = (GameObject)Instantiate(friendObject.gameObject, new Vector3(0, 0, 0), Quaternion.identity); go.transform.SetParent(popupController.friendList, false); Text[] textComponents = go.GetComponentsInChildren<Text>(); textComponents[0].text = facebookProfile.friends[i].name; Button[] buttonComponents = go.GetComponentsInChildren<Button>(); string idToSend = facebookProfile.friends[i].id; string nameToSend = facebookProfile.friends[i].name; buttonComponents[0].onClick.AddListener(() => ViewFriendsCinema(idToSend, nameToSend)); buttonComponents[1].onClick.AddListener(() => ViewFriendsCinema(idToSend, nameToSend)); } } else { pnlNoFriends.SetActive(true); // if the user has not logged into Facebook, hide the facebook friends button cmdFriends.SetActive(false); } } catch (Exception) { } #endregion // this will change depending on starting upgrade levels and other queues etc #region Load / New Game if (ButtonScript.friendData != null) { GameObject.Find("Bottom Panel").SetActive(false); GameObject.Find("lblOwnerName").GetComponent<Text>().text = ButtonScript.owner + "'s Cinema"; ButtonScript.dataCopy = ButtonScript.loadGame; ButtonScript.loadGame = ButtonScript.friendData; ButtonScript.friendData = null; } else { GameObject.Find("FriendPanel").SetActive(false); } // get Player data. If not null, load game if (ButtonScript.loadGame == null) { financeController.Inititalise(45000, 4); carpetColour = GetColourFromID(1); customerController.reputation = new Reputation(); customerController.reputation.Initialise(); OtherObjectScript.CreateStaffSlot(1, new Vector3(37.8f, 12.3f, 0)); #region Floor Tiles floorTiles = new GameObject[40, 80]; // initialise the floor tiles for (int i = 0; i < tmpArray.Length; i++) { string name = tmpArray[i].name; string[] tmp = name.Split('~'); int x = int.Parse(tmp[1]); int y = int.Parse(tmp[2]); tmpArray[i].GetComponent<SpriteRenderer>().color = carpetColour; tmpArray[i].GetComponent<SpriteRenderer>().sprite = ColourBackground; //tmpArray[i].GetComponent<SpriteRenderer>().sprite = profilePicture; // for funny times, uncomment this line floorTiles[x, y] = tmpArray[i]; } #endregion for (int i = 0; i < 1; i++) { Vector3 pos = floorTiles[i * 11, 0].transform.position; ShopController.theScreens.Add(new ScreenObject((i + 1), 0)); ShopController.theScreens[i].SetPosition((int)pos.x, (int)pos.y); } ShopController.theScreens[0].Upgrade(); ShopController.theScreens[0].UpgradeComplete(); // NYAH NextDay(false, false); // do staff intro thing here popupController.ShowPopup(99, "Welcome!!! This is your cinema!\nLets get started by hiring some staff shall we?"); foodArea = null; } else { statusCode = 0; PlayerData data = ButtonScript.loadGame; carpetColour = new Color(data.carpetColour[0], data.carpetColour[1], data.carpetColour[2]); shopController.LoadDecorations(data.hasRedCarpet, data.posters); isMarbleFloor = data.marbleFloor; customerController.reputation = data.reputation; foodArea = data.foodArea; options.Load(data.options); int boxLevel = data.boxOfficeLevel; OtherObjectScript.CreateStaffSlot(1, new Vector3(37.8f, 12.3f, 0)); for (int i = 0; i < boxLevel - 1; i++) { OtherObjectScript.UpgradeBoxOffice(); } #region Floor Tiles // initialise the floor tiles floorTiles = new GameObject[40, 80]; for (int i = 0; i < tmpArray.Length; i++) { string name = tmpArray[i].name; string[] tmp = name.Split('~'); int x = int.Parse(tmp[1]); int y = int.Parse(tmp[2]); tmpArray[i].GetComponent<SpriteRenderer>().color = carpetColour; if (!isMarbleFloor) { tmpArray[i].GetComponent<SpriteRenderer>().sprite = ColourBackground; } else { tmpArray[i].GetComponent<SpriteRenderer>().sprite = marbleSquares[UnityEngine.Random.Range(0, 3)]; } floorTiles[x, y] = tmpArray[i]; } #endregion ShopController.theScreens = new List<ScreenObject>(data.theScreens); SaveableStaff[] s = data.staffMembers; for (int i = 0; i < s.Length; i++) { int id = s[i].index; string name = s[i].name; Transform transform = staffPrefab; int dayHired = s[i].dayHired; int tID = s[i].transformID; int[] attributes = s[i].attributes; float[,] cols = s[i].colourArrays; int hair = s[i].hairStyleID; int extras = s[i].extrasID; GameObject go = GameObject.Find("AppearanceController"); AppearanceScript aS = go.GetComponent<AppearanceScript>(); Sprite hairSprite = null; Sprite extraSprite = null; if (hair != 9) { hairSprite = aS.hairStyles[hair]; } if (extras != 5) { extraSprite = aS.extraImages[extras]; } Color[] c = new Color[3]; for (int colID = 0; colID < 3; colID++) { c[colID] = new Color(cols[colID, 0], cols[colID, 1], cols[colID, 2]); } StaffMember newStaff = new StaffMember(id, name, transform, dayHired, tID, hairSprite); newStaff.SetColours(c, hair, extras); newStaff.SetSprites(hairSprite, extraSprite); newStaff.SetAttributes(attributes); int x = 35 + (2 * (newStaff.GetIndex() % 6)); ; int y = 2 * (newStaff.GetIndex() / 6); staffMembers.Add(newStaff); CreateStaff(newStaff, x, y); } filmShowings = new List<FilmShowing>(data.filmShowings); currDay = data.currentDay; numScreens = ShopController.theScreens.Count; financeController.Inititalise(data.totalCoins, data.numPopcorn); ShopController.otherObjects = new List<OtherObject>(data.otherObjects); NextDay(false, false); currDay--; // needed for some reason // hopefully un-breaks things for (int i = 0; i < ShopController.theScreens.Count; i++) { Vector3 pos = new Vector3(ShopController.theScreens[i].GetX(), ShopController.theScreens[i].GetY(), 0); ShopController.theScreens[i].SetPosition((int)pos.x, (int)(pos.y)); } // sort staff appearance GameObject[] staffs = GameObject.FindGameObjectsWithTag("Staff"); for (int i = 0; i < staffs.Length; i++) { SpriteRenderer[] srs = staffs[i].GetComponentsInChildren<SpriteRenderer>(); srs[0].color = staffMembers[i].GetColourByIndex(0); srs[1].color = staffMembers[i].GetColourByIndex(2); srs[2].color = staffMembers[i].GetColourByIndex(2); srs[3].color = staffMembers[i].GetColourByIndex(1); srs[4].color = staffMembers[i].GetColourByIndex(1); srs[3].sprite = staffMembers[i].GetHairStyle(); srs[4].sprite = staffMembers[i].GetExtras(); } shopController.ShowPosters(0); shopController.ShowPosters(1); if (popcornSpent > 0) { financeController.RemovePopcorn(Controller.popcornSpent); financeController.popcornLabel.text = financeController.GetNumPopcorn().ToString(); Controller.popcornSpent = 0; DoAutosave(); } string fbID = FBScript.current.id; try { if (isOwned) { Gifting g = new Gifting(); List<String> gifts = g.GetGifts(fbID); if (gifts.Count > 0) { List<int> counts = new List<int>(); List<string> names = new List<string>(); // group together - i.e. Susan McDonaldman: 3 for (int i = 0; i < gifts.Count; i++) { bool found = false; for (int checkLoop = 0; checkLoop < names.Count; checkLoop++) { if (names[checkLoop].Equals(gifts[i])) { found = true; counts[checkLoop]++; break; } } if (!found) { names.Add(gifts[i]); counts.Add(1); } } financeController.AddPopcorn(gifts.Count); for (int i = 0; i < names.Count; i++) { // add the element / objects Transform t = Instantiate(giftObject, new Vector2(0, 0), Quaternion.identity) as Transform; // set parent to the element container Transform giftContainer = GameObject.Find("GiftContainer").transform; t.SetParent(giftContainer); // change the values Text[] txts = t.GetComponentsInChildren<Text>(); txts[0].text = names[i]; txts[1].text = counts[i].ToString(); } // show the popup GameObject giftPanel = GameObject.Find("GiftList"); giftPanel.GetComponent<Canvas>().enabled = true; DoAutosave(); } } } catch (Exception) { popupController.ShowPopup(0, "Error getting Gifts"); } } #endregion // create some test screens for (int i = 0; i < ShopController.theScreens.Count; i++) { Vector3 pos = new Vector3(ShopController.theScreens[i].GetX(), ShopController.theScreens[i].GetY() * 0.8f, 0); // change pos and element here pos.y += 0.8f; shopController.AddScreen(ShopController.theScreens[i], pos, height); SetTiles(2, (int)(ShopController.theScreens[i].GetX()), (int)(ShopController.theScreens[i].GetY()), 11, 15); } // do same for other objects for (int i = 0; i < ShopController.otherObjects.Count; i++) { Vector3 pos = new Vector3(ShopController.otherObjects[i].xPos, ShopController.otherObjects[i].yPos * 0.8f, 0); DimensionTuple t = shopController.GetBounds(ShopController.otherObjects[i].type); shopController.AddObject(pos, i, height, ShopController.otherObjects[i].type, true); SetTiles(2, (int)(ShopController.otherObjects[i].xPos), (int)(ShopController.otherObjects[i].yPos), t.width, t.height); } //createColourPicker(); if (updateTileState != null) { updateTileState(33, 0, 14, 16, 1, true); updateTileState(33, 16, 14, 4, 2, true); } GameObject[] pointers = GameObject.FindGameObjectsWithTag("Pointer"); for (int i = 0; i < pointers.Length; i++) { pointers[i].GetComponent<Transform>().GetComponent<SpriteRenderer>().enabled = false; } dayLabel.text = "DAY: " + currDay.ToString(); // create staff slots for food area if not null if (foodArea != null) { GameObject go = GameObject.FindGameObjectWithTag("Food Area"); Vector2 pos = go.transform.position; for (int i = 0; i < foodArea.tableStatus + 1; i++) { OtherObjectScript.CreateStaffSlot(2, pos + new Vector2(3 + (2.5f * i), 7.95f)); } if (foodArea.tableStatus == 1) { foodQueue.Upgrade(); } } NewShowTimes(); }