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); } }
public override bool Execute() { // get to the player data PlayerData playerData = DataController.m_instance.m_playerData; // change the buttons switch (playerData.m_general.m_location) { case PD_General.Location.DockingBay: case PD_General.Location.Planetside: SpaceflightController.m_instance.m_buttonController.ChangeButtonSet(ButtonController.ButtonSet.CommandA); break; default: SpaceflightController.m_instance.m_buttonController.ChangeButtonSet(ButtonController.ButtonSet.CommandB); break; } // get the personnel file on our captain PD_Personnel.PD_PersonnelFile personnelFile = playerData.m_crewAssignment.GetPersonnelFile(PD_CrewAssignment.Role.Captain); // set the name of the captain SpaceflightController.m_instance.m_buttonController.ChangeOfficerText("Captain " + personnelFile.m_name); return(true); }
// 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; } } }
// train the currently selected skill private void TrainSelectedSkill() { // get access to the player data PlayerData playerData = DataController.m_instance.m_playerData; // get access to the bank player data PD_Bank bank = playerData.m_bank; if (bank.m_currentBalance < 300) { UpdateTrainingText(5); SoundController.m_instance.PlaySound(SoundController.Sound.Error); } else { // get access to the current personnel file we are looking at PD_Personnel.PD_PersonnelFile personnelFile = playerData.m_personnel.m_personnelList[m_currentFileIndex]; // get access to the race data for this personnel file GD_CrewRace race = DataController.m_instance.m_gameData.m_crewRaceList[m_currentRaceIndex]; // calculate the current skill and maximum skill points for the selected skill int currentSkill = personnelFile.GetSkill(m_currentSkillIndex); int maximumSkill = race.GetMaximumSkill(m_currentSkillIndex); // check if the maximum skill is zero if (maximumSkill == 0) { UpdateTrainingText(4); SoundController.m_instance.PlaySound(SoundController.Sound.Error); } else if (currentSkill < maximumSkill) // check if we are still below the maximum skill points { // increase the skill by the learn amount personnelFile.SetSkill(m_currentSkillIndex, Math.Min(maximumSkill, currentSkill + race.m_learningRate)); // take off 300 credits from the bank balance bank.m_currentBalance -= 300; // update the bank balance text UpdateBankBalanceText(); // update the skill values text UpdateSkillValues(); // play a ui sound SoundController.m_instance.PlaySound(SoundController.Sound.Update); } else // the selected skill is already maxxed out { UpdateTrainingText(3); SoundController.m_instance.PlaySound(SoundController.Sound.Error); } } }
// this is called if we clicked on the train button public void TrainClicked() { InputController.m_instance.Debounce(); // check if the current race is an android if (m_currentRaceIndex == 4) { UpdateTrainingText(1); SoundController.m_instance.PlaySound(SoundController.Sound.Error); } else { // get access to the player data PlayerData playerData = DataController.m_instance.m_playerData; // get access to the current personnel file we are looking at PD_Personnel.PD_PersonnelFile personnelFile = playerData.m_personnel.m_personnelList[m_currentFileIndex]; // get access to the race data for this personnel file GD_CrewRace race = DataController.m_instance.m_gameData.m_crewRaceList[m_currentRaceIndex]; // enable the train button only if the current personnel is not maxxed out int maxTotalPoints = 0; int currentTotalPoints = 0; for (int skillIndex = 0; skillIndex < c_numSkills; skillIndex++) { maxTotalPoints = race.GetMaximumSkill(skillIndex); currentTotalPoints = personnelFile.GetSkill(skillIndex); } // check if we are maxxed out if (currentTotalPoints < maxTotalPoints) { // switch to the train select skill state SwitchToTrainCrewmemberState(); } else { UpdateTrainingText(2); SoundController.m_instance.PlaySound(SoundController.Sound.Error); } } // play a ui sound SoundController.m_instance.PlaySound(SoundController.Sound.Activate); }
public override bool Execute() { // change the buttons SpaceflightController.m_instance.m_buttonController.ChangeButtonSet(ButtonController.ButtonSet.Science); // get to the player data PlayerData playerData = DataController.m_instance.m_playerData; // get the personnel file on this officer PD_Personnel.PD_PersonnelFile personnelFile = playerData.m_crewAssignment.GetPersonnelFile(PD_CrewAssignment.Role.ScienceOfficer); // set the name of the officer SpaceflightController.m_instance.m_buttonController.ChangeOfficerText("Officer " + personnelFile.m_name); return(true); }
void UpdateDisplay() { // show the up arrow only if we are not at the first position index m_upArrowImage.gameObject.SetActive(m_currentRole != PD_CrewAssignment.Role.First); // show the down arrow only if we are not at the last position index m_downArrowImage.gameObject.SetActive(m_currentRole != (PD_CrewAssignment.Role.Count - 1)); // put the position selection box in the right place float offset = (int)m_currentRole * m_positionValuesText.renderedHeight / (int)PD_CrewAssignment.Role.Count; RectTransform rectTransform = m_selectionXform.GetComponent <RectTransform>(); rectTransform.offsetMin = m_baseSelectionOffsetMin + new Vector3(0.0f, -offset, 0.0f); rectTransform.offsetMax = m_baseSelectionOffsetMax + new Vector3(0.0f, -offset, 0.0f); // 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]; // update the crewmember name if (personnelFile.m_vitality > 0) { m_nameText.text = personnelFile.m_name + " - " + personnelFile.m_vitality + "% vitality"; } else { m_nameText.text = personnelFile.m_name + " - DEAD"; } // update the skill values m_skillValuesText.text = ""; for (int skillIndex = 0; skillIndex < c_numSkills; skillIndex++) { m_skillValuesText.text += personnelFile.GetSkill(skillIndex).ToString(); if (skillIndex < (c_numSkills - 1)) { m_skillValuesText.text += Environment.NewLine; } } }
// this is called when we hit enter in the name input field public void OnEndEdit() { InputController.m_instance.Debounce(); if (m_nameInputField.text.Length == 0) { // cancel because the player did not type in anything SwitchToViewFileState(); // play a ui sound SoundController.m_instance.PlaySound(SoundController.Sound.Deactivate); } else { // get the current race game data GD_CrewRace race = DataController.m_instance.m_gameData.m_crewRaceList[m_currentRaceIndex]; // create a new personnel file PD_Personnel.PD_PersonnelFile personnelFile = DataController.m_instance.m_playerData.m_personnel.CreateNewPersonnel(); // set up the personnel file personnelFile.m_name = m_nameInputField.text; personnelFile.m_vitality = 100.0f; personnelFile.m_crewRaceId = m_currentRaceIndex; personnelFile.m_science = race.m_scienceInitial; personnelFile.m_navigation = race.m_navigationInitial; personnelFile.m_engineering = race.m_engineeringInitial; personnelFile.m_communications = race.m_communicationsInitial; personnelFile.m_medicine = race.m_medicineInitial; // add the new personnel file to the list DataController.m_instance.m_playerData.m_personnel.m_personnelList.Add(personnelFile); // make the new file our current one m_currentFileIndex = DataController.m_instance.m_playerData.m_personnel.m_personnelList.Count - 1; // switch to the doing nothing state SwitchToViewFileState(); // play a ui sound SoundController.m_instance.PlaySound(SoundController.Sound.Update); } }
// update the skill values private void UpdateSkillValues() { // get access to the player data PlayerData playerData = DataController.m_instance.m_playerData; // get access to the current personnel file we are looking at PD_Personnel.PD_PersonnelFile personnelFile = playerData.m_personnel.m_personnelList[m_currentFileIndex]; // update the skill values with the ones in this personnel file m_skillValuesText.text = ""; for (int skillIndex = 0; skillIndex < c_numSkills; skillIndex++) { m_skillValuesText.text += personnelFile.GetSkill(skillIndex).ToString(); if (skillIndex < (c_numSkills - 1)) { m_skillValuesText.text += Environment.NewLine; } } }
public override bool Execute() { // do we want to show the respond button? m_showingRespondButton = SpaceflightController.m_instance.m_encounter.AliensWantToConnect(); // decide which button set to use var buttonSet = (m_showingRespondButton) ? ButtonController.ButtonSet.CommunicationsB : ButtonController.ButtonSet.CommunicationsA; // change the buttons SpaceflightController.m_instance.m_buttonController.ChangeButtonSet(buttonSet); // get to the player data PlayerData playerData = DataController.m_instance.m_playerData; // get the personnel file on this officer PD_Personnel.PD_PersonnelFile personnelFile = playerData.m_crewAssignment.GetPersonnelFile(PD_CrewAssignment.Role.CommunicationsOfficer); // set the name of the officer SpaceflightController.m_instance.m_buttonController.ChangeOfficerText("Officer " + personnelFile.m_name); return(true); }
// update screen for the view file state private bool UpdateScreenForViewFileState(bool[] gameObjectIsVisible, bool[] buttonIsInteractable) { // dont show personnel file by default bool showPersonnelFile = false; // get access to the player data PlayerData playerData = DataController.m_instance.m_playerData; // enable the create button only if we have less than 20 personnel files if (playerData.m_personnel.m_personnelList.Count < 20) { buttonIsInteractable[(int)Buttons.CreateButton] = true; } // check if we have any personnel files if (playerData.m_personnel.m_personnelList.Count == 0) { // we dont have any personnel files m_fileNumberText.text = "No Personnel Files Found"; } else { // get access to the current personnel file we are looking at PD_Personnel.PD_PersonnelFile personnelFile = playerData.m_personnel.m_personnelList[m_currentFileIndex]; // update the current race index m_currentRaceIndex = personnelFile.m_crewRaceId; // update the personnel file number m_fileNumberText.text = "File # " + (m_currentFileIndex + 1) + ": " + personnelFile.m_name; // enable the previous button if we are not looking at the first personnel file if (m_currentFileIndex > 0) { buttonIsInteractable[(int)Buttons.PreviousButton] = true; } // enable the next button if we are not looking at the last personnel file if (m_currentFileIndex < (playerData.m_personnel.m_personnelList.Count - 1)) { buttonIsInteractable[(int)Buttons.NextButton] = true; } // show the vitaliaty text gameObjectIsVisible[(int)GameObjects.VitalityText] = true; // show the delete button gameObjectIsVisible[(int)GameObjects.DeleteButton] = true; // enable the delete button buttonIsInteractable[(int)Buttons.DeleteButton] = true; // show the train button gameObjectIsVisible[(int)GameObjects.TrainButton] = true; // enable the train button buttonIsInteractable[(int)Buttons.TrainButton] = true; // update the skill values UpdateSkillValues(); // we do want to show the personnel file showPersonnelFile = true; } // always enable the exit button buttonIsInteractable[(int)Buttons.ExitButton] = true; // let the caller know if we want to show the personnel file return(showPersonnelFile); }