Skip to content

Commit 8609933

Browse files
committed
returned getMinimalMoneyToBuild, added goto button in Diplomacy
1 parent c397180 commit 8609933

File tree

10 files changed

+49
-25
lines changed

10 files changed

+49
-25
lines changed

Assets/ES-base.unity

2.18 KB
Binary file not shown.

Assets/code/Logic/EntryPoint/MainCamera.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ void Update()
9292
Game.setUnityAPI();
9393

9494
myCamera = this.GetComponent<Camera>();
95-
gameObject.transform.position = new Vector3(Game.Player.getCapital().getPosition().x,
96-
Game.Player.getCapital().getPosition().y, gameObject.transform.position.z);
95+
focusCamera(Game.Player.getCapital());
96+
//gameObject.transform.position = new Vector3(Game.Player.getCapital().getPosition().x,
97+
// Game.Player.getCapital().getPosition().y, gameObject.transform.position.z);
9798
loadingPanel.hide();
9899
topPanel.show();
99100
bottomPanel.show();
@@ -256,4 +257,10 @@ void showMessageBox()
256257
mesPanel.show(mes);
257258
}
258259
// This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
260+
public void focusCamera(Province province)
261+
{
262+
gameObject.transform.position = new Vector3(province.getPosition().x,
263+
province.getPosition().y, gameObject.transform.position.z);
264+
}
265+
259266
}

Assets/code/Logic/Factory.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ internal Factory(Province province, Agent factoryOwner, FactoryType type) : base
166166
if (getCountry().economy.getValue() == Economy.PlannedEconomy)
167167
setPriorityAutoWithPlannedEconomy();
168168
}
169+
//internal Value getMinimalMoneyForUpgrade()
170+
//{
171+
// return Game.market.getCost(getUpgradeNeeds());
172+
//}
169173
internal StorageSet getUpgradeNeeds()
170174
{
171175
if (getLevel() < Options.FactoryMediumTierLevels)
@@ -422,7 +426,7 @@ internal Procent getMargin()
422426
}
423427
internal Value getReopenCost()
424428
{
425-
return new Value(Options.factoryMoneyReservPerLevel);
429+
return new Value(Options.factoryMoneyReservePerLevel);
426430

427431
}
428432
//internal Value getUpgradeCost()
@@ -628,7 +632,7 @@ internal bool isToRemove()
628632

629633
float wantsMinMoneyReserv()
630634
{
631-
return getExpences() * Factory.xMoneyReservForResources + Options.factoryMoneyReservPerLevel * level;
635+
return getExpences() * Factory.xMoneyReservForResources + Options.factoryMoneyReservePerLevel * level;
632636
}
633637
public void simulateClosing()
634638
{

Assets/code/Logic/FactoryType.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,18 @@ internal FactoryType(string name, Storage basicProduction, bool shaft)
154154
}
155155
else
156156
{
157-
Value cost = Game.market.getCost(this.getBuildNeeds());
158-
cost.add(Options.factoryMoneyReservPerLevel);
157+
//Value cost = Game.market.getCost(this.getBuildNeeds());
158+
//cost.add(Options.factoryMoneyReservPerLevel);
159+
Value cost = getMinimalMoneyToBuild();
159160
return agent.canPay(cost);
160161
}
161162
},
162163
delegate
163164
{
164165
var sb = new StringBuilder();
165-
Value cost = Game.market.getCost(this.getBuildNeeds());
166-
cost.add(Options.factoryMoneyReservPerLevel);
166+
//Value cost = Game.market.getCost(this.getBuildNeeds());
167+
//cost.add(Options.factoryMoneyReservPerLevel);
168+
Value cost = getMinimalMoneyToBuild();
167169
sb.Append("Have ").Append(cost).Append(" coins");
168170
sb.Append(" or (with ").Append(Economy.PlannedEconomy).Append(") have ").Append(this.getBuildNeeds());
169171
return sb.ToString();
@@ -202,12 +204,12 @@ public static IEnumerable<FactoryType> getNonResourceTypes(Country country)
202204
yield return next;
203205
}
204206

205-
//internal Value getBuildCost()
206-
//{
207-
// Value result = Game.market.getCost(getBuildNeeds());
208-
// result.add(Options.factoryMoneyReservPerLevel);
209-
// return result;
210-
//}
207+
internal Value getMinimalMoneyToBuild()
208+
{
209+
Value result = Game.market.getCost(getBuildNeeds());
210+
result.add(Options.factoryMoneyReservePerLevel);
211+
return result;
212+
}
211213
internal StorageSet getBuildNeeds()
212214
{
213215
//return new Storage(Product.Food, 40f);
@@ -299,7 +301,7 @@ internal Value getPossibleProfit(Province province)
299301
}
300302
internal Procent getPossibleMargin(Province province)
301303
{
302-
return Procent.makeProcent(getPossibleProfit(province), Game.market.getCost(this.getBuildNeeds()));
304+
return Procent.makeProcent(getPossibleProfit(province), getMinimalMoneyToBuild());
303305
}
304306
//internal bool canBuildNewFactory(FactoryType type)
305307
//{

Assets/code/Logic/NonAbstractPopUnit.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,9 @@ internal override void invest()
488488
if (proposition != null && proposition.canBuildNewFactory(getProvince()) &&
489489
(getProvince().getUnemployedWorkers() > Options.minUnemploymentToBuldFactory || getProvince().getAverageFactoryWorkforceFullfilling() > Options.minFactoryWorkforceFullfillingToBuildNew))
490490
{
491-
Value buildCost = Game.market.getCost(proposition.getBuildNeeds());
492-
buildCost.add(Options.factoryMoneyReservPerLevel);
491+
//Value buildCost = Game.market.getCost(proposition.getBuildNeeds());
492+
//buildCost.add(Options.factoryMoneyReservePerLevel);
493+
Value buildCost = proposition.getMinimalMoneyToBuild();
493494
if (canPay(buildCost))
494495
{
495496
Factory found = new Factory(getProvince(), this, proposition);

Assets/code/Logic/Options.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static class Options
5252
internal static readonly int minDaysBeforeSalaryCut = 2;
5353
internal static readonly int howOftenCheckForFactoryReopenning = 30;
5454

55-
internal static readonly float factoryMoneyReservPerLevel = 20f;
55+
internal static readonly float factoryMoneyReservePerLevel = 20f;
5656
internal static readonly float minMarginToRiseSalary = 0.01f;
5757
internal static readonly float factoryEachLevelEfficiencyBonus = 0.05f;
5858
//internal static float factoryHaveResourceInProvinceBonus = 0.2f;

Assets/code/PanelTables/BuildPanelTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ override protected void AddButtons()
4646
////Adding cost
4747
//if (Game.player.isInvented(InventionType.capitalism))
4848
if (Economy.isMarket.checkIftrue(Game.Player))
49-
AddButton(Game.market.getCost(next.getBuildNeeds()).ToString(), next);
49+
AddButton(next.getMinimalMoneyToBuild().ToString(), next);
5050
else
5151
AddButton(next.getBuildNeeds().ToString(), next);
5252

Assets/code/Panels/BuildPanel.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BuildPanel : DragPanel
1616
void Start()
1717
{
1818
MainCamera.buildPanel = this;
19-
GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, MainCamera.topPanel.GetComponent<RectTransform>().rect.height * -1f);
19+
GetComponent<RectTransform>().anchoredPosition = new Vector2(50f, -100f);
2020
buildButton.interactable = false;
2121
hide();
2222
}
@@ -33,13 +33,14 @@ public void onBuildClick()
3333
//if (Game.player.economy.allowsFactoryBuildingByGovernment())
3434
{
3535
bool buildSomething = false;
36-
var resourceToBuild = selectedFactoryType.getBuildNeeds();
36+
3737
if (Economy.isMarket.checkIftrue(Game.Player))
3838
//if (Game.player.economy.status == Economy.StateCapitalism)
3939
//have money /resource
4040
{
41-
Value cost = Game.market.getCost(resourceToBuild);
42-
cost.add(Options.factoryMoneyReservPerLevel);
41+
//Value cost = Game.market.getCost(resourceToBuild);
42+
//cost.add(Options.factoryMoneyReservePerLevel);
43+
Value cost = selectedFactoryType.getMinimalMoneyToBuild();
4344
if (Game.Player.canPay(cost))
4445
{
4546
var factory = new Factory(Game.selectedProvince, Game.Player, selectedFactoryType);
@@ -52,6 +53,7 @@ public void onBuildClick()
5253
else // non market
5354
{
5455
//todo remove grain connection
56+
var resourceToBuild = selectedFactoryType.getBuildNeeds();
5557
Storage needFood = resourceToBuild.getFirstStorage(Product.Grain);
5658
if (Game.Player.countryStorageSet.has(needFood))
5759
{
@@ -82,7 +84,7 @@ public void refresh()
8284
{
8385
sb.Clear();
8486
sb.Append("Build ").Append(selectedFactoryType);
85-
var cost = Game.market.getCost(selectedFactoryType.getBuildNeeds());
87+
var cost =selectedFactoryType.getMinimalMoneyToBuild();
8688
sb.Append("\n\nResources to build: ").Append(selectedFactoryType.getBuildNeeds()).Append(" cost: ").Append(cost);
8789
sb.Append("\nEveryday resource input: ").Append(selectedFactoryType.resourceInput);
8890

Assets/code/Panels/DiplomacyPanel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class DiplomacyPanel : DragPanel
88
{
99
public Text captionText, generalText;
1010
public Button giveControlToAi, giveControlToPlayer;
11+
public MainCamera mainCamera;
1112
Country selectedCountry;
1213
StringBuilder sb = new StringBuilder();
1314
// Use this for initialization
@@ -79,6 +80,11 @@ public void onSurrenderClick()
7980
Game.givePlayerControlToAI();
8081
setButtonsState();
8182
}
83+
public void onGoToClick()
84+
{
85+
if (selectedCountry != Country.NullCountry)
86+
mainCamera.focusCamera(selectedCountry.getCapital());
87+
}
8288
public void onRegainControlClick()
8389
{
8490
Game.takePlayerControlOfThatCountry(selectedCountry);

Assets/code/Utils/Conditions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ public bool isAllTrue(object forWhom)
8787
/// </summary>
8888
public class Condition : Name
8989
{
90-
internal static readonly Condition IsNotImplemented = new Condition(delegate { return 2 * 2 == 5 || Game.devMode; }, "Feature is implemented", true);
90+
internal static readonly Condition IsNotImplemented
91+
//= new Condition(delegate { return 2 * 2 == 5 || Game.devMode; }, "Feature is implemented", true);
92+
= new Condition(delegate { return 2 * 2 == 5; }, "Feature is implemented", true);
9193
internal static readonly Condition AlwaysYes = new Condition(x => 2 * 2 == 4, "Always Yes condition", true);
9294

9395
protected readonly Func<object, bool> checkingFunction;

0 commit comments

Comments
 (0)