Exemple #1
0
 /// <summary>
 /// 连接DSP网关
 /// </summary>
 private bool ConnectDSP()
 {
     try
     {
         // 连接DSP网关
         return(DSPHelper.Connect());
     }
     catch (Exception ex)
     {
         // 记日志
         LogHelper.Error("异常", "连接DSP网关失败", ex);
         return(false);
     }
 }
Exemple #2
0
        void DrawStationResourceGUI(IEnumerable <ResStationGroup> stations, float MaxWidth = 150, int MaxStationsPerLine = 5)
        {
            int stationsNum = 0;

            foreach (var station in stations)
            {
                if (stationsNum % MaxStationsPerLine == 0)
                {
                    GUILayout.BeginHorizontal();
                }
                GUILayout.BeginVertical(UnityEngine.GUI.skin.box, GUILayout.Width(1.0f * MaxWidth), GUILayout.MaxWidth(1.0f * MaxWidth));
                GUILayout.BeginVertical(GUILayout.Width(1.0f * MaxWidth), GUILayout.MaxWidth(1.0f * MaxWidth), GUILayout.MinHeight(50));
                GUILayout.Label($"{station.station.name}", UITheme.TextAlignStyle, GUILayout.Width(0.98f * MaxWidth));
                if (station.station.stationComponent.isCollector)
                {
                    GUILayout.Label($"Collector", UITheme.TextAlignStyle);
                }
                else if (station.station.stationComponent.isStellar)
                {
                    GUILayout.Label($"Warpers: {station.station.stationComponent.warperCount}", UITheme.TextAlignStyle);
                }
                GUILayout.Label($"{DSPHelper.PositionToLatLon(station.station.stationPosition)}", UITheme.TextAlignStyle, UITheme.LocationColWidth);
                GUILayout.EndVertical();



                GUILayout.Label($"Planet: {station.station.planetData.name.Translate()}", UITheme.TextAlignStyle, GUILayout.Width(0.96f * MaxWidth));
                GUILayout.Label($"Amount: {station.product.item.count}/{station.product.item.max}", UITheme.TextAlignStyle, GUILayout.Width(0.86f * MaxWidth));

                GUILayout.BeginHorizontal(GUILayout.Width(1.0f * MaxWidth), GUILayout.MaxWidth(1.0f * MaxWidth));
                GUILayout.Label($"L: {station.product.item.localLogic}", station.product.item.localLogic == ELogisticStorage.Demand ? UITheme.DemandStyle : UITheme.SupplyStyle, GUILayout.Width(0.49f * MaxWidth), GUILayout.MinWidth(0.49f * MaxWidth));
                GUILayout.Label($"R: {station.product.item.remoteLogic}", station.product.item.remoteLogic == ELogisticStorage.Demand ? UITheme.DemandStyle : UITheme.SupplyStyle, GUILayout.Width(0.49f * MaxWidth), GUILayout.MinWidth(0.49f * MaxWidth));
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();

                if (++stationsNum % MaxStationsPerLine == 0 || stationsNum == stations.Count())
                {
                    GUILayout.EndHorizontal();
                }
            }
        }
        void DrawVeinMiners(IEnumerable <MinerNotificationDetail> miners, string parentId, bool includePlanet = false)
        {
            GUIStyle boxStyle = new GUIStyle(UnityEngine.GUI.skin.box)
            {
                margin = new RectOffset(5, 0, 0, 0)
            };

            foreach (var item in miners)
            {
                var myId            = parentId + "." + item.minerComponent.id;
                var alarmSign       = (item.signType != SignData.NONE) ? UITheme.Sign_state[DSPHelper.SignNumToTextureIndex(item.signType)] : Texture2D.blackTexture;
                var resourceTexture = item.resourceTexture ? item.resourceTexture : Texture2D.blackTexture;

                // Debug.Log("Drawing sign-state-" + item.signType);

                GUILayout.BeginHorizontal(boxStyle, GUILayout.MaxHeight(45));
                if (includePlanet)
                {
                    GUILayout.Label($"{item.planetName}", UITheme.TextAlignStyle, UITheme.PlanetColWidth);
                }
                GUILayout.Label($"{DSPHelper.PositionToLatLon(item.plantPosition)}", UITheme.TextAlignStyle, UITheme.LocationColWidth);
                GUILayout.Label($"{DSPHelper.WorkStateToText(item.minerComponent.workstate, item.consumerRatio)}", UITheme.TextAlignStyle, UITheme.LocationColWidth);

                GUILayout.BeginHorizontal(UITheme.VeinTypeColWidth);
                GUILayout.Box(alarmSign, UITheme.VeinIconLayoutOptions);
                GUILayout.Label(DSPHelper.SignNumToText(item.signType), UITheme.TextAlignStyle);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal(UITheme.VeinTypeColWidth);
                GUILayout.Box(resourceTexture, UITheme.VeinIconLayoutOptions);
                GUILayout.Label($"{item.veinName}", UITheme.TextAlignStyle);
                GUILayout.EndHorizontal();

                GUILayout.Label($"{item.veinAmount}", UITheme.TextAlignStyle, UITheme.VeinAmountColWidth);
                GUILayout.Label($"{Math.Round(item.miningRatePerMin, 0)}", UITheme.TextAlignStyle, UITheme.VeinRateColWidth);
                GUILayout.Label($"{item.minutesToEmptyVeinTxt}", UITheme.TextAlignStyle, UITheme.VeinETAColWidth);

                GUILayout.EndHorizontal();
            }
        }
