Example #1
0
        public bool IsMarkedForRemoval(DesignInfo design)
        {
            if (design == null)
            {
                throw new ArgumentNullException(nameof(design));
            }

            var game   = this.gameInstance;
            var orders = game.Orders[this.PlayerInstance(game)];

            return(orders.DiscardOrders.Contains(design.Data));
        }
Example #2
0
        public static void SyncSpeed(App game, DesignInfo design)
        {
            double mass         = (double)design.Mass;
            float  acceleration = design.Acceleration;
            float  topSpeed     = design.TopSpeed;
            float  num1         = topSpeed / acceleration;
            float  num2         = 0.0f;
            float  num3         = 0.0f;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                ShipSectionAsset shipSectionAsset = designSection.ShipSectionAsset;
                if (shipSectionAsset != null)
                {
                    if ((double)shipSectionAsset.NodeSpeed > 0.0)
                    {
                        num3 = shipSectionAsset.NodeSpeed;
                    }
                    if ((double)shipSectionAsset.FtlSpeed > 0.0)
                    {
                        num2 = shipSectionAsset.FtlSpeed;
                    }
                }
            }
            float num4 = 0.0f;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                DesignSectionInfo sectionInfo      = designSection;
                ShipSectionAsset  shipSectionAsset = game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == sectionInfo.FilePath));
                num4 += shipSectionAsset.Maneuvering.RotationSpeed;
            }
            string     text1      = string.Format("{0} kg", (object)design.Mass);
            string     text2      = string.Format("{0} km/s\x00B2", (object)design.Acceleration);
            string     text3      = string.Format("{0} deg/s", (object)num4);
            string     text4      = string.Format("{0} km/s (in {1}s)", (object)topSpeed, (object)Math.Max(1, (int)num1));
            PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(design.PlayerID);

            if (game.AssetDatabase.GetFaction(playerInfo.FactionID).CanUseNodeLine(new bool?()))
            {
                game.UI.SetText("gameShipFTLSpeed", string.Format("{0} ly", (object)num3));
            }
            else
            {
                game.UI.SetText("gameShipFTLSpeed", string.Format("{0} ly", (object)num2));
            }
            game.UI.SetText("gameShipTopSpeedTime", text4);
            game.UI.SetText("gameShipTurnSpeed", text3);
            game.UI.SetText("gameShipThrust", text2);
            game.UI.SetText("gameShipMass", text1);
            game.UI.SetPropertyFloat("gameSpeedGraph", "accel", acceleration);
            game.UI.SetPropertyFloat("gameSpeedGraph", "max_speed", topSpeed);
        }
        public void KeepDesign(DesignInfo design)
        {
            var game = this.gameInstance;

            if (game.IsReadOnly)
            {
                return;
            }

            game.Orders[this.PlayerInstance(game)].RefitOrders.Remove(design.Data);
            game.Orders[this.PlayerInstance(game)].DiscardOrders.Remove(design.Data);
        }
        public void Cancel()
        {
            DesignInfo DesignInfo = ApplicationDesignService.GetUIDesignInfo(DesignProperty.PropertyID);

            if (DesignInfo != null)
            {
                UIDesignInfo = DesignInfo;
            }
            else
            {
                InitDesignInfo();
            }
        }
Example #5
0
 public void New(
     Player player,
     DesignInfo design,
     string shipName,
     int serialNumber,
     bool autoAddDrawable = true)
 {
     this.Clear();
     this._ship[this._loadShip] = Ship.CreateShip(this._game, Matrix.Identity, design, shipName, serialNumber, 0, 0, player, 0, -1, -1, autoAddDrawable, true, false, (IEnumerable <Player>)null);
     this.PostNewShip(player);
     this._ready   = false;
     this._loading = true;
 }
Example #6
0
        public SavePage(DesignInfo design)
        {
            InitializeComponent();

            var writer = new QRWriter();

            QRCode.BarcodeOptions.Width       = (int)DeviceDisplay.MainDisplayInfo.Width;
            QRCode.BarcodeOptions.Height      = (int)DeviceDisplay.MainDisplayInfo.Width;
            QRCode.BarcodeOptions.PureBarcode = true;

            //ISO-8859-1 ????
            QRCode.BarcodeValue = Encoding.GetEncoding("ISO-8859-1").GetString(writer.Write(design));
        }
