コード例 #1
0
ファイル: BuildPanel.cs プロジェクト: gkjolin/Prosperity-Wars
        public override void Refresh()
        {
            if (Game.previoslySelectedProvince != Game.selectedProvince)
            {
                selectFactoryType(null);
            }

            table.Refresh();
            if (selectedFactoryType != null)
            {
                sb.Clear();
                sb.Append("Build ").Append(selectedFactoryType);
                sb.Append("\n\nResources to build: ").Append(selectedFactoryType.GetBuildNeeds().getString(", "));
                sb.Append(".");
                if (Game.Player.economy.getValue() != Economy.PlannedEconomy)
                {
                    var cost = selectedFactoryType.GetBuildCost();
                    sb.Append(" cost: ").Append(cost);
                }
                sb.Append("\nEveryday resource input: ");
                if (selectedFactoryType.resourceInput == null)
                {
                    sb.Append("none");
                }
                else
                {
                    sb.Append(selectedFactoryType.resourceInput);
                }

                descriptionText.text = sb.ToString();

                // fix that duplicate:
                buildButton.interactable = selectedFactoryType.conditionsBuildThis.isAllTrue(Game.Player, Game.selectedProvince, out buildButton.GetComponent <ToolTipHandler>().text);
                if (!selectedFactoryType.canBuildNewFactory(Game.selectedProvince, Game.Player))
                {
                    buildButton.interactable = false;
                }
                if (buildButton.interactable)
                {
                    buildButton.GetComponentInChildren <Text>().text = "Build " + selectedFactoryType;
                }
            }
            else
            {
                buildButton.interactable = false;
                buildButton.GetComponentInChildren <Text>().text = "Select building";
                if (Game.selectedProvince == null)
                {
                    descriptionText.text = "Select province where to build";
                }
                else if (ProductionType.getAllInventedFactories(Game.Player).Where(x => x.canBuildNewFactory(Game.selectedProvince, Game.Player)).Count() == 0)
                {
                    descriptionText.text = "Nothing to build now";
                }
                else
                {
                    descriptionText.text = "Select building from left";
                }
            }
        }
コード例 #2
0
ファイル: Province.cs プロジェクト: nasa03/Prosperity-Wars
        /// <summary>
        /// Don't use it for aristocrats
        /// Doesn't check if enterprise is invented, also doesn't check
        /// conNotLForNotCountry, conAllowsForeignInvestments, conHaveMoneyOrResourcesToUpgrade
        /// </summary>
        public IEnumerable <IInvestable> AllInvestmentProjects()//Agent investor
        {
            var upgradeInvestments = AllFactories.Where(x =>
                                                        Factory.conditionsUpgrade.isAllTrue(null, x) //investor
                                                                                                     //x.Province.CanUpgradeFactory(x.Type, investor)
                                                        && x.GetWorkForceFulFilling().isBiggerThan(Options.minFactoryWorkforceFulfillingToInvest)
                                                        );

            foreach (var item in upgradeInvestments)
            {
                yield return(item);
            }

            var buildInvestments = ProductionType.getAllInventedByAnyoneFactories().Where(x => x.canBuildNewFactory(this, null)); //investor

            foreach (var item in buildInvestments)
            {
                yield return(new NewFactoryProject(this, item));
            }

            // Don't need extra check (notLf, allowsForeignInvestments) in 2 next circle.
            //Because AI Countries use it only for themselves, Aristocrats use it only in won province
            foreach (var item in GetSales())
            {
                yield return(item);
            }

            var reopenEnterprises = AllFactories.Where(x => x.IsClosed && !x.isBuilding());

            foreach (var item in reopenEnterprises)
            {
                yield return(item);
            }
        }