Exemple #4
0
        public override void DrawTabGUI(eTAB_TYPES selectedTab)
        {
            var parentId = eTAB_SOURCE_TYPE.LogisticStations + "." + selectedTab;

            if (selectedTab == eTAB_TYPES.TAB_PLANET)
            {
                var productsPerStation = FilteredSource[selectedTab].GroupBy(pair => pair.station, (group, pairList) => new { station = group, products = pairList });
                var stationsPerPlanet  = productsPerStation.GroupBy(pair => pair.station.planetData, (group, pairList) => new { planet = group, stations = pairList });

                foreach (var stationsPlanetGroup in stationsPerPlanet)
                {
                    var myPlanetId = parentId + "." + stationsPlanetGroup.planet.id;

                    GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box);
                    DrawCollapsedChildrenChevron(myPlanetId, out bool childrenCollapsed);
                    GUILayout.Label($"<b>Planet {stationsPlanetGroup.planet.name.Translate() }</b>", UITheme.TextAlignStyle, GUILayout.Width(170));
                    GUILayout.EndHorizontal();

                    if (!childrenCollapsed)
                    {
                        foreach (var statProdGroup in stationsPlanetGroup.stations)
                        {
                            var myStationId = myPlanetId + "." + statProdGroup.station.stationComponent.id;
                            GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box);

                            GUILayout.BeginVertical(UnityEngine.GUI.skin.box, GUILayout.Width(75), GUILayout.MaxWidth(75));
                            DrawCollapsedChildrenChevron(myStationId, out bool stationCildrenCollapsed);
                            GUILayout.Label($"{statProdGroup.station.name}", UITheme.TextAlignStyle);
                            if (statProdGroup.station.stationComponent.isCollector)
                            {
                                GUILayout.Label($"Collector", UITheme.TextAlignStyle);
                            }
                            else if (statProdGroup.station.stationComponent.isStellar)
                            {
                                GUILayout.Label($"Warpers: {statProdGroup.station.stationComponent.warperCount}", UITheme.TextAlignStyle);
                            }
                            GUILayout.Label($"{DSPHelper.PositionToLatLon(statProdGroup.station.stationPosition)}", UITheme.TextAlignStyle, UITheme.LocationColWidth);
                            GUILayout.EndVertical();

                            if (!stationCildrenCollapsed)
                            {
                                foreach (var product in statProdGroup.products)
                                {
                                    GUILayout.BeginVertical(UnityEngine.GUI.skin.box, GUILayout.Width(150), GUILayout.MaxWidth(150));
                                    GUILayout.BeginHorizontal(GUILayout.Width(150), GUILayout.MaxWidth(150), GUILayout.MinHeight(50));
                                    GUILayout.Box(product.product.itemProto.iconSprite.texture, UITheme.VeinIconLayoutSmallOptions);
                                    GUILayout.Label($"{product.product.itemProto.name}", UITheme.TextAlignStyle, GUILayout.Width(120));
                                    GUILayout.EndHorizontal();
                                    GUILayout.Label($"Amount: {product.product.item.count}/{product.product.item.max}", UITheme.TextAlignStyle, GUILayout.Width(130));
                                    GUILayout.BeginHorizontal(GUILayout.Width(150), GUILayout.MaxWidth(150));
                                    GUILayout.Label($"L: {product.product.item.localLogic}", product.product.item.localLogic == ELogisticStorage.Demand ? UITheme.DemandStyle : UITheme.SupplyStyle, GUILayout.Width(73), GUILayout.MinWidth(73));
                                    GUILayout.Label($"R: {product.product.item.remoteLogic}", product.product.item.remoteLogic == ELogisticStorage.Demand ? UITheme.DemandStyle : UITheme.SupplyStyle, GUILayout.Width(73), GUILayout.MinWidth(73));
                                    GUILayout.EndHorizontal();
                                    GUILayout.EndVertical();
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                }
            }
            else if (selectedTab == eTAB_TYPES.TAB_RESOURCE)
            {
                var stationsPerResource = FilteredSource[selectedTab].GroupBy(pair => pair.product.item.itemId, pair => new ResStationGroup()
                {
                    station = pair.station, product = pair.product
                })
                                          .Select(grp => new { itemId = grp.Key, itemProto = LDB.items.Select(grp.Key), stations = grp }).OrderBy(grp => grp.itemProto.name.Translate());

                foreach (var resource in stationsPerResource)
                {
                    var myId = parentId + "." + resource.itemId;

                    var resourceTexture = resource.itemProto.iconSprite.texture;

                    GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box);
                    DrawCollapsedChildrenChevron(myId, out bool resChildrenCollapsed);
                    GUILayout.Label($"<b>Resource</b>", UITheme.TextAlignStyle, GUILayout.Width(65));
                    GUILayout.Box(resourceTexture, UITheme.VeinIconLayoutOptions);
                    GUILayout.Label($"<b>{resource.itemProto.Name.Translate()}</b>", UITheme.TextAlignStyle);
                    GUILayout.EndHorizontal();

                    var interstellarDemand = resource.stations.Where(s => s.station.stationComponent.isStellar && s.product.item.remoteLogic == ELogisticStorage.Demand);
                    var interstellarSupply = resource.stations.Where(s => s.station.stationComponent.isStellar && s.product.item.remoteLogic == ELogisticStorage.Supply);
                    var interstellarNone   = resource.stations.Where(s => s.station.stationComponent.isStellar && s.product.item.remoteLogic == ELogisticStorage.None);

                    var localDemand = resource.stations.Where(s => !s.station.stationComponent.isStellar && s.product.item.localLogic == ELogisticStorage.Demand);
                    var localSupply = resource.stations.Where(s => !s.station.stationComponent.isStellar && s.product.item.localLogic == ELogisticStorage.Supply);
                    var localNone   = resource.stations.Where(s => !s.station.stationComponent.isStellar && s.product.item.localLogic == ELogisticStorage.None);

                    List <PresOrderTuple> presOrder = new List <PresOrderTuple>()
                    {
                        { new PresOrderTuple()
                          {
                              name = "Interstellar Supply", stations = interstellarSupply, style = UITheme.SupplyStyle
                          } },
                        { new PresOrderTuple()
                          {
                              name = "Interstellar Demand", stations = interstellarDemand, style = UITheme.DemandStyle
                          } },
                        { new PresOrderTuple()
                          {
                              name = "Interstellar Storage", stations = interstellarNone, style = UITheme.TextAlignStyle
                          } },
                        { new PresOrderTuple()
                          {
                              name = "Planetary Supply", stations = localSupply, style = UITheme.SupplyStyle
                          } },
                        { new PresOrderTuple()
                          {
                              name = "Planetary Demand", stations = localDemand, style = UITheme.DemandStyle
                          } },
                        { new PresOrderTuple()
                          {
                              name = "Planetary Storage", stations = localNone, style = UITheme.TextAlignStyle
                          } }
                    };

                    if (!resChildrenCollapsed)
                    {
                        foreach (var pres in presOrder)
                        {
                            if (pres.stations.Count() > 0)
                            {
                                var logTypeByResourceId = myId + "." + pres.name;

                                var stationsByPlanetByResource = pres.stations
                                                                 .GroupBy(m => m.station.planetData.name.Translate()).OrderBy(g => g.Key)
                                                                 .Select(mtg => new { Name = mtg.Key, Stations = mtg.ToList() });

                                GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box);
                                GUILayout.BeginVertical(UnityEngine.GUI.skin.box, GUILayout.Width(75), GUILayout.MaxWidth(75));
                                //DrawCollapsedChildrenChevron(logTypeByResourceId, out bool logTypeByResourceChildrenCollapsed);
                                GUILayout.Label($"{pres.name}", pres.style);
                                GUILayout.EndVertical();

                                //if (!logTypeByResourceChildrenCollapsed)
                                {
                                    GUILayout.BeginVertical();
                                    foreach (var stationsPlanet in stationsByPlanetByResource)
                                    {
                                        var mStationsByPlanetId = logTypeByResourceId + "-" + stationsPlanet.Name;
                                        GUILayout.BeginHorizontal(UnityEngine.GUI.skin.box);
                                        DrawCollapsedChildrenChevron(mStationsByPlanetId, out bool stationsByPlanetChildrenCollapsed);
                                        GUILayout.Label($"<b>Planet {stationsPlanet.Name}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65));
                                        GUILayout.Label($"  <b># P.L.S: {stationsPlanet.Stations.Where(s => !s.station.stationComponent.isStellar).Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65));
                                        GUILayout.Label($"  <b># I.L.S: {stationsPlanet.Stations.Where(s => s.station.stationComponent.isStellar && !s.station.stationComponent.isCollector).Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65));
                                        GUILayout.Label($"  <b># Collectors: {stationsPlanet.Stations.Where(s => s.station.stationComponent.isCollector).Count()}</b>", UITheme.TextAlignStyle, GUILayout.MinWidth(65));
                                        GUILayout.EndHorizontal();

                                        if (!stationsByPlanetChildrenCollapsed)
                                        {
                                            GUILayout.BeginVertical();
                                            DrawStationResourceGUI(stationsPlanet.Stations, MaxWidth: 165, MaxStationsPerLine: 4);
                                            GUILayout.EndVertical();
                                        }
                                    }
                                    GUILayout.EndVertical();
                                }

                                GUILayout.EndHorizontal();
                            }
                        }
                    }
                }
            }
        }