示例#1
0
        void CheckGrounded()
        {
            //Debug.Log("Checking to see if the airplane is on the ground...");
            if (wheels.Count > 0)
            {
                //Check to see how many wheels are on the ground
                int groundedCount = 0;
                foreach (Airplane_Wheel wheel in wheels)
                {
                    if (wheel.IsGrounded)
                    {
                        groundedCount++;
                    }
                }

                //Set our Airplane state using the above data
                if (groundedCount == wheels.Count)
                {
                    isGrounded = true;
                    isFlying   = false;

                    if (rb.velocity.magnitude < 1f)
                    {
                        isLanded      = true;
                        airplaneState = AirplaneState.LANDED;
                    }
                    else
                    {
                        isLanded      = false;
                        airplaneState = AirplaneState.GROUNDED;
                    }
                }
                else
                {
                    isGrounded    = false;
                    isFlying      = true;
                    airplaneState = AirplaneState.FLYING;
                }
            }
        }
示例#2
0
        private void StartPlaying()
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                if (playing)
                {
                    StopPlaying();
                }

                file               = File.OpenRead(fileName);
                binaryReader       = new BinaryReader(file);
                aircraftParameters = new AircraftParameters();
                aircraftParameters.ReadParameters(binaryReader.ReadString());
                if (airplaneModel == null)
                {
                    airplaneModel = new AirplaneModel(this);
                }
                playing       = true;
                startTime     = -1;
                relativeTime  = 0;
                previousState = new AirplaneState();
                nextState     = new AirplaneState();
                nextTime      = binaryReader.ReadDouble();
                nextState.Read(binaryReader);
                currentState.Gear  = nextState.Gear;
                currentState.Flaps = nextState.Flaps;
                if (currentState.Gear)
                {
                    Gear = 1.0;
                }
                if (currentState.Flaps)
                {
                    Flaps = 1.0;
                }
                airplaneModel.StartEngine();
            }
        }