コード例 #1
0
ファイル: PlayerData.cs プロジェクト: Blakeley00/starflight
    // 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);
        }
    }
コード例 #2
0
    // 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);
            }
        }
    }
コード例 #3
0
ファイル: BankPanel.cs プロジェクト: Blakeley00/starflight
    // panel open
    public override bool Open()
    {
        // base panel open
        base.Open();

        // get access to the bank player data
        PD_Bank bank = DataController.m_instance.m_playerData.m_bank;

        // update the date, transactions, and amount list text
        m_dateListText.text         = "";
        m_transactionsListText.text = "";
        m_amountListText.text       = "";

        for (int transactionId = 0; transactionId < bank.m_transactionList.Count; transactionId++)
        {
            PD_Bank.Transaction transaction = bank.m_transactionList[transactionId];

            DateTime dateTime = DateTime.ParseExact(transaction.m_stardate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
            m_dateListText.text         += dateTime.ToShortDateString();
            m_transactionsListText.text += transaction.m_description;
            m_amountListText.text       += transaction.m_amount;

            if (transactionId < (bank.m_transactionList.Count - 1))
            {
                m_dateListText.text         += Environment.NewLine;
                m_transactionsListText.text += Environment.NewLine;
                m_amountListText.text       += Environment.NewLine;
            }
        }

        // update the current balance text
        m_currentBalanceText.text = "Your current balance is " + string.Format("{0:n0}", bank.m_currentBalance) + " M.U.";

        // force the text object to update (so we can get the correct height)
        m_currentBalanceText.ForceMeshUpdate();

        // force the canvas to update so we can get the height of the date viewport
        Canvas.ForceUpdateCanvases();

        // get the height of the date viewport
        float viewportHeight = m_dateMask.GetComponent <RectTransform>().rect.height;

        // calculate the offset we need to show the bottom of the list
        float offset = Mathf.Max(0.0f, m_dateListText.renderedHeight - viewportHeight);

        // move up the text in all 3 columns
        m_dateListText.rectTransform.offsetMax         = new Vector3(0.0f, offset, 0.0f);
        m_transactionsListText.rectTransform.offsetMax = new Vector3(0.0f, offset, 0.0f);
        m_amountListText.rectTransform.offsetMax       = new Vector3(0.0f, offset, 0.0f);

        // automatically select the "exit" button for the player
        m_exitButton.Select();

        // panel was opened
        return(true);
    }
コード例 #4
0
    // update the bank balance text and show it
    private void UpdateBankBalanceText()
    {
        // get access to the bank player data
        PD_Bank bank = DataController.m_instance.m_playerData.m_bank;

        // update the bank balance
        m_bankBalanceText.text = "Bank balance: " + string.Format("{0:n0}", bank.m_currentBalance) + " M.U.";

        // show the training text
        m_bankBalanceText.gameObject.SetActive(true);
    }