void OnClick() { ///grab the ref to the current chosen staff CurrentStaffPick hireStaffMember = (CurrentStaffPick)transform.parent.GetComponent <CurrentStaffPick>(); ///grab a ref to the gameResorces GameResources gr = (GameResources)HospitalPrefabs.ScriptsObject.GetComponent <GameResources>(); //instauiate the new staff member switch (hireStaffMember.staffType) { case StaffType.Cthuluburse: GameObject newStaff1 = (GameObject)Instantiate(HospitalPrefabs.Cthuluburse, new Vector3(20, 0.1f, 20), Quaternion.identity); ///spawns the gameobject newStaff1.GetComponent <StaffPersistantData>().staffData = _staffList.GrabCtuluburse(hireStaffMember.staffListPosition); ///copy data from the StaffList ///minus the cost gr.Glitter -= _staffList.GrabCtuluburse(hireStaffMember.staffListPosition).cost; _staffList.RemoveCthuluburse(hireStaffMember.staffListPosition); ///removes the data from the staFF LIST //Add the GameObject to the HiredSTaffList _hiredList.AddStaff(newStaff1); break; case StaffType.Octodoctor: GameObject newStaff2 = (GameObject)Instantiate(HospitalPrefabs.Octodoctor, new Vector3(20, 0.1f, 20), Quaternion.identity); newStaff2.GetComponent <StaffPersistantData>().staffData = _staffList.GrabOctodoctor(hireStaffMember.staffListPosition); ///minus the cost gr.Glitter -= _staffList.GrabOctodoctor(hireStaffMember.staffListPosition).cost; _staffList.RemoveOctodoctor(hireStaffMember.staffListPosition); _hiredList.AddStaff(newStaff2); break; case StaffType.Yetitor: GameObject newStaff3 = (GameObject)Instantiate(HospitalPrefabs.Yetitor, new Vector3(10, 0.1f, 10), Quaternion.identity); newStaff3.GetComponent <StaffPersistantData>().staffData = _staffList.GrabYetitor(hireStaffMember.staffListPosition); //minus the cost gr.Glitter -= _staffList.GrabYetitor(hireStaffMember.staffListPosition).cost; _staffList.RemoveYetitor(hireStaffMember.staffListPosition); _hiredList.AddStaff(newStaff3); break; } ///refesh the list with a delegate if (refreshStaffButtons != null) { refreshStaffButtons(hireStaffMember.staffType); } }
//show the cthuluburse name in the buttons public void ShowCthuluburseName() { UILabel staffName = (UILabel)transform.GetComponentInChildren <UILabel>(); if (staff.GrabCtuluburse(index) == null) { staffName.text = "NONE LEFT"; //no more to show from the stafflist } else { staffName.text = staff.GrabCtuluburse(index).name; } pick.staffType = currentStaffType; }