コード例 #1
0
ファイル: Pirates.cs プロジェクト: zerk-js/SOTSII-SOS
        public void AddInstance(
            GameDatabase gamedb,
            AssetDatabase assetdb,
            GameSession game,
            int SystemId,
            int OrbitId)
        {
            Random         random = new Random();
            PirateBaseInfo pbi    = new PirateBaseInfo();

            pbi.SystemId          = SystemId;
            pbi.NumShips          = assetdb.GlobalPiracyData.PiracyMinBaseShips;
            pbi.TurnsUntilAddShip = assetdb.GlobalPiracyData.PiracyBaseTurnsPerUpdate;
            float             num = StarSystemVars.Instance.SizeToRadius(game.GameDatabase.GetPlanetInfo(OrbitId).Size) + (float)StarSystemVars.Instance.StationOrbitDistance;
            OrbitalObjectInfo orbitalObjectInfo = gamedb.GetOrbitalObjectInfo(OrbitId);
            OrbitalPath       path = new OrbitalPath();

            path.Scale        = new Vector2(num, num);
            path.Rotation     = new Vector3(0.0f, 0.0f, 0.0f);
            path.DeltaAngle   = random.NextInclusive(0.0f, 360f);
            path.InitialAngle = 0.0f;
            DesignInfo designInfo = gamedb.GetDesignInfo(this.PirateBaseDesignId);

            pbi.BaseStationId = gamedb.InsertStation(OrbitId, orbitalObjectInfo.StarSystemID, path, designInfo.Name, this.PlayerId, designInfo);
            gamedb.InsertPirateBaseInfo(pbi);
        }
コード例 #2
0
        public override void Initialize()
        {
            StationInfo       stationInfo        = this._app.GameDatabase.GetStationInfo(this._stationID);
            OrbitalObjectInfo orbitalObjectInfo1 = this._app.GameDatabase.GetOrbitalObjectInfo(this._stationID);
            OrbitalObjectInfo orbitalObjectInfo2 = this._app.GameDatabase.GetOrbitalObjectInfo(orbitalObjectInfo1.ParentID.Value);

            if (stationInfo == null || orbitalObjectInfo1 == null)
            {
                this._app.UI.CloseDialog((Dialog)this, true);
            }
            else
            {
                this._app.UI.SetText(this._app.UI.Path(this.ID, "station_class"), string.Format(App.Localize("@STATION_LEVEL"), (object)stationInfo.DesignInfo.StationLevel.ToString(), (object)stationInfo.DesignInfo.StationType.ToDisplayText(this._app.LocalPlayer.Faction.Name)));
                this._app.UI.SetText(this._app.UI.Path(this.ID, "upkeep_cost"), string.Format(App.Localize("@STATION_UPKEEP_COST"), (object)GameSession.CalculateStationUpkeepCost(this._app.GameDatabase, this._app.AssetDatabase, stationInfo).ToString()));
                if (stationInfo.DesignInfo.StationType == StationType.NAVAL)
                {
                    this._app.UI.SetText(this._app.UI.Path(this.ID, "naval_capacity"), string.Format(App.Localize("@STATION_FLEET_CAPACITY"), (object)this._app.GameDatabase.GetSystemSupportedCruiserEquivalent(this._app.Game, orbitalObjectInfo2.StarSystemID, this._app.LocalPlayer.ID).ToString()));
                }
                else
                {
                    this._app.UI.SetVisible(this._app.UI.Path(this.ID, "naval_capacity"), false);
                }
                StationUI.SyncStationDetailsWidget(this._app.Game, "detailsCard", this._stationID, true);
                StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(orbitalObjectInfo2.StarSystemID);
                this._app.UI.SetText("gameStationName", orbitalObjectInfo1.Name);
                this._enteredStationName = orbitalObjectInfo2.Name;
                this._app.UI.SetText(this._app.UI.Path(this.ID, "system_name"), string.Format(App.Localize("@STATION_BUILT"), (object)starSystemInfo.Name).ToUpperInvariant());
            }
        }
コード例 #3
0
ファイル: Swarmers.cs プロジェクト: zerk-js/SOTSII-SOS
        public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int SystemId, int OrbitId)
        {
            int num1 = OrbitId;

            if (gamedb.GetLargeAsteroidInfo(OrbitId) == null && gamedb.GetAsteroidBeltInfo(OrbitId) == null)
            {
                OrbitalObjectInfo orbitalObjectInfo = gamedb.GetOrbitalObjectInfo(OrbitId);
                StarSystemInfo    starSystemInfo    = gamedb.GetStarSystemInfo(SystemId);
                gamedb.RemoveOrbitalObject(orbitalObjectInfo.ID);
                if (!orbitalObjectInfo.ParentID.HasValue)
                {
                    num1 = gamedb.InsertAsteroidBelt(new int?(), orbitalObjectInfo.StarSystemID, orbitalObjectInfo.OrbitalPath, "Swarmed Asteroid Belt", App.GetSafeRandom().Next());
                }
                else
                {
                    int         num2        = gamedb.GetStarSystemOrbitalObjectInfos(SystemId).Where <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x => !x.ParentID.HasValue)).Count <OrbitalObjectInfo>();
                    OrbitalPath orbitalPath = gamedb.OrbitNumberToOrbitalPath(num2 + 1, StellarClass.Parse(starSystemInfo.StellarClass).Size, new float?());
                    num1 = gamedb.InsertAsteroidBelt(new int?(), orbitalObjectInfo.StarSystemID, orbitalPath, "Swarmed Asteroid Belt", App.GetSafeRandom().Next());
                }
            }
            SwarmerInfo si = new SwarmerInfo();

            si.GrowthStage    = 0;
            si.SystemId       = SystemId;
            si.OrbitalId      = num1;
            si.HiveFleetId    = new int?(gamedb.InsertFleet(this.PlayerId, 0, SystemId, SystemId, "Swarm", FleetType.FL_NORMAL));
            si.QueenFleetId   = new int?();
            si.SpawnHiveDelay = 1;
            gamedb.InsertSwarmerInfo(si);
            gamedb.InsertShip(si.HiveFleetId.Value, this._hiveStage1DesignId, null, (ShipParams)0, new int?(), 0);
        }
コード例 #4
0
ファイル: MorrigiRelic.cs プロジェクト: zerk-js/SOTSII-SOS
        public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int SystemId, int OrbitId)
        {
            OrbitalObjectInfo orbitalObjectInfo = gamedb.GetOrbitalObjectInfo(OrbitId);

            gamedb.RemoveOrbitalObject(orbitalObjectInfo.ID);
            int orbitalId = gamedb.InsertAsteroidBelt(orbitalObjectInfo.ParentID, orbitalObjectInfo.StarSystemID, orbitalObjectInfo.OrbitalPath, "Morrigi Relic Belt", App.GetSafeRandom().Next());
            int fleetID   = gamedb.InsertFleet(this.PlayerId, 0, SystemId, SystemId, "Morrigi Relic", FleetType.FL_NORMAL);

            gamedb.InsertMorrigiRelicInfo(new MorrigiRelicInfo()
            {
                SystemId     = SystemId,
                FleetId      = fleetID,
                IsAggressive = true
            });
            Random     safeRandom       = App.GetSafeRandom();
            Matrix     orbitalTransform = gamedb.GetOrbitalTransform(orbitalId);
            List <int> list             = MorrigiRelic._designIds.Where <int>((Func <int, bool>)(x => x != MorrigiRelic._designIds.Last <int>())).ToList <int>();

            for (int shipIndex = 0; shipIndex < safeRandom.Next(1, assetdb.GlobalMorrigiRelicData.NumTombs + 1); ++shipIndex)
            {
                int num = gamedb.InsertShip(fleetID, safeRandom.Choose <int>((IList <int>)list), null, (ShipParams)0, new int?(), 0);
                this.SetRelicPosition(safeRandom, gamedb, assetdb, num, shipIndex, orbitalTransform);
                for (int index = 0; index < assetdb.GlobalMorrigiRelicData.NumFighters; ++index)
                {
                    int shipID = gamedb.InsertShip(fleetID, MorrigiRelic._designIds.Last <int>(), null, (ShipParams)0, new int?(), 0);
                    gamedb.SetShipParent(shipID, num);
                }
            }
        }
コード例 #5
0
 protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
 {
     if (msgType == "button_clicked")
     {
         if (!(panelName == "event_dialog_close"))
         {
             return;
         }
         OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this._stationID);
         if (orbitalObjectInfo != null)
         {
             orbitalObjectInfo.Name = this._enteredStationName;
             this._app.GameDatabase.UpdateOrbitalObjectInfo(orbitalObjectInfo);
         }
         if (!string.IsNullOrWhiteSpace(this._enteredStationName) && this._enteredStationName.Count <char>() > 0)
         {
             this._app.UI.CloseDialog((Dialog)this, true);
         }
         else
         {
             this._app.UI.CreateDialog((Dialog) new GenericTextDialog(this._app, App.Localize("@INVALID_STATION_NAME"), App.Localize("@INVALID_STATION_NAME_TEXT"), "dialogGenericMessage"), null);
         }
     }
     else
     {
         if (!(msgType == "text_changed") || !(panelName == "gameStationName"))
         {
             return;
         }
         this._enteredStationName = msgParams[0];
     }
 }
