Exemplo n.º 1
0
        void UpdateLaunchsite()
        {
            if (selectedSite == null)
            {
                openSite.SetActive(false);
                siteIsOpen.SetActive(false);
                siteCannoteBeOpened.SetActive(true);
            }
            else
            {
                var    site  = selectedSite;
                string state = site.OpenCloseState;

                if (state == "Closed")
                {
                    float openCost = site.OpenCost / 2;
                    openSite.Text(Localizer.Format(KKLocalization.OpenSiteForFunds, site.LaunchSiteName, openCost));
                    openSite.SetActive(true);
                    siteIsOpen.SetActive(false);
                    siteCannoteBeOpened.SetActive(false);
                }
                else if (state == "Open")
                {
                    openSite.SetActive(false);
                    siteIsOpen.SetActive(true);
                    siteCannoteBeOpened.SetActive(false);
                }
                else if (state == "OpenLocked" || state == "ClosedLocked")
                {
                    openSite.SetActive(false);
                    siteIsOpen.SetActive(false);
                    siteCannoteBeOpened.SetActive(true);
                }
            }
        }
Exemplo n.º 2
0
        public void UpdateUI(StaticInstance selectedFacility)
        {
            this.selectedFacility = selectedFacility;
            hangar = selectedFacility.myFacilities[0] as Hangar;

            int   craftOccupancy = hangar.storedVessels.Count;
            int   craftCapacity  = hangar.FacilityCraftCapacity;
            float maxMass        = hangar.FacilityMassCapacity;

            if (maxMass < 1)
            {
                maxMass = 25;
            }
            maxCraft.Info($"{craftCapacity}");
            maxMassPerCraft.Info($"{maxMass:F1} t");

            if (craftOccupancy < 1)
            {
                noCraft.SetActive(true);
                storedCraftBlock.SetActive(false);
            }
            else
            {
                noCraft.SetActive(false);
                storedCraftBlock.SetActive(true);

                storedCraftHeader.Text(Localizer.Format(KKLocalization.HangarStoredCraft, hangar.storedVessels.Count, craftCapacity));
                BuildCraftList();
            }

            float  mass     = FlightGlobals.ActiveVessel.GetTotalMass();
            double distance = Vector3.Distance(FlightGlobals.ActiveVessel.gameObject.transform.position, selectedFacility.position);

            bool   tooHeavy = mass > maxMass;
            bool   isFull   = craftOccupancy >= craftCapacity;
            double tooFar   = distance - KerbalKonstructs.instance.facilityUseRange;

            vesselTooHeavy.SetActive(tooHeavy);
            hangarIsFull.SetActive(isFull);
            hangarTooFar.SetActive(tooFar >= 0);
            if (tooHeavy)
            {
                vesselTooHeavy.Info($"{mass:F1} t/{maxMass:F1} t");
            }
            if (tooFar >= 0)
            {
                hangarTooFar.Text(Localizer.Format(KKLocalization.HangarTooFar, tooFar));
            }
            storeVessel.interactable = !(tooHeavy || isFull || tooFar >= 0);
        }
Exemplo n.º 3
0
 void UpdateFaclilitiesGroup()
 {
     BuildFacilities();
     facilityScan.interactable = FlightGlobals.ActiveVessel.Landed;
     if (FlightGlobals.ActiveVessel.Landed)
     {
         if (allFacilities.Count == 0)
         {
             noFacilitiesWithin.SetActive(true);
             nearbyFacilities.SetActive(false);
         }
         else
         {
             noFacilitiesWithin.SetActive(false);
             nearbyFacilities.SetActive(false);
         }
     }
     else
     {
         noFacilitiesWithin.SetActive(false);
         nearbyFacilities.SetActive(true);
     }
 }
