Esempio n. 1
0
        // Update is called once per frame
        private void Update()
        {
            if (!MapOptions.MadeChoise && !Game.devMode)
            {
                return;
            }
            //starts loading thread
            if (game == null)// && Input.GetKeyUp(KeyCode.Backspace))
            {
                LoadGame();
            }
            else
#if UNITY_WEBGL
            if (!gameLoadingIsFinished)  // non multi-threading
#else
            if (game.IsDone && !gameLoadingIsFinished)
#endif
            {
                OnGameLoaded();
            }
#if !UNITY_WEBGL
            else     // multi-threading
            {
                loadingPanel.updateStatus(game.getStatus());
            }
#endif
            if (gameLoadingIsFinished)
            {
                UpdateMapTooltip();

                if (World.Get.IsRunning && !MessagePanel.IsOpenAny())
                {
                    if (Game.isPlayerSurrended() || !Game.Player.IsAlive || Time.time - previousFrameTime >= simulationSpeedLimit)
                    {
                        World.simulate();
                        //Unit.RedrawAll();

                        previousFrameTime = Time.time;
                        //refreshAllActive();
                        UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
                    }
                }

                if (Game.provincesToRedrawArmies.Count > 0)
                {
                    Unit.RedrawAll();
                }

                if (Input.GetKeyDown(KeyCode.Return)) // enter key
                {
                    CloseToppestPanel();
                }

                DrawFogOfWar();

                //if (Message.HasUnshownMessages())
                //    MessagePanel.Instance.ShowMessageBox(LinksManager.Get.CameraLayerCanvas, this);
            }
        }
Esempio n. 2
0
 public void onDestroyClick()
 {
     //if (shownFactory.whyCantDestroyFactory() == null)
     {
         factory.destroyImmediately();
         //MainCamera.refreshAllActive();
         UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
     }
 }
Esempio n. 3
0
 private void changeReformValue()
 {
     if (!(ReferenceEquals(selectedReformType, null)) && selectedReformValue != null && selectedReformType != selectedReformValue)
     {
         selectedReformType.SetValue(selectedReformValue);
         //MainCamera.refreshAllActive();
         UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
     }
 }
Esempio n. 4
0
        //public void findNoonesEterprises()
        //{
        //    foreach (var item in Province.allProvinces)
        //    {
        //        foreach (var fact in item.allFactories)
        //        {
        //            if (fact.getOwner() == null)
        //                new Message("", "Null owner in " + item + " " + fact, "Got it");
        //            else
        //            if (fact.getOwner() is PopUnit)
        //            {
        //                var owner = fact.getOwner() as PopUnit;
        //                if (!owner.IsAlive)
        //                    new Message("", "Dead pop owner in " + item + " " + fact, "Got it"); ;
        //            }
        //            else
        //            if (fact.getOwner() is Country)
        //            {
        //                var c = fact.getOwner() as Country;
        //                if (!c.IsAlive)
        //                    new Message("", "Dead country owner in " + item + " " + fact, "Got it"); ;
        //            }
        //        }
        //    }
        //}
        public void onTakeLoan()
        {
            Money loan = Game.Player.Bank.HowBigCreditCanGive(Game.Player).Copy();

            if (loanLimit.value != 1f)
            {
                loan.Multiply((decimal)loanLimit.value);
            }
            Game.Player.Bank.GiveCredit(Game.Player, loan);
            //MainCamera.refreshAllActive();
            UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
        }
Esempio n. 5
0
 public void onUpgradeClick()
 {
     //if (shownFactory.getConditionsForFactoryUpgradeFast(Game.player))
     {
         factory.upgrade(Game.Player);
         //MainCamera.refreshAllActive();
         UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
         if (Game.Player != factory.Country)
         {
             factory.Country.Diplomacy.ChangeRelation(Game.Player, Options.RelationImpactOnGovernmentInvestment.get());
         }
     }
 }
Esempio n. 6
0
        public void onGrantIndependenceClick()
        {
            Country whomGrant = Game.selectedProvince.AllCores().Where(x => x != Game.Player && !x.IsAlive).Random();

            if (whomGrant == null)
            {
                whomGrant = Game.selectedProvince.AllCores().Where(x => x != Game.Player).Random();
            }

            whomGrant.onGrantedProvince(Game.selectedProvince);
            //MainCamera.refreshAllActive();
            UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
        }
Esempio n. 7
0
 public void onPutInDeposit()
 {
     if (loanLimit.value == 1f)//.Copy()
     {
         Game.Player.Bank.ReceiveMoney(Game.Player, Game.Player.Cash);
     }
     else
     {
         Game.Player.Bank.ReceiveMoney(Game.Player, Game.Player.Cash.Copy().Multiply((decimal)depositLimit.value));
     }
     //MainCamera.refreshAllActive();
     UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
 }
Esempio n. 8
0
        public void onBuildClick()
        {
            bool buildSomething = false;
            Factory factory;
            if (Economy.isMarket.checkIfTrue(Game.Player))
            {
                MoneyView cost = selectedFactoryType.GetBuildCost(Game.Player.market);
                if (Game.Player.CanPay(cost))
                {
                    factory = Game.selectedProvince.BuildFactory(Game.Player, selectedFactoryType, cost);
                    Game.Player.PayWithoutRecord(factory, cost, Register.Account.Construction);
                    buildSomething = true;
                    MainCamera.factoryPanel.show(factory);
                    if (Game.Player != factory.Country)
                        factory.Country.Diplomacy.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, Game.Player.market.getCost(resourceToBuild));
                    Game.Player.countryStorageSet.Subtract(needFood);
                    buildSomething = true;
                    MainCamera.factoryPanel.show(factory);
                    if (Game.Player != factory.Country)
                        factory.Country.Diplomacy.ChangeRelation(Game.Player, Options.RelationImpactOnGovernmentInvestment.get());
                }
            }

            if (buildSomething)
            {
                selectedFactoryType = null;
                UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
                //MainCamera.refreshAllActive();
            }
        }
Esempio n. 9
0
 public void onNationalizeClick()
 {
     Game.Player.Nationilize(factory);
     //MainCamera.refreshAllActive();
     UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
 }
Esempio n. 10
0
 public void OnBuyClick()
 {
     factory.ownership.BuyStandardShare(Game.Player);
     UIEvents.RiseSomethingVisibleToPlayerChangedInWorld(EventArgs.Empty, this);
     //MainCamera.refreshAllActive();
 }