コード例 #6
0
ファイル: Locust.cs プロジェクト: zerk-js/SOTSII-SOS
        public static Matrix GetSpawnTransform(App app, int systemId)
        {
            bool              flag = false;
            float             num1 = 0.0f;
            float             num2 = 0.0f;
            OrbitalObjectInfo orbitalObjectInfo1 = (OrbitalObjectInfo)null;
            Vector3           vector3_1          = Vector3.Zero;
            Vector3?          nullable           = new Vector3?();

            foreach (OrbitalObjectInfo orbitalObjectInfo2 in app.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId))
            {
                ColonyInfo colonyInfoForPlanet = app.GameDatabase.GetColonyInfoForPlanet(orbitalObjectInfo2.ID);
                if (!flag || colonyInfoForPlanet != null)
                {
                    PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(orbitalObjectInfo2.ID);
                    float      num3       = 1000f;
                    if (planetInfo != null)
                    {
                        num3 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);
                    }
                    Vector3 position = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position;
                    float   num4     = position.Length + num3;
                    if ((double)num4 > (double)num1 || !flag && colonyInfoForPlanet != null)
                    {
                        orbitalObjectInfo1 = orbitalObjectInfo2;
                        num1      = num4;
                        flag      = colonyInfoForPlanet != null;
                        vector3_1 = position;
                        num2      = num3 + 10000f;
                        nullable  = !orbitalObjectInfo2.ParentID.HasValue || orbitalObjectInfo2.ParentID.Value == 0 ? new Vector3?() : new Vector3?(app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position);
                        if (flag)
                        {
                            break;
                        }
                    }
                }
            }
            if (orbitalObjectInfo1 == null)
            {
                return(Matrix.Identity);
            }
            Vector3 vector3_2 = Vector3.Zero;

            if (nullable.HasValue)
            {
                Matrix  world = Matrix.CreateWorld(Vector3.Zero, Vector3.Normalize(nullable.Value), Vector3.UnitY);
                Vector3 v1    = Vector3.Normalize(vector3_1 - nullable.Value);
                vector3_2 = world.Right * num2;
                if ((double)Vector3.Dot(world.Right, v1) < 0.0)
                {
                    vector3_2 *= -1f;
                }
            }
            Vector3 vector3_3 = -vector3_1;
            double  num5      = (double)vector3_3.Normalize();
            Vector3 position1 = vector3_1 - vector3_3 * num2 + vector3_2;

            return(Matrix.CreateWorld(position1, Vector3.Normalize(vector3_1 - position1), Vector3.UnitY));
        }
コード例 #7
0
 public ColonySelfSufficientDialog(App game, int planetId, int missionId)
     : base(game, "dialogColonySelfSufficientEvent")
 {
     this.orbitalObject = game.GameDatabase.GetOrbitalObjectInfo(planetId);
     this.planet        = game.GameDatabase.GetPlanetInfo(planetId);
     this.colony        = game.GameDatabase.GetColonyInfoForPlanet(planetId);
     this.mission       = game.GameDatabase.GetMissionInfo(missionId);
 }
コード例 #8
0
        public override void Initialize()
        {
            this._app.UI.SetText(this._app.UI.Path(this.ID, SuperWorldDialog.UIGemDesc), string.Format(App.Localize("@UI_DIALOGSUPERWORLD_GEM_DESC"), (object)this._app.AssetDatabase.GemWorldCivMaxBonus));
            this._app.UI.SetText(this._app.UI.Path(this.ID, SuperWorldDialog.UIForgeDesc), string.Format(App.Localize("@UI_DIALOGSUPERWORLD_FORGE_DESC"), (object)this._app.AssetDatabase.ForgeWorldImpMaxBonus, (object)this._app.AssetDatabase.ForgeWorldIOBonus));
            OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this._app.GameDatabase.GetColonyInfo(this.colonyId).OrbitalObjectID);
            StarSystemInfo    starSystemInfo    = this._app.GameDatabase.GetStarSystemInfo(orbitalObjectInfo.StarSystemID);

            this._app.UI.SetText(this._app.UI.Path(this.ID, SuperWorldDialog.UILocation), string.Format(App.Localize("@UI_DIALOGSUPERWORLD_LOCATION"), (object)orbitalObjectInfo.Name, (object)starSystemInfo.Name));
        }
コード例 #9
0
 private static void InsertIndependentSystem(
     Random random,
     StarSystemInfo system,
     OrbitalObjectInfo orbit,
     GameDatabase gamedb,
     AssetDatabase assetdb)
 {
     ScriptModules.GenerateIndependentRace(random, system, orbit, gamedb, assetdb);
 }
コード例 #10
0
        public StellarBody.Params GetStellarBodyParams(GameSession game, int orbitalId)
        {
            OrbitalObjectInfo orbitalObjectInfo   = game.GameDatabase.GetOrbitalObjectInfo(orbitalId);
            ColonyInfo        colonyInfoForPlanet = game.GameDatabase.GetColonyInfoForPlanet(orbitalId);
            PlanetInfo        planetInfo          = game.GameDatabase.GetPlanetInfo(orbitalId);
            SystemColonyType  colonyType          = SystemColonyType.Normal;
            int        num;
            double     population;
            PlayerInfo povPlayerInfo;

            if (colonyInfoForPlanet != null)
            {
                num           = colonyInfoForPlanet.PlayerID;
                population    = colonyInfoForPlanet.ImperialPop;
                povPlayerInfo = game.GameDatabase.GetPlayerInfo(num);
                if (orbitalObjectInfo != null && povPlayerInfo != null)
                {
                    HomeworldInfo homeworldInfo = game.GameDatabase.GetHomeworlds().FirstOrDefault <HomeworldInfo>((Func <HomeworldInfo, bool>)(x => x.SystemID == orbitalObjectInfo.StarSystemID));

                    if (homeworldInfo != null && homeworldInfo.SystemID != 0 && homeworldInfo.PlayerID == povPlayerInfo.ID)
                    {
                        colonyType = SystemColonyType.Home;
                    }
                    else if (game.GameDatabase.GetProvinceInfos().Any <ProvinceInfo>((Func <ProvinceInfo, bool>)(x =>
                    {
                        if (x.CapitalSystemID != orbitalObjectInfo.StarSystemID || x.PlayerID != povPlayerInfo.ID)
                        {
                            return(false);
                        }
                        int capitalSystemId = x.CapitalSystemID;
                        int?homeworld = povPlayerInfo.Homeworld;
                        if (capitalSystemId == homeworld.GetValueOrDefault())
                        {
                            return(!homeworld.HasValue);
                        }
                        return(true);
                    })))
                    {
                        colonyType = SystemColonyType.Capital;
                    }
                }
            }
            else
            {
                num           = 0;
                population    = 0.0;
                povPlayerInfo = game.GameDatabase.GetPlayerInfo(game.LocalPlayer.ID);
            }
            FactionInfo factionInfo   = game.GameDatabase.GetFactionInfo(povPlayerInfo.FactionID);
            float       hazard        = Math.Abs(planetInfo.Suitability - factionInfo.IdealSuitability);
            float       stratModifier = (float)game.App.GetStratModifier <int>(StratModifiers.MaxColonizableHazard, povPlayerInfo.ID);
            float       radius        = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);
            Matrix      transform     = orbitalObjectInfo.OrbitalPath.GetTransform(0.0);

            return(this.GetStellarBodyParams(StarSystemMapUI.SelectIcon(planetInfo, game.GameDatabase.GetStarSystemOrbitalObjectInfos(orbitalObjectInfo.StarSystemID), (IEnumerable <PlanetInfo>)game.GameDatabase.GetStarSystemPlanetInfos(orbitalObjectInfo.StarSystemID)), transform.Position, radius, orbitalId, num, planetInfo.Type, hazard, stratModifier, factionInfo.Name, (float)planetInfo.Biosphere, population, new int?(), Colony.GetColonyStage(game.GameDatabase, num, (double)hazard), colonyType));
        }
コード例 #11
0
 protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
 {
     if (msgType == "button_clicked")
     {
         if (panelName == "okButton")
         {
             this._app.UI.CloseDialog((Dialog)this, true);
         }
         if (panelName == "detailbutton" || !(panelName == "placeColonyTrapsbtn"))
         {
             return;
         }
         this._colonytrapDialog = this._app.UI.CreateDialog((Dialog) new DialogColonyTrap(this._app, this._systemID, this._fleetID), null);
     }
     else if (msgType == "dialog_closed")
     {
         if (!(panelName == this._colonytrapDialog))
         {
             return;
         }
         this.UpdateCanPlaceTraps();
     }
     else if (msgType == "list_sel_changed")
     {
         if (!(panelName == "gamePlanetList"))
         {
             return;
         }
         int orbitalObjectID = int.Parse(msgParams[0]);
         OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(orbitalObjectID);
         bool flag = false;
         if (orbitalObjectInfo != null && orbitalObjectInfo.ParentID.HasValue)
         {
             PlanetInfo planetInfo = this._app.GameDatabase.GetPlanetInfo(orbitalObjectInfo.ParentID.Value);
             if (planetInfo != null)
             {
                 this._app.UI.Send((object)"SetSel", (object)this._app.UI.Path(this.ID, "system_map"), (object)1, (object)planetInfo.ID);
                 flag = true;
             }
         }
         if (flag)
         {
             return;
         }
         this._app.UI.Send((object)"SetSel", (object)this._app.UI.Path(this.ID, "system_map"), (object)1, (object)orbitalObjectID);
     }
     else
     {
         if (!(msgType == "mapicon_clicked"))
         {
             return;
         }
         this._app.UI.Send((object)"SetSel", (object)this._app.UI.Path(this.ID, "planetListWidget"), (object)int.Parse(msgParams[0]));
     }
 }