Example #7
0
        public static void SyncSectionArmor(
            App game,
            string panelId,
            ShipSectionAsset sectionAsset,
            DesignInfo design)
        {
            string panelId1 = game.UI.Path(panelId, "partArmor");
            string panelId2 = game.UI.Path(panelId, "partArmorTop");
            string panelId3 = game.UI.Path(panelId, "partArmorBtm");
            string panelId4 = game.UI.Path(panelId, "partArmorSide");
            string panelId5 = game.UI.Path(panelId, "partStruct");
            string panelId6 = game.UI.Path(panelId, "partStructBar");
            int    num1     = 0;
            int    num2     = sectionAsset.Structure;

            if (design != null)
            {
                DesignSectionInfo designSectionInfo = ((IEnumerable <DesignSectionInfo>)design.DesignSections).FirstOrDefault <DesignSectionInfo>((Func <DesignSectionInfo, bool>)(x => x.FilePath == sectionAsset.FileName));
                List <string>     list = designSectionInfo.Techs.Select <int, string>((Func <int, string>)(x => game.GameDatabase.GetTechFileID(x))).ToList <string>();
                num1 = Ship.GetArmorBonusFromTech(game.AssetDatabase, list);
                num2 = Ship.GetStructureWithTech(game.AssetDatabase, list, num2);
                foreach (DesignModuleInfo module in designSectionInfo.Modules)
                {
                    string        moduleAsset   = game.GameDatabase.GetModuleAsset(module.ModuleID);
                    LogicalModule logicalModule = game.AssetDatabase.Modules.FirstOrDefault <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == moduleAsset));
                    if (logicalModule != null)
                    {
                        num2 += (int)logicalModule.StructureBonus;
                    }
                }
            }
            int    propertyValue1 = sectionAsset.Armor[1].Y + num1;
            int    propertyValue2 = sectionAsset.Armor[3].Y + num1;
            int    propertyValue3 = Math.Max(sectionAsset.Armor[2].Y, sectionAsset.Armor[0].Y) + num1;
            int    num3           = sectionAsset.Armor[1].X * (sectionAsset.Armor[1].Y + num1) + sectionAsset.Armor[3].X * (sectionAsset.Armor[3].Y + num1) + sectionAsset.Armor[0].X * (sectionAsset.Armor[0].Y + num1) + sectionAsset.Armor[2].X * (sectionAsset.Armor[2].Y + num1);
            int    propertyValue4 = 10;
            int    propertyValue5 = 10000;
            string text1          = num3.ToString("N0");
            string text2          = num2.ToString("N0");

            game.UI.SetText(panelId1, text1);
            game.UI.SetPropertyInt(panelId2, "value", propertyValue1);
            game.UI.SetPropertyInt(panelId3, "value", propertyValue2);
            game.UI.SetPropertyInt(panelId4, "value", propertyValue3);
            game.UI.SetPropertyInt(panelId2, "max_value", propertyValue4);
            game.UI.SetPropertyInt(panelId3, "max_value", propertyValue4);
            game.UI.SetPropertyInt(panelId4, "max_value", propertyValue4);
            game.UI.SetText(panelId5, text2);
            game.UI.SetPropertyInt(panelId6, "value", num2);
            game.UI.SetPropertyInt(panelId6, "max_value", propertyValue5);
        }
        public void LoadDesign(DesignInfo design)
        {
            Design = design;

            var scale = (float)DeviceDisplay.MainDisplayInfo.Width / Design.Bitmap.Width;

            Matrix.ScaleX = scale;
            Matrix.ScaleY = scale;

            MaxScale = scale * 3;
            MinScale = scale / 3;

            InvalidateSurface();
        }
Example #9
0
 public DesignDetailsCard(App game, int designid, int?ShipID, UICommChannel ui, string id)
     : base(ui, id)
 {
     this.App    = game;
     this.Design = this.App.GameDatabase.GetDesignInfo(designid);
     if (ShipID.HasValue)
     {
         this.Ship = this.App.GameDatabase.GetShipInfo(ShipID.Value, false);
     }
     else
     {
         this.Ship = (ShipInfo)null;
     }
 }
Example #10
0
        private void UpdateStationDesignInfo(DesignInfo di)
        {
            int num = 0;

            foreach (DesignSectionInfo designSection in di.DesignSections)
            {
                DesignSectionInfo dsi = designSection;
                if (dsi.WeaponBanks != null)
                {
                    dsi.WeaponBanks.Clear();
                }
                ShipSectionAsset section = this.App.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == dsi.FilePath));
                if (dsi.Modules != null)
                {
                    foreach (DesignModuleInfo module in dsi.Modules)
                    {
                        string        moduleass     = this.App.GameDatabase.GetModuleAsset(module.ModuleID);
                        LogicalModule logicalModule = this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == moduleass));
                        if (logicalModule != null && ((IEnumerable <LogicalBank>)logicalModule.Banks).Count <LogicalBank>() > 0)
                        {
                            int fireMode = 0;
                            ShipSectionAsset            shipSectionAsset = this._ship.DesignInfo.DesignSections[0].ShipSectionAsset;
                            IEnumerable <LogicalWeapon> preferredWeapons = LogicalWeapon.EnumerateWeaponFits(shipSectionAsset.Faction, shipSectionAsset.SectionName, this.App.GameDatabase.GetAvailableWeapons(this.App.AssetDatabase, this.App.LocalPlayer.ID).Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(weapona => weapona.IsVisible)), logicalModule.Banks[0].TurretSize, logicalModule.Banks[0].TurretClass).Where <LogicalWeapon>((Func <LogicalWeapon, bool>)(x =>
                            {
                                if ((double)x.Range <= 1500.0)
                                {
                                    return(x.DefaultWeaponSize == WeaponEnums.WeaponSizes.VeryLight);
                                }
                                return(true);
                            }));
                            int           designID;
                            int           targetFilter;
                            LogicalWeapon logicalWeapon = Ship.SelectWeapon(section, logicalModule.Banks[0], (IEnumerable <WeaponAssignment>)null, preferredWeapons, this.App.GameDatabase.GetAvailableWeapons(this.App.AssetDatabase, this.App.LocalPlayer.ID), module.MountNodeName, out designID, out targetFilter, out fireMode);
                            int?          nullable      = new int?();
                            if (logicalWeapon != null && !module.WeaponID.HasValue)
                            {
                                nullable = this.App.GameDatabase.GetWeaponID(logicalWeapon.FileName, this.App.LocalPlayer.ID);
                            }
                            else if (module.WeaponID.HasValue)
                            {
                                nullable = module.WeaponID;
                            }
                            this.ModuleBankdict[module.ID] = module.MountNodeName;
                            ++num;
                            module.WeaponID = nullable;
                        }
                    }
                }
            }
        }
