public List <string> removePilotsForTransfer(EmployeeTransfer et) { // Unless we're removing all the pilots, we have to save the pilot on the aircraft. string busyPilot = null; if (et.getPilots() < getNumbPilots() && aircraft != null && aircraft.hasPilot()) { // Remove the pilot from hired pilots busyPilot = aircraft.getPilot(); hiredPilots.Remove(busyPilot); } List <string> removedPilots = new List <string>(); for (int i = 0; i < et.getPilots(); i++) { string pilot = hiredPilots.Last.Value; hiredPilots.Remove(pilot); removedPilots.Add(pilot); occupiedLivingSpace--; } if (busyPilot != null) { // Restore the pilot to hired pilots hiredPilots.AddLast(busyPilot); } return(removedPilots); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string transferID = Request.QueryString.Get("transferID"); EmployeeTransferBLL objTransferBll = new EmployeeTransferBLL(); EmployeeTransfer obj = objTransferBll.GetEmployeeTransfer(Convert.ToInt32(transferID)); txtName.Text = obj.EmployeeName; txtWorkNo.Text = obj.WorkNo; lblOrg.Text = obj.TransferToOrgName; ViewState["EmployeeID"] = obj.EmployeeID.ToString(); OracleAccess db = new OracleAccess(); string strSql = "select * from Employee where Employee_ID=" + ViewState["EmployeeID"]; DataRow dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0]; txtPostNo.Text = dr["Identity_CardNo"].ToString(); BindWorkShopStart(); BindWorkgroupStart(); OrganizationBLL objBll = new OrganizationBLL(); IList <RailExam.Model.Organization> objList = objBll.GetOrganizationsByParentID(obj.TransferToOrgID); foreach (RailExam.Model.Organization organization in objList) { ListItem item = new ListItem(); item.Value = organization.OrganizationId.ToString(); item.Text = organization.ShortName; ddlWorkshop.Items.Add(item); } } }
public void addSoldiersForTransfer(EmployeeTransfer et) { foreach (Soldier s in et.getSoldiers()) { this.addHiredSoldier(s); occupiedLivingSpace++; } }
public List <string> removeWorkersForTransfer(EmployeeTransfer et) { List <string> removedWorkers = new List <string>(); for (int i = 0; i < et.getWorkers(); i++) { string worker = hiredWorkers.Last.Value; hiredWorkers.Remove(worker); removedWorkers.Add(worker); occupiedLivingSpace--; } return(removedWorkers); }
public void addWorkersForTransfer(EmployeeTransfer et, List <string> workers) { if (et.getWorkers() != workers.Count) { Debug.Log("Something went wrong"); } foreach (string w in workers) { this.addHiredWorker(w); occupiedLivingSpace++; } }
public void addPilotsForTransfer(EmployeeTransfer et, List <string> pilots) { if (et.getPilots() != pilots.Count) { Debug.Log("Something went wrong"); } foreach (string p in pilots) { this.addHiredPilot(p); occupiedLivingSpace++; } }
public List <string> removeScientistsForTransfer(EmployeeTransfer et) { List <string> removedScientists = new List <string>(); for (int i = 0; i < et.getScientists(); i++) { string scientist = hiredScientists.Last.Value; hiredScientists.Remove(scientist); removedScientists.Add(scientist); occupiedLivingSpace--; } return(removedScientists); }
public void addScientistsForTransfer(EmployeeTransfer et, List <string> scientists) { if (et.getScientists() != scientists.Count) { Debug.Log("Something went wrong"); } foreach (string s in scientists) { this.addHiredScientist(s); occupiedLivingSpace++; } }
public EmployeeTransfer GetEmployeeTransfer(int transferID) { EmployeeTransfer employee = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_EMPLOYEE_Transfer_G"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_employee_transfer_id", DbType.Int32, transferID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { employee = CreateModelObject(dataReader); } } return(employee); }
public IList <EmployeeTransfer> GetEmployeeTransferOutByOrgID(int orgID) { IList <EmployeeTransfer> employees = new List <EmployeeTransfer>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_EMPLOYEE_TRANSFER_OUT_G"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_org_id", DbType.String, orgID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { EmployeeTransfer employee = CreateModelObject(dataReader); employees.Add(employee); } } return(employees); }
public void removeSoldiersForTransfer(EmployeeTransfer et) { foreach (Soldier s in et.getSoldiers()) { if (aircraft != null && aircraft.getSoldiers().Contains(s)) { aircraft.removeSoldier(s); } Weapon wep = s.getWeapon(); Weapon arm = s.getArmor(); if (wep != null) { s.setWeapon(null); this.dequip(wep); } if (arm != null) { s.setArmor(null); this.dequip(arm); } this.removeHiredSoldier(s); occupiedLivingSpace--; } }
protected void btnOk_Click(object sender, EventArgs e) { string[] strID = hfEmployeeID.Value.Split(','); EmployeeTransferBLL objBll = new EmployeeTransferBLL(); IList <EmployeeTransfer> objList = new List <EmployeeTransfer>(); OracleAccess db = new OracleAccess(); string strSql; if (PrjPub.CurrentLoginUser.SuitRange == 1) { strSql = @"select getstationorgid(org_id) stationorgid,count(*) AdminCount, GetOrgName(getstationorgid(org_id)) stationName from system_user s left join employee e on s.employee_id=e.employee_id where role_id=123 group by getstationorgid(org_id)"; } else { strSql = @"select getstationorgid(org_id) stationorgid,count(*) AdminCount, GetOrgName(getstationorgid(org_id)) stationName from system_user s left join employee e on s.employee_id=e.employee_id where role_id=123 and getstationorgid(org_id)=" + PrjPub.CurrentLoginUser.StationOrgID + @" group by getstationorgid(org_id)"; } DataTable dtCount = db.RunSqlDataSet(strSql).Tables[0]; strSql = @"select GetStationOrgID(org_id) stationorgid,s.* from Employee a inner join system_user s on s.employee_id=a.employee_id where a.Employee_ID in (" + hfEmployeeID.Value + ")"; DataTable dtEmployee = db.RunSqlDataSet(strSql).Tables[0]; strSql = @"select a.*,b.Employee_Name from EMPLOYEE_TRANSFER a inner join Employee b on a.Employee_ID=b.Employee_ID where getstationorgid(org_id)=" + PrjPub.CurrentLoginUser.StationOrgID; DataTable dtHasTrans = db.RunSqlDataSet(strSql).Tables[0]; Hashtable htCount = new Hashtable(); int count = 0; string error = string.Empty; for (int i = 0; i < strID.Length; i++) { EmployeeTransfer objTransfer = new EmployeeTransfer(); objTransfer.EmployeeID = Convert.ToInt32(strID[i]); objTransfer.TransferToOrgID = Convert.ToInt32(ddlOrg.SelectedValue); objList.Add(objTransfer); if (strID[i] == PrjPub.CurrentLoginUser.EmployeeID.ToString()) { count++; } DataRow[] drAdmin = dtEmployee.Select("Employee_ID=" + strID[i] + " and Role_ID=123"); if (drAdmin.Length > 0) { string stationid = drAdmin[0]["StationOrgID"].ToString(); if (htCount.ContainsKey(stationid)) { int num = Convert.ToInt32(htCount[stationid]); htCount[stationid] = num + 1; } else { htCount.Add(stationid, 1); } } DataRow[] drHasTrans = dtHasTrans.Select("Employee_ID=" + strID[i]); if (drHasTrans.Length > 0) { error = "学员【" + drHasTrans[0]["Employee_Name"] + "】已经处于调出状态,不能重复调出!"; break; } } if (error != "") { ClientScript.RegisterClientScriptBlock(GetType(), "", "alert('" + error + "')", true); return; } string strMessage = ""; foreach (DataRow dr in dtCount.Rows) { string stationid = dr["stationorgid"].ToString(); if (htCount.ContainsKey(stationid)) { int nownum = Convert.ToInt32(htCount[stationid]); if (nownum == Convert.ToInt32(dr["AdminCount"].ToString())) { strMessage = "必须为" + dr["stationName"] + "至少保留一位站段管理员!"; break; } } } if (count > 0) { ClientScript.RegisterClientScriptBlock(GetType(), "", "alert('" + PrjPub.CurrentLoginUser.EmployeeName + "是当前操作人员,不能被调出!')", true); return; } if (strMessage != "") { ClientScript.RegisterClientScriptBlock(GetType(), "", "alert('" + strMessage + "')", true); return; } objBll.AddEmployeeTransfer(objList); SystemLogBLL objLogBll = new SystemLogBLL(); objLogBll.WriteLog("将部分员工调至" + ddlOrg.SelectedItem.Text); Response.Write("<script>window.returnValue='true';window.close();</script>"); }
public List<string> removePilotsForTransfer(EmployeeTransfer et) { // Unless we're removing all the pilots, we have to save the pilot on the aircraft. string busyPilot = null; if (et.getPilots() < getNumbPilots() && aircraft != null && aircraft.hasPilot()) { // Remove the pilot from hired pilots busyPilot = aircraft.getPilot(); hiredPilots.Remove(busyPilot); } List<string> removedPilots = new List<string>(); for (int i = 0; i < et.getPilots(); i++) { string pilot = hiredPilots.Last.Value; hiredPilots.Remove(pilot); removedPilots.Add(pilot); occupiedLivingSpace--; } if (busyPilot != null) { // Restore the pilot to hired pilots hiredPilots.AddLast(busyPilot); } return removedPilots; }
public void addSoldiersForTransfer(EmployeeTransfer et) { foreach (Soldier s in et.getSoldiers()) { this.addHiredSoldier (s); occupiedLivingSpace++; } }
public void addPilotsForTransfer(EmployeeTransfer et, List<string> pilots) { if (et.getPilots() != pilots.Count) Debug.Log("Something went wrong"); foreach (string p in pilots) { this.addHiredPilot(p); occupiedLivingSpace++; } }
public List<string> removeWorkersForTransfer(EmployeeTransfer et) { List<string> removedWorkers = new List<string>(); for (int i = 0; i < et.getWorkers(); i++) { string worker = hiredWorkers.Last.Value; hiredWorkers.Remove(worker); removedWorkers.Add(worker); occupiedLivingSpace--; } return removedWorkers; }
public void removeSoldiersForTransfer(EmployeeTransfer et) { foreach (Soldier s in et.getSoldiers()) { if (aircraft != null && aircraft.getSoldiers().Contains(s)) aircraft.removeSoldier(s); Weapon wep = s.getWeapon(); Weapon arm = s.getArmor(); if (wep != null) { s.setWeapon (null); this.dequip(wep); } if (arm != null) { s.setArmor(null); this.dequip(arm); } this.removeHiredSoldier(s); occupiedLivingSpace--; } }
public List<string> removeScientistsForTransfer(EmployeeTransfer et) { List<string> removedScientists = new List<string>(); for (int i = 0; i < et.getScientists(); i++) { string scientist = hiredScientists.Last.Value; hiredScientists.Remove(scientist); removedScientists.Add(scientist); occupiedLivingSpace--; } return removedScientists; }
void showTopMenu() { TextAnchor old = GUI.skin.box.alignment; GUI.skin.box.alignment = TextAnchor.MiddleCenter; // Top Menu: GUILayout.BeginArea(new Rect(0, 0, Screen.width, topMenuHeight)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Prev", GUILayout.ExpandHeight(true), GUILayout.Width(topMenuHeight))) { currentBase = manager.previousBase(); eTransfer = new EmployeeTransfer(); wTransfer = new WeaponTransfer(); soldierSelected = 0; pilotSelected = 0; facilitiesMessage = ""; researchMessage = ""; productionMessage = ""; storeMessage = ""; transferMessage = ""; aircraftMessage = ""; } GUILayout.Box("Base Name: " + currentBase.getName(), GUILayout.ExpandHeight(true), GUILayout.Width(Screen.width/2)); if (GUILayout.Button("Next", GUILayout.ExpandHeight(true), GUILayout.Width(topMenuHeight))) { currentBase = manager.nextBase(); eTransfer = new EmployeeTransfer(); wTransfer = new WeaponTransfer(); soldierSelected = 0; pilotSelected = 0; facilitiesMessage = ""; researchMessage = ""; productionMessage = ""; storeMessage = ""; transferMessage = ""; aircraftMessage = ""; } GUILayout.Box("Money: "+gameManager.Instance.getMoney(), GUILayout.ExpandHeight(true)); if (GUILayout.Button("Back", GUILayout.Width(topMenuHeight), GUILayout.ExpandHeight (true))) { if (menuShown == BASE_MAIN) { GUI.skin.box.alignment = old; manager.setLevel("WorldMap"); } else if (menuShown == EQUIP) { menuShown = AIRCRAFT; } else { menuShown = BASE_MAIN; } } GUILayout.EndHorizontal(); GUILayout.EndArea(); GUI.skin.box.alignment = old; }
public void addScientistsForTransfer(EmployeeTransfer et, List<string> scientists) { if (et.getScientists() != scientists.Count) Debug.Log("Something went wrong"); foreach (string s in scientists) { this.addHiredScientist(s); occupiedLivingSpace++; } }
void transferWindow(int windowID) { float margin = 15; int space = 10; float toolbarHeight = 40; float selectionAreaWidth = 7*Screen.width/12 - 2*margin; float transferAreaHeight = (Screen.height-topMenuHeight-3*margin)/2; float selectionItemWidth = selectionAreaWidth/2; float buttonSize = 15; float numberWidth = 30; float transferItemWidth = 240; GUIStyle centeredLabelStyle = new GUIStyle(); centeredLabelStyle.normal = GUI.skin.label.normal; centeredLabelStyle.alignment = TextAnchor.MiddleCenter; centeredLabelStyle.margin = GUI.skin.label.margin; GUIStyle titleLabelStyle = new GUIStyle(); titleLabelStyle.normal = GUI.skin.label.normal; titleLabelStyle.alignment = TextAnchor.MiddleCenter; titleLabelStyle.margin = GUI.skin.label.margin; titleLabelStyle.fontSize = 30; string[] categories = {"Equipment", "Employees"}; showTopMenu(); // Toolbar to select category GUILayout.BeginArea(new Rect(margin, topMenuHeight+margin, selectionAreaWidth, toolbarHeight)); int oldCategory = category; category = GUILayout.Toolbar(category, categories, GUILayout.ExpandHeight(true)); if (oldCategory != category) { // Switching categories scrollPosition = new Vector2(0,0); scrollPositionT = new Vector2(0,0); } GUILayout.EndArea(); // Selection Area GUILayout.BeginArea(new Rect(margin, topMenuHeight+margin+toolbarHeight+margin, selectionAreaWidth, Screen.height-topMenuHeight-toolbarHeight-3*margin), GUI.skin.box); scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandHeight(true)); GUILayout.BeginVertical (); // Column titles GUILayout.BeginHorizontal (); if (category == 0) GUILayout.Label("Items", titleLabelStyle, GUILayout.Width(selectionItemWidth)); if (category == 1) GUILayout.Label("Employees", titleLabelStyle, GUILayout.Width(selectionItemWidth)); GUILayout.Label("Available/Transfer", titleLabelStyle); GUILayout.EndHorizontal(); // Column entries if (category == 0) { // Item Transfer List<Weapon> baseWeapons = currentBase.getPurchasedItems(); foreach (Weapon w in baseWeapons) { GUILayout.Space(space); GUILayout.BeginHorizontal(); GUILayout.Label(w.getName(), centeredLabelStyle, GUILayout.Width (selectionItemWidth)); GUILayout.FlexibleSpace(); GUILayout.Label(""+(currentBase.getAmountPurchased(w) - wTransfer.getQuantity(w)) , centeredLabelStyle, GUILayout.Width (numberWidth)); GUILayout.Space(space); GUILayout.BeginVertical(); if (GUILayout.Button ("", increaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (wTransfer.getQuantity(w) + currentBase.getEquipped(w) == currentBase.getAmountPurchased(w)) { // Trying to transfer a weapon that a soldier is equipped with. transferMessage = "All remaining items of this type are currently in use by soldiers."; } else if (wTransfer.getQuantity(w) < currentBase.getAmountPurchased(w)) { wTransfer.addWeapon(w); } } if (GUILayout.Button ("", decreaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (wTransfer.getQuantity(w) > 0) wTransfer.removeWeapon(w); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } else if (category == 1) { // Employee Transfer LinkedList<Soldier> soldiers = currentBase.getHiredSoldiers(); // Soldiers foreach (Soldier s in soldiers) { GUILayout.Space(space); GUILayout.BeginHorizontal(); GUILayout.Label(s.getName(), centeredLabelStyle, GUILayout.Width (selectionItemWidth)); GUILayout.FlexibleSpace(); if (eTransfer.containsSoldier(s)) { GUILayout.Label("0", centeredLabelStyle, GUILayout.Width (numberWidth)); } else { GUILayout.Label("1", centeredLabelStyle, GUILayout.Width (numberWidth)); } GUILayout.Space(space); GUILayout.BeginVertical(); if (GUILayout.Button ("", increaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (!eTransfer.containsSoldier(s)) { if (s.getWeapon() != null || s.getArmor() != null) { transferMessage = "This soldier is equipped with "; if (s.getWeapon() != null) transferMessage += s.getWeapon().getName(); if (s.getWeapon() != null && s.getArmor() != null) transferMessage += " and "; if (s.getArmor() != null) transferMessage += s.getArmor().getName(); transferMessage += ". These will not be transferred."; } if (currentBase.getAircraft() != null && currentBase.getAircraft().contains(s)) { // Soldier will be removed from aircraft when transfer is processed transferMessage += "\nThis soldier will be removed from the aircraft"; } eTransfer.addSoldier(s); } } if (GUILayout.Button ("", decreaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; eTransfer.removeSoldier (s); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } // Scientists if (currentBase.getNumbScientists() > 0) { GUILayout.Space(space); GUILayout.BeginHorizontal(); GUILayout.Label("Scientists", centeredLabelStyle, GUILayout.Width (selectionItemWidth)); GUILayout.FlexibleSpace(); GUILayout.Label("" + (currentBase.getNumbScientists() - eTransfer.getScientists()) , centeredLabelStyle, GUILayout.Width (numberWidth)); GUILayout.Space(space); GUILayout.BeginVertical(); if (GUILayout.Button ("", increaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (eTransfer.getScientists() < currentBase.getNumbScientists()) eTransfer.addScientist(); } if (GUILayout.Button ("", decreaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (eTransfer.getScientists() > 0) eTransfer.removeScientist (); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } // Workers if (currentBase.getNumbWorkers() > 0) { GUILayout.Space(space); GUILayout.BeginHorizontal(); GUILayout.Label("Workers", centeredLabelStyle, GUILayout.Width (selectionItemWidth)); GUILayout.FlexibleSpace(); GUILayout.Label("" + (currentBase.getNumbWorkers() - eTransfer.getWorkers()) , centeredLabelStyle, GUILayout.Width (numberWidth)); GUILayout.Space(space); GUILayout.BeginVertical(); int busyWorkers = 0; foreach (ProductionOrder p in currentBase.getActiveOrders()) { busyWorkers += p.getWorkers(); } if (GUILayout.Button ("", increaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (eTransfer.getWorkers() < currentBase.getNumbWorkers() - busyWorkers) eTransfer.addWorker(); else if (busyWorkers > 0) transferMessage = "All remaining workers are busy"; } if (GUILayout.Button ("", decreaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (eTransfer.getWorkers() > 0) eTransfer.removeWorker (); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } // Pilots if (currentBase.getNumbPilots() > 0) { GUILayout.Space(space); GUILayout.BeginHorizontal(); GUILayout.Label("Pilots", centeredLabelStyle, GUILayout.Width (selectionItemWidth)); GUILayout.FlexibleSpace(); GUILayout.Label("" + (currentBase.getNumbPilots() - eTransfer.getPilots()) , centeredLabelStyle, GUILayout.Width (numberWidth)); GUILayout.Space(space); GUILayout.BeginVertical(); if (GUILayout.Button ("", increaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (eTransfer.getPilots() < currentBase.getNumbPilots()) { // If there is only one pilot left in base and aircraft has a pilot, the pilot will be removed from aircraft. if (currentBase.getNumbPilots() - eTransfer.getPilots() == 1 && currentBase.getAircraft() != null && currentBase.getAircraft().hasPilot()) { transferMessage = "Pilot will be removed from the aircraft"; } eTransfer.addPilot(); } } if (GUILayout.Button ("", decreaseSkin.button, GUILayout.Width (buttonSize), GUILayout.Height (buttonSize))) { transferMessage = ""; if (eTransfer.getPilots() > 0) eTransfer.removePilot (); } GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } else { GUILayout.Label("No corresponding category!!"); } GUILayout.EndVertical (); GUILayout.EndScrollView(); GUILayout.EndArea(); // Destination Base Area GUILayout.BeginArea(new Rect(margin+selectionAreaWidth+margin, topMenuHeight+margin, Screen.width-selectionAreaWidth-3*margin, Screen.height-topMenuHeight-transferAreaHeight-3*margin), GUI.skin.box); GUILayout.BeginVertical(); GUILayout.Space(margin); GUILayout.Label("Destination Base", titleLabelStyle); GUILayout.Space(space); float baseNameHeight = 50; GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(GUILayout.Height(baseNameHeight)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Prev", GUILayout.Width(baseNameHeight), GUILayout.ExpandHeight (true))) { destBase = manager.getBaseBefore(destBase); transferMessage = ""; } GUILayout.Label(destBase.getName(), centeredLabelStyle, GUILayout.ExpandHeight (true), GUILayout.Width(200)); if (GUILayout.Button("Next", GUILayout.Width(baseNameHeight), GUILayout.ExpandHeight (true))) { destBase = manager.getBaseAfter(destBase); transferMessage = ""; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal (); GUILayout.FlexibleSpace(); GUILayout.Label ("Storage available: " + (destBase.getTotalStorageSpace() - destBase.getUsedStorage()), centeredLabelStyle); GUILayout.Space(space); GUILayout.Label ("Living space available: " + (destBase.getLivingSpace() - destBase.getOccupiedLivingSpace()), centeredLabelStyle); GUILayout.Space(space); GUILayout.Label(transferMessage, centeredLabelStyle); GUILayout.Space(margin); GUILayout.EndVertical(); GUILayout.EndArea(); // Current Transfer Area GUILayout.BeginArea(new Rect(margin+selectionAreaWidth+margin, Screen.height-margin-transferAreaHeight, Screen.width-selectionAreaWidth-3*margin, transferAreaHeight), GUI.skin.box); GUILayout.BeginHorizontal(); GUILayout.Space (margin); GUILayout.BeginVertical(); GUILayout.Space(margin); scrollPositionT = GUILayout.BeginScrollView(scrollPositionT, GUILayout.ExpandHeight(true)); // Items foreach (Weapon w in wTransfer.getWeapons()) { GUILayout.BeginHorizontal (); GUILayout.FlexibleSpace(); GUILayout.Label (w.getName(), GUILayout.Width(transferItemWidth)); GUILayout.Label ("" + wTransfer.getQuantity(w), centeredLabelStyle, GUILayout.Width(numberWidth)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(space); } foreach (Soldier s in eTransfer.getSoldiers()) { GUILayout.BeginHorizontal (); GUILayout.FlexibleSpace(); GUILayout.Label (s.getName(), GUILayout.Width(transferItemWidth)); GUILayout.Label ("1", centeredLabelStyle, GUILayout.Width(numberWidth)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(space); } if (eTransfer.getScientists() > 0) { GUILayout.BeginHorizontal (); GUILayout.FlexibleSpace(); GUILayout.Label ("Scientists", GUILayout.Width(transferItemWidth)); GUILayout.Label ("" + eTransfer.getScientists(), centeredLabelStyle, GUILayout.Width(numberWidth)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(space); } if (eTransfer.getWorkers() > 0) { GUILayout.BeginHorizontal (); GUILayout.FlexibleSpace(); GUILayout.Label ("Workers", GUILayout.Width(transferItemWidth)); GUILayout.Label ("" + eTransfer.getWorkers(), centeredLabelStyle, GUILayout.Width(numberWidth)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(space); } if (eTransfer.getPilots() > 0) { GUILayout.BeginHorizontal (); GUILayout.FlexibleSpace(); GUILayout.Label ("Pilots", GUILayout.Width(transferItemWidth)); GUILayout.Label ("" + eTransfer.getPilots(), centeredLabelStyle, GUILayout.Width(numberWidth)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(space); } GUILayout.EndScrollView (); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Transfer", GUILayout.Width (200))) { if (wTransfer.getStorageSpace() > (destBase.getTotalStorageSpace() - destBase.getUsedStorage())) { transferMessage = "Not enough storage space in destination base"; } else if (eTransfer.getLivingSpace() > (destBase.getLivingSpace() - destBase.getOccupiedLivingSpace())) { transferMessage = "Not enough living space in destination base"; } else if (currentBase.Equals(destBase)) { transferMessage = "Current base and destination base are the same"; } else { transferMessage = ""; currentBase.removeForTransfer(wTransfer); currentBase.removeSoldiersForTransfer(eTransfer); List<string> scientists = currentBase.removeScientistsForTransfer(eTransfer); List<string> workers = currentBase.removeWorkersForTransfer(eTransfer); List<string> pilots = currentBase.removePilotsForTransfer(eTransfer); destBase.addForTransfer(wTransfer); destBase.addSoldiersForTransfer(eTransfer); destBase.addScientistsForTransfer(eTransfer, scientists); destBase.addWorkersForTransfer(eTransfer, workers); destBase.addPilotsForTransfer(eTransfer, pilots); eTransfer = new EmployeeTransfer(); wTransfer = new WeaponTransfer(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(margin); GUILayout.EndVertical(); GUILayout.Space(margin); GUILayout.EndHorizontal(); GUILayout.EndArea (); }
public void addWorkersForTransfer(EmployeeTransfer et, List<string> workers) { if (et.getWorkers() != workers.Count) Debug.Log("Something went wrong"); foreach (string w in workers) { this.addHiredWorker(w); occupiedLivingSpace++; } }