コード例 #12
0
 public static void SyncPlanetListControl(
     GameSession game,
     string panelName,
     IEnumerable <int> orbitalObjects)
 {
     game.UI.ClearItems(panelName);
     foreach (int orbitalObject in orbitalObjects)
     {
         OrbitalObjectInfo orbitalObjectInfo = game.GameDatabase.GetOrbitalObjectInfo(orbitalObject);
         FleetUI.SyncPlanetItemControl(game, panelName, orbitalObjectInfo);
     }
     game.UI.AutoSize(panelName);
 }
コード例 #13
0
ファイル: Pirates.cs プロジェクト: zerk-js/SOTSII-SOS
        public static Matrix GetSpawnTransform(App app, PirateBaseInfo pbi)
        {
            if (pbi == null)
            {
                return(Matrix.Identity);
            }
            StationInfo       stationInfo       = app.GameDatabase.GetStationInfo(pbi.BaseStationId);
            OrbitalObjectInfo orbitalObjectInfo = app.GameDatabase.GetOrbitalObjectInfo(stationInfo.OrbitalObjectID);
            Matrix            orbitalTransform1 = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo.ID);
            Matrix            orbitalTransform2 = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo.ParentID.Value);
            Vector3           vector3           = Vector3.Normalize(orbitalTransform1.Position - orbitalTransform2.Position);

            return(Matrix.CreateWorld(orbitalTransform1.Position + vector3 * 2000f, -vector3, Vector3.UnitY));
        }
コード例 #14
0
ファイル: Pirates.cs プロジェクト: zerk-js/SOTSII-SOS
        public static Matrix GetBaseEnemyFleetTrans(App app, PirateBaseInfo pbi)
        {
            if (pbi == null)
            {
                return(Matrix.Identity);
            }
            StationInfo       stationInfo       = app.GameDatabase.GetStationInfo(pbi.BaseStationId);
            OrbitalObjectInfo orbitalObjectInfo = app.GameDatabase.GetOrbitalObjectInfo(stationInfo.OrbitalObjectID);
            float             radius            = StarSystemVars.Instance.SizeToRadius(app.GameDatabase.GetPlanetInfo(orbitalObjectInfo.ParentID.Value).Size);
            Matrix            orbitalTransform  = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo.ParentID.Value);
            Vector3           vector3           = Vector3.Normalize(orbitalTransform.Position);

            return(Matrix.CreateWorld(orbitalTransform.Position + vector3 * (float)((double)radius + 750.0 + 1000.0), -vector3, Vector3.UnitY));
        }
コード例 #15
0
        public override void FindNewTarget(IEnumerable <IGameObject> objs)
        {
            this.m_SpaceBattle = true;
            List <StellarBody> source        = new List <StellarBody>();
            List <MoonData>    moonDataList  = new List <MoonData>();
            List <StarModel>   starModelList = new List <StarModel>();

            foreach (IGameObject gameObject in objs)
            {
                if (gameObject is StellarBody)
                {
                    StellarBody stellarBody = gameObject as StellarBody;
                    source.Add(stellarBody);
                    this.m_SpaceBattle = false;
                }
                else if (gameObject is StarModel)
                {
                    StarModel starModel = gameObject as StarModel;
                    starModelList.Add(starModel);
                    this.m_SpaceBattle = false;
                }
            }
            foreach (StellarBody stellarBody in source)
            {
                foreach (OrbitalObjectInfo moon in this.m_Game.GameDatabase.GetMoons(stellarBody.Parameters.OrbitalID))
                {
                    OrbitalObjectInfo ooi = moon;
                    moonDataList.Add(new MoonData()
                    {
                        ParentID = ooi.ParentID.Value,
                        Moon     = source.First <StellarBody>((Func <StellarBody, bool>)(x => x.Parameters.OrbitalID == ooi.ID))
                    });
                }
            }
            foreach (MoonData moonData in moonDataList)
            {
                source.Remove(moonData.Moon);
            }
            this.m_Planets = source;
            this.m_Moons   = moonDataList;
            this.m_Stars   = starModelList;
            if (!this.m_SpaceBattle)
            {
                return;
            }
            this.m_State = SystemKillerStates.SPACEBATTLE;
        }
コード例 #16
0
        public static void SyncPlanetItemControl(
            GameSession game,
            string panelName,
            OrbitalObjectInfo orbital)
        {
            PlanetInfo planetInfo = game.GameDatabase.GetPlanetInfo(orbital.ID);

            if (planetInfo == null)
            {
                return;
            }
            game.GameDatabase.GetMoons(orbital.ID);
            string        propertyValue        = App.Localize("@UI_PLANET_TYPE_" + planetInfo.Type.ToUpperInvariant());
            Vector4       color                = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
            AIColonyIntel colonyIntelForPlanet = game.GameDatabase.GetColonyIntelForPlanet(game.LocalPlayer.ID, planetInfo.ID);

            if (colonyIntelForPlanet != null)
            {
                PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(colonyIntelForPlanet.OwningPlayerID);
                color.X = playerInfo.PrimaryColor.X * (float)byte.MaxValue;
                color.Y = playerInfo.PrimaryColor.Y * (float)byte.MaxValue;
                color.Z = playerInfo.PrimaryColor.Z * (float)byte.MaxValue;
                color.W = (float)byte.MaxValue;
            }
            game.UI.AddItem(panelName, string.Empty, orbital.ID, string.Empty);
            string itemGlobalId = game.UI.GetItemGlobalID(panelName, string.Empty, orbital.ID, string.Empty);
            string panelId      = game.UI.Path(itemGlobalId, "expand_button");

            game.UI.SetVisible(panelId, false);
            bool flag = game.GameDatabase.CanColonizePlanet(game.LocalPlayer.ID, planetInfo.ID, game.GameDatabase.GetStratModifier <int>(StratModifiers.MaxColonizableHazard, game.LocalPlayer.ID)) || colonyIntelForPlanet != null && colonyIntelForPlanet.PlayerID == game.LocalPlayer.ID;

            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.idle.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.idle.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.mouse_over.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_idle.mouse_over.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.idle.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.idle.h_bad"), (!flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.mouse_over.h_good"), (flag ? 1 : 0) != 0);
            game.UI.SetVisible(game.UI.Path(itemGlobalId, "header_sel.mouse_over.h_bad"), (!flag ? 1 : 0) != 0);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.idle", orbital.Name, color, false);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_idle.mouse_over", orbital.Name, color, false);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.idle", orbital.Name, color, true);
            FleetUI.SyncSelectablePlanetListControl(game, itemGlobalId, "header_sel.mouse_over", orbital.Name, color, true);
            game.UI.SetPropertyString(game.UI.Path(itemGlobalId, "planetItemPlanetType"), "text", propertyValue);
            game.UI.AutoSize(game.UI.Path(itemGlobalId, "expanded"));
        }
