Ejemplo n.º 1
0
        private void HDG()
        {
            if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl().StartsWith("RC"))
            {
                mFlightComputer.Enqueue(DriveCommand.DistanceHeading(Dist, Heading, mSteerClamp, Speed));
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Wheel: ");
                GUILayout.FlexibleSpace();
                GUILayout.Label(mSteerClamp.ToString("P"));
                GUILayout.Label("Clamp", GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Hdg.", GUILayout.Width(50));
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref Mheading, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Dist.", GUILayout.Width(50));
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Speed", GUILayout.Width(50));
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m/s)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            Mheading = RTUtil.ConstrictNum(Mheading, 360);
            mDist    = RTUtil.ConstrictNum(mDist, false);
            mSpeed   = RTUtil.ConstrictNum(mSpeed, false);
        }
Ejemplo n.º 2
0
        private void Target()
        {
            if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl().StartsWith("RC"))
            {
                mFlightComputer.Enqueue(DriveCommand.Coord(mSteerClamp, Latitude, Longitude, Speed));
            }
            else if (GameSettings.MODIFIER_KEY.GetKey() && ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) != MouseClick))
            {
                MouseClick = Input.GetMouseButton(0) || Input.GetMouseButton(1);
                Vector2 latlon;
                if (MouseClick && RTUtil.CBhit(mFlightComputer.mAttachedVessel.mainBody, out latlon))
                {
                    Latitude  = latlon.x;
                    Longitude = latlon.y;

                    if (Input.GetMouseButton(1))
                    {
                        mFlightComputer.Enqueue(DriveCommand.Coord(mSteerClamp, Latitude, Longitude, Speed));
                    }
                }
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Wheel: ");
                GUILayout.FlexibleSpace();
                GUILayout.Label(mSteerClamp.ToString("P"));
                GUILayout.Label("Clamp", GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("LAT.", GUILayout.Width(50));
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mLatitude, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("LON.", GUILayout.Width(50));
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mLongditude, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Speed", GUILayout.Width(50));
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m/s)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();


            mLatitude   = RTUtil.ConstrictNum(mLatitude);
            mLongditude = RTUtil.ConstrictNum(mLongditude);
            mSpeed      = RTUtil.ConstrictNum(mSpeed, false);
        }
Ejemplo n.º 3
0
        private void Fine()
        {
            if (Event.current.Equals(Event.KeyboardEvent("return")) && Speed != 0)
            {
                if (GUI.GetNameOfFocusedControl() == "RC1" && mSteering != 0 && Turn != 0)
                {
                    EnqueueTurn();
                }
                else if (GUI.GetNameOfFocusedControl() == "RC2" && Dist != 0)
                {
                    EnqueueDist();
                }
                else if (GUI.GetNameOfFocusedControl() == "RC3")
                {
                    if (!distDefault && mSteering != 0 && Turn != 0)
                    {
                        EnqueueTurn();
                    }
                    else if (distDefault && Dist != 0)
                    {
                        EnqueueDist();
                    }
                }
            }


            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Wheel: ");
                GUILayout.FlexibleSpace();
                GUILayout.Label(Math.Abs(mSteering).ToString("P"));
                if (mSteering != 0)
                {
                    if (mSteering < 0)
                    {
                        GUILayout.Label("right", GUILayout.Width(40));
                    }
                    else
                    {
                        GUILayout.Label("left", GUILayout.Width(40));
                    }
                }
                else
                {
                    GUILayout.Label("", GUILayout.Width(40));
                }
            }
            GUILayout.EndHorizontal();

            RTUtil.HorizontalSlider(ref mSteering, 1, -1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Turn", GUILayout.Width(50));
                GUI.SetNextControlName("RC1");
                RTUtil.TextField(ref mTurn, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Dist.", GUILayout.Width(50));
                GUI.SetNextControlName("RC2");
                RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Speed", GUILayout.Width(50));
                GUI.SetNextControlName("RC3");
                RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false));
                GUILayout.Label("(m/s)", GUI.skin.textField, GUILayout.Width(40));
            }
            GUILayout.EndHorizontal();

            mTurn  = RTUtil.ConstrictNum(mTurn, 90);
            mDist  = RTUtil.ConstrictNum(mDist, false);
            mSpeed = RTUtil.ConstrictNum(mSpeed);


            if (prevTurn != Turn)
            {
                distDefault = false;
            }
            else if (prevDist != Dist)
            {
                distDefault = true;
            }

            prevTurn = Turn;
            prevDist = Dist;
        }