Example #11
0
        public IEnumerable <DesignInfo> RefitCandidates(DesignInfo design)
        {
            if (design == null)
            {
                throw new ArgumentNullException(nameof(design));
            }

            var game       = this.gameInstance;
            var playerProc = game.Derivates[this.PlayerInstance(game)];

            return(playerProc.RefitCosts[design.Data].
                   Where(x => !x.Key.IsObsolete).
                   Select(x => new DesignInfo(x.Key, playerProc.DesignStats[x.Key])));
        }
 private bool CanMountBattleRider(DesignInfo design)
 {
     WeaponEnums.TurretClasses?turretclass = StrategicAI.BattleRiderMountSet.GetMatchingTurretClass(design);
     return(this.RiderListMap.FirstOrDefault <DialogLoaFleetCompositor.RiderStruct>((Func <DialogLoaFleetCompositor.RiderStruct, bool>)(x => x.WingData.Any <DialogLoaFleetCompositor.RiderWingStruct>((Func <DialogLoaFleetCompositor.RiderWingStruct, bool>)(j =>
     {
         WeaponEnums.TurretClasses turretClasses = j.wingdata.Class;
         WeaponEnums.TurretClasses?nullable = turretclass;
         if ((turretClasses != nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
         {
             return !j.riders.Any <int>();
         }
         return false;
     })))) != null);
 }
Example #13
0
        public void CreateImagesForOtherColor(int campaignId, string prodIdAndColor, CampaignProductRecord p,
                                              DesignInfo data, string frontPath, string backPath, string color)
        {
            var destForder = Path.Combine(Server.MapPath("/Media/campaigns/"), campaignId.ToString(), prodIdAndColor);

            if (!Directory.Exists(destForder))
            {
                Directory.CreateDirectory(destForder);
            }

            if (!Directory.Exists(destForder + "/normal"))
            {
                Directory.CreateDirectory(destForder + "/normal");
            }
            if (!Directory.Exists(destForder + "/big"))
            {
                Directory.CreateDirectory(destForder + "/big");
            }

            var frontTemplate = new Bitmap(frontPath);
            var backTemplate  = new Bitmap(backPath);

            var rgba = ColorTranslator.FromHtml(color);

            var front = BuildProductImage(frontTemplate, _imageHelper.Base64ToBitmap(data.Front), rgba,
                                          p.ProductRecord.ProductImageRecord.Width, p.ProductRecord.ProductImageRecord.Height,
                                          p.ProductRecord.ProductImageRecord.PrintableFrontTop,
                                          p.ProductRecord.ProductImageRecord.PrintableFrontLeft,
                                          p.ProductRecord.ProductImageRecord.PrintableFrontWidth,
                                          p.ProductRecord.ProductImageRecord.PrintableFrontHeight);

            front.Save(Path.Combine(destForder, "normal", "front.png"));

            var back = BuildProductImage(backTemplate, _imageHelper.Base64ToBitmap(data.Back), rgba,
                                         p.ProductRecord.ProductImageRecord.Width, p.ProductRecord.ProductImageRecord.Height,
                                         p.ProductRecord.ProductImageRecord.PrintableBackTop,
                                         p.ProductRecord.ProductImageRecord.PrintableBackLeft,
                                         p.ProductRecord.ProductImageRecord.PrintableBackWidth,
                                         p.ProductRecord.ProductImageRecord.PrintableBackHeight);

            back.Save(Path.Combine(destForder, "normal", "back.png"));

            _imageHelper.ResizeImage(front, p.ProductRecord.ProductImageRecord.Width * 2, p.ProductRecord.ProductImageRecord.Height * 2).Save(Path.Combine(destForder, "big", "front.png"));
            _imageHelper.ResizeImage(back, p.ProductRecord.ProductImageRecord.Width * 2, p.ProductRecord.ProductImageRecord.Height * 2).Save(Path.Combine(destForder, "big", "back.png"));

            frontTemplate.Dispose();
            backTemplate.Dispose();
            front.Dispose();
            back.Dispose();
        }
Example #14
0
        /// <summary>
        /// Updates the design of the specified user.
        /// </summary>
        /// <param name="userId">Internal identifier of the user.</param>
        /// <param name="design">Design of the user.</param>
        public void Update(int userId, DesignInfo design)
        {
            // Get an instance of the Design DAO using the DALFactory
            IDesign dao = (IDesign)DALFactory.DAO.Create(DALFactory.Module.Design);

            try
            {
                dao.Update(userId, design);
            }
            catch
            {
                throw;
            }
        }
Example #15
0
        private void SyncDesignTooltipByDesign(string panelId, int designID)
        {
            DesignInfo designInfo = this._game.GameDatabase.GetDesignInfo(designID);
            List <SectionEnumerations.DesignAttribute> list = this._game.GameDatabase.GetDesignAttributesForDesign(designInfo.ID).ToList <SectionEnumerations.DesignAttribute>();
            List <int> intList = new List <int>();

            foreach (DesignSectionInfo designSection in designInfo.DesignSections)
            {
                foreach (WeaponBankInfo weaponBank in designSection.WeaponBanks)
                {
                    if (weaponBank.WeaponID.HasValue && !intList.Contains(weaponBank.WeaponID.Value))
                    {
                        intList.Add(weaponBank.WeaponID.Value);
                    }
                }
            }
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblDesignName"), designInfo.Name);
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblShipName"), "");
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblFirstSection"), ((IEnumerable <DesignSectionInfo>)designInfo.DesignSections).Count <DesignSectionInfo>() > 0 ? designInfo.DesignSections[0].ShipSectionAsset.Title : "");
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblSecondSection"), ((IEnumerable <DesignSectionInfo>)designInfo.DesignSections).Count <DesignSectionInfo>() > 1 ? designInfo.DesignSections[1].ShipSectionAsset.Title : "");
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblThirdSection"), ((IEnumerable <DesignSectionInfo>)designInfo.DesignSections).Count <DesignSectionInfo>() > 2 ? designInfo.DesignSections[2].ShipSectionAsset.Title : "");
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblAttributeName"), !designInfo.isAttributesDiscovered || list.Count <= 0 ? "" : App.Localize("@UI_" + list.First <SectionEnumerations.DesignAttribute>().ToString()));
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblUpkeep"), GameSession.CalculateShipUpkeepCost(this._game.AssetDatabase, designInfo, 1f, false).ToString());
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblShipAge"), "");
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblSupply"), string.Format("{0}/{1}", (object)designInfo.SupplyRequired, (object)designInfo.SupplyAvailable));
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblPower"), string.Format("{0}/{1}", (object)designInfo.PowerRequired, (object)designInfo.PowerAvailable));
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblCrew"), string.Format("{0}/{1}", (object)designInfo.CrewRequired, (object)designInfo.CrewAvailable));
            this.App.UI.SetText(this.App.UI.Path(panelId, "lblEndurance"), designInfo.GetEndurance(this._game.Game).ToString());
            this.App.UI.ClearItems("lstWeaponIcons");
            foreach (int num in intList)
            {
                string        asset         = this.App.GameDatabase.GetWeaponAsset(num);
                LogicalWeapon logicalWeapon = this.App.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => x.FileName == asset));
                if (logicalWeapon != null)
                {
                    this.App.UI.AddItem("lstWeaponIcons", string.Empty, num, "");
                    this.App.UI.SetPropertyString(this.App.UI.Path(this.App.UI.GetItemGlobalID("lstWeaponIcons", string.Empty, num, ""), "imgWeaponIcon"), "sprite", logicalWeapon.IconSpriteName);
                }
            }
            float num1 = ShipTooltip.ArmorPanelShape.W / 2f;

            this.App.UI.SetShape("top_armor", 0, 0, (int)ShipTooltip.ArmorPanelShape.W, (int)num1);
            this.App.UI.SetShape("bottom_armor", 0, (int)num1, (int)ShipTooltip.ArmorPanelShape.W, (int)num1);
            this.App.UI.SetShape("left_armor", 0, 0, (int)num1, (int)ShipTooltip.ArmorPanelShape.H);
            this.App.UI.SetShape("right_armor", (int)num1, 0, (int)num1, (int)ShipTooltip.ArmorPanelShape.H);
            this._builder.New(this.App.GetPlayer(designInfo.PlayerID), designInfo, "The Ship You Wish your Ship was", 0, false);
            this._ready     = false;
            this._activated = false;
        }