コード例 #17
0
ファイル: ColonizeDialog.cs プロジェクト: zerk-js/SOTSII-SOS
        public override void Initialize()
        {
            this._sky        = new Sky(this._app, SkyUsage.StarMap, 0);
            this._crits      = new GameObjectSet(this._app);
            this._planetView = this._crits.Add <PlanetView>();
            this._crits.Add((IGameObject)this._sky);
            OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this._planetID);
            StarSystemInfo    starSystemInfo    = this._app.GameDatabase.GetStarSystemInfo(orbitalObjectInfo.StarSystemID);

            this._app.UI.SetText("gameColonyName", orbitalObjectInfo.Name);
            this._enteredColonyName = orbitalObjectInfo.Name;
            this._app.UI.SetVisible(this._app.UI.Path(this.ID, "btnAbandon"), false);
            this._app.UI.SetText(this._app.UI.Path("colonyCreateTitle"), (this._homeworld ? App.Localize("@UI_STARMAP_HOMEWORLD_ESTABLISHED") : App.Localize("@UI_STARMAP_COLONY_ESTABLISHED")) + " - " + starSystemInfo.Name);
            this._cameraReduced                 = new OrbitCameraController(this._app);
            this._cameraReduced.MinDistance     = 2.5f;
            this._cameraReduced.MaxDistance     = 100f;
            this._cameraReduced.DesiredDistance = 50f;
            this._cameraReduced.DesiredYaw      = MathHelper.DegreesToRadians(45f);
            this._cameraReduced.DesiredPitch    = -MathHelper.DegreesToRadians(25f);
            this._cameraReduced.SnapToDesiredPosition();
            this._starmapReduced = new StarMap(this._app, this._app.Game, this._sky);
            this._starmapReduced.Initialize(this._crits);
            this._starmapReduced.SetCamera(this._cameraReduced);
            this._starmapReduced.FocusEnabled = false;
            this._starmapReduced.SetFocus((IGameObject)this._starmapReduced.Systems.Reverse[starSystemInfo.ID]);
            this._starmapReduced.Select((IGameObject)this._starmapReduced.Systems.Reverse[starSystemInfo.ID]);
            this._starmapReduced.SelectEnabled = false;
            this._starmapReduced.PostSetProp("MissionTarget", (object)this._starmapReduced.Systems.Reverse[starSystemInfo.ID].ObjectID, (object)true);
            this._starmapReduced.PostSetProp("CullCenter", this._app.GameDatabase.GetStarSystemInfo(starSystemInfo.ID).Origin);
            this._starmapReduced.PostSetProp("CullRadius", 15f);
            this._app.UI.Send((object)"SetGameObject", (object)this._app.UI.Path(this.ID, "gameStarMapViewport"), (object)this._starmapReduced.ObjectID);
            this.CachePlanet(this._app.GameDatabase.GetPlanetInfo(this._planetID));
            this._planetView.PostSetProp("Planet", this._cachedPlanet != null ? this._cachedPlanet.ObjectID : 0);
            this._app.UI.Send((object)"SetGameObject", (object)this._app.UI.Path(this.ID, "system_details.Planet_panel"), (object)this._planetView.ObjectID);
            StarSystemMapUI.Sync(this._app, orbitalObjectInfo.StarSystemID, this._app.UI.Path(this.ID, "system_map"), true);
            StarSystemUI.SyncSystemDetailsWidget(this._app, "colony_event_dialog.system_details", orbitalObjectInfo.StarSystemID, true, true);
            StarSystemUI.SyncPlanetDetailsControl(this._app.Game, this._app.UI.Path(this.ID, "system_details"), this._planetID);
            StarSystemUI.SyncColonyDetailsWidget(this._app.Game, this._app.UI.Path(this.ID, "colony_details"), orbitalObjectInfo.ID, "");
            this._app.UI.SetVisible(this._app.UI.Path(this.ID, "system_map"), true);
            this._app.UI.SetVisible(this._app.UI.Path(this.ID, "gameStarMapViewport"), false);
            this._app.UI.AddItem(this._app.UI.Path(this.ID, "gameViewportList"), "", 0, App.Localize("@SYSTEMDETAILS_SYS_MAP"));
            this._app.UI.AddItem(this._app.UI.Path(this.ID, "gameViewportList"), "", 1, App.Localize("@SYSTEMDETAILS_STAR_MAP"));
            this._app.UI.SetSelection(this._app.UI.Path(this.ID, "gameViewportList"), 0);
            this._crits.Activate();
        }
コード例 #18
0
        public override void Initialize()
        {
            this._sky        = new Sky(this._app, SkyUsage.StarMap, 0);
            this._crits      = new GameObjectSet(this._app);
            this._planetView = this._crits.Add <PlanetView>();
            this._crits.Add((IGameObject)this._sky);
            StationInfo       stationInfo        = this._app.GameDatabase.GetStationInfo(this._stationID);
            OrbitalObjectInfo orbitalObjectInfo1 = this._app.GameDatabase.GetOrbitalObjectInfo(this._stationID);
            OrbitalObjectInfo orbitalObjectInfo2 = this._app.GameDatabase.GetOrbitalObjectInfo(orbitalObjectInfo1.ParentID.Value);

            this._app.UI.SetText(this._app.UI.Path(this.ID, "station_class"), string.Format(App.Localize("@STATION_LEVEL"), (object)stationInfo.DesignInfo.StationLevel.ToString(), (object)stationInfo.DesignInfo.StationType.ToString()));
            this._app.UI.SetText(this._app.UI.Path(this.ID, "upkeep_cost"), string.Format(App.Localize("@STATION_UPKEEP_COST"), (object)GameSession.CalculateStationUpkeepCost(this._app.GameDatabase, this._app.AssetDatabase, stationInfo).ToString()));
            if (stationInfo.DesignInfo.StationType == StationType.NAVAL)
            {
                this._app.UI.SetText(this._app.UI.Path(this.ID, "naval_capacity"), string.Format(App.Localize("@STATION_FLEET_CAPACITY"), (object)this._app.GameDatabase.GetSystemSupportedCruiserEquivalent(this._app.Game, orbitalObjectInfo2.StarSystemID, this._app.LocalPlayer.ID).ToString()));
            }
            else
            {
                this._app.UI.SetVisible(this._app.UI.Path(this.ID, "naval_capacity"), false);
            }
            StarSystemInfo starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(orbitalObjectInfo2.StarSystemID);

            this._app.UI.SetText("gameStationName", orbitalObjectInfo1.Name);
            this._enteredStationName = orbitalObjectInfo2.Name;
            this._app.UI.SetText(this._app.UI.Path(this.ID, "system_name"), string.Format(App.Localize("@STATION_BUILT"), (object)starSystemInfo.Name).ToUpperInvariant());
            this._cameraReduced                 = new OrbitCameraController(this._app);
            this._cameraReduced.MinDistance     = 1002.5f;
            this._cameraReduced.MaxDistance     = 10000f;
            this._cameraReduced.DesiredDistance = 2000f;
            this._cameraReduced.DesiredYaw      = MathHelper.DegreesToRadians(45f);
            this._cameraReduced.DesiredPitch    = -MathHelper.DegreesToRadians(25f);
            this._cameraReduced.SnapToDesiredPosition();
            this._starmapReduced = new StarMap(this._app, this._app.Game, this._sky);
            this._starmapReduced.Initialize(this._crits);
            this._starmapReduced.SetCamera(this._cameraReduced);
            this._starmapReduced.FocusEnabled = false;
            this._starmapReduced.PostSetProp("Selected", this._starmapReduced.Systems.Reverse[starSystemInfo.ID].ObjectID);
            this._starmapReduced.PostSetProp("CullCenter", this._app.GameDatabase.GetStarSystemInfo(starSystemInfo.ID).Origin);
            this._starmapReduced.PostSetProp("CullRadius", 15f);
            DesignInfo di = DesignLab.CreateStationDesignInfo(this._app.AssetDatabase, this._app.GameDatabase, this._app.LocalPlayer.ID, stationInfo.DesignInfo.StationType, stationInfo.DesignInfo.StationLevel, false);

            this._stationModel = new StarSystemDummyOccupant(this._app, this._app.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == di.DesignSections[0].FilePath)).ModelName, stationInfo.DesignInfo.StationType);
            this._stationModel.PostSetScale(1f / 500f);
            this._stationModel.PostSetPosition(this._trans);
        }
コード例 #19
0
ファイル: ColonizeDialog.cs プロジェクト: zerk-js/SOTSII-SOS
        private void Confirm()
        {
            OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this._planetID);

            if (orbitalObjectInfo != null)
            {
                orbitalObjectInfo.Name = this._enteredColonyName;
                this._app.GameDatabase.UpdateOrbitalObjectInfo(orbitalObjectInfo);
            }
            if (!string.IsNullOrWhiteSpace(this._enteredColonyName) && this._enteredColonyName.Count <char>() > 0)
            {
                this._app.UI.CloseDialog((Dialog)this, true);
            }
            else
            {
                this._app.UI.CreateDialog((Dialog) new GenericTextDialog(this._app, App.Localize("@INVALID_COLONY_NAME"), App.Localize("@INVALID_COLONY_NAME_TEXT"), "dialogGenericMessage"), null);
            }
        }
コード例 #20
0
        public static Matrix GetSpawnTransform(App app, int systemId)
        {
            bool              flag = false;
            float             num1 = 0.0f;
            float             num2 = 0.0f;
            OrbitalObjectInfo orbitalObjectInfo1 = (OrbitalObjectInfo)null;
            Vector3           vector3            = Vector3.Zero;

            foreach (OrbitalObjectInfo orbitalObjectInfo2 in app.GameDatabase.GetStarSystemOrbitalObjectInfos(systemId))
            {
                ColonyInfo colonyInfoForPlanet = app.GameDatabase.GetColonyInfoForPlanet(orbitalObjectInfo2.ID);
                if (!flag || colonyInfoForPlanet != null)
                {
                    PlanetInfo planetInfo = app.GameDatabase.GetPlanetInfo(orbitalObjectInfo2.ID);
                    float      num3       = 1000f;
                    if (planetInfo != null)
                    {
                        num3 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size);
                    }
                    Vector3 position = app.GameDatabase.GetOrbitalTransform(orbitalObjectInfo2.ID).Position;
                    float   num4     = position.Length + num3;
                    if ((double)num4 > (double)num1 || !flag && colonyInfoForPlanet != null)
                    {
                        orbitalObjectInfo1 = orbitalObjectInfo2;
                        num1    = num4;
                        flag    = colonyInfoForPlanet != null;
                        vector3 = position;
                        num2    = num3 + 10000f;
                        if (flag)
                        {
                            break;
                        }
                    }
                }
            }
            if (orbitalObjectInfo1 == null)
            {
                return(Matrix.Identity);
            }
            Vector3 forward = -vector3;
            double  num5    = (double)forward.Normalize();

            return(Matrix.CreateWorld(vector3 - forward * num2, forward, Vector3.UnitY));
        }
