Exemplo n.º 1
0
        private void GUI_ShipToEVA(Rect screen_rect)
        {
            //Debug.LogError("GUI_ShipToEVA begin : TransportMode=" + this.TransportMode);
            if (this.ShipToEVASubMode == null)
            {
                //Debug.LogError("GUI_ShipToEVA 1 : ShipToEVASubMode=" + this.ShipToEVASubMode);
                if (GUILayout.Button("Back"))
                {
                    this.TransportMode    = null;
                    this.ShipToEVASubMode = null;
                }

                GUILayout.Label("Selet Target Location: ");
                if (GUILayout.Button("Ship To Ground"))
                {
                    this.ShipToEVASubMode = "ShipToGround";
                    //Debug.LogError("GUI_ShipToEVA Button1 : ShipToEVASubMode=" + this.ShipToEVASubMode);
                }
                if (GUILayout.Button("Ship To Space"))
                {
                    this.ShipToEVASubMode = "ShipToSpace";
                    //Debug.LogError("GUI_ShipToEVA Button2 : ShipToEVASubMode=" + this.ShipToEVASubMode);
                }
            }
            else
            {
                if (GUILayout.Button("Back"))
                {
                    this.ShipToEVASubMode = null;
                }

                switch (this.ShipToEVASubMode)
                {
                case "ShipToGround":


                    transporter_hinge.transform.parent           = this.CurrentMotherShip.transform; // ...child to our part...
                    transporter_hinge.transform.localPosition    = Vector3.zero;
                    transporter_hinge.transform.localEulerAngles = Vector3.zero;
                    Vector3 gee = FlightGlobals.getGeeForceAtPosition(this.CurrentMotherShip.transform.position);
                    transporter_hinge.transform.rotation = Quaternion.LookRotation(gee.normalized);

                    transporter_target.transform.parent           = transporter_hinge.transform; // ...child to our part...
                    transporter_target.transform.localPosition    = Vector3.zero;
                    transporter_target.transform.localEulerAngles = Vector3.zero;

                    if (gimbalDebug2 == null)
                    {
                        gimbalDebug2 = new GimbalDebug();
                    }
                    else
                    {
                        gimbalDebug2.removeGimbal();
                    }
                    gimbalDebug2.drawGimbal(transporter_target, 3, 0.2f);

                    float heightFromSurface = ((float)this.CurrentMotherShip.altitude - this.CurrentMotherShip.heightFromTerrain < 0F) ? (float)this.CurrentMotherShip.altitude : this.CurrentMotherShip.heightFromTerrain;
                    heightFromSurface = (heightFromSurface != -1) ? heightFromSurface : (float)this.CurrentMotherShip.altitude;
                    fixed_height      = heightFromSurface - 0.5f;
                    transporter_target.transform.localPosition = Vector3.forward * fixed_height;

                    // Planet Scanner
                    planetScanner.activateScanner(zoomFactor, screen_rect);
                    GUILayout.Label("zoomFactor: " + Math.Round(zoomFactor, 2));
                    zoomFactor = GUILayout.HorizontalSlider(zoomFactor, 2.01F, 100.0F);
                    // Planet Scanner



                    GUILayout.Label("Select a Kerbal");
                    // Kerbal List
                    List <ProtoCrewMember> crewList = this.CurrentMotherShip.GetVesselCrew();

                    GUILayout.BeginVertical(scrollview_style);
                    ShipToEVAscrollPosition = GUILayout.BeginScrollView(ShipToEVAscrollPosition);
                    foreach (ProtoCrewMember cm in crewList)
                    {
                        if (GUILayout.Button("EVA " + cm.name))
                        {
                            //TransportMode = null;
                            transportKerbal_ShipToGround(cm);
                        }
                    }
                    GUILayout.EndScrollView();
                    GUILayout.EndVertical();

                    /*
                     */
                    break;

                case "ShipToSpace":
                    //Debug.LogError("GUI_ShipToEVA 4 : ShipToEVASubMode=" + this.ShipToEVASubMode);

                    GUILayout.Label("Set Required Distance from Ship in Meter");
                    fixed_beam_distance = Int32.Parse(GUILayout.TextField(fixed_beam_distance.ToString(), 25));

                    transporter_target.transform.parent           = this.CurrentMotherShip.transform; // ...child to our part...
                    transporter_target.transform.localPosition    = Vector3.zero;
                    transporter_target.transform.localEulerAngles = Vector3.zero;
                    transporter_target.transform.localPosition    = Vector3.up * fixed_beam_distance;


                    GUILayout.Label("Select a Kerbal");
                    // Kerbal List
                    List <ProtoCrewMember> crewList2 = this.CurrentMotherShip.GetVesselCrew();
                    GUILayout.BeginVertical(scrollview_style);
                    ShipToEVAscrollPosition = GUILayout.BeginScrollView(ShipToEVAscrollPosition);
                    foreach (ProtoCrewMember cm in crewList2)
                    {
                        if (GUILayout.Button("EVA " + cm.name))
                        {
                            //TransportMode = null;
                            transportKerbal_ShipToSpace(cm);
                        }
                    }
                    GUILayout.EndScrollView();
                    GUILayout.EndVertical();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public void activateScanner(float zoom, Rect screen_rect)
        {
            Debug.Log("ImpulseDrive: PlanetScanner activateScanner 1 ");

            //this.CameraProbe = null;
            //this.pScannScreen = null;

            PlanetScanner_initialize(screen_rect);
            Debug.Log("ImpulseDrive: PlanetScanner activateScanner 2 ");


            zoomFactor = zoom;


            Camera_hinge.transform.parent           = this.CurrentMotherShip.transform; // ...child to our part...
            Camera_hinge.transform.localPosition    = Vector3.zero;
            Camera_hinge.transform.localEulerAngles = Vector3.zero;
            Vector3 gee = FlightGlobals.getGeeForceAtPosition(this.CurrentMotherShip.transform.position);

            Camera_hinge.transform.rotation = Quaternion.LookRotation(gee.normalized);

            Debug.Log("ImpulseDrive: PlanetScanner activateScanner 3 ");

            CameraProbe.transform.parent           = Camera_hinge.transform; // ...child to our part...
            CameraProbe.transform.localPosition    = Vector3.zero;
            CameraProbe.transform.localEulerAngles = Vector3.zero;

            Debug.Log("ImpulseDrive: PlanetScanner activateScanner 4 ");

            if (gimbalDebug2 != null)
            {
                gimbalDebug2.removeGimbal();
            }
            if (gimbalDebug2 == null)
            {
                gimbalDebug2 = new GimbalDebug();
            }
            else
            {
                gimbalDebug2.removeGimbal();
            }
            gimbalDebug2.drawGimbal(CameraProbe, 3, 0.2f);


            Debug.Log("ImpulseDrive: PlanetScanner activateScanner 5 ");

            float heightFromSurface = ((float)this.CurrentMotherShip.altitude - this.CurrentMotherShip.heightFromTerrain < 0F) ? (float)this.CurrentMotherShip.altitude : this.CurrentMotherShip.heightFromTerrain;

            heightFromSurface = (heightFromSurface != -1) ? heightFromSurface : (float)this.CurrentMotherShip.altitude;
            fixed_height      = heightFromSurface - (2000 / zoom);
            CameraProbe.transform.localPosition = Vector3.forward * fixed_height;

            Debug.Log("ImpulseDrive: PlanetScanner activateScanner 6 ");



            float vFOVrad         = CameraProbe.camera.fieldOfView * Mathf.Deg2Rad;
            float cameraHeightAt1 = Mathf.Tan(vFOVrad * .5f);
            float picWidth        = (heightFromSurface - fixed_height) * 0.866025f;



            if (heightFromSurface > 100000F)
            {
                GUILayout.Label("PlanetScanner out of Range - max range 50Km");
            }
            else
            {
                GUILayout.Label("foo4");
                GUILayout.BeginHorizontal();

                CameraDisplayTexture = RTImage(CameraProbe.camera);
                content = new GUIContent(CameraDisplayTexture, "");
                GUILayout.Box(content, GUILayout.Height(260), GUILayout.Width(260));

                GUILayout.Label("");
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                //PlanetScannerWindowPosition = LCARS_Utilities.ClampToScreen(GUI.Window(PlanetScannerWindowID, PlanetScannerWindowPosition, PlanetScannerWindow, ""));
            }

            //Debug.Log("ImpulseDrive: PlanetScanner activateScanner 4 ");


            GUILayout.Label("picWidth=" + picWidth);
            GUILayout.Label(this.CurrentMotherShip.RevealSituationString());
            GUILayout.Label(this.CurrentMotherShip.latitude + " lat /" + this.CurrentMotherShip.longitude + "lon");

            if ((Time.time - lastFixedUpdate) > logInterval)
            {
                Debug.Log("ImpulseDrive: PlanetScanner UnloadUnusedAssets");
                Resources.UnloadUnusedAssets();
                lastFixedUpdate = Time.time;
            }

            float power = PT.L1_usage + PT.L2_usage;

            this.PowSys.draw(PT.takerName, power);
        }
        //GimbalDebug foo4 = new GimbalDebug();
        internal void CreateBeam(Vessel v)
        {
            UnityEngine.Debug.Log("ImpulseDrive TractorBeam: CreateBeam 1 ");
            Vessel Parent = FlightGlobals.ActiveVessel;

            //Vector3d parentPosition_current = Parent.findWorldCenterOfMass();
            //Vector3d childPosition_current = v.findWorldCenterOfMass();
            Vector3d parentPosition_current = Parent.GetWorldPos3D();
            Vector3d childPosition_current  = v.GetWorldPos3D();



            float   distance  = Vector3.Distance(parentPosition_current, childPosition_current);
            Vector3 newVector = childPosition_current - parentPosition_current;
            //UnityEngine.Debug.Log("ImpulseDrive TractorBeam: CreateBeam 2 ");

            TBeam nb = new TBeam();

            UnityEngine.Debug.Log("ImpulseDrive TractorBeam: CreateBeam 3-7 ");

            BeamDrawer   BD1       = new BeamDrawer();
            LineRenderer LR1       = new LineRenderer();
            BeamDrawer   BD2       = new BeamDrawer();
            LineRenderer LR2       = new LineRenderer();
            BeamDrawer   debug_BD1 = new BeamDrawer();
            LineRenderer debug_LR1 = new LineRenderer();
            BeamDrawer   debug_BD2 = new BeamDrawer();
            LineRenderer debug_LR2 = new LineRenderer();

            nb.beamID         = v.id.ToString();
            nb.ship           = v;
            nb.ShipPosition   = childPosition_current;
            nb.ShipRotation   = nb.ship.transform.rotation;
            nb.ParentPosition = parentPosition_current;
            nb.ParentRotation = Parent.transform.rotation;


            nb.force    = 0.5F;
            nb.distance = distance;

            nb.Empty1 = new GameObject("Empty1");
            nb.Empty2 = new GameObject("Empty2");

            /*
             */
            nb.ship.GoOffRails();

            //foo1.drawGimbal(nb.Empty1, 10, 1f);
            foo2.drawGimbal(nb.Empty2, 12, 0.5f);
            //foo4.drawGimbal(childPosition_current, 20, 0.5f);

            //nb.Empty2.transform.parent = nb.Empty1.transform;
            //nb.Empty2.transform.rotation = FlightGlobals.ActiveVessel.transform.rotation;
            nb.Vector = newVector;

            nb.y_slider = nb.yAngle;
            nb.z_slider = nb.zAngle;
            nb.x_slider = nb.xAngle;

            nb.BeamDrawer1         = BD1;
            nb.LineRenderer1       = LR1;
            nb.BeamDrawer2         = BD2;
            nb.LineRenderer2       = LR2;
            nb.debug1_BeamDrawer   = debug_BD1;
            nb.debug1_LineRenderer = debug_LR1;
            nb.debug2_BeamDrawer   = debug_BD2;
            nb.debug2_LineRenderer = debug_LR2;

            nb.hold_distance = true;
            nb.hold_Vector   = true;

            UnityEngine.Debug.Log("ImpulseDrive WeaponSystems: CreateTarget TractorSound ");
            nb.TractorSound = new FXGroup("TractorSound");
            GameObject audioObj = new GameObject();

            nb.audioObj = audioObj;
            nb.audioObj.transform.position     = FlightGlobals.ActiveVessel.transform.position;
            nb.audioObj.transform.parent       = FlightGlobals.ActiveVessel.transform;  // add to parent
            nb.TractorSound.audio              = audioObj.AddComponent <AudioSource>();
            nb.TractorSound.audio.dopplerLevel = 0f;
            nb.TractorSound.audio.Stop();
            nb.TractorSound.audio.clip = GameDatabase.Instance.GetAudioClip(TractorSoundFile);
            nb.TractorSound.audio.loop = true;
            // Seek to a random position in the sound file so we don't have
            // harmonic effects when burning at multiple RCS nozzles.
            nb.TractorSound.audio.time = UnityEngine.Random.Range(0, nb.TractorSound.audio.clip.length);
            nb.TractorSound.audio.Play();
            nb.TractorSound.audio.enabled = false;

            try
            {
                if (nb.TractorSound != null && nb.TractorSound.audio != null)
                {
                    nb.soundVolume = GameSettings.SHIP_VOLUME * TractorSoundVolume;
                    nb.TractorSound.audio.enabled = true;
                    nb.TractorSound.audio.volume  = nb.soundVolume;
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("TractorSound Error OnUpdate: " + ex.Message);
            }


            this.BeamList.Add(nb);
            this.BeamIDList.Add(nb.beamID);

            nb                    = null;
            BD1                   = null;
            LR1                   = null;
            BD2                   = null;
            LR2                   = null;
            debug_BD1             = null;
            debug_LR1             = null;
            debug_BD2             = null;
            debug_LR2             = null;
            childPosition_current = Vector3.zero;
        }