Exemplo n.º 4
0
        void UpdateUI()
        {
            // assume we don't have any staffing
            maxStaff     = 0;
            currentStaff = 0;

            // check if we can access the staffing variables
            if (barracks != null)
            {
                currentStaff = barracks.StaffCurrent;
                maxStaff     = barracks.StaffMax;
            }
            else if (production != null)
            {
                currentStaff = production.StaffCurrent;
                maxStaff     = production.StaffMax;
            }

            /* FIXME this should be moved into barracks/production loading
             *              if (maxStaff < 1) {
             *  maxStaff = staticInstance.model.DefaultStaffMax;
             *
             *  if (maxStaff < 1) {
             *      barracks.StaffMax = 0;
             *  } else {
             *      barracks.StaffMax = maxStaff;
             *  }
             * }
             */


            if (maxStaff > 0)
            {
                float CountEmpty = maxStaff - currentStaff;

                BuildStaffList(currentStaff, maxStaff);

                staffList.SetActive(true);
                noStaffRequired.SetActive(false);
                barracksGroup.SetActive(barracks != null);
                nonbarracksGroup.SetActive(barracks == null);
                if (barracks != null)
                {
                    staff.Info($"{currentStaff} / {maxStaff}");
                    unassignedStaff.Info($"{barracks.StaffAvailable} / {currentStaff}");

                    hireTip.Info($"{Barracks.hireFundCost:F0}");
                    fireTipCost.Info($"{Barracks.fireRefund:F0}");
                    fireTipRep.Info($"{Barracks.fireRepCost:F0}");
                }
                else
                {
                    assignedStaff.Info($"{currentStaff} / {maxStaff}");
                }
            }
            else
            {
                staffList.SetActive(false);
                noStaffRequired.SetActive(true);
                barracksGroup.SetActive(false);
                nonbarracksGroup.SetActive(false);
            }
        }
Exemplo n.º 5
0
        void UpdateUI()
        {
            landingGuide.SetIsOnWithoutNotify(LandingGuideUI.instance.IsOpen());
            navGuidance.SetIsOnWithoutNotify(NavGuidanceSystem.instance.IsOpen());

            var Range = float.PositiveInfinity;

            //FIXME atmo scaling? other worlds? ...
            if (FlightGlobals.ActiveVessel.altitude > 75000)
            {
                center = null;
                noBasesBeacon.SetActive(true);
                noNearestBase.SetActive(false);
                nearestBaseGroup.SetActive(false);
            }
            else
            {
                center = StaticDatabase.GetClosestLaunchCenter();;
                if (center == null)
                {
                    noBasesBeacon.SetActive(false);
                    noNearestBase.SetActive(true);
                    nearestBaseGroup.SetActive(false);
                }
                else
                {
                    noBasesBeacon.SetActive(false);
                    noNearestBase.SetActive(false);
                    nearestBaseGroup.SetActive(true);

                    Vector3 vPosition = FlightGlobals.ActiveVessel.GetTransform().position;
                    ngsSite = LaunchSiteManager.getNearestBase(center, vPosition);
                    Range   = Vector3.Distance(center.gameObject.transform.position, vPosition);
                    string info;
                    if (Range < 10000)
                    {
                        info = center.Group + " at " + Range.ToString("#0.0") + " m";
                    }
                    else
                    {
                        info = center.Group + " at " + (Range / 1000).ToString("#0.0") + " km";
                    }
                    nearestBase.Info(info);
                    bool ngs = NavGuidanceSystem.instance.IsOpen();
                    ngsFiller.SetActive(!ngs);
                    setNGSTarget.SetActive(ngs);
                }
            }

            if (!MiscUtils.isCareerGame())
            {
                careerGroup.SetActive(false);
            }
            else
            {
                careerGroup.SetActive(true);

                if (!FlightGlobals.ActiveVessel.Landed || Range > 5000)
                {
                    //FIXME a bouncy landing will be laggy
                    if (launchsiteItems.Count > 0)
                    {
                        launchsiteItems.Clear();
                        UIKit.UpdateListContent(launchsiteItems);
                    }
                    basesCanBeOpened.SetActive(true);
                    openSite.SetActive(false);
                    siteIsOpen.SetActive(false);
                    siteCannoteBeOpened.SetActive(false);
                }
                else
                {
                    basesCanBeOpened.SetActive(false);
                    if (launchsiteItems.Count != center.launchsites.Count)
                    {
                        BuildLaunchsites();
                    }
                    UpdateLaunchsite();
                }

                //if (Range > 100000)
                //{
                //    if (bLanded)
                //    {
                //        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                //        GUILayout.Space(2);
                //        GUILayout.Label("This feature is WIP.", LabelInfo);
                //        GUI.enabled = false;
                //        if (GUILayout.Button("Found a New Base", GUILayout.Height(23)))
                //        {
                //            foundingBase = true;
                //        }
                //        GUI.enabled = true;
                //        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                //        GUILayout.Space(2);
                //    }
                //}
                //else
                //{
                //    GUILayout.Label("This feature is WIP.", LabelInfo);
                //}
            }

            UpdateFaclilitiesGroup();
        }