コード例 #21
0
 protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
 {
     if (msgType == "button_clicked")
     {
         if (panelName == "okButton")
             this._app.UI.CloseDialog((Dialog)this, true);
         if (!(panelName == "detailbutton"))
             ;
     }
     else if (msgType == "list_sel_changed")
     {
         if (panelName == "gamePlanetList")
         {
             int orbitalObjectID = int.Parse(msgParams[0]);
             OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(orbitalObjectID);
             bool flag = false;
             if (orbitalObjectInfo != null && orbitalObjectInfo.ParentID.HasValue)
             {
                 PlanetInfo planetInfo = this._app.GameDatabase.GetPlanetInfo(orbitalObjectInfo.ParentID.Value);
                 if (planetInfo != null)
                 {
                     this._app.UI.Send((object)"SetSel", (object)this._app.UI.Path(this.ID, "system_map"), (object)1, (object)planetInfo.ID);
                     flag = true;
                 }
             }
             if (flag)
                 return;
             this._app.UI.Send((object)"SetSel", (object)this._app.UI.Path(this.ID, "system_map"), (object)1, (object)orbitalObjectID);
         }
         else
         {
             if (!(panelName == "gameViewportList"))
                 return;
             this.SetColonyViewMode(int.Parse(msgParams[0]));
         }
     }
     else
     {
         if (!(msgType == "mapicon_clicked"))
             return;
         this._app.UI.Send((object)"SetSel", (object)this._app.UI.Path(this.ID, "planetListWidget"), (object)int.Parse(msgParams[0]));
     }
 }
コード例 #22
0
        protected override void OnEnter()
        {
            base.OnEnter();
            this.UI.SetVisible("overlayStationList", false);
            this.UI.SetVisible("stationTypes", true);
            EmpireBarUI.SyncTitleFrame(this.App);
            this.App.UI.ClearItems("station_list");
            List <StationInfo> upgradableStations = this.App.Game.GetUpgradableStations(this.App.GameDatabase.GetStationForSystemAndPlayer(this.TargetSystem, this.App.LocalPlayer.ID).ToList <StationInfo>());

            foreach (StationInfo stationInfo in upgradableStations)
            {
                this.App.UI.AddItem("station_list", string.Empty, stationInfo.OrbitalObjectID, string.Empty);
                StationUI.SyncStationDetailsWidget(this.App.Game, this.App.UI.GetItemGlobalID("station_list", string.Empty, stationInfo.OrbitalObjectID, string.Empty), stationInfo.OrbitalObjectID, true);
            }
            OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this.StartSelect);

            this.SelectedStation = orbitalObjectInfo == null || orbitalObjectInfo.StarSystemID != this.TargetSystem ? upgradableStations[0].OrbitalObjectID : this.StartSelect;
            this.App.UI.SetSelection("station_list", this.SelectedStation);
        }
コード例 #23
0
 protected void SetSelectedObject(int orbitalId, string trigger)
 {
     this.SelectedObject = orbitalId;
     if (trigger != "gameSystemContentsList")
     {
         if (this.SelectedObject == 0)
         {
             this.App.UI.ClearSelection("gameSystemContentsList");
         }
         else if (this.SelectedObject == StarSystemDetailsUI.StarItemID)
         {
             this.App.UI.SetSelection("gameSystemContentsList", this.SelectedObject);
         }
         else
         {
             OrbitalObjectInfo orbitalObjectInfo = this.App.GameDatabase.GetOrbitalObjectInfo(this.SelectedObject);
             if (!orbitalObjectInfo.ParentID.HasValue)
             {
                 this.App.UI.SetSelection("gameSystemContentsList", this.SelectedObject);
             }
             else
             {
                 IGameObject planetViewObject;
                 this._starsystem.PlanetMap.Reverse.TryGetValue(orbitalObjectInfo.ParentID.Value, out planetViewObject);
                 StarSystemUI.SyncPlanetDetailsWidget(this.App.Game, "planetDetailsWidget", this._currentSystem, orbitalId, planetViewObject, this._planetView);
                 if (planetViewObject != null)
                 {
                     this.App.UI.SetSelection("gameSystemContentsList", orbitalObjectInfo.ParentID.Value);
                 }
                 else
                 {
                     this.App.UI.ClearSelection("gameSystemContentsList");
                 }
             }
         }
         this.Focus(this.SelectedObject);
     }
     StarSystemUI.SyncPlanetDetailsWidget(this.App.Game, "planetDetailsWidget", this.CurrentSystem, this.SelectedObject, this.GetPlanetViewGameObject(this.CurrentSystem, this.SelectedObject), this._planetView);
     StarSystemUI.SyncColonyDetailsWidget(this.App.Game, "colonyDetailsWidget", this.SelectedObject, "");
 }
