Пример #1
0
        private void OnKerbalStatusChange(ProtoCrewMember pcm, ProtoCrewMember.RosterStatus oldStatus, ProtoCrewMember.RosterStatus newStatus)
        {
            if (oldStatus == ProtoCrewMember.RosterStatus.Assigned && newStatus == ProtoCrewMember.RosterStatus.Available)
            {
                FlightLog tmpLog = new FlightLog();
                foreach (FlightLog.Entry entry in pcm.careerLog.Entries.Union(pcm.flightLog.Entries))
                {
                    tmpLog.AddEntry(entry);
                }

                float xp  = KerbalRoster.CalculateExperience(pcm.careerLog);
                float xp2 = KerbalRoster.CalculateExperience(tmpLog);

                float amount = (xp2 - xp) * multiplier;

                if (currency == Currency.Funds)
                {
                    Funding.Instance.AddFunds(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Reputation)
                {
                    Reputation.Instance.AddReputation(amount, TransactionReasons.Strategies);
                }
                else if (currency == Currency.Science)
                {
                    ResearchAndDevelopment.Instance.AddScience(amount, TransactionReasons.Strategies);
                }

                CurrencyPopup.Instance.AddPopup(currency, amount, TransactionReasons.Strategies, Parent.Config.Title, false);
            }
        }
Пример #2
0
        public void Training()
        {
            foreach (ProtoCrewMember crew in vessel.GetVesselCrew())
            {
                var thisCrew = crew;
                var oldLevel = crew.experienceLevel;
                var teacher  = GetTeacher(crew.experienceTrait.Title);
                //Teachers have to be a level higher than students
                if (teacher.experienceLevel > crew.experienceLevel)
                {
                    //Then, we simulate training by creating some new flights.
                    var maxLevel = GetSituationLevel();

                    foreach (var flight in teacher.careerLog.GetFlights())
                    {
                        if (crew.experienceLevel < maxLevel)
                        {
                            foreach (var logEntry in flight.Entries)
                            {
                                if (!crew.flightLog.HasEntry(logEntry.type, logEntry.target))
                                {
                                    if (logEntry.type != FlightLog.EntryType.PlantFlag.ToString())
                                    {
                                        crew.flightLog.AddEntry(logEntry.type, logEntry.target);
                                        crew.careerLog.AddEntry(logEntry.type, logEntry.target);
                                    }
                                }
                                crew.experience      = KerbalRoster.CalculateExperience(crew.flightLog);
                                crew.experienceLevel = KerbalRoster.CalculateExperienceLevel(crew.experience);
                            }
                        }
                    }
                    if (oldLevel < crew.experienceLevel)
                    {
                        string msg = string.Format("{0} trained to level {1} {2}", crew.name, crew.experienceLevel,
                                                   crew.experienceTrait.Title);
                        ScreenMessages.PostScreenMessage(msg, 5f, ScreenMessageStyle.UPPER_CENTER);
                    }
                }
            }
        }