コード例 #1
0
        protected void causeFainting(Vessel vessel, ProtoCrewMember astronaut, AstronautData astronautData)
        {
            string message;

            //Apply fainting immediately if the vessel is loaded
            if (vessel.loaded)
            {
                astronaut.SetInactive(faintDurationSeconds, true);
                if (!string.IsNullOrEmpty(playerMessage))
                {
                    ScreenMessages.PostScreenMessage(astronaut.name + " " + playerMessage, 5.0f, ScreenMessageStyle.UPPER_LEFT);
                }
            }

            //Vessel isn't loaded, record the info we need so we can make kerbals faint when vessel is loaded.
            else
            {
                if (!astronautData.keyValuePairs.ContainsKey(FaintDurationKey))
                {
                    astronautData.keyValuePairs.Add(FaintDurationKey, faintDurationSeconds.ToString());
                }
                else
                {
                    //Add to existing duration
                    float currentDuration = 0;
                    float.TryParse(astronautData.keyValuePairs[FaintDurationKey], out currentDuration);
                    currentDuration += faintDurationSeconds;
                    astronautData.keyValuePairs[FaintDurationKey] = currentDuration.ToString();
                }

                if (!astronautData.keyValuePairs.ContainsKey(FaintMessageKey))
                {
                    astronautData.keyValuePairs.Add(FaintMessageKey, astronautData.name + " " + playerMessage);
                }
                else
                {
                    //Add to existing message
                    message = astronautData.name + " " + playerMessage;
                    if (!astronautData.keyValuePairs[FaintMessageKey].Contains(message))
                    {
                        astronautData.keyValuePairs[FaintMessageKey] += (";" + message);
                    }

                    //Inform player
                    string[] messages = astronautData.keyValuePairs[FaintMessageKey].Split(';');
                    for (int messageIndex = 0; messageIndex < messages.Length; messageIndex++)
                    {
                        ScreenMessages.PostScreenMessage(messages[messageIndex], 5.0f, ScreenMessageStyle.UPPER_LEFT);
                    }
                }
            }
        }
コード例 #2
0
        public bool StartCourse()
        {
            //set all the kerbals to unavailable and begin tracking time
            if (Started)
            {
                return(true);
            }

            //ensure we have more than the minimum number of students and not more than the maximum number
            int studentCount = Students.Count;

            if (seatMax > 0 && studentCount > seatMax)
            {
                return(false);
            }
            if (seatMin > 0 && studentCount < seatMin)
            {
                return(false);
            }

            //attempt to take the required funds
            double cost = CalculateCost();

            if (Funding.Instance.Funds < cost)
            {
                return(false);
            }
            Funding.Instance.AddFunds(-cost, TransactionReasons.None);

            Started = true;
            if (Teacher != null)
            {
                Teacher.SetInactive(time + 1d);
            }
            foreach (ProtoCrewMember student in Students)
            {
                student.SetInactive(time + 1d);
            }

            return(true);
            //fire an event
        }