コード例 #1
0
        private void WeaponSelectorSelectedWeaponChanged(object sender, bool isRightClick)
        {
            int?nullable = new int?();

            if (this._weaponSelector.SelectedWeapon != null)
            {
                nullable = this.App.GameDatabase.GetWeaponID(this._weaponSelector.SelectedWeapon.FileName, this.App.LocalPlayer.ID);
            }
            if (nullable.HasValue)
            {
                this._selectedModule.WeaponID = new int?(nullable.Value);
                if (isRightClick)
                {
                    foreach (DesignModuleInfo module in this.WorkingDesign.DesignSections[0].Modules)
                    {
                        string moduleass = this.App.GameDatabase.GetModuleAsset(module.ModuleID);
                        if (((IEnumerable <LogicalBank>) this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == moduleass)).Banks).Count <LogicalBank>() > 0)
                        {
                            module.WeaponID = new int?(nullable.Value);
                        }
                    }
                }
                this.UpdateListitem(isRightClick);
            }
            DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign);
            this.UpdateUICostETA();
            this.HideWeaponSelector();
        }
コード例 #2
0
ファイル: VonNeumann.cs プロジェクト: zerk-js/SOTSII-SOS
        public static VonNeumann InitializeEncounter(
            GameDatabase gamedb,
            AssetDatabase assetdb)
        {
            VonNeumann vonNeumann = new VonNeumann();

            vonNeumann.PlayerId = gamedb.InsertPlayer("Von Neumann", "vonneumann", new int?(), assetdb.RandomEncounterPrimaryColor, new Vector3(0.0f), "", "\\base\\factions\\vonneumann\\avatars\\Vonneumann_Avatar.tga", 0.0, 0, false, false, false, 0, AIDifficulty.Normal);
            foreach (KeyValuePair <VonNeumann.VonNeumannShipDesigns, VonNeumann.VonNeumannDesignInfo> keyValuePair in VonNeumann.StaticShipDesigns.ToList <KeyValuePair <VonNeumann.VonNeumannShipDesigns, VonNeumann.VonNeumannDesignInfo> >())
            {
                DesignInfo design = new DesignInfo(vonNeumann.PlayerId, keyValuePair.Key.ToString(), new string[1]
                {
                    string.Format("factions\\{0}\\sections\\{1}", (object)"vonneumann", (object)keyValuePair.Value.AssetName)
                });
                DesignLab.SummarizeDesign(assetdb, gamedb, design);
                VonNeumann.StaticShipDesigns[keyValuePair.Key] = new VonNeumann.VonNeumannDesignInfo()
                {
                    DesignId  = gamedb.InsertDesignByDesignInfo(design),
                    AssetName = keyValuePair.Value.AssetName
                };
            }
            vonNeumann._outlyingStars = EncounterTools.GetOutlyingStars(gamedb);
            return(vonNeumann);
        }