Example #16
0
        public double RefitCost(DesignInfo design, DesignInfo refitWith)
        {
            if (design == null)
            {
                throw new ArgumentNullException(nameof(design));
            }
            if (refitWith == null)
            {
                throw new ArgumentNullException(nameof(refitWith));
            }

            var game = this.gameInstance;

            return(game.Derivates[this.PlayerInstance(game)].RefitCosts[design.Data][refitWith.Data]);
        }
        public DesignInfo RefittingWith(DesignInfo design)
        {
            var game   = this.gameInstance;
            var player = this.PlayerInstance(game);
            var orders = game.Orders[player];

            if (game.IsReadOnly || !orders.RefitOrders.ContainsKey(design.Data))
            {
                return(null);
            }

            var targetDesign = orders.RefitOrders[design.Data];

            return(new DesignInfo(targetDesign, game.Derivates[targetDesign.Owner].DesignStats[targetDesign], game.Statics));
        }
Example #18
0
        public static SystemKiller InitializeEncounter(
            GameDatabase gamedb,
            AssetDatabase assetdb)
        {
            SystemKiller systemKiller = new SystemKiller();

            systemKiller.PlayerId = gamedb.InsertPlayer("System Killer", "grandmenaces", new int?(), assetdb.RandomEncounterPrimaryColor, new Vector3(0.0f), "", "\\base\\factions\\grandmenaces\\avatars\\Systemkiller_Avatar.tga", 0.0, 0, false, false, false, 0, AIDifficulty.Normal);
            DesignInfo design = new DesignInfo(systemKiller.PlayerId, "System Killer", new string[1]
            {
                string.Format("factions\\{0}\\sections\\{1}", (object)"grandmenaces", (object)"systemkiller.section")
            });

            systemKiller._systemKillerDesignId = gamedb.InsertDesignByDesignInfo(design);
            return(systemKiller);
        }