コード例 #24
0
ファイル: StarSystemMapUI.cs プロジェクト: zerk-js/SOTSII-SOS
 private static bool HasMoons(
     PlanetInfo planetInfo,
     IEnumerable <OrbitalObjectInfo> orbitalObjectInfos,
     IEnumerable <PlanetInfo> planetInfos)
 {
     foreach (OrbitalObjectInfo orbitalObjectInfo in orbitalObjectInfos.Where <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x =>
     {
         if (x.ParentID.HasValue)
         {
             return(x.ParentID.Value == planetInfo.ID);
         }
         return(false);
     })))
     {
         OrbitalObjectInfo moon = orbitalObjectInfo;
         if (planetInfos.Any <PlanetInfo>((Func <PlanetInfo, bool>)(x => x.ID == moon.ID)))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #25
0
ファイル: StarSystemMapUI.cs プロジェクト: zerk-js/SOTSII-SOS
 private static bool HasTerrestrialMoons(
     PlanetInfo planetInfo,
     IEnumerable <OrbitalObjectInfo> orbitalObjectInfos,
     IEnumerable <PlanetInfo> planetInfos)
 {
     foreach (OrbitalObjectInfo orbitalObjectInfo in orbitalObjectInfos.Where <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x =>
     {
         if (x.ParentID.HasValue)
         {
             return(x.ParentID.Value == planetInfo.ID);
         }
         return(false);
     })))
     {
         OrbitalObjectInfo moon        = orbitalObjectInfo;
         PlanetInfo        planetInfo1 = planetInfos.FirstOrDefault <PlanetInfo>((Func <PlanetInfo, bool>)(x => x.ID == moon.ID));
         if (planetInfo1 != null && StarSystemMapUI.IsTerrestrialPlanet(planetInfo1))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #26
0
        public static Matrix GetBaseEnemyFleetTrans(
            App app,
            int systemId,
            OrbitalObjectInfo[] objects)
        {
            if (((IEnumerable <OrbitalObjectInfo>)objects).Count <OrbitalObjectInfo>() == 0)
            {
                return(Matrix.Identity);
            }
            GardenerInfo gardenerInfo = app.GameDatabase.GetGardenerInfos().ToList <GardenerInfo>().FirstOrDefault <GardenerInfo>((Func <GardenerInfo, bool>)(x => x.SystemId == systemId));
            float        num1         = 0.0f;
            Matrix       matrix       = Matrix.Identity;

            foreach (OrbitalObjectInfo orbitalObjectInfo in objects)
            {
                OrbitalObjectInfo oo         = orbitalObjectInfo;
                PlanetInfo        planetInfo = app.GameDatabase.GetPlanetInfo(oo.ID);
                if (planetInfo != null && !(planetInfo.Type == "barren") && !(planetInfo.Type == "gaseous"))
                {
                    if (gardenerInfo == null || (gardenerInfo.ShipOrbitMap.Where <KeyValuePair <int, int> >((Func <KeyValuePair <int, int>, bool>)(x => x.Value == oo.ID)).Count <KeyValuePair <int, int> >() != 0 || (double)num1 <= 0.0))
                    {
                        Vector3 position      = app.GameDatabase.GetOrbitalTransform(planetInfo.ID).Position;
                        float   lengthSquared = position.LengthSquared;
                        if ((double)lengthSquared > (double)num1)
                        {
                            num1 = lengthSquared;
                            Vector3 forward = position;
                            double  num2    = (double)forward.Normalize();
                            matrix = Matrix.CreateWorld(Vector3.Zero, forward, Vector3.UnitY);
                            float num3 = StarSystemVars.Instance.SizeToRadius(planetInfo.Size) + 3000f;
                            matrix.Position = position - matrix.Forward * num3;
                        }
                    }
                }
            }
            return(matrix);
        }
コード例 #27
0
ファイル: AsteroidMonitor.cs プロジェクト: zerk-js/SOTSII-SOS
        public void AddInstance(GameDatabase gamedb, AssetDatabase assetdb, int SystemId, int OrbitId)
        {
            OrbitalObjectInfo orbitalObjectInfo = gamedb.GetOrbitalObjectInfo(OrbitId);

            gamedb.RemoveOrbitalObject(orbitalObjectInfo.ID);
            int orbitalId = gamedb.InsertAsteroidBelt(orbitalObjectInfo.ParentID, orbitalObjectInfo.StarSystemID, orbitalObjectInfo.OrbitalPath, "Asteroid Monitor Belt", App.GetSafeRandom().Next());

            gamedb.InsertAsteroidMonitorInfo(new AsteroidMonitorInfo()
            {
                SystemId     = SystemId,
                OrbitalId    = orbitalId,
                IsAggressive = true
            });
            Matrix orbitalTransform = gamedb.GetOrbitalTransform(orbitalId);
            int    fleetID          = gamedb.InsertFleet(this.PlayerId, 0, SystemId, SystemId, "Asteroid Monitor", FleetType.FL_NORMAL);
            int    shipId1          = gamedb.InsertShip(fleetID, this._monitorCommandDesignId, null, (ShipParams)0, new int?(), 0);

            this.SetMonitorPosition(gamedb, shipId1, 0, assetdb.GlobalAsteroidMonitorData.NumMonitors, true, orbitalTransform);
            for (int shipIndex = 0; shipIndex < assetdb.GlobalAsteroidMonitorData.NumMonitors; ++shipIndex)
            {
                int shipId2 = gamedb.InsertShip(fleetID, this._monitorDesignId, null, (ShipParams)0, new int?(), 0);
                this.SetMonitorPosition(gamedb, shipId2, shipIndex, assetdb.GlobalAsteroidMonitorData.NumMonitors, false, orbitalTransform);
            }
        }
コード例 #28
0
        public void SyncEnemySide(int playerid)
        {
            CombatData       combat  = this._app.Game.CombatData.GetCombat(this._app.GameDatabase, this._combatID, this._systemID, this._turn);
            PlayerCombatData player1 = combat.GetPlayer(this._app.LocalPlayer.ID);

            if (player1 == null)
            {
                this._app.UI.CloseDialog((Dialog)this, true);
            }
            else
            {
                foreach (PlanetWidget sideplanetWidget in this._EnemySideplanetWidgets)
                {
                    sideplanetWidget.Terminate();
                }
                this._EnemySideplanetWidgets.Clear();
                IEnumerable <PlayerInfo> playerInfos    = this._app.GameDatabase.GetPlayerInfos();
                StarSystemInfo           starSystemInfo = this._app.GameDatabase.GetStarSystemInfo(combat.SystemID);
                App.Localize("@ADMIRAL_LOCATION_DEEP_SPACE");
                if (starSystemInfo != (StarSystemInfo)null)
                {
                    string name = starSystemInfo.Name;
                }
                int    val2_1 = 0;
                int    val2_2 = 0;
                float  val2_3 = 0.0f;
                float  val2_4 = 0.0f;
                double num1   = 0.0;
                double num2   = 0.0;
                float  num3   = 0.0f;
                int    num4   = 0;
                Dictionary <int, float> dictionary1 = new Dictionary <int, float>();
                PlayerInfo       player             = playerInfos.FirstOrDefault <PlayerInfo>((Func <PlayerInfo, bool>)(x => x.ID == playerid));
                PlayerCombatData player2            = combat.GetPlayer(player.ID);
                if (player2 != null)
                {
                    this._app.GameDatabase.GetDiplomacyInfo(player1.PlayerID, player.ID);
                    PlayerSetup playerSetup    = this._app.GameSetup.Players.FirstOrDefault <PlayerSetup>((Func <PlayerSetup, bool>)(x => x.databaseId == player.ID));
                    string      propertyValue1 = playerSetup == null || !(playerSetup.Name != "") || playerSetup.AI ? player.Name : playerSetup.Name;
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "name"), "text", propertyValue1);
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "playeravatar"), "texture", player.AvatarAssetPath);
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "alliesAvatars", "badge"), "texture", player.BadgeAssetPath);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "primaryColor"), "color", player.PrimaryColor);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "alliesAvatars", "secondaryColor"), "color", player.SecondaryColor);
                    this._app.UI.SetPropertyColorNormalized(this._app.UI.Path("enemySide", "empireColor"), "color", player.PrimaryColor);
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerName"), "text", propertyValue1);
                    List <ShipData>   shipData1   = player2.ShipData;
                    List <WeaponData> weaponData1 = player2.WeaponData;
                    List <PlanetData> planetData1 = player2.PlanetData;
                    int   count  = shipData1.Count;
                    int   val1_1 = 0;
                    float val1_2 = 0.0f;
                    float val1_3 = 0.0f;
                    Dictionary <int, string> dictionary2 = new Dictionary <int, string>();
                    int userItemId1 = 0;
                    this._app.UI.ClearItems(this._app.UI.Path("enemySide", "fleetDamage"));
                    foreach (ShipData shipData2 in shipData1)
                    {
                        val1_1 += shipData2.killCount;
                        val1_2 += shipData2.damageDealt;
                        val1_3 += shipData2.damageReceived;
                        num4   += shipData2.destroyed ? 1 : 0;
                        DesignInfo designInfo = this._app.GameDatabase.GetDesignInfo(shipData2.designID);
                        if (designInfo != null)
                        {
                            RealShipClasses?realShipClass = designInfo.GetRealShipClass();
                            if ((realShipClass.GetValueOrDefault() != RealShipClasses.AssaultShuttle ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0)
                            {
                                realShipClass = designInfo.GetRealShipClass();
                                if ((realShipClass.GetValueOrDefault() != RealShipClasses.Drone ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0)
                                {
                                    realShipClass = designInfo.GetRealShipClass();
                                    if ((realShipClass.GetValueOrDefault() != RealShipClasses.BoardingPod ? 1 : (!realShipClass.HasValue ? 1 : 0)) != 0 && this._app.Game.ScriptModules.MeteorShower.PlayerID != player.ID)
                                    {
                                        string propertyValue2 = "";
                                        if (shipData2.destroyed)
                                        {
                                            propertyValue2 = designInfo.Name + " class ship has been destroyed.";
                                        }
                                        else if ((double)shipData2.damageReceived > 0.0)
                                        {
                                            propertyValue2 = designInfo.Name + " class ship has been damaged.";
                                        }
                                        if (propertyValue2 != "")
                                        {
                                            this._app.UI.AddItem(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, "");
                                            this._app.UI.SetPropertyString(this._app.UI.Path(this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "fleetDamage"), "", userItemId1, ""), "name"), "text", propertyValue2);
                                            ++userItemId1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    this._app.UI.SetPropertyString(this._app.UI.Path("enemySide", "playerData", "playerScore"), "text", (shipData1.Count - num4).ToString() + "/" + shipData1.Count.ToString());
                    this._app.UI.SetSliderRange(this._app.UI.Path("enemySide", "playerData", "assets"), 0, shipData1.Count);
                    this._app.UI.SetSliderValue(this._app.UI.Path("enemySide", "playerData", "assets"), shipData1.Count - num4);
                    foreach (WeaponData weaponData2 in weaponData1)
                    {
                        if (!dictionary1.ContainsKey(weaponData2.weaponID))
                        {
                            dictionary1.Add(weaponData2.weaponID, 0.0f);
                        }
                        Dictionary <int, float> dictionary3;
                        int weaponId;
                        (dictionary3 = dictionary1)[weaponId = weaponData2.weaponID] = dictionary3[weaponId] + weaponData2.damageDealt;
                    }
                    this._app.UI.ClearItems(this._app.UI.Path("enemySide", "weaponDamage"));
                    int    num5        = 0;
                    int    userItemId2 = 0;
                    string str         = null;
                    foreach (int key in dictionary1.Keys)
                    {
                        int weapon = key;
                        if (num5 == 5 || str == null)
                        {
                            this._app.UI.AddItem(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, "");
                            str = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "weaponDamage"), "", userItemId2, "");
                            ++userItemId2;
                            num5 = 0;
                            for (int index = 0; index < 5; ++index)
                            {
                                this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + index.ToString()), false);
                            }
                        }
                        this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "damageDealt"), "text", dictionary1[weapon].ToString("N0"));
                        LogicalWeapon logicalWeapon  = this._app.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.UniqueWeaponID == weapon));
                        string        iconSpriteName = logicalWeapon.IconSpriteName;
                        this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString(), "weaponIcon"), "sprite", iconSpriteName);
                        this._app.UI.SetPropertyString(this._app.UI.Path(str, "weapon" + num5.ToString()), "tooltip", logicalWeapon.WeaponName);
                        this._app.UI.SetVisible(this._app.UI.Path(str, "weapon" + num5.ToString()), true);
                        ++num5;
                    }
                    this._app.UI.ClearItems(this._app.UI.Path("enemySide", "planetDamage"));
                    foreach (PlanetData planetData2 in planetData1)
                    {
                        ColonyInfo colonyInfoForPlanet = this._app.GameDatabase.GetColonyInfoForPlanet(planetData2.orbitalObjectID);
                        if (colonyInfoForPlanet != null)
                        {
                            num1 += planetData2.imperialDamage;
                            num2 += planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage));
                            num3 += planetData2.infrastructureDamage;
                            this._app.UI.AddItem(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, "");
                            string            itemGlobalId       = this._app.UI.GetItemGlobalID(this._app.UI.Path("enemySide", "planetDamage"), "", colonyInfoForPlanet.ID, "");
                            OrbitalObjectInfo orbitalObjectInfo  = this._app.GameDatabase.GetOrbitalObjectInfo(colonyInfoForPlanet.OrbitalObjectID);
                            PlanetInfo        planetInfo         = this._app.GameDatabase.GetPlanetInfo(colonyInfoForPlanet.OrbitalObjectID);
                            Faction           faction            = this._app.AssetDatabase.GetFaction(this._app.GameDatabase.GetPlayerFactionID(colonyInfoForPlanet.PlayerID));
                            double            civilianPopulation = this._app.GameDatabase.GetCivilianPopulation(colonyInfoForPlanet.OrbitalObjectID, faction.ID, faction.HasSlaves());
                            float             num6 = planetInfo != null ? planetInfo.Infrastructure : 0.0f;
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "planetName"), "text", orbitalObjectInfo != null ? orbitalObjectInfo.Name : "?");
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "civslbl"), "text", civilianPopulation.ToString("N0"));
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "implbl"), "text", colonyInfoForPlanet.ImperialPop.ToString("N0"));
                            this._app.UI.SetPropertyString(this._app.UI.Path(itemGlobalId, "infralbl"), "text", num6.ToString());
                            double num7 = civilianPopulation + planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage));
                            this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "civAmount"), 0, (int)num7);
                            this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "civAmount"), (int)(num7 - planetData2.civilianDamage.Sum <PopulationData>((Func <PopulationData, double>)(x => x.damage))));
                            double num8 = colonyInfoForPlanet.ImperialPop + planetData2.imperialDamage;
                            this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "impAmount"), 0, (int)num8);
                            this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "impAmount"), (int)(num8 - planetData2.imperialDamage));
                            float num9 = num6 + planetData2.infrastructureDamage;
                            this._app.UI.SetSliderRange(this._app.UI.Path(itemGlobalId, "infraAmount"), 0, (int)(100.0 * (double)num9));
                            this._app.UI.SetSliderValue(this._app.UI.Path(itemGlobalId, "infraAmount"), (int)(100.0 * ((double)num9 - (double)planetData2.infrastructureDamage)));
                            if (planetInfo != null)
                            {
                                this._EnemySideplanetWidgets.Add(new PlanetWidget(this._app, itemGlobalId));
                                this._EnemySideplanetWidgets.Last <PlanetWidget>().Sync(planetInfo.ID, false, false);
                            }
                        }
                    }
                    Math.Max(count, val2_1);
                    Math.Max(val1_1, val2_2);
                    Math.Max(val1_2, val2_3);
                    Math.Max(val1_3, val2_4);
                }
                this._app.UI.AutoSizeContents(this._app.UI.Path(this.ID, "enemySide"));
            }
        }