コード例 #3
0
ファイル: Pirates.cs プロジェクト: zerk-js/SOTSII-SOS
        public int SpawnPirateFleet(GameSession game, int targetSystem, int numShips)
        {
            Random random  = new Random();
            int    fleetID = game.GameDatabase.InsertFleet(this.PlayerID, 0, targetSystem, 0, "Pirate Raiders", FleetType.FL_NORMAL);
            Dictionary <LogicalWeapon, int> dictionary1 = new Dictionary <LogicalWeapon, int>();
            List <PlayerInfo> list1          = game.GameDatabase.GetStandardPlayerInfos().ToList <PlayerInfo>();
            List <PlayerInfo> playerInfoList = new List <PlayerInfo>();

            foreach (PlayerInfo playerInfo in list1)
            {
                Faction faction = game.AssetDatabase.GetFaction(playerInfo.FactionID);
                if (faction.Name != "liir_zuul" && faction.Name != "hiver" && faction.Name != "loa")
                {
                    playerInfoList.Add(playerInfo);
                }
                foreach (LogicalWeapon key in game.GameDatabase.GetAvailableWeapons(game.AssetDatabase, playerInfo.ID).ToList <LogicalWeapon>())
                {
                    if (!dictionary1.ContainsKey(key))
                    {
                        dictionary1.Add(key, 1);
                    }
                    else
                    {
                        Dictionary <LogicalWeapon, int> dictionary2;
                        LogicalWeapon index;
                        (dictionary2 = dictionary1)[index = key] = dictionary2[index] + 1;
                    }
                }
            }
            if (playerInfoList.Count > 0)
            {
                List <LogicalWeapon> availableWeapons = new List <LogicalWeapon>();
                foreach (LogicalWeapon logicalWeapon in game.AssetDatabase.Weapons.ToList <LogicalWeapon>())
                {
                    if (((IEnumerable <LogicalTurretClass>)logicalWeapon.TurretClasses).Count <LogicalTurretClass>() > 0 && WeaponEnums.IsBattleRider(logicalWeapon.DefaultWeaponClass))
                    {
                        availableWeapons.Add(logicalWeapon);
                    }
                }
                foreach (KeyValuePair <LogicalWeapon, int> keyValuePair in dictionary1)
                {
                    if (keyValuePair.Value > 1 && !availableWeapons.Contains(keyValuePair.Key))
                    {
                        availableWeapons.Add(keyValuePair.Key);
                    }
                }
                for (int index1 = 0; index1 < numShips + 1; ++index1)
                {
                    PlayerInfo playerInfo = random.Choose <PlayerInfo>((IList <PlayerInfo>)playerInfoList);
                    Faction    faction    = game.AssetDatabase.GetFaction(playerInfo.FactionID);
                    DesignInfo design1    = DesignLab.DesignShip(game, ShipClass.BattleRider, ShipRole.BOARDINGPOD, WeaponRole.PLANET_ATTACK, playerInfo.ID);
                    DesignInfo design2    = DesignLab.DesignShip(game, ShipClass.BattleRider, ShipRole.DRONE, WeaponRole.UNDEFINED, playerInfo.ID);
                    design1.PlayerID = this.PlayerID;
                    design2.PlayerID = this.PlayerID;
                    game.GameDatabase.InsertDesignByDesignInfo(design1);
                    game.GameDatabase.InsertDesignByDesignInfo(design2);
                    DesignInfo designInfo1;
                    if (index1 == 0)
                    {
                        DesignInfo designInfo2 = DesignLab.DesignShip(game, ShipClass.Cruiser, ShipRole.COMMAND, WeaponRole.UNDEFINED, playerInfo.ID);
                        designInfo1 = new DesignInfo(playerInfo.ID, "", new string[3]
                        {
                            ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Command)).FilePath,
                            ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Mission)).FilePath,
                            ((IEnumerable <DesignSectionInfo>)designInfo2.DesignSections).First <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Engine)).FilePath
                        });
                    }
                    else
                    {
                        List <ShipSectionAsset> availableSections = game.GetAvailableShipSections(playerInfo.ID).ToList <ShipSectionAsset>();
                        List <string>           list2             = ((IEnumerable <string>)Pirates.availableCommandSections).ToList <string>();
                        List <string>           list3             = ((IEnumerable <string>)Pirates.availableMissionSections).ToList <string>();
                        List <string>           list4             = ((IEnumerable <string>)Pirates.availableEngineSections).ToList <string>();
                        for (int index2 = 0; index2 < list2.Count <string>(); ++index2)
                        {
                            list2[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list2[index2]);
                        }
                        for (int index2 = 0; index2 < list3.Count <string>(); ++index2)
                        {
                            list3[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list3[index2]);
                        }
                        for (int index2 = 0; index2 < list4.Count <string>(); ++index2)
                        {
                            list4[index2] = string.Format("factions\\{0}\\sections\\{1}", (object)faction.Name, (object)list4[index2]);
                        }
                        list2.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x))));
                        list3.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x))));
                        list4.RemoveAll((Predicate <string>)(x => !availableSections.Any <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(y => y.FileName == x))));
                        designInfo1 = new DesignInfo(playerInfo.ID, "", new string[3]
                        {
                            random.Choose <string>((IList <string>)list2),
                            random.Choose <string>((IList <string>)list3),
                            random.Choose <string>((IList <string>)list4)
                        });
                    }
                    designInfo1.Name = DesignLab.GenerateDesignName(game.AssetDatabase, game.GameDatabase, (DesignInfo)null, designInfo1, DesignLab.NameGenerators.FactionRandom);
                    DesignLab.SummarizeDesign(game.AssetDatabase, game.GameDatabase, designInfo1);
                    DesignInfo design3 = DesignLab.AssignWeaponsToDesign(game, designInfo1, availableWeapons, this.PlayerId, WeaponRole.BRAWLER, (AITechStyles)null);
                    design3.PlayerID = this.PlayerID;
                    int designID  = game.GameDatabase.InsertDesignByDesignInfo(design3);
                    int carrierID = game.GameDatabase.InsertShip(fleetID, designID, null, (ShipParams)0, new int?(), 0);
                    game.AddDefaultStartingRiders(fleetID, designID, carrierID);
                }
            }
            return(fleetID);
        }
コード例 #4
0
        public override void Initialize()
        {
            this.App.UI.HideTooltip();
            this.BankDict       = new Dictionary <string, int>();
            this.ItemIDDict     = new Dictionary <string, string>();
            this.ModuleBankdict = new Dictionary <int, string>();
            DesignInfo designInfo = this._ship.DesignInfo;

            if (designInfo.DesignSections[0].Modules.Any <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x =>
            {
                ModuleEnums.StationModuleType?stationModuleType = x.StationModuleType;
                if ((stationModuleType.GetValueOrDefault() != ModuleEnums.StationModuleType.Combat ? 0 : (stationModuleType.HasValue ? 1 : 0)) != 0)
                {
                    return(!x.WeaponID.HasValue);
                }
                return(false);
            })))
            {
                this.UpdateStationDesignInfo(designInfo);
                this._app.GameDatabase.UpdateDesign(designInfo);
            }
            this.WorkingDesign = new DesignInfo(this._ship.DesignInfo.PlayerID, this._ship.DesignInfo.Name, new string[1]
            {
                this._ship.DesignInfo.DesignSections[0].FilePath
            });
            this.WorkingDesign.StationLevel = designInfo.StationLevel;
            this.WorkingDesign.StationType  = designInfo.StationType;
            DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign);
            this.WorkingDesign.DesignSections[0].Modules          = new List <DesignModuleInfo>();
            this.WorkingDesign.DesignSections[0].WeaponBanks      = new List <WeaponBankInfo>();
            this.WorkingDesign.DesignSections[0].Techs            = new List <int>();
            this.WorkingDesign.DesignSections[0].ShipSectionAsset = designInfo.DesignSections[0].ShipSectionAsset;
            int num = 0;

            foreach (DesignModuleInfo module in designInfo.DesignSections[0].Modules)
            {
                DesignModuleInfo designModuleInfo = new DesignModuleInfo()
                {
                    MountNodeName     = module.MountNodeName,
                    ModuleID          = module.ModuleID,
                    WeaponID          = module.WeaponID,
                    DesignID          = module.DesignID,
                    StationModuleType = module.StationModuleType,
                    ID = num
                };
                ++num;
                this.WorkingDesign.DesignSections[0].Modules.Add(designModuleInfo);
            }
            this.UpdateStationDesignInfo(this.WorkingDesign);
            this.App.UI.ClearItems(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID));
            DesignLab.SummarizeDesign(this._app.AssetDatabase, this._app.GameDatabase, this.WorkingDesign);
            foreach (DesignSectionInfo designSection in this.WorkingDesign.DesignSections)
            {
                foreach (DesignModuleInfo module in designSection.Modules)
                {
                    if (module.WeaponID.HasValue)
                    {
                        this.App.UI.AddItem(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID), "", module.ID, "");
                        string        itemGlobalId  = this.App.UI.GetItemGlobalID(this.App.UI.Path(this.ID, RetrofitStationDialog.RetrofitBankListID), "", module.ID, "");
                        string        asset         = this.App.GameDatabase.GetWeaponAsset(module.WeaponID.Value);
                        LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.First <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset));
                        this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "wepimg"), "sprite", logicalWeapon.IconSpriteName);
                        string index = "retrofitButton|" + module.ID.ToString();
                        this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "btnImageButton"), "id", index);
                        if (!this.BankDict.ContainsKey(index))
                        {
                            this.BankDict[index] = module.ID;
                        }
                        if (!this.ItemIDDict.ContainsKey(index))
                        {
                            this.ItemIDDict[index] = itemGlobalId;
                        }
                    }
                }
            }
            this._weaponSelector = new WeaponSelector(this.App.UI, "gameWeaponSelector", "");
            this.App.UI.SetParent(this._weaponSelector.ID, this.UI.Path(this.ID, "gameWeaponSelectorbox"));
            this._weaponSelector.SelectedWeaponChanged += new WeaponSelectionChangedEventHandler(this.WeaponSelectorSelectedWeaponChanged);
            StationInfo stationInfo = this.App.GameDatabase.GetStationInfosByPlayerID(this._ship.DesignInfo.PlayerID).FirstOrDefault <StationInfo>((Func <StationInfo, bool>)(x => x.ShipID == this._ship.ID));

            if (stationInfo != null)
            {
                StationUI.SyncStationDetailsWidget(this.App.Game, this.UI.Path(this.ID, "stationDetails"), stationInfo.OrbitalObjectID, true);
            }
            this.UpdateUICostETA();
            this.App.UI.SetEnabled(this.UI.Path(this.ID, "okButton"), (this.DesignChanged() ? 1 : 0) != 0);
        }