Example #19
0
        public void InitDesigns(GameDatabase db)
        {
            List <DesignInfo> list = db.GetDesignInfosForPlayer(this.PlayerId).ToList <DesignInfo>();

            this._slaveDiskDesignId      = db.AddOrGetEncounterDesignInfo((IEnumerable <DesignInfo>)list, this.PlayerId, "Slave Disk", "slavers", "br_slavedisk.section");
            this._wraithAbductorDesignId = db.AddOrGetEncounterDesignInfo((IEnumerable <DesignInfo>)list, this.PlayerId, "Slaver Wraith Abductor", "slavers", "cr_wraith_abductor.section");
            this._scavengerDesignId      = db.AddOrGetEncounterDesignInfo((IEnumerable <DesignInfo>)list, this.PlayerId, "Slaver Scavenger", "slavers", "cr_mis_scavenger.section", "cr_cmd.section", "cr_eng_fusion.section");
            DesignInfo designInfo1 = db.GetDesignInfo(this._slaveDiskDesignId);
            DesignInfo designInfo2 = db.GetDesignInfo(this._scavengerDesignId);

            designInfo1.Role = ShipRole.SLAVEDISK;
            designInfo2.Role = ShipRole.SCAVENGER;
            db.UpdateDesign(designInfo1);
            db.UpdateDesign(designInfo2);
        }
Example #20
0
 public static ShipSectionAsset GetSectionAsset(
     App game,
     DesignInfo design,
     ShipSectionType sectionType)
 {
     foreach (DesignSectionInfo designSection1 in design.DesignSections)
     {
         DesignSectionInfo designSection    = designSection1;
         ShipSectionAsset  shipSectionAsset = game.AssetDatabase.ShipSections.First <ShipSectionAsset>((Func <ShipSectionAsset, bool>)(x => x.FileName == designSection.FilePath));
         if (shipSectionAsset.Type == sectionType)
         {
             return(shipSectionAsset);
         }
     }
     return((ShipSectionAsset)null);
 }
Example #21
0
 private void InitDesignInfo()
 {
     UIDesignInfo = new DesignInfo();
     UIDesignInfo.GridColAlign      = "left";
     UIDesignInfo.GridColSorting    = "str";
     UIDesignInfo.GridColType       = "ro";
     UIDesignInfo.GridHeader        = "";
     UIDesignInfo.GridWidth         = 0;
     UIDesignInfo.InputType         = "TextBox";
     UIDesignInfo.ReferType         = "";
     UIDesignInfo.QueryForm         = "Fuzzy";
     UIDesignInfo.IsRequired        = false;
     UIDesignInfo.IsReadOnly        = false;
     UIDesignInfo.ValidateType      = "None";
     UIDesignInfo.IsPropertyChanged = true;
 }
