Skip to content

Commit

Permalink
returned getMinimalMoneyToBuild, added goto button in Diplomacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashet committed Nov 26, 2017
1 parent c397180 commit 8609933
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 25 deletions.
Binary file modified Assets/ES-base.unity
Binary file not shown.
11 changes: 9 additions & 2 deletions Assets/code/Logic/EntryPoint/MainCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ void Update()
Game.setUnityAPI();

myCamera = this.GetComponent<Camera>();
gameObject.transform.position = new Vector3(Game.Player.getCapital().getPosition().x,
Game.Player.getCapital().getPosition().y, gameObject.transform.position.z);
focusCamera(Game.Player.getCapital());
//gameObject.transform.position = new Vector3(Game.Player.getCapital().getPosition().x,
// Game.Player.getCapital().getPosition().y, gameObject.transform.position.z);
loadingPanel.hide();
topPanel.show();
bottomPanel.show();
Expand Down Expand Up @@ -256,4 +257,10 @@ void showMessageBox()
mesPanel.show(mes);
}
// This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
public void focusCamera(Province province)
{
gameObject.transform.position = new Vector3(province.getPosition().x,
province.getPosition().y, gameObject.transform.position.z);
}

}
8 changes: 6 additions & 2 deletions Assets/code/Logic/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ internal Factory(Province province, Agent factoryOwner, FactoryType type) : base
if (getCountry().economy.getValue() == Economy.PlannedEconomy)
setPriorityAutoWithPlannedEconomy();
}
//internal Value getMinimalMoneyForUpgrade()
//{
// return Game.market.getCost(getUpgradeNeeds());
//}
internal StorageSet getUpgradeNeeds()
{
if (getLevel() < Options.FactoryMediumTierLevels)
Expand Down Expand Up @@ -422,7 +426,7 @@ internal Procent getMargin()
}
internal Value getReopenCost()
{
return new Value(Options.factoryMoneyReservPerLevel);
return new Value(Options.factoryMoneyReservePerLevel);

}
//internal Value getUpgradeCost()
Expand Down Expand Up @@ -628,7 +632,7 @@ internal bool isToRemove()

float wantsMinMoneyReserv()
{
return getExpences() * Factory.xMoneyReservForResources + Options.factoryMoneyReservPerLevel * level;
return getExpences() * Factory.xMoneyReservForResources + Options.factoryMoneyReservePerLevel * level;
}
public void simulateClosing()
{
Expand Down
24 changes: 13 additions & 11 deletions Assets/code/Logic/FactoryType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,18 @@ internal FactoryType(string name, Storage basicProduction, bool shaft)
}
else
{
Value cost = Game.market.getCost(this.getBuildNeeds());
cost.add(Options.factoryMoneyReservPerLevel);
//Value cost = Game.market.getCost(this.getBuildNeeds());
//cost.add(Options.factoryMoneyReservPerLevel);
Value cost = getMinimalMoneyToBuild();
return agent.canPay(cost);
}
},
delegate
{
var sb = new StringBuilder();
Value cost = Game.market.getCost(this.getBuildNeeds());
cost.add(Options.factoryMoneyReservPerLevel);
//Value cost = Game.market.getCost(this.getBuildNeeds());
//cost.add(Options.factoryMoneyReservPerLevel);
Value cost = getMinimalMoneyToBuild();
sb.Append("Have ").Append(cost).Append(" coins");
sb.Append(" or (with ").Append(Economy.PlannedEconomy).Append(") have ").Append(this.getBuildNeeds());
return sb.ToString();
Expand Down Expand Up @@ -202,12 +204,12 @@ public static IEnumerable<FactoryType> getNonResourceTypes(Country country)
yield return next;
}

//internal Value getBuildCost()
//{
// Value result = Game.market.getCost(getBuildNeeds());
// result.add(Options.factoryMoneyReservPerLevel);
// return result;
//}
internal Value getMinimalMoneyToBuild()
{
Value result = Game.market.getCost(getBuildNeeds());
result.add(Options.factoryMoneyReservePerLevel);
return result;
}
internal StorageSet getBuildNeeds()
{
//return new Storage(Product.Food, 40f);
Expand Down Expand Up @@ -299,7 +301,7 @@ internal Value getPossibleProfit(Province province)
}
internal Procent getPossibleMargin(Province province)
{
return Procent.makeProcent(getPossibleProfit(province), Game.market.getCost(this.getBuildNeeds()));
return Procent.makeProcent(getPossibleProfit(province), getMinimalMoneyToBuild());
}
//internal bool canBuildNewFactory(FactoryType type)
//{
Expand Down
5 changes: 3 additions & 2 deletions Assets/code/Logic/NonAbstractPopUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,9 @@ internal override void invest()
if (proposition != null && proposition.canBuildNewFactory(getProvince()) &&
(getProvince().getUnemployedWorkers() > Options.minUnemploymentToBuldFactory || getProvince().getAverageFactoryWorkforceFullfilling() > Options.minFactoryWorkforceFullfillingToBuildNew))
{
Value buildCost = Game.market.getCost(proposition.getBuildNeeds());
buildCost.add(Options.factoryMoneyReservPerLevel);
//Value buildCost = Game.market.getCost(proposition.getBuildNeeds());
//buildCost.add(Options.factoryMoneyReservePerLevel);
Value buildCost = proposition.getMinimalMoneyToBuild();
if (canPay(buildCost))
{
Factory found = new Factory(getProvince(), this, proposition);
Expand Down
2 changes: 1 addition & 1 deletion Assets/code/Logic/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static class Options
internal static readonly int minDaysBeforeSalaryCut = 2;
internal static readonly int howOftenCheckForFactoryReopenning = 30;

internal static readonly float factoryMoneyReservPerLevel = 20f;
internal static readonly float factoryMoneyReservePerLevel = 20f;
internal static readonly float minMarginToRiseSalary = 0.01f;
internal static readonly float factoryEachLevelEfficiencyBonus = 0.05f;
//internal static float factoryHaveResourceInProvinceBonus = 0.2f;
Expand Down
2 changes: 1 addition & 1 deletion Assets/code/PanelTables/BuildPanelTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ override protected void AddButtons()
////Adding cost
//if (Game.player.isInvented(InventionType.capitalism))
if (Economy.isMarket.checkIftrue(Game.Player))
AddButton(Game.market.getCost(next.getBuildNeeds()).ToString(), next);
AddButton(next.getMinimalMoneyToBuild().ToString(), next);
else
AddButton(next.getBuildNeeds().ToString(), next);

Expand Down
12 changes: 7 additions & 5 deletions Assets/code/Panels/BuildPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BuildPanel : DragPanel
void Start()
{
MainCamera.buildPanel = this;
GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, MainCamera.topPanel.GetComponent<RectTransform>().rect.height * -1f);
GetComponent<RectTransform>().anchoredPosition = new Vector2(50f, -100f);
buildButton.interactable = false;
hide();
}
Expand All @@ -33,13 +33,14 @@ public void onBuildClick()
//if (Game.player.economy.allowsFactoryBuildingByGovernment())
{
bool buildSomething = false;
var resourceToBuild = selectedFactoryType.getBuildNeeds();

if (Economy.isMarket.checkIftrue(Game.Player))
//if (Game.player.economy.status == Economy.StateCapitalism)
//have money /resource
{
Value cost = Game.market.getCost(resourceToBuild);
cost.add(Options.factoryMoneyReservPerLevel);
//Value cost = Game.market.getCost(resourceToBuild);
//cost.add(Options.factoryMoneyReservePerLevel);
Value cost = selectedFactoryType.getMinimalMoneyToBuild();
if (Game.Player.canPay(cost))
{
var factory = new Factory(Game.selectedProvince, Game.Player, selectedFactoryType);
Expand All @@ -52,6 +53,7 @@ public void onBuildClick()
else // non market
{
//todo remove grain connection
var resourceToBuild = selectedFactoryType.getBuildNeeds();
Storage needFood = resourceToBuild.getFirstStorage(Product.Grain);
if (Game.Player.countryStorageSet.has(needFood))
{
Expand Down Expand Up @@ -82,7 +84,7 @@ public void refresh()
{
sb.Clear();
sb.Append("Build ").Append(selectedFactoryType);
var cost = Game.market.getCost(selectedFactoryType.getBuildNeeds());
var cost =selectedFactoryType.getMinimalMoneyToBuild();
sb.Append("\n\nResources to build: ").Append(selectedFactoryType.getBuildNeeds()).Append(" cost: ").Append(cost);
sb.Append("\nEveryday resource input: ").Append(selectedFactoryType.resourceInput);

Expand Down
6 changes: 6 additions & 0 deletions Assets/code/Panels/DiplomacyPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class DiplomacyPanel : DragPanel
{
public Text captionText, generalText;
public Button giveControlToAi, giveControlToPlayer;
public MainCamera mainCamera;
Country selectedCountry;
StringBuilder sb = new StringBuilder();
// Use this for initialization
Expand Down Expand Up @@ -79,6 +80,11 @@ public void onSurrenderClick()
Game.givePlayerControlToAI();
setButtonsState();
}
public void onGoToClick()
{
if (selectedCountry != Country.NullCountry)
mainCamera.focusCamera(selectedCountry.getCapital());
}
public void onRegainControlClick()
{
Game.takePlayerControlOfThatCountry(selectedCountry);
Expand Down
4 changes: 3 additions & 1 deletion Assets/code/Utils/Conditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public bool isAllTrue(object forWhom)
/// </summary>
public class Condition : Name
{
internal static readonly Condition IsNotImplemented = new Condition(delegate { return 2 * 2 == 5 || Game.devMode; }, "Feature is implemented", true);
internal static readonly Condition IsNotImplemented
//= new Condition(delegate { return 2 * 2 == 5 || Game.devMode; }, "Feature is implemented", true);
= new Condition(delegate { return 2 * 2 == 5; }, "Feature is implemented", true);
internal static readonly Condition AlwaysYes = new Condition(x => 2 * 2 == 4, "Always Yes condition", true);

protected readonly Func<object, bool> checkingFunction;
Expand Down

0 comments on commit 8609933

Please sign in to comment.