コード例 #3
0
 protected SimpleProduction(ProductionType type, Province province) : base(province)
 {
     this.type = type;
     //gainGoodsThisTurn = new Storage(this.Type.basicProduction.Product);
     //storage = new Storage(this.Type.basicProduction.Product);
     //sentToMarket = new Storage(this.Type.basicProduction.Product);
     changeProductionType(this.type.basicProduction.Product);
 }
コード例 #4
0
ファイル: Province.cs プロジェクト: nasa03/Prosperity-Wars
 public Factory findFactory(ProductionType proposition)
 {
     foreach (Factory f in allFactories)
     {
         if (f.Type == proposition)
         {
             return(f);
         }
     }
     return(null);
 }
コード例 #5
0
ファイル: Province.cs プロジェクト: nasa03/Prosperity-Wars
 /// <summary>
 /// check type for null outside
 /// </summary>
 public bool hasFactory(ProductionType type)
 {
     foreach (Factory f in allFactories)
     {
         if (f.Type == type)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #6
0
ファイル: Province.cs プロジェクト: nasa03/Prosperity-Wars
 public Factory BuildFactory(IShareOwner investor, ProductionType type, MoneyView cost, bool instantBuild = false)
 {
     //if (getAllFactories().Any(x => x.Type == type)) //todo temporally
     //{
     //    throw new Exception("Can't have 2 same factory types");
     //}
     //else
     {
         var res = new Factory(this, investor, type, cost, instantBuild);
         allFactories.Add(res);
         return(res);
     }
 }
コード例 #7
0
ファイル: Science.cs プロジェクト: nasa03/Prosperity-Wars
 public bool IsInventedArtisanship(ProductionType production)
 {
     if (!IsInvented(production.basicProduction.Product) ||
         (production.basicProduction.Product == Product.Cattle && !IsInvented(Invention.Domestication))
         )
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #8
0
ファイル: Province.cs プロジェクト: nasa03/Prosperity-Wars
        /// <summary>
        ///  If byWhom == Game.Player checks money/resources availability. If not then not.
        /// </summary>
        public bool CanUpgradeFactory(ProductionType type, Agent byWhom)
        {
            var factory = findFactory(type);

            if (factory == null)
            {
                return(false);
            }
            else
            {
                return(Factory.conditionsUpgrade.isAllTrue(byWhom, factory));
            }
        }
コード例 #9
0
ファイル: Science.cs プロジェクト: nasa03/Prosperity-Wars
        public bool IsInventedFactory(ProductionType production)
        {
            return(IsInvented(production.basicProduction.Product) &&
                   production.AllRequiredInventions.All(x => IsInvented(x))); // returns true is requirements are empty


            // why it's not invented
            //if (!IsInventedArtisanship(production)
            //     || production.IsResourceProcessing() && !IsInvented(Invention.Manufactures)
            //     || production == ProductionType.WeaverFactory && !IsInvented(Invention.JohnKayFlyingshuttle)
            // )
            //    return false;
            //else
            //    return true;
        }
コード例 #10
0
        private void changeProductionType()
        {
            var newProductionType = ProductionType.getAllInventedArtisanships(Country).
                                    Where(x => !x.isResourceGathering() && x.basicProduction.Product != Product.Education).Where(x => x.getPossibleProfit().isNotZero()).MaxBy(x => x.getPossibleProfit().Get());

            if (newProductionType != null)
            {
                if (artisansProduction == null ||
                    (artisansProduction != null && newProductionType != artisansProduction.Type))

                {
                    artisansProduction = new ArtisanProduction(newProductionType, Province, this);
                    base.changeProductionType(artisansProduction.Type.basicProduction.Product);
                }
            }
        }
コード例 #11
0
ファイル: BuildPanel.cs プロジェクト: gkjolin/Prosperity-Wars
        public void onBuildClick()
        {
            bool    buildSomething = false;
            Factory factory;

            if (Economy.isMarket.checkIfTrue(Game.Player))
            {
                MoneyView cost = selectedFactoryType.GetBuildCost();
                if (Game.Player.CanPay(cost))
                {
                    factory = Game.selectedProvince.BuildFactory(Game.Player, selectedFactoryType, cost);
                    Game.Player.PayWithoutRecord(factory, cost);
                    buildSomething = true;
                    MainCamera.factoryPanel.show(factory);
                    if (Game.Player != factory.Country)
                    {
                        factory.Country.changeRelation(Game.Player, Options.RelationImpactOnGovernmentInvestment.get());
                    }
                }
            }
            else // non market
            {
                //todo remove grain connection
                var     resourceToBuild = selectedFactoryType.GetBuildNeeds();
                Storage needFood        = resourceToBuild.GetFirstSubstituteStorage(Product.Grain);
                if (Game.Player.countryStorageSet.has(needFood))
                {
                    factory = Game.selectedProvince.BuildFactory(Game.Player, selectedFactoryType, World.market.getCost(resourceToBuild));
                    Game.Player.countryStorageSet.Subtract(needFood);
                    buildSomething = true;
                    MainCamera.factoryPanel.show(factory);
                    if (Game.Player != factory.Country)
                    {
                        factory.Country.changeRelation(Game.Player, Options.RelationImpactOnGovernmentInvestment.get());
                    }
                }
            }

            if (buildSomething)
            {
                selectedFactoryType = null;
                MainCamera.refreshAllActive();
            }
        }
コード例 #12
0
        //bool isStorable()
        //{
        //    return storable;
        //}
        //void setStorable(bool isStorable)
        //{
        //    storable = isStorable;
        //}

        internal Value getDefaultPrice()
        {
            if (isResource())
            {
                return(defaultPrice.Copy().Multiply(Options.defaultPriceLimitMultiplier));
            }
            else
            {
                var type = ProductionType.whoCanProduce(this);
                if (type == null)
                {
                    return(defaultPrice.Copy().Multiply(Options.defaultPriceLimitMultiplier));
                }
                else
                {
                    Value res = Game.market.getCost(type.resourceInput);
                    res.Multiply(Options.defaultPriceLimitMultiplier);
                    res.Divide(type.basicProduction);
                    return(res);
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Don't call it directly
        /// </summary>

        public Factory(Province province, IShareOwner investor, ProductionType type, ReadOnlyValue cost)
            : base(type, province)
        {
            //this.buildByPlannedEconomy = buildByPlannedEconomy;
            ownership = new Owners(this);
            if (investor != null) // that mean that factory is a fake
            {
                currentInvestor = investor;
                //assuming this is level 0 building
                constructionNeeds = new StorageSet(Type.GetBuildNeeds());

                ownership.Add(investor, cost);

                salary.set(province.getLocalMinSalary());
                if (Country.economy.getValue() == Economy.PlannedEconomy)
                {
                    setPriorityAutoWithPlannedEconomy();
                }
                //else
                //    Debug.Log(investor + " invested " + cost + " in building new " + this);
            }
        }
コード例 #14
0
ファイル: World.cs プロジェクト: nasa03/Prosperity-Wars
        private static void IndustrialStart()
        {
            foreach (var item in AllExistingCountries())
            {
                item.Science.Invent(Invention.Universities);
                item.Science.Invent(Invention.Manufactures);
                item.Science.Invent(Invention.Metal);
                item.Science.Invent(Invention.Gunpowder);



                var resurceEnterprise = ProductionType.whoCanProduce(item.Capital.getResource());
                var aristocrats       = item.Capital.AllPops.Where(x => x.Type == PopType.Aristocrats).First() as Aristocrats;

                if (resurceEnterprise != null && item.Science.IsInvented(resurceEnterprise.basicProduction.Product))
                {
                    item.Capital.BuildFactory(aristocrats, resurceEnterprise, resurceEnterprise.GetBuildCost(item.market), true);
                }

                var processingEnterprises = ProductionType.getAllInventedFactories(item).Where(x => x.hasInput() || x == ProductionType.University);

                var capitalists = item.Capital.AllPops.Where(x => x.Type == PopType.Capitalists).First() as Capitalists;
                for (int i = 0; i < 3; i++)
                {
                    var processingEnterprise = processingEnterprises.Random();
                    if (processingEnterprise.canBuildNewFactory(item.Capital, capitalists))
                    {
                        item.Capital.BuildFactory(capitalists, processingEnterprise, processingEnterprise.GetBuildCost(item.market), true);
                    }
                }

                //ProductionType.getAllInventedFactories(Country).Where(x=>x.canBuildNewFactory);
                //var res = new Factory(this, investor, type, cost);
                //allFactories.Add(res);
            }
        }
コード例 #15
0
        /// <summary>
        /// Basic constructor for resource getting FactoryType
        /// </summary>
        internal ProductionType(string name, Storage basicProduction, bool shaft)
        {
            //var product = basicProduction.Product;
            //if (product == Product.Cattle|| product == Product.Cotton || product == Product.Fish
            //    || product == Product.Fruit|| product == Product.Grain
            //    || product == Product.Tobacco || product == Product.Wood )
            //    _isRural = true;

            this.name  = name;
            nameWeight = name.GetWeight();
            if (name == "Gold pit")
            {
                GoldMine = this;
            }
            if (name == "Furniture factory")
            {
                Furniture = this;
            }
            if (name == "Metal pit")
            {
                MetalDigging = this;
            }
            if (name == "Metal smelter")
            {
                MetalSmelter = this;
            }
            if (name == "Barnyard")
            {
                Barnyard = this;
            }
            allTypes.Add(this);
            this.basicProduction = basicProduction;

            enoughMoneyOrResourcesToBuild = new Condition(
                delegate(object forWhom)
            {
                var agent = forWhom as Agent;
                if (agent.Country.economy.getValue() == Economy.PlannedEconomy)
                {
                    return(agent.Country.countryStorageSet.has(GetBuildNeeds()));
                }
                else
                {
                    var cost = GetBuildCost();
                    return(agent.CanPay(cost));
                }
            },
                delegate
            {
                var sb   = new StringBuilder();
                var cost = GetBuildCost();
                sb.Append("Have ").Append(cost).Append(" coins");
                sb.Append(" or (with ").Append(Economy.PlannedEconomy).Append(") have ").Append(GetBuildNeeds().getString(", "));
                return(sb.ToString());
            }, true);

            // Using: Country () , province, this <FactoryType>
            // used in BuildPanel only, only for Game.Player
            // Should be: de-facto Country, Investor, this <FactoryType> (change Economy.isNot..)
            // Ideally: Agent, FactoryProject
            // or put it in FactoryProject
            conditionsBuildThis = new DoubleConditionsList(new List <Condition> {
                Economy.isNotLF, Economy.isNotInterventionism, enoughMoneyOrResourcesToBuild,
                allowsForeignInvestments
            });                             //
            this.shaft = shaft;
        }
コード例 #16
0
        static ProductionType()
        {
            new ProductionType("Forestry", new Storage(Product.Wood, 2f), false);
            new ProductionType("Gold pit", new Storage(Product.Gold, 2f * Options.goldToCoinsConvert), true);
            new ProductionType("Metal pit", new Storage(Product.MetalOre, 2f), true);
            new ProductionType("Coal pit", new Storage(Product.Coal, 6f), true);
            new ProductionType("Cotton farm", new Storage(Product.Cotton, 2f), false);
            new ProductionType("Quarry", new Storage(Product.Stone, 2f), true);
            new ProductionType("Orchard", new Storage(Product.Fruit, 2f), false);
            new ProductionType("Fishery", new Storage(Product.Fish, 2f), false);
            new ProductionType("Tobacco farm", new Storage(Product.Tobacco, 2f), false);

            new ProductionType("Oil rig", new Storage(Product.Oil, 2f), true);
            new ProductionType("Rubber plantation", new Storage(Product.Rubber, 1f), false);

            StorageSet resourceInput = new StorageSet();

            resourceInput.Set(new Storage(Product.Grain, 1f));
            new ProductionType("Barnyard", new Storage(Product.Cattle, 2f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Lumber, 1f));
            new ProductionType("Furniture factory", new Storage(Product.Furniture, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Wood, 1f));
            new ProductionType("Sawmill", new Storage(Product.Lumber, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Fuel, 0.5f));
            resourceInput.Set(new Storage(Product.MetalOre, 2f));
            new ProductionType("Metal smelter", new Storage(Product.Metal, 8f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Fibers, 1f));
            new ProductionType("Weaver factory", new Storage(Product.Clothes, 4f), resourceInput);

            //resourceInput = new StorageSet();
            //resourceInput.Set(new Storage(Product.Fuel, 0.5f));
            //resourceInput.Set(new Storage(Product.Stone, 2f));
            //new ProductionType("Cement factory", new Storage(Product.Cement, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Sugar, 1f));
            new ProductionType("Distillery", new Storage(Product.Liquor, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Metal, 1f));
            new ProductionType("Smithery", new Storage(Product.ColdArms, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Stone, 1f));
            resourceInput.Set(new Storage(Product.Metal, 1f));
            new ProductionType("Ammunition factory", new Storage(Product.Ammunition, 8f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Lumber, 1f));
            resourceInput.Set(new Storage(Product.Metal, 1f));
            new ProductionType("Firearms factory", new Storage(Product.Firearms, 8f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Lumber, 1f));
            resourceInput.Set(new Storage(Product.Metal, 1f));
            new ProductionType("Artillery factory", new Storage(Product.Artillery, 8f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Oil, 1f));
            new ProductionType("Oil refinery", new Storage(Product.MotorFuel, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Metal, 1f));
            new ProductionType("Machinery factory", new Storage(Product.Machinery, 4f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Machinery, 1f));
            resourceInput.Set(new Storage(Product.Metal, 1f));
            resourceInput.Set(new Storage(Product.Rubber, 1f));
            new ProductionType("Car factory", new Storage(Product.Cars, 12f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Machinery, 1f));
            resourceInput.Set(new Storage(Product.Metal, 1f));
            resourceInput.Set(new Storage(Product.Artillery, 1f));
            new ProductionType("Tank factory", new Storage(Product.Tanks, 12f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Lumber, 1f));
            resourceInput.Set(new Storage(Product.Metal, 1f));
            resourceInput.Set(new Storage(Product.Machinery, 1f));
            new ProductionType("Airplane factory", new Storage(Product.Airplanes, 12f), resourceInput);

            resourceInput = new StorageSet();
            resourceInput.Set(new Storage(Product.Metal, 1f));
            resourceInput.Set(new Storage(Product.Oil, 1f));
            resourceInput.Set(new Storage(Product.Rubber, 1f));
            new ProductionType("Electronics factory", new Storage(Product.Electronics, 12f), resourceInput);

            University = new ProductionType("University", new Storage(Product.Education, 4f), new StorageSet());
        }
コード例 #17
0
 public NewFactoryProject(Province province, ProductionType type)
 {
     Type          = type;
     this.province = province;
 }
コード例 #18
0
ファイル: BuildPanel.cs プロジェクト: gkjolin/Prosperity-Wars
 public void selectFactoryType(ProductionType newSelection)
 {
     selectedFactoryType = newSelection;
 }
コード例 #19
0
 public ArtisanProduction(ProductionType type, Province province, Artisans artisan) : base(type, province)
 {
     this.artisan = artisan;
 }
コード例 #20
0
ファイル: BuildPanel.cs プロジェクト: gkjolin/Prosperity-Wars
 public override void Show()
 {
     selectedFactoryType = null; // changed province
     base.Show();
 }