Example #22
0
        public void DisbandDesign(DesignInfo design)
        {
            if (design == null)
            {
                throw new ArgumentNullException(nameof(design));
            }

            var game = this.gameInstance;

            if (game.IsReadOnly)
            {
                return;
            }

            game.Orders[this.PlayerInstance(game)].DiscardOrders.Add(design.Data);
        }
    /// <summary>
    /// Looks up a model and loads it from the assetbundle and spawns it at a position with a rotation and a scale
    /// </summary>
    /// <param name="infoList">List of all model infos</param>
    /// <param name="objectName">Name  of model to be spawned</param>
    /// <param name="position">Position of model to be spawned</param>
    /// <param name="rotation">Rotation of model to be spawned</param>
    /// <param name="scale">Scale of model to be spawned</param>
    public static IEnumerator LoadObjectAtPositionAndRotation(List <DesignInfo> infoList, string objectName, Vector3 position, Quaternion rotation, Vector3 scale)
    {
        // Load and retrieve the AssetBundle
        AssetBundle[] bundles = DataManager.modelBundles.ToArray();
        AssetBundle   bundle  = new AssetBundle();

        for (int i = 0; i < bundles.Length; i++)
        {
            if (bundles[i].Contains(objectName))
            {
                bundle = bundles[i];
                break;
            }
        }

        // Load the object asynchronously
        AssetBundleRequest request = bundle.LoadAssetAsync(objectName, typeof(GameObject));

        // Wait for completion
        yield return(request);

        // Get the reference to the loaded object
        GameObject newObject = Instantiate(request.asset) as GameObject;

        newObject.transform.position = position;
        newObject.transform.rotation = rotation;

        DesignInfo objectInfo = null;

        foreach (DesignInfo info in infoList)
        {
            if (info.Name.ToLower() == objectName.ToLower())
            {
                objectInfo = info;
            }
        }

        // Create the model in the world
        newObject.AddComponent <ObjectInfo>();
        newObject.GetComponent <ObjectInfo>().info = objectInfo;
        newObject.AddComponent <BoxCollider>();
        CalculateLocalBounds(newObject);
        newObject.transform.localScale = scale;
        newObject.GetComponent <BoxCollider>().isTrigger = true;
        newObject.layer = LayerMask.NameToLayer("DesignObject");
        newObject.tag   = "Models";
    }
Example #24
0
        public QRResponse Read(byte[] fullQR)
        {
            // byte encoding flag and qr code size for normal patterns
            if (fullQR[0] != 0x40 ||    // byte encoding
                fullQR[1] != 0x26 ||    // QR size (12-bit), first 8-bits
                fullQR[2] >> 4 != 0x0C) // QR size (12-bit), last 4 bits
            {
                return(new QRResponse
                {
                    Success = false,
                    Message = Labels.OnlyNormalPatternsSupported
                });
            }

            // HACK!!!! to skip 2.5 bytes ( 2 bytes and 4 bits )
            string byteString = ByteArrayToHexString(fullQR);

            byteString = byteString.Substring(5) + "0";
            byte[] bytes = HexStringToByteArray(byteString);

            // extract necessary information
            var info = new DesignInfo
            {
                Title           = GetString(bytes, 0, 0x29),
                Author          = GetString(bytes, 0x2C, 0x3D),
                Town            = GetString(bytes, 0x42, 0x53),
                RawColorPalette = GetBytes(bytes, 0x58, 0x66),
                RawDesignData   = GetBytes(bytes, 0x6C, bytes.Length).Take(512).ToArray()
            };

            if (bytes[0x69] != 0x09)
            {
                return(new QRResponse
                {
                    Success = false,
                    Message = Labels.OnlyNormalPatternsSupported
                });
            }

            info.Bitmap = CreateBitmap(info.RawDesignData, info.RawColorPalette);

            return(new QRResponse
            {
                Success = true,
                Design = info
            });
        }
Example #25
0
 private void UpdateUICostETA()
 {
     if (this.Allshiptog)
     {
         this.App.GameDatabase.GetFleetInfo(this._ship.FleetID);
         int numships = this.App.GameDatabase.GetShipInfoByFleetID(this._ship.FleetID, false).ToList <ShipInfo>().Where <ShipInfo>((Func <ShipInfo, bool>)(x => x.DesignID == this._ship.DesignID)).Count <ShipInfo>();
         this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.RetrofitTimeID), Kerberos.Sots.StarFleet.StarFleet.GetTimeRequiredToRetrofit(this.App, this._ship, numships).ToString());
         DesignInfo newestRetrofitDesign = Kerberos.Sots.StarFleet.StarFleet.GetNewestRetrofitDesign(this._ship.DesignInfo, this.App.GameDatabase.GetVisibleDesignInfosForPlayer(this.App.LocalPlayer.ID));
         this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.RetrofitCostID), (Kerberos.Sots.StarFleet.StarFleet.CalculateRetrofitCost(this.App, this._ship.DesignInfo, newestRetrofitDesign) * numships).ToString());
     }
     else
     {
         this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.RetrofitTimeID), Kerberos.Sots.StarFleet.StarFleet.GetTimeRequiredToRetrofit(this.App, this._ship, 1).ToString());
         DesignInfo newestRetrofitDesign = Kerberos.Sots.StarFleet.StarFleet.GetNewestRetrofitDesign(this._ship.DesignInfo, this.App.GameDatabase.GetVisibleDesignInfosForPlayer(this.App.LocalPlayer.ID));
         this.App.UI.SetText(this.App.UI.Path(this.ID, RetrofitShipDialog.RetrofitCostID), Kerberos.Sots.StarFleet.StarFleet.CalculateRetrofitCost(this.App, this._ship.DesignInfo, newestRetrofitDesign).ToString());
     }
 }
