void ChangeCurrentPersonnelId(int personnelId, bool forceUpdate = false) { // don't do anything if we aren't changing the file index to a different one if ((personnelId != m_currentPersonnelId) || forceUpdate) { // update the current personnel id m_currentPersonnelId = personnelId; // get access to the crew assignment player data PD_CrewAssignment crewAssignment = DataController.m_instance.m_playerData.m_crewAssignment; // get access to the personnel player data PD_Personnel personnel = DataController.m_instance.m_playerData.m_personnel; // get the personnel file PD_Personnel.PD_PersonnelFile personnelFile = personnel.m_personnelList[m_currentPersonnelId]; // assign this personnel to this position crewAssignment.Assign(m_currentRole, personnelFile.m_fileId); // update the assigned crewmember list UpdateAssignedCrewmemberList(); // play a sound SoundController.m_instance.PlaySound(SoundController.Sound.Update); } }
// update the assigned crewmember list void UpdateAssignedCrewmemberList() { // get access to the crew assignment player data PD_CrewAssignment crewAssignment = DataController.m_instance.m_playerData.m_crewAssignment; // start with an empty text string m_positionValuesText.text = ""; // go through each position for (PD_CrewAssignment.Role role = PD_CrewAssignment.Role.First; role < PD_CrewAssignment.Role.Count; role++) { // get the file id for the assigned crewmember if (crewAssignment.IsAssigned(role)) { // get the personnel file for that role PD_Personnel.PD_PersonnelFile personnelFile = crewAssignment.GetPersonnelFile(role); // add the crewmember's name m_positionValuesText.text += personnelFile.m_name; } else { // add the not assigned text m_positionValuesText.text += "[Not Assigned]"; } if (role < (PD_CrewAssignment.Role.Count - 1)) { m_positionValuesText.text += Environment.NewLine; } } }
void ChangeCurrentRole(PD_CrewAssignment.Role role) { // update the current position index m_currentRole = role; // get access to the crew assignment player data PD_CrewAssignment crewAssignment = DataController.m_instance.m_playerData.m_crewAssignment; // check if we have don't have someone assigned to this position if (!crewAssignment.IsAssigned(m_currentRole)) { // automatically select the first personnel file ChangeCurrentPersonnelId(0, true); } else { // get the current file id for this position int fileId = crewAssignment.GetFileId(m_currentRole); // get access to the personnel player data PD_Personnel personnel = DataController.m_instance.m_playerData.m_personnel; // update the current personnel id m_currentPersonnelId = personnel.GetPersonnelId(fileId); } // play a sound SoundController.m_instance.PlaySound(SoundController.Sound.Update); }
// this resets our player progress to the new game state public void Reset() { var gameData = DataController.m_instance.m_gameData; m_version = c_currentVersion; m_isCurrentGame = false; m_general = new PD_General(); m_starport = new PD_Starport(); m_personnel = new PD_Personnel(); m_crewAssignment = new PD_CrewAssignment(); m_bank = new PD_Bank(); m_playerShip = new PD_PlayerShip(); m_knownArtifacts = new PD_KnownArtifacts(); m_encounterList = new PD_Encounter[gameData.m_encounterList.Length]; m_terrainVehicle = new PD_TerrainVehicle(); m_shipsLog = new PD_ShipsLog(); m_general.Reset(); m_starport.Reset(); m_personnel.Reset(); m_crewAssignment.Reset(); m_bank.Reset(); m_playerShip.Reset(); m_knownArtifacts.Reset(); m_shipsLog.Reset(); for (var i = 0; i < gameData.m_encounterList.Length; i++) { m_encounterList[i] = new PD_Encounter(); m_encounterList[i].Reset(i); } }