コード例 #29
0
 protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
 {
     if (msgType == "button_clicked" && panelName == "okButton")
     {
         this._app.UI.CloseDialog((Dialog)this, true);
     }
     if (msgType == "mouse_enter")
     {
         string[] strArray                  = panelName.Split('|');
         int      orbitalObjectID           = int.Parse(strArray[0]);
         ModuleEnums.StationModuleType type = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         StationInfo stationInfo            = this.App.GameDatabase.GetStationInfo(orbitalObjectID);
         IEnumerable <StationModules.StationModule> source = ((IEnumerable <StationModules.StationModule>)StationModules.Modules).Where <StationModules.StationModule>((Func <StationModules.StationModule, bool>)(x => x.SMType == type));
         if (source.Count <StationModules.StationModule>() > 0)
         {
             string upper = stationInfo.DesignInfo.StationType.ToDisplayText(this.App.GameDatabase.GetFactionName(this.App.GameDatabase.GetPlayerFactionID(stationInfo.PlayerID))).ToUpper();
             this.App.UI.SetPropertyString("moduleDescriptionText", "text", App.Localize(string.Format(source.ElementAt <StationModules.StationModule>(0).Description, (object)upper)));
         }
     }
     else
     {
         int num1 = msgType == "mouse_leave" ? 1 : 0;
     }
     if (msgType == "list_sel_changed")
     {
         if (panelName == "station_list")
         {
             this.PopulateModulesList(this.App.GameDatabase.GetStationInfo(int.Parse(msgParams[0])));
         }
         else if (panelName == "filterDropdown")
         {
             this._currentFilterMode = (StationType)int.Parse(msgParams[0]);
             this.SyncStationList();
         }
     }
     if (!(msgType == "button_clicked"))
     {
         return;
     }
     if (panelName == "upgradeButton")
     {
         OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this._selectedStation.OrbitalObjectID);
         this._starmap.GetUpgradeMissionOverlay().StartSelect = orbitalObjectInfo.ID;
         this._app.UI.CloseDialog((Dialog)this, true);
         this._starmap.ShowUpgradeMissionOverlay(orbitalObjectInfo.StarSystemID);
     }
     else if (panelName.StartsWith("modque"))
     {
         ModuleEnums.StationModuleType moduleID            = (ModuleEnums.StationModuleType) int.Parse(panelName.Split('|')[1]);
         List <LogicalModuleMount>     stationModuleMounts = this.App.Game.GetAvailableStationModuleMounts(this.App.GameDatabase.GetStationInfo(this._selectedStation.OrbitalObjectID));
         List <DesignModuleInfo>       queuedModules       = this.App.GameDatabase.GetQueuedStationModules(this._selectedStation.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
         stationModuleMounts.Where <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => queuedModules.Any <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(y => y.MountNodeName == x.NodeName)))).ToList <LogicalModuleMount>();
         DesignModuleInfo designModuleInfo = queuedModules.FirstOrDefault <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x =>
         {
             ModuleEnums.StationModuleType?stationModuleType1 = x.StationModuleType;
             ModuleEnums.StationModuleType stationModuleType2 = moduleID;
             if (stationModuleType1.GetValueOrDefault() == stationModuleType2)
             {
                 return(stationModuleType1.HasValue);
             }
             return(false);
         }));
         if (designModuleInfo != null)
         {
             this.App.GameDatabase.RemoveQueuedStationModule(designModuleInfo.ID);
         }
         this.SyncModuleItems();
         this.SyncBuildQueue();
     }
     else if (panelName == "filterDiplomatic")
     {
         StationManagerDialog.StationViewFilter[StationType.DIPLOMATIC] = !StationManagerDialog.StationViewFilter[StationType.DIPLOMATIC];
         this.SyncStationList();
     }
     else if (panelName == "filterScience")
     {
         StationManagerDialog.StationViewFilter[StationType.SCIENCE] = !StationManagerDialog.StationViewFilter[StationType.SCIENCE];
         this.SyncStationList();
     }
     else if (panelName == "filterCivilian")
     {
         StationManagerDialog.StationViewFilter[StationType.CIVILIAN] = !StationManagerDialog.StationViewFilter[StationType.CIVILIAN];
         this.SyncStationList();
     }
     else if (panelName == "filterNaval")
     {
         StationManagerDialog.StationViewFilter[StationType.NAVAL] = !StationManagerDialog.StationViewFilter[StationType.NAVAL];
         this.SyncStationList();
     }
     else if (panelName == "filterMining")
     {
         StationManagerDialog.StationViewFilter[StationType.MINING] = !StationManagerDialog.StationViewFilter[StationType.MINING];
         this.SyncStationList();
     }
     else if (panelName == "filterSDS")
     {
         StationManagerDialog.StationViewFilter[StationType.DEFENCE] = !StationManagerDialog.StationViewFilter[StationType.DEFENCE];
         this.SyncStationList();
     }
     else if (panelName == "filterGate")
     {
         StationManagerDialog.StationViewFilter[StationType.GATE] = !StationManagerDialog.StationViewFilter[StationType.GATE];
         this.SyncStationList();
     }
     else if (panelName == "confirmOrderButton")
     {
         StationInfo stationInfo = this.App.GameDatabase.GetStationInfo(this._selectedStation.OrbitalObjectID);
         StationModuleQueue.UpdateStationMapsForFaction(this.App.LocalPlayer.Faction.Name);
         StationModuleQueue.ConfirmStationQueuedItems(this.App.Game, stationInfo, this._queuedItemMap);
         this.SyncModuleItems();
         this.SyncBuildQueue();
     }
     else if (panelName.EndsWith("module_up"))
     {
         string[] strArray                  = panelName.Split('|');
         int      orbitalObjectID           = int.Parse(strArray[0]);
         ModuleEnums.StationModuleType type = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         StationInfo stationInfo            = this.App.GameDatabase.GetStationInfo(orbitalObjectID);
         this.App.GameDatabase.GetModuleID(this.App.AssetDatabase.GetStationModuleAsset(type, this.App.Game.LocalPlayer.Faction.Name), this.App.Game.LocalPlayer.ID);
         List <LogicalModuleMount> stationModuleMounts = this.App.Game.GetAvailableStationModuleMounts(stationInfo);
         List <DesignModuleInfo>   list = this.App.GameDatabase.GetQueuedStationModules(this._selectedStation.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
         list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x =>
         {
             ModuleEnums.StationModuleType?stationModuleType1 = x.StationModuleType;
             ModuleEnums.StationModuleType stationModuleType2 = type;
             if (stationModuleType1.GetValueOrDefault() == stationModuleType2)
             {
                 return(stationModuleType1.HasValue);
             }
             return(false);
         })).ToList <DesignModuleInfo>();
         int num2 = list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.StationModuleType.Value] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Count <DesignModuleInfo>();
         if (this._queuedItemMap.Where <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.Key] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Sum <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, int>)(x => x.Value)) >= stationModuleMounts.Where <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => x.ModuleType == AssetDatabase.StationModuleTypeToMountTypeMap[type].ToString())).Count <LogicalModuleMount>() - num2)
         {
             return;
         }
         Dictionary <ModuleEnums.StationModuleType, int> queuedItemMap;
         ModuleEnums.StationModuleType index;
         (queuedItemMap = this._queuedItemMap)[index = type] = queuedItemMap[index] + 1;
         this.SyncModuleItems();
     }
     else if (panelName.EndsWith("module_down"))
     {
         string[] strArray = panelName.Split('|');
         int.Parse(strArray[0]);
         ModuleEnums.StationModuleType index1 = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         if (this._queuedItemMap[index1] <= 0)
         {
             return;
         }
         Dictionary <ModuleEnums.StationModuleType, int> queuedItemMap;
         ModuleEnums.StationModuleType index2;
         (queuedItemMap = this._queuedItemMap)[index2 = index1] = queuedItemMap[index2] - 1;
         this.SyncModuleItems();
     }
     else if (panelName.EndsWith("module_max"))
     {
         string[] strArray                  = panelName.Split('|');
         int      orbitalObjectID           = int.Parse(strArray[0]);
         ModuleEnums.StationModuleType type = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         StationInfo stationInfo            = this.App.GameDatabase.GetStationInfo(orbitalObjectID);
         this.App.GameDatabase.GetModuleID(this.App.AssetDatabase.GetStationModuleAsset(type, this.App.Game.LocalPlayer.Faction.Name), this.App.Game.LocalPlayer.ID);
         List <LogicalModuleMount> stationModuleMounts = this.App.Game.GetAvailableStationModuleMounts(stationInfo);
         List <DesignModuleInfo>   list = this.App.GameDatabase.GetQueuedStationModules(this._selectedStation.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
         list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x =>
         {
             ModuleEnums.StationModuleType?stationModuleType1 = x.StationModuleType;
             ModuleEnums.StationModuleType stationModuleType2 = type;
             if (stationModuleType1.GetValueOrDefault() == stationModuleType2)
             {
                 return(stationModuleType1.HasValue);
             }
             return(false);
         })).ToList <DesignModuleInfo>();
         int num2 = list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.StationModuleType.Value] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Count <DesignModuleInfo>();
         int num3 = stationModuleMounts.Where <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => x.ModuleType == AssetDatabase.StationModuleTypeToMountTypeMap[type].ToString())).Count <LogicalModuleMount>();
         int num4 = this._queuedItemMap.Where <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.Key] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Sum <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, int>)(x => x.Value));
         if (num4 >= num3 - num2)
         {
             return;
         }
         Dictionary <ModuleEnums.StationModuleType, int> queuedItemMap;
         ModuleEnums.StationModuleType index;
         (queuedItemMap = this._queuedItemMap)[index = type] = queuedItemMap[index] + (num3 - num2 - num4);
         this.SyncModuleItems();
     }
     else
     {
         if (!(panelName == "autoUpgradeButton"))
         {
             return;
         }
         this.AutoFillModules();
     }
 }
コード例 #30
0
ファイル: StarSystemMapUI.cs プロジェクト: zerk-js/SOTSII-SOS
        internal static void Sync(App game, int systemId, string mapPanelId, bool isClickable)
        {
            bool flag = StarMap.IsInRange(game.Game.GameDatabase, game.LocalPlayer.ID, game.GameDatabase.GetStarSystemInfo(systemId), (Dictionary <int, List <ShipInfo> >)null);

            StarSystemMapUI.ResetMap(game, mapPanelId);
            if (systemId == 0)
            {
                return;
            }
            float        time         = 0.0f;
            GameDatabase gameDatabase = game.GameDatabase;
            IEnumerable <OrbitalObjectInfo> orbitalObjectInfos = gameDatabase.GetStarSystemOrbitalObjectInfos(systemId);
            StarSystemInfo starSystemInfo = gameDatabase.GetStarSystemInfo(systemId);
            StellarClass   stellarClass   = StellarClass.Parse(starSystemInfo.StellarClass);

            if (starSystemInfo.IsDeepSpace)
            {
                return;
            }
            float num1 = StarHelper.CalcRadius(StellarSize.Ia);
            float num2 = StarHelper.CalcRadius(StellarSize.VII);
            float num3 = ScalarExtensions.Lerp(0.67f, 3f, (float)(((double)StarHelper.CalcRadius(stellarClass.Size) - (double)num2) / ((double)num1 - (double)num2)));

            StarSystemMapUI.IconParams iconParams1 = StarSystemMapUI.IconParams.Default;
            iconParams1.ObjectID  = StarSystemDetailsUI.StarItemID;
            iconParams1.Text      = starSystemInfo.Name;
            iconParams1.Icon      = "sysmap_star";
            iconParams1.X         = 0.0f;
            iconParams1.Y         = 0.0f;
            iconParams1.Scale     = num3;
            iconParams1.Color     = StarHelper.CalcIconColor(stellarClass);
            iconParams1.Clickable = isClickable;
            StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams1);
            foreach (AsteroidBeltInfo asteroidBeltInfo in gameDatabase.GetStarSystemAsteroidBeltInfos(systemId))
            {
                AsteroidBeltInfo           asteroidBelt      = asteroidBeltInfo;
                OrbitalObjectInfo          orbitalObjectInfo = orbitalObjectInfos.First <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x => x.ID == asteroidBelt.ID));
                StarSystemMapUI.IconParams iconParams2       = new StarSystemMapUI.IconParams();
                iconParams2.SetPos(game, orbitalObjectInfos, time, orbitalObjectInfo.ID);
                iconParams2.ObjectID  = orbitalObjectInfo.ID;
                iconParams2.Icon      = "sysmap_roiddust";
                iconParams2.Scale     = 0.85f;
                iconParams2.Color     = Vector4.One;
                iconParams2.Text      = orbitalObjectInfo.Name;
                iconParams2.Clickable = false;
                StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams2);
            }
            PlanetInfo[] systemPlanetInfos = gameDatabase.GetStarSystemPlanetInfos(systemId);
            foreach (OrbitalObjectInfo orbitalObjectInfo in orbitalObjectInfos.Where <OrbitalObjectInfo>((Func <OrbitalObjectInfo, bool>)(x => !x.ParentID.HasValue)))
            {
                OrbitalObjectInfo orbital    = orbitalObjectInfo;
                PlanetInfo        planetInfo = ((IEnumerable <PlanetInfo>)systemPlanetInfos).FirstOrDefault <PlanetInfo>((Func <PlanetInfo, bool>)(x => x.ID == orbital.ID));
                if (planetInfo != null)
                {
                    string str = StarSystemMapUI.SelectIcon(planetInfo, orbitalObjectInfos, (IEnumerable <PlanetInfo>)systemPlanetInfos);
                    if (string.IsNullOrEmpty(str))
                    {
                        App.Log.Trace(string.Format("Planet {0} does not have an icon to represent it in the mini system map.", (object)orbital.Name), "gui");
                    }
                    else
                    {
                        AIColonyIntel colonyIntelForPlanet = game.GameDatabase.GetColonyIntelForPlanet(game.LocalPlayer.ID, planetInfo.ID);
                        if (colonyIntelForPlanet != null && flag)
                        {
                            Vector3 primaryColor = game.GameDatabase.GetPlayerInfo(colonyIntelForPlanet.OwningPlayerID).PrimaryColor;
                            Vector4 vector4      = new Vector4(primaryColor.X, primaryColor.Y, primaryColor.Z, 1f);
                            StarSystemMapUI.IconParams iconParams2 = StarSystemMapUI.IconParams.Default;
                            iconParams2.SetPos(game, orbitalObjectInfos, time, planetInfo.ID);
                            iconParams2.ObjectID  = 0;
                            iconParams2.Icon      = "sysmap_ownerring";
                            iconParams2.Scale     = 0.85f;
                            iconParams2.Color     = vector4;
                            iconParams2.Text      = string.Empty;
                            iconParams2.Clickable = false;
                            StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams2);
                        }
                        StarSystemMapUI.IconParams iconParams3 = new StarSystemMapUI.IconParams();
                        iconParams3.SetPos(game, orbitalObjectInfos, time, planetInfo.ID);
                        iconParams3.ObjectID  = planetInfo.ID;
                        iconParams3.Icon      = str;
                        iconParams3.Scale     = 0.85f;
                        iconParams3.Color     = Vector4.One;
                        iconParams3.Text      = orbital.Name;
                        iconParams3.Clickable = isClickable;
                        StarSystemMapUI.AddMapIcon(game, mapPanelId, iconParams3);
                    }
                }
            }
        }