Example #26
0
        protected override void OnPrepare(GameState prev, object[] stateParams)
        {
            if (this.App.GameDatabase == null)
            {
                this.App.NewGame();
                this._targetSystemID = this.App.GameDatabase.GetPlayerHomeworld(this.App.LocalPlayer.ID).SystemID;
                DesignInfo design = new DesignInfo();
                design.PlayerID          = this.App.LocalPlayer.ID;
                design.DesignSections    = new DesignSectionInfo[1];
                design.DesignSections[0] = new DesignSectionInfo()
                {
                    DesignInfo = design
                };
                design.DesignSections[0].FilePath = "factions\\" + this.App.LocalPlayer.Faction.Name + "\\sections\\sn_drone_satellite.section";
                int designID = this.App.GameDatabase.InsertDesignByDesignInfo(design);
                int id       = this.App.GameDatabase.InsertOrGetDefenseFleetInfo(this._targetSystemID, this.App.LocalPlayer.ID).ID;
                for (int index = 0; index < 5; ++index)
                {
                    this.App.GameDatabase.InsertShip(id, designID, null, (ShipParams)0, new int?(), 0);
                }
            }
            this._targetSystemID = ((IEnumerable <object>)stateParams).Count <object>() <= 0 ? this.App.GameDatabase.GetPlayerHomeworld(this.App.LocalPlayer.ID).SystemID : (int)stateParams[0];
            PlanetInfo planetInfo = this.App.GameDatabase.GetPlanetInfosOrbitingStar(this._targetSystemID).FirstOrDefault <PlanetInfo>();

            this._selectedPlanetID = planetInfo == null ? 0 : planetInfo.ID;
            base.OnPrepare(prev, new object[2]
            {
                (object)this._targetSystemID,
                (object)this._selectedPlanetID
            });
            this._pendingObjects = new List <IGameObject>();
            this._manager        = new DefenseManager(this.App);
            this._dmcrits        = new GameObjectSet(this.App);
            this.App.UI.LoadScreen("DefenseManager");
            this._fleetWidget = new FleetWidget(this.App, "DefenseManager.gameFleetList");
            bool enabled = true;

            if (((IEnumerable <object>)stateParams).Count <object>() >= 2)
            {
                enabled = (bool)stateParams[1];
            }
            this._fleetWidget.EnableRightClick = enabled;
            this._fleetWidget.SetEnabled(enabled);
            this._defenseWidget = new DefenseWidget(this.App, "defenseItemTray");
            this._fleetWidget.OnFleetsModified += new FleetWidget.FleetsModifiedDelegate(this.FleetsModified);
        }
Example #27
0
        public static Comet InitializeEncounter(GameDatabase gamedb, AssetDatabase assetdb)
        {
            if (assetdb.GetFaction("grandmenaces") == null)
            {
                return((Comet)null);
            }
            Comet comet = new Comet();

            comet.PlayerId = gamedb.InsertPlayer(nameof(Comet), "grandmenaces", new int?(), assetdb.RandomEncounterPrimaryColor, new Vector3(0.0f), "", "\\base\\factions\\grandmenaces\\avatars\\Comet_Avatar.tga", 0.0, 0, false, false, false, 0, AIDifficulty.Normal);
            DesignInfo design = new DesignInfo(comet.PlayerId, nameof(Comet), new string[1]
            {
                string.Format("factions\\{0}\\sections\\{1}", (object)"grandmenaces", (object)"Comet.section")
            });

            comet._cometDesignId = gamedb.InsertDesignByDesignInfo(design);
            return(comet);
        }
Example #28
0
        public FleetWidget.FilterShips LeftListFilter(ShipInfo ship, DesignInfo design)
        {
            FleetInfo fleetInfo = this._app.GameDatabase.GetFleetInfo(ship.FleetID);

            if ((fleetInfo != null ? fleetInfo.PlayerID : design.PlayerID) != this._app.LocalPlayer.ID)
            {
                return(FleetWidget.FilterShips.Ignore);
            }
            int num = 0;

            foreach (DesignSectionInfo designSection in design.DesignSections)
            {
                ShipSectionAsset shipSectionAsset = this._app.AssetDatabase.GetShipSectionAsset(designSection.FilePath);
                num += shipSectionAsset.RepairPoints;
            }
            return(num > 0 ? FleetWidget.FilterShips.Enable : FleetWidget.FilterShips.Ignore);
        }
Example #29
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);
        }
Example #30
0
        private void BuildProject(GameSession game, ref VonNeumannInfo vi)
        {
            int        num        = Math.Min(game.AssetDatabase.GlobalVonNeumannData.BuildRate, (int)((double)vi.Resources * (double)game.AssetDatabase.DefaultStratModifiers[StratModifiers.OverharvestModifier]));
            DesignInfo designInfo = game.GameDatabase.GetDesignInfo(vi.ProjectDesignId.Value);

            if (vi.ConstructionProgress + num > designInfo.ProductionCost || this.ForceVonNeumannAttackCycle)
            {
                vi.Resources -= (int)((double)(designInfo.ProductionCost - vi.ConstructionProgress) / (double)game.AssetDatabase.DefaultStratModifiers[StratModifiers.OverharvestModifier]);
                string name             = "";
                int?   projectDesignId1 = vi.ProjectDesignId;
                int    designId1        = VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.SeekerMothership].DesignId;
                if ((projectDesignId1.GetValueOrDefault() != designId1 ? 0 : (projectDesignId1.HasValue ? 1 : 0)) != 0)
                {
                    name = "Von Neumann Seeker";
                }
                else
                {
                    int?projectDesignId2 = vi.ProjectDesignId;
                    int designId2        = VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.BerserkerMothership].DesignId;
                    if ((projectDesignId2.GetValueOrDefault() != designId2 ? 0 : (projectDesignId2.HasValue ? 1 : 0)) != 0)
                    {
                        name = "Von Neumann Berserker";
                    }
                    else
                    {
                        int?projectDesignId3 = vi.ProjectDesignId;
                        int designId3        = VonNeumann.StaticShipDesigns[VonNeumann.VonNeumannShipDesigns.PlanetKiller].DesignId;
                        if ((projectDesignId3.GetValueOrDefault() != designId3 ? 0 : (projectDesignId3.HasValue ? 1 : 0)) != 0)
                        {
                            name = "Von Neumann System Killer";
                        }
                    }
                }
                int fleetID = game.GameDatabase.InsertFleet(this.PlayerId, 0, vi.SystemId, vi.SystemId, name, FleetType.FL_NORMAL);
                game.GameDatabase.InsertShip(fleetID, vi.ProjectDesignId.Value, null, (ShipParams)0, new int?(), 0);
                vi.ConstructionProgress = 0;
                vi.ProjectDesignId      = new int?();
            }
            else
            {
                vi.Resources            -= (int)((double)game.AssetDatabase.GlobalVonNeumannData.BuildRate / (double)game.AssetDatabase.DefaultStratModifiers[StratModifiers.OverharvestModifier]);
                vi.ConstructionProgress += num;
            }
        }
Example #31
0
        public bool Generate()
        {
            Initialize();

            designInfo = new DesignInfo[designs.Count];

            designCount = 0;
            foreach (Level design in designs)
            {
                // Extract design data.
                Array2D<Cell> designData = new Array2D<Cell>(design.Data);
                if (useEntireLevel)
                {
                    designData.Replace(Cell.Outside, Cell.Wall);
                }

                // Create a map of all squares that cannot be altered, initialized to false.
                Array2D<bool> designFixed = new Array2D<bool>(designData.Height, designData.Width);
                Coordinate2D sokobanCoord = Coordinate2D.Undefined;
                int designBoxes = 0;
                foreach (Coordinate2D coord in designData.NonPerimeterCoordinates)
                {
                    if (clearDesign)
                    {
                        if (designData[coord] != Cell.Wall)
                        {
                            designData[coord] = Cell.Empty;
                        }
                    }
                    if (designData[coord] != Cell.Undefined)
                    {
                        // Record squares that should not be changed.
                        designFixed[coord] = true;
                    }
                    if (Level.IsSokoban(designData[coord]))
                    {
                        // Remove sokoban if present but record its coordinate.
                        designData[coord] &= ~Cell.Sokoban;
                        sokobanCoord = coord;
                    }
                    if (Level.IsBox(designData[coord]))
                    {
                        // Count boxes included in design.
                        designBoxes++;
                    }
                }

                // Store in design array.
                DesignInfo info = new DesignInfo();
                info.Data = designData;
                info.Fixed = designFixed;
                info.SokobanCoordinate = sokobanCoord;
                info.Boxes = designBoxes;
                designInfo[designCount] = info;
                designCount++;
            }

            // Now generate levels.
            if (threads == 1)
            {
                return GenerateLevels();
            }
            return MultiThreadedGenerateLevels();
        }
Example #32
0
        public static void DebugDesign(AssetDatabase assetDatabase, GameDatabase gameDatabase, DesignInfo designIn)
        {
            try
            {

            }
            catch (Exception ex)
            {
                SotsosLog("exception: {0}",ex.Message);
            }
        }
Example #33
0
        public static void CalculateRetrofitCost(App App, DesignInfo olddesign, DesignInfo RetrofitDesign)
        {
            try
            {
                //

                //Debug.WriteLine("cost is {0}", );
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }