Ejemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            timeSinceLastCrash += Time.deltaTime;

            // Fail Check
            if (FailCheck())
            {
                return;
            }

            // Check Pause Button
            if (QuadcopterControls.Pause())
            {
                TogglePause();
            }

            if (!_Paused)
            {
                // Update State
                _States.UpdateStates(ref _Settings);
            }

            if (QuadcopterControls.ResetOrientation())
            {
                transform.eulerAngles = Vector3.zero;
            }

            if (QuadcopterControls.ResetLevel())
            {
                transform.position    = _SpawnPosition;
                transform.eulerAngles = Vector3.zero;

                if (cameraOverride != null)
                {
                    cameraOverride.setHealth(0.0f);
                }

                _Settings._Broken = false;
            }

            // Udate Controls
            GamepadManager.Update();
        }
Ejemplo n.º 2
0
        public void UpdateStates(ref Quadcopter.Settings Settings)
        {
            // Thrusters
            thrusters = QuadcopterControls.GetAnalog(Settings._ThrusterControl);

            if (thrusters < 0.0f)
            {
                thrusterState = ThrusterState.DOWNWARDS;
            }
            else if (thrusters > 0.0f)
            {
                thrusterState = ThrusterState.UPWARDS;
            }
            else if (Settings._ThrusterRest)
            {
                thrusterState = ThrusterState.STILL;
            }
            else
            {
                thrusterState = ThrusterState.OFF;
            }

            // Pitch
            float Pitch = QuadcopterControls.GetAnalog(Settings._PitchControl);

            if (Pitch < 0.0f)
            {
                pitchrotation = PitchRotation.CCW;
            }
            else if (Pitch > 0.0f)
            {
                pitchrotation = PitchRotation.CW;
            }
            else
            {
                pitchrotation = PitchRotation.NONE;
            }

            // Yaw
            float Yaw = QuadcopterControls.GetAnalog(Settings._YawControl);

            if (Yaw < 0.0f)
            {
                yawrotation = YawRotation.CCW;
            }
            else if (Yaw > 0.0f)
            {
                yawrotation = YawRotation.CW;
            }
            else
            {
                yawrotation = YawRotation.NONE;
            }

            // Roll
            float Roll = QuadcopterControls.GetAnalog(Settings._RollControl);

            if (Roll < 0.0f)
            {
                rollrotation = RollRotation.CCW;
            }
            else if (Roll > 0.0f)
            {
                rollrotation = RollRotation.CW;
            }
            else
            {
                rollrotation = RollRotation.NONE;
            }

            // Return Euler Changes
            eulerchanges = new Vector3(Pitch, Yaw, Roll);
        }