public int extrasID; // which extra option was selected // CONSTRUCTOR for the class public SaveableStaff(StaffMember s) { this.index = s.GetIndex(); this.currentJob = s.GetJobID(); this.dayHired = s.GetStartDay(); this.name = s.GetStaffname(); this.attributes = s.GetAttributes(); this.transformID = s.GetTransformID(); Color[] c = s.GetAllColours(); // set colours for (int i = 0; i < 3; i++) { colourArrays[i,0] = c[i].r; colourArrays[i,1] = c[i].g; colourArrays[i,2] = c[i].b; } hairStyleID = s.GetHairID(); extrasID = s.GetExtrasID(); }
/// <summary> /// Create a staff member /// </summary> /// <param name="staff">The staff member object associated with the Game Object</param> /// <param name="xPos">The x position of the staff member</param> /// <param name="yPos">The y position of the staff member</param> void CreateStaff(StaffMember staff, int xPos, int yPos) { // get the colours to set the components to Color[] colours = AppearanceScript.colours; Vector3 pos = new Vector3(xPos, yPos); Transform t = staff.GetTransform(); GameObject goStaff = (GameObject)Instantiate(t.gameObject, pos, Quaternion.identity); goStaff.name = "Staff#" + staff.GetIndex(); goStaff.tag = "Staff"; goStaff.GetComponent<mouseDrag>().staffMember = staff; float x = pos.x; float y = pos.y; goStaff.GetComponent<mouseDrag>().staffMember.SetVector(x, y); // colours[2] = skin // colours[1] = hair // colours[0] = shirt SpriteRenderer[] components = goStaff.GetComponentsInChildren<SpriteRenderer>(); components[0].color = colours[0]; components[1].color = colours[2]; components[2].color = colours[2]; components[3].color = colours[1]; components[4].color = colours[1]; components[0].sortingOrder = xPos; components[1].sortingOrder = xPos + 2; components[2].sortingOrder = xPos + 1; components[3].sortingOrder = xPos + 3; components[4].sortingOrder = xPos + 2; components[5].sortingOrder = xPos + 3; components[6].sortingOrder = xPos + 1; // TODO: sort the colour if not 0 or 2 components[3].sprite = AppearanceScript.hairStyle; components[4].sprite = AppearanceScript.extraOption; GameObject[] sms = GameObject.FindGameObjectsWithTag("Staff"); for (int i = 0; i < sms.Length; i++) { sms[i].GetComponent<SpriteRenderer>().color = colours[0]; } // staff menu stuff GameObject go = (GameObject)Instantiate(staffInfoObject.gameObject, new Vector3(0, 0, 0), Quaternion.identity); go.transform.SetParent(popupController.staffList, false); Image[] imgs = go.GetComponentsInChildren<Image>(); Text[] txts = go.GetComponentsInChildren<Text>(); imgs[1].color = staff.GetColourByIndex(2); imgs[2].color = staff.GetColourByIndex(1); imgs[3].color = staff.GetColourByIndex(1); if (staff.GetHairStyle() != null) { imgs[3].sprite = staff.GetHairStyle(); } else { imgs[3].sprite = null; imgs[3].color = new Color(0, 0, 0, 0); } if (staff.GetExtras() != null) { imgs[2].sprite = staff.GetExtras(); } else { imgs[2].sprite = null; imgs[2].color = new Color(0, 0, 0, 0); } txts[0].text = staff.GetStaffname(); Button b = imgs[4].GetComponent<Button>(); b.onClick.AddListener(() => MoveToStaffLocation(staff.GetIndex())); Button b2 = imgs[5].GetComponent<Button>(); b2.onClick.AddListener(() => ViewStaffMemberInfo(staff.GetIndex())); staffMenuList.Add(go); // check if the collar needs to change int totalAttribute = staff.GetLevel(); SpriteRenderer collar = goStaff.transform.FindChild("collar").GetComponent<SpriteRenderer>(); collar.sprite = collarImages[totalAttribute - 1]; }