Skip to content

Commit

Permalink
fixes #211
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashet committed Jun 22, 2017
1 parent e9f7091 commit 97125bc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 37 deletions.
15 changes: 8 additions & 7 deletions Assets/code/Logic/Country.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ public Country(string iname, Culture iculture, Color color, Province capital) :
new Modifier(x=>(x as Country).government.getValue() == this.government.getValue(), "Same form of government", 0.002f, false),
new Modifier (x=>(x as Country).getLastAttackDateOn(this).getYearsSince() > Options.CountryTimeToForgetBattle
&& this.getLastAttackDateOn(x as Country).getYearsSince() > Options.CountryTimeToForgetBattle,"Lives in peace with us", 0.005f, false),
new Modifier (x=>(x as Country).getLastAttackDateOn(this).getYearsSince() > 0 && (x as Country).getLastAttackDateOn(this).getYearsSince() < 10 ,"Recently attacked us", -0.05f, false),
new Modifier (x=>(x as Country).getLastAttackDateOn(this).getYearsSince() > 0 && (x as Country).getLastAttackDateOn(this).getYearsSince() < 15,
"Recently attacked us", -0.05f, false),
new Modifier (x=> this.isThreatenBy(x as Country),"We are weaker", -0.05f, false),
new Modifier (delegate(System.Object x) { Country bully = isThereBadboyCountry(); return bully != null && bully!= x as Country && bully!= this; },"There is bigger threat to the world", 0.05f, false),
new Modifier (x=>isThereBadboyCountry() ==x,"You are very bad boy", -0.05f, false)
new Modifier (delegate(System.Object x) { Country bully = isThereBadboyCountry(); return bully != null && bully!= x as Country && bully!= this; },"There is bigger threat to the world", 0.05f, false)
//, new Modifier (x=>isThereBadboyCountry() ==x,"You are very bad boy", -0.05f, false)
});
bank = new Bank();
staff = new GeneralStaff(this);
Expand Down Expand Up @@ -129,8 +130,8 @@ internal static void makeCountries(Game game)
var cultureNameGenerator = new CultureNameGenerator();
int howMuchCountries = Province.allProvinces.Count / Options.ProvincesPerCountry;
howMuchCountries += Game.Random.Next(6);
if (howMuchCountries < 7)
howMuchCountries = 7;
if (howMuchCountries < 8)
howMuchCountries = 8;
for (int i = 0; i < howMuchCountries; i++)
{
game.updateStatus("Making countries.." + i);
Expand Down Expand Up @@ -185,7 +186,7 @@ public DateTime getLastAttackDateOn(Country country)
if (myLastAttackDate.ContainsKey(country))
return myLastAttackDate[country];
else
return DateTime.MaxValue;
return DateTime.MinValue;
}
private bool hasCores(Country country)
{
Expand Down Expand Up @@ -509,7 +510,7 @@ internal void think()
{
var possibleTarget = getNeighborProvinces().MinBy(x => getRelationTo(x.getCountry()).get());
if (possibleTarget != null
&& getRelationTo(possibleTarget.getCountry()).get() < 1f
&& (getRelationTo(possibleTarget.getCountry()).get() < 1f || Game.Random.Next(100)==1)
&& this.getStreght() > 0
&& (this.getStreght() > possibleTarget.getCountry().getStreght() * 0.25f
|| possibleTarget.getCountry() == Country.NullCountry
Expand Down
36 changes: 16 additions & 20 deletions Assets/code/Logic/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public class Game : ThreadedJob

internal static StringBuilder threadDangerSB = new StringBuilder();

public static DateTime date = new DateTime(0);
public static DateTime date = new DateTime(50, 1, 1);
internal static bool devMode = false;
private static int mapMode;
private static bool surrended = true;
private static bool surrended = false;
internal static Material defaultCountryBorderMaterial, defaultProvinceBorderMaterial, selectedProvinceBorderMaterial;
private readonly Rect mapBorders;

Expand All @@ -47,8 +47,6 @@ public Game()
}
public void initialize()
{


makeProducts();
market.initialize();
makeFactoryTypes();
Expand Down Expand Up @@ -163,14 +161,15 @@ static private void deleteSomeProvinces()
static private void setStartResources()
{
//Country.allCountries[0] is null country
Country.allCountries[1].getCapital().setResource(Product.Wood);
//Country.allCountries[1].getCapital().setResource(Product.Wood);// player

//Country.allCountries[0].getCapital().setResource(Product.Wood;
Country.allCountries[2].getCapital().setResource(Product.Fruit);
Country.allCountries[3].getCapital().setResource(Product.Gold);
Country.allCountries[4].getCapital().setResource(Product.Wool);
Country.allCountries[5].getCapital().setResource(Product.Stone);
Country.allCountries[6].getCapital().setResource(Product.MetallOre);
Country.allCountries[7].getCapital().setResource(Product.Wood);
}

static private void makePopTypes()
Expand All @@ -183,7 +182,7 @@ static private void makePopTypes()
new PrimitiveStorageSet(new List<Storage> { new Storage(Product.Food, 0.2f), new Storage(Product.ColdArms, 0.2f), new Storage(Product.Firearms, 0.4f), new Storage(Product.Ammunition, 0.6f), new Storage(Product.Artillery, 0.2f), new Storage(Product.Cars, 0.2f), new Storage(Product.Tanks, 0.2f), new Storage(Product.Airplanes, 0.2f), new Storage(Product.Fuel, 0.6f) }));
new PopType(PopType.PopTypes.Capitalists, null, "Capitalists", 1f,
new PrimitiveStorageSet(new List<Storage> { new Storage(Product.Food, 0.2f), new Storage(Product.ColdArms, 0.2f), new Storage(Product.Firearms, 0.4f), new Storage(Product.Ammunition, 0.6f), new Storage(Product.Artillery, 0.2f), new Storage(Product.Cars, 0.2f), new Storage(Product.Tanks, 0.2f), new Storage(Product.Airplanes, 0.2f), new Storage(Product.Fuel, 0.6f) }));
new PopType(PopType.PopTypes.Farmers, new Storage(Product.findByName("Food"), 1.2f), "Farmers", 1f,
new PopType(PopType.PopTypes.Farmers, new Storage(Product.findByName("Food"), 1.0f), "Farmers", 1f,
new PrimitiveStorageSet(new List<Storage> { new Storage(Product.Food, 0.2f), new Storage(Product.ColdArms, 0.2f), new Storage(Product.Firearms, 0.4f), new Storage(Product.Ammunition, 0.6f), new Storage(Product.Artillery, 0.2f), new Storage(Product.Cars, 0.2f), new Storage(Product.Tanks, 0.2f), new Storage(Product.Airplanes, 0.2f), new Storage(Product.Fuel, 0.6f) }));
new PopType(PopType.PopTypes.Workers, null, "Workers", 1f,
new PrimitiveStorageSet(new List<Storage> { new Storage(Product.Food, 0.2f), new Storage(Product.ColdArms, 0.2f), new Storage(Product.Firearms, 0.4f), new Storage(Product.Ammunition, 0.6f), new Storage(Product.Artillery, 0.2f), new Storage(Product.Cars, 0.2f), new Storage(Product.Tanks, 0.2f), new Storage(Product.Airplanes, 0.2f), new Storage(Product.Fuel, 0.6f) }));
Expand Down Expand Up @@ -250,10 +249,7 @@ public static void redrawMapAccordingToMapMode(int newMapMode)
{
mapMode = newMapMode;
foreach (var item in Province.allProvinces)
if (item != Game.selectedProvince)
{
item.updateColor(getProvinceColorAccordingToMapMode(item));
}
item.updateColor(getProvinceColorAccordingToMapMode(item));
}

internal static void continueSimulation()
Expand Down Expand Up @@ -406,7 +402,7 @@ internal static Value getAllMoneyInWorld()
return allMoney;
}
static void CreateRandomPopulation()
{
{

foreach (Province province in Province.allProvinces)
{
Expand Down Expand Up @@ -453,19 +449,19 @@ static void CreateRandomPopulation()
}

}
}
}

internal static bool isPlayerSurrended()
{
return surrended;
}

static void generateMapImage()
{

//Texture2D mapImage = new Texture2D(100, 100);
//Texture2D mapImage = new Texture2D(160 + Random.Next(60), 70 + Random.Next(60));
Texture2D mapImage = new Texture2D(120 + Random.Next(40), 60 + Random.Next(40));
Texture2D mapImage = new Texture2D(160 + Random.Next(60), 70 + Random.Next(60));
//Texture2D mapImage = new Texture2D(120 + Random.Next(40), 80 + Random.Next(40));
//Texture2D mapImage = new Texture2D(300, 300);
Color emptySpaceColor = Color.black;//.setAlphaToZero();
mapImage.setColor(emptySpaceColor);
Expand Down Expand Up @@ -511,9 +507,9 @@ static Mesh getMeshID(Color color)
if (color == all.getColorID())
return all.landMesh;
return null;
}
}





static bool FindProvinceCenters()
Expand Down Expand Up @@ -591,7 +587,7 @@ static bool FindProvinceCenters()
//}
//return false;
}

public static void PrepareForNewTick()
{
Game.market.sentToMarket.setZero();
Expand All @@ -607,7 +603,7 @@ public static void PrepareForNewTick()
province.BalanceEmployableWorkForce();
{
foreach (var item in province.getProducers())
item.setStatisticToZero();
item.setStatisticToZero();
}
}
}
Expand All @@ -621,7 +617,7 @@ static void makeHelloMessage()
+ "\n\nYou play as " + Game.Player.getName() + " country yet there is no much gameplay for now. You can try to growth economy or conquer the world."
+ "\n\nTry arrows or WASD for scrolling map and mouse wheel for scale"
+ "\nEnter key to close top window, space - to pause\\unpause"
, "Ok");
, "Ok");
}
static void loadImages()
{
Expand Down
4 changes: 2 additions & 2 deletions Assets/code/Logic/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public static class Options
internal static readonly float CountryBadBoyWorldLimit = 0.10f;
internal static readonly int FactoryMediumTierLevels = 8 + 1;
internal static readonly int FactoryMediumHighLevels = 15 + 1;
internal static readonly int CountryTimeToForgetBattle = 30;
internal static readonly int CountryTimeToForgetBattle = 40;
internal static readonly int MapRedrawRate = 20; // bigger number - less often redraw
internal static readonly int ProvinceLakeShance = 8; // bigger - less lakes
internal static readonly int ProvincesPerCountry = 6;
internal static readonly int ProvincesPerCountry = 3;// don't do it lees than 3 - ugly
internal static readonly int PopMinimalMobilazation = 50;
}
2 changes: 1 addition & 1 deletion Assets/code/Panels/MilitaryPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void refresh(bool rebuildDropdown)
if (rebuildDropdown)
{
//Game.player.homeArmy.balance(Game.player.sendingArmy, new Procent(armySendLimit.value));
//armySendLimit.value = 0; // cause extra mobilization
armySendLimit.value = 0; // cause extra mobilization
rebuildDropDown();
}
sb.Clear();
Expand Down
8 changes: 1 addition & 7 deletions Assets/code/Panels/ProvincePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ void Start()
{
MainCamera.provincePanel = this;
hide();
}

// Update is called once per frame
void Update()
{

}
}
public void hide()
{
gameObject.SetActive(false);
Expand Down

0 comments on commit 97125bc

Please sign in to comment.