public static void chooseNextTechno(byte player, string text, string caption) { string technoName = Statistics.technologies[Form1.game.playerList[player].currentResearch].name; ai Ai = new ai(); byte[] technos = ai.returnDisponibleTechnologies(player); byte nextTechno = ai.randomTechnology(player); string[] choices = technoListStrings(player, technos); userChoice uc = new userChoice( caption, text, choices, 0, language.getAString(language.order.uiAccept), language.getAString(language.order.uiOpenTechnoTree) ); uc.ShowDialog(); int res = uc.result; if (res == -1) { // science tree Form1.game.playerList[player].currentResearch = (byte)nextTechno; sciTree sciTree1 = new sciTree(); sciTree1.ShowDialog(); } else { // accept Form1.game.playerList[player].currentResearch = (byte)technos[res]; } }
/// <summary> /// Return unit's position in transport /// </summary> /// <param name="player"></param> /// <param name="transport"></param> /// <returns></returns> public static int askForWhichUnitToDisembark(byte player, int transport) { int[] uwcd = unitsWhoCanDisembark(player, transport); if (uwcd.Length == 1) { if ( System.Windows.Forms.MessageBox.Show( "Are you sure you want to disembark " + uiWrap.unitInfo(player, Form1.game.playerList[player].unitList[transport].transport[uwcd[0]]).ToLower() + ".", "Unloading unit", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.None, System.Windows.Forms.MessageBoxDefaultButton.Button1 ) == System.Windows.Forms.DialogResult.Yes ) { return(uwcd[0]); } else { return(-1); } } else { string[] choices = new string[uwcd.Length + 1]; for (int i = 0; i < uwcd.Length; i++) { choices[i] = uiWrap.unitInfo(player, Form1.game.playerList[player].unitList[transport].transport[uwcd[i]]); } choices[choices.Length - 1] = "All"; userChoice ui = new userChoice( language.getAString(language.order.uiUnloadingUnit), language.getAString(language.order.uiPleaseChooseUnitToUnload), choices, 0, language.getAString(language.order.uiUnload), language.getAString(language.order.cancel) ); ui.ShowDialog(); int result = ui.result; if (result == -1) { return(-1); } else if (result == uwcd.Length) { return(100); } else { return(uwcd[result]); } } }
/// <summary> /// Return transport number /// </summary> /// <param name="player"></param> /// <param name="transport"></param> /// <returns></returns> public static int askForWhichShipToJoin(byte player, int x, int y) { int[] twfs = withFreeSpace(player, x, y); if (twfs.Length == 1) { /* if ( * System.Windows.Forms.MessageBox.Show( * "Are you sure you want to load " + uiWrap.unitInfo( player, Form1.game.playerList[ player ].unitList[ transport ].transport[ uwcd[ 0 ] ] ).ToLower() + ".", * "Loading unit on ship", * System.Windows.Forms.MessageBoxButtons.YesNo, * System.Windows.Forms.MessageBoxIcon.None, * System.Windows.Forms.MessageBoxDefaultButton.Button1 * ) == System.Windows.Forms.DialogResult.Yes * ) * {*/ return(twfs[0]); /*} * else * { * return -1; * }*/ } else { string[] choices = new string[twfs.Length]; for (int i = 0; i < choices.Length; i++) { choices[i] = uiWrap.unitInfo(player, twfs[i]); } userChoice ui = new userChoice( language.getAString(language.order.uiLoadingUnitOnShip), language.getAString(language.order.uiPleaseChooseAShip), choices, 0, language.getAString(language.order.uiEmbark), language.getAString(language.order.cancel) ); ui.ShowDialog(); int result = ui.result; if (result == -1) { return(-1); } else { return(twfs[result]); } } }
public static void populate( bool forceChooseLanguage ) { moreThanOneLanguageFileDetected = true; string languageFilePath = ""; if ( !forceChooseLanguage && Form1.options.languageFile.Length > 0 ) { languageFilePath = Form1.options.languageFile; try { System.IO.FileStream file1 = new System.IO.FileStream( languageFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read ); } catch //( System.Exception e ) { forceChooseLanguage = true; } } if ( forceChooseLanguage || languageFilePath == "" ) { string[] strList1 = System.IO.Directory.GetFiles( Form1.appPath + "\\languages\\" ); int pos = 0; int[] refer = new int[ strList1.Length ]; int english = 0; for ( int i = 0; i < strList1.Length; i ++ ) if ( System.IO.Path.GetExtension( strList1[ i ] ) == ".lng" ) { if ( System.IO.Path.GetFileNameWithoutExtension( strList1[ i ] ).ToLower() == "english" ) english = pos; refer[ pos ] = i; pos ++; } if ( pos == 0 ) { System.Windows.Forms.MessageBox.Show( "Sorry, no language files detected. Make sure you have the .lng files in the same directory than pocketHumanity.exe!", "Error" ); // Application.End(); } else if ( pos == 1 ) { languageFilePath = strList1[ refer[ 0 ] ]; moreThanOneLanguageFileDetected = false; } else { moreThanOneLanguageFileDetected = true; string[] strList3 = new string[ pos ]; for ( int i = 0; i < pos; i++ ) { strList3[ i ] = System.IO.Path.GetFileNameWithoutExtension( strList1[ refer[ i ] ] ); } userChoice ui = new userChoice( "Language file", "Please choose a language", strList3, english, "Ok", "Default" ); platformSpec.cursor.showWaitCursor = false; ui.ShowDialog(); int res = ui.result; if ( res == -1 ) res = english; languageFilePath = strList1[ refer[ res ] ]; } } System.IO.FileStream file = new System.IO.FileStream( languageFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read ); System.IO.StreamReader sr = new System.IO.StreamReader( file, true ); // structures.cfgFile cfgFile = cfgOut.getValues; // = // cfgFile.languageFile = languageFilePath; Form1.options.languageFile = languageFilePath; // cfgOut.getValues = cfgFile; // cfgOut.writeCfgFile(); Form1.options.save(); string fullList = sr.ReadToEnd(); string[] temp = fullList.Split( "\n".ToCharArray() ); int tot = 0; //System.Collections.BitArray isOk = new System.Collections.BitArray( temp.Length, false ); bool[] isOk = new bool[ temp.Length ]; for ( int i = 0; i < temp.Length; i ++ ) { temp[ i ] = temp[ i ].TrimEnd( "\r".ToCharArray() ); if ( temp[ i ] != "" && !temp[ i ].StartsWith( "//" ) ) { isOk[ i ] = true; tot ++; } } list = new string[ tot ]; int pos1 = 0; for ( int i = 0; i < temp.Length; i ++ ) if ( isOk[ i ] ) { list[ pos1 ] = temp[ i ]; pos1 ++; } curLanguage = languageFilePath; sr.Close(); file.Close(); }
public void buildConstruction(Form1 form1) // Building( Stat.Building building ) { bool keepGoing = true; if ( population == 1 && construction.list[0] == Statistics.units[(byte)Form1.unitType.colon] ) { if (player.player == player.game.curPlayerInd) { Stat.Construction[] ib = ai.whatCanBeBuilt( player.player, city ); string[] choices = uiWrap.buildingListStrings(player.player, city, ib); form1.zoomOnCity(player.player, city); userChoice ui = new userChoice( language.getAString(language.order.uiNewConstrution), String.Format(language.getAString(language.order.uiNewConstrution), name), choices, 0, language.getAString(language.order.ok), language.getAString(language.order.uiGoToCity) ); ui.ShowDialog(); int res = ui.result; if (res == -1) { form1.openCityFrm(player.player, city); keepGoing = false; } else if (res == 0) { keepGoing = true; /* construction.points -= Statistics.units[ construction.list[ 0 ].ind ].cost; * Form1.game.curPlayer.createUnit ( X, Y, (byte)construction.list[ 0 ].ind ); * Form1.game.curPlayerInd.cityList[ i ].kill(); * continue;*/ } else { // si non construction.list[0] = ib[res]; keepGoing = false; /* Form1.construction.list[ 0 ].ind = ib[ res ].info; * Form1.construction.list[ 0 ].type = ib[ res ].type;*/ } } else { ai.chooseConstruction(player.player, city); } } // else if (keepGoing) { construction.points -= construction.list[0].cost; //Statistics.units[ construction.list[ 0 ].ind ].cost; if (construction.list[0] is Stat.Unit) // construction.list[ 0 ].type == 1 ) { // units player.createUnit(X, Y, (byte)construction.list[0].type); if (construction.list[0] == Statistics.units[(byte)Form1.unitType.colon]) //construction.list[ 0 ].ind == (byte)Form1.unitType.colon ) { if (population > 1) { labor.autoRemoveLabor(player.player, city, true); population--; } else { kill(); } } } else if (construction.list[0] is Stat.Building) { // buildings buildingList[construction.list[0].type] = true; aiPref.setBuildingUpkeep(player.player); #region special buildings #endregion } else if (construction.list[0] is Stat.SmallWonder) { // buildings // buildingList[ construction.list[ 0 ].type ] = true; /// aiPref.setBuildingUpkeep( player.player ); player.smallWonderList.buildWonder(construction.list[0]); #region special #endregion } else if (construction.list[0] is Stat.Wonder) { // buildings // buildingList[ construction.list[ 0 ].type ] = true; // aiPref.setBuildingUpkeep( player.player ); player.game.wonderList.buildWonder(construction.list[0]); #region special switch (construction.list[0].type) { case (int)Stat.Wonder.list.chinaWall: break; } #endregion } if (!dead) { if (player.isCurPlayer) { if (construction.list[1] != null) { construction.removeFirst(); } else { form1.zoomOnCity(player.player, city); uiWrap.choseConstruction(player.player, city, false); } } else { ai.chooseConstruction(player.player, city); } } } }
public static void choseConstruction(byte player, int city, bool allNew) { string text; if (allNew) { text = "Please chose a construction for " + Form1.game.playerList[player].cityList[city].name + "."; } else { string builtName = Form1.game.playerList[player].cityList[city].construction.list[0].name ; /* if ( Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type == (byte)enums.cityBuildType.unit ) * builtName = Statistics.units[ Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind ].name; * else //if ( Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type == (byte)enums.cityBuildType.building ) * builtName = Statistics.buildings[ Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind ].name;*/ text = String.Format(language.getAString(language.order.uiJustBuiltA), Form1.game.playerList[player].cityList[city].name, builtName.ToLower()); // Form1.game.playerList[ player ].cityList[ city ].name + " just built a " + builtName.ToLower() + ". Please choose its next construction."; } // ai Ai = new ai(); Stat.Construction[] ib = ai.whatCanBeBuilt( player, city ); string[] choices = uiWrap.buildingListStrings(player, city, ib); int Default = 0; ai.chooseConstruction(player, city); for (int i = 0; i < ib.Length; i++) { if ( Form1.game.playerList[player].cityList[city].construction.list[0] == ib[i] // Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type == ib[ i ].type && // Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind == ib[ i ].info ) { Default = i; break; } } userChoice uc = new userChoice( language.getAString(language.order.uiNewConstrution), text, choices, Default, language.getAString(language.order.uiAccept), language.getAString(language.order.uiGoToCity) ); uc.ShowDialog(); int res = uc.result; if (res == -1) { // Ai.chooseConstruction( player, city ); open.cityFrm(player, city, null); } else { // si non Form1.game.playerList[player].cityList[city].construction.list[0] = ib[res]; /* Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind = ib[ res ].info; * Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type = ib[ res ].type;*/ } }
public void buildConstruction( Form1 form1 ) // Building( Stat.Building building ) { bool keepGoing = true; if ( population == 1 && construction.list[ 0 ] == Statistics.units[ (byte)Form1.unitType.colon ] ) { if ( player.player == player.game.curPlayerInd ) { Stat.Construction[] ib = ai.whatCanBeBuilt( player.player, city ); string[] choices = uiWrap.buildingListStrings( player.player, city, ib ); form1.zoomOnCity( player.player, city ); userChoice ui = new userChoice( language.getAString( language.order.uiNewConstrution ), String.Format( language.getAString( language.order.uiNewConstrution ), name ), choices, 0, language.getAString( language.order.ok ), language.getAString( language.order.uiGoToCity ) ); ui.ShowDialog(); int res = ui.result; if ( res == -1 ) { form1.openCityFrm( player.player, city ); keepGoing = false; } else if ( res == 0 ) { keepGoing = true; /* construction.points -= Statistics.units[ construction.list[ 0 ].ind ].cost; Form1.game.curPlayer.createUnit ( X, Y, (byte)construction.list[ 0 ].ind ); Form1.game.curPlayerInd.cityList[ i ].kill(); continue;*/ } else { // si non construction.list[0] = ib[res]; keepGoing = false; /* Form1.construction.list[ 0 ].ind = ib[ res ].info; Form1.construction.list[ 0 ].type = ib[ res ].type;*/ } } else ai.chooseConstruction( player.player, city ); } // else if ( keepGoing ) { construction.points -= construction.list[ 0 ].cost; //Statistics.units[ construction.list[ 0 ].ind ].cost; if ( construction.list[ 0 ] is Stat.Unit ) // construction.list[ 0 ].type == 1 ) { // units player.createUnit( X, Y, (byte)construction.list[ 0 ].type ); if ( construction.list[ 0 ] == Statistics.units[ (byte)Form1.unitType.colon ] ) //construction.list[ 0 ].ind == (byte)Form1.unitType.colon ) { if ( population > 1 ) { labor.autoRemoveLabor( player.player, city, true ); population --; } else { kill(); } } } else if ( construction.list[ 0 ] is Stat.Building ) { // buildings buildingList[ construction.list[ 0 ].type ] = true; aiPref.setBuildingUpkeep( player.player ); #region special buildings #endregion } else if ( construction.list[ 0 ] is Stat.SmallWonder ) { // buildings // buildingList[ construction.list[ 0 ].type ] = true; /// aiPref.setBuildingUpkeep( player.player ); player.smallWonderList.buildWonder( construction.list[ 0 ] ); #region special #endregion } else if ( construction.list[ 0 ] is Stat.Wonder ) { // buildings // buildingList[ construction.list[ 0 ].type ] = true; // aiPref.setBuildingUpkeep( player.player ); player.game.wonderList.buildWonder( construction.list[ 0 ] ); #region special switch ( construction.list[ 0 ].type ) { case (int)Stat.Wonder.list.chinaWall: break; } #endregion } if ( !dead ) { if ( player.isCurPlayer ) { if ( construction.list[ 1 ] != null ) { construction.removeFirst(); } else { form1.zoomOnCity( player.player, city ); uiWrap.choseConstruction( player.player, city, false ); } } else { ai.chooseConstruction( player.player, city ); } } } }
public static void chooseNextTechno( byte player, string text, string caption ) { string technoName = Statistics.technologies[ Form1.game.playerList[ player ].currentResearch ].name; ai Ai = new ai(); byte[] technos = ai.returnDisponibleTechnologies( player ); byte nextTechno = ai.randomTechnology( player ); string[] choices = technoListStrings( player, technos ); userChoice uc = new userChoice( caption, text, choices, 0, language.getAString( language.order.uiAccept ), language.getAString( language.order.uiOpenTechnoTree ) ); uc.ShowDialog(); int res = uc.result; if ( res == -1 ) { // science tree Form1.game.playerList[ player ].currentResearch = (byte)nextTechno; sciTree sciTree1 = new sciTree(); sciTree1.ShowDialog(); } else { // accept Form1.game.playerList[ player ].currentResearch = (byte)technos[ res ]; } }
public static void choseConstruction( byte player, int city, bool allNew ) { string text; if ( allNew ) { text = "Please chose a construction for " + Form1.game.playerList[ player ].cityList[ city ].name + "."; } else { string builtName = Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].name ; /* if ( Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type == (byte)enums.cityBuildType.unit ) builtName = Statistics.units[ Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind ].name; else //if ( Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type == (byte)enums.cityBuildType.building ) builtName = Statistics.buildings[ Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind ].name;*/ text = String.Format( language.getAString( language.order.uiJustBuiltA ), Form1.game.playerList[ player ].cityList[ city ].name, builtName.ToLower() ); // Form1.game.playerList[ player ].cityList[ city ].name + " just built a " + builtName.ToLower() + ". Please choose its next construction."; } // ai Ai = new ai(); Stat.Construction[] ib = ai.whatCanBeBuilt( player, city ); string[] choices = uiWrap.buildingListStrings( player, city, ib ); int Default = 0; ai.chooseConstruction( player, city ); for ( int i = 0; i < ib.Length; i ++ ) if ( Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ] == ib[ i ] // Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type == ib[ i ].type && // Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind == ib[ i ].info ) { Default = i; break; } userChoice uc = new userChoice( language.getAString( language.order.uiNewConstrution ), text, choices, Default, language.getAString( language.order.uiAccept ), language.getAString( language.order.uiGoToCity ) ); uc.ShowDialog(); int res = uc.result; if ( res == -1 ) { // Ai.chooseConstruction( player, city ); open.cityFrm( player, city, null ); } else { // si non Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ] = ib[ res ]; /* Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].ind = ib[ res ].info; Form1.game.playerList[ player ].cityList[ city ].construction.list[ 0 ].type = ib[ res ].type;*/ } }
private void miTransfertSlave_Click(object sender, EventArgs e) { userNumberInput uni = new userNumberInput( "Transfert slaves", "How many slaves do you want to transfert? max: " + Form1.game.playerList[ player ].cityList[ city ].slaves.total.ToString(), 1, Form1.game.playerList[ player ].cityList[ city ].slaves.total, "Ok", "Cancel" ); uni.ShowDialog(); if ( uni.result != -1 ) { int[] order = new int[ Form1.game.playerList[ player ].cityNumber ]; int tot = 0; for ( int c = 1; c <= Form1.game.playerList[ player ].cityNumber; c ++ ) if ( !Form1.game.playerList[ player ].cityList[ c ].dead && c != city ) { order[ tot ] = c; tot++; } string[] names = new string[ tot ]; for ( int c = 0; c < names.Length; c++ ) { names[ c ] = Form1.game.playerList[ player ].cityList[ order[ c ] ].name; } userChoice uc = new userChoice( "Transfert slaves", "Please choose where to send the slaves.", names, 0, "Ok", "Cancel" ); uc.ShowDialog(); if ( uc.result != -1 ) { int eta = Form1.game.playerList[ player ].slaves.moveSlave( city, order[ uc.result ], uni.result ); MessageBox.Show( String.Format( "The slaves will be at destination in {0} turns.", eta ), "Slave transfert" ); } } enableButtons(); }
/// <summary> /// Return transport number /// </summary> /// <param name="player"></param> /// <param name="transport"></param> /// <returns></returns> public static int askForWhichShipToJoin( byte player, int x, int y ) { int[] twfs = withFreeSpace( player, x, y ); if ( twfs.Length == 1 ) { /* if ( System.Windows.Forms.MessageBox.Show( "Are you sure you want to load " + uiWrap.unitInfo( player, Form1.game.playerList[ player ].unitList[ transport ].transport[ uwcd[ 0 ] ] ).ToLower() + ".", "Loading unit on ship", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.None, System.Windows.Forms.MessageBoxDefaultButton.Button1 ) == System.Windows.Forms.DialogResult.Yes ) {*/ return twfs[ 0 ]; /*} else { return -1; }*/ } else { string[] choices = new string[ twfs.Length ]; for ( int i = 0; i < choices.Length; i ++ ) choices[ i ] = uiWrap.unitInfo( player, twfs[ i ] ); userChoice ui = new userChoice( language.getAString( language.order.uiLoadingUnitOnShip ), language.getAString( language.order.uiPleaseChooseAShip ), choices, 0, language.getAString( language.order.uiEmbark ), language.getAString( language.order.cancel ) ); ui.ShowDialog(); int result = ui.result; if ( result == -1 ) return -1; else return twfs[ result ]; } }
/// <summary> /// Return unit's position in transport /// </summary> /// <param name="player"></param> /// <param name="transport"></param> /// <returns></returns> public static int askForWhichUnitToDisembark( byte player, int transport ) { int[] uwcd = unitsWhoCanDisembark( player, transport ); if ( uwcd.Length == 1 ) { if ( System.Windows.Forms.MessageBox.Show( "Are you sure you want to disembark " + uiWrap.unitInfo( player, Form1.game.playerList[ player ].unitList[ transport ].transport[ uwcd[ 0 ] ] ).ToLower() + ".", "Unloading unit", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.None, System.Windows.Forms.MessageBoxDefaultButton.Button1 ) == System.Windows.Forms.DialogResult.Yes ) return uwcd[ 0 ]; else return -1; } else { string[] choices = new string[ uwcd.Length + 1 ]; for ( int i = 0; i < uwcd.Length; i++ ) choices[ i ] = uiWrap.unitInfo( player, Form1.game.playerList[ player ].unitList[ transport ].transport[ uwcd[ i ] ] ); choices[ choices.Length - 1 ] = "All"; userChoice ui = new userChoice( language.getAString( language.order.uiUnloadingUnit ), language.getAString( language.order.uiPleaseChooseUnitToUnload ), choices, 0, language.getAString( language.order.uiUnload ), language.getAString( language.order.cancel ) ); ui.ShowDialog(); int result = ui.result; if ( result == -1 ) return -1; else if ( result == uwcd.Length ) return 100; else return uwcd[ result ]; } }
public static void populate(bool forceChooseLanguage) { moreThanOneLanguageFileDetected = true; string languageFilePath = ""; if ( !forceChooseLanguage && Form1.options.languageFile.Length > 0 ) { languageFilePath = Form1.options.languageFile; try { System.IO.FileStream file1 = new System.IO.FileStream(languageFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read); } catch //( System.Exception e ) { forceChooseLanguage = true; } } if ( forceChooseLanguage || languageFilePath == "" ) { string[] strList1 = System.IO.Directory.GetFiles(Form1.appPath + "\\languages\\"); int pos = 0; int[] refer = new int[strList1.Length]; int english = 0; for (int i = 0; i < strList1.Length; i++) { if (System.IO.Path.GetExtension(strList1[i]) == ".lng") { if (System.IO.Path.GetFileNameWithoutExtension(strList1[i]).ToLower() == "english") { english = pos; } refer[pos] = i; pos++; } } if (pos == 0) { System.Windows.Forms.MessageBox.Show("Sorry, no language files detected. Make sure you have the .lng files in the same directory than pocketHumanity.exe!", "Error"); // Application.End(); } else if (pos == 1) { languageFilePath = strList1[refer[0]]; moreThanOneLanguageFileDetected = false; } else { moreThanOneLanguageFileDetected = true; string[] strList3 = new string[pos]; for (int i = 0; i < pos; i++) { strList3[i] = System.IO.Path.GetFileNameWithoutExtension(strList1[refer[i]]); } userChoice ui = new userChoice( "Language file", "Please choose a language", strList3, english, "Ok", "Default" ); platformSpec.cursor.showWaitCursor = false; ui.ShowDialog(); int res = ui.result; if (res == -1) { res = english; } languageFilePath = strList1[refer[res]]; } } System.IO.FileStream file = new System.IO.FileStream(languageFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.StreamReader sr = new System.IO.StreamReader(file, true); // structures.cfgFile cfgFile = cfgOut.getValues; // = // cfgFile.languageFile = languageFilePath; Form1.options.languageFile = languageFilePath; // cfgOut.getValues = cfgFile; // cfgOut.writeCfgFile(); Form1.options.save(); string fullList = sr.ReadToEnd(); string[] temp = fullList.Split("\n".ToCharArray()); int tot = 0; //System.Collections.BitArray isOk = new System.Collections.BitArray( temp.Length, false ); bool[] isOk = new bool[temp.Length]; for (int i = 0; i < temp.Length; i++) { temp[i] = temp[i].TrimEnd("\r".ToCharArray()); if ( temp[i] != "" && !temp[i].StartsWith("//") ) { isOk[i] = true; tot++; } } list = new string[tot]; int pos1 = 0; for (int i = 0; i < temp.Length; i++) { if (isOk[i]) { list[pos1] = temp[i]; pos1++; } } curLanguage = languageFilePath; sr.Close(); file.Close(); }
public void aquireTechno(byte techno) { technos[techno].researched = true; // Form1.game.playerList[ player ].technos[ Form1.game.playerList[ player ].currentResearch ].researched = true; if (currentResearch == techno) { // ai Ai = new ai(); byte[] possibleTechnos = ai.returnDisponibleTechnologies(player); if (player == Form1.game.curPlayerInd) { string technoName = Statistics.technologies[currentResearch].name; if (possibleTechnos.Length > 0) { byte nextTechno = ai.randomTechnology(player); string[] choices = uiWrap.technoListStrings(player, possibleTechnos); userChoice ui = new userChoice( language.getAString(language.order.uiNewTechnology), String.Format(language.getAString(language.order.uiYouJustDiscovered), technoName), choices, 0, language.getAString(language.order.ok), language.getAString(language.order.uiOpenTechnoTree) ); ui.ShowDialog(); int res = ui.result; if (res == -1) { // science tree currentResearch = nextTechno; sciTree sciTree1 = new sciTree(); sciTree1.ShowDialog(); } else { // accept currentResearch = (byte)possibleTechnos[res]; } } else { if (currentResearch != 0) { System.Windows.Forms.MessageBox.Show( String.Format(language.getAString(language.order.uiYouJustDiscoveredEverything), Statistics.technologies[Form1.game.playerList[player].currentResearch].name), language.getAString(language.order.uiNewTechnology) ); } currentResearch = 0; technos[currentResearch].pntDiscovered = 0; } } else // cpu { if (possibleTechnos.Length > 0) { byte nextTechnos = ai.randomTechnology(player); currentResearch = nextTechnos; } else { currentResearch = 0; technos[Form1.game.playerList[player].currentResearch].pntDiscovered = 0; } } } /* Form1.game.playerList[ player ].technos[ techno ].researched = true; * * if ( Form1.game.playerList[ player ].currentResearch == techno ) * { * if ( player == Form1.game.curPlayerInd ) * { * uiWrap.chooseNextTechno( * player, * "You just aquired " + Statistics.technologies[ Form1.game.playerList[ player ].currentResearch ].name.ToLower() + ". Please choose your next research.", * "Technology aquired" * ); * } * else * { * ai Ai = new ai(); * Form1.game.playerList[ player ].currentResearch = Ai.randomTechnology( player ); * } * * }*/ }
public void aquireTechno( byte techno ) { technos[ techno ].researched = true; // Form1.game.playerList[ player ].technos[ Form1.game.playerList[ player ].currentResearch ].researched = true; if ( currentResearch == techno ) { // ai Ai = new ai(); byte[] possibleTechnos = ai.returnDisponibleTechnologies( player ); if ( player == Form1.game.curPlayerInd ) { string technoName = Statistics.technologies[ currentResearch ].name; if ( possibleTechnos.Length > 0 ) { byte nextTechno = ai.randomTechnology( player ); string[] choices = uiWrap.technoListStrings( player, possibleTechnos ); userChoice ui = new userChoice( language.getAString( language.order.uiNewTechnology ), String.Format( language.getAString( language.order.uiYouJustDiscovered ), technoName ), choices, 0, language.getAString( language.order.ok ), language.getAString( language.order.uiOpenTechnoTree ) ); ui.ShowDialog(); int res = ui.result; if ( res == -1 ) { // science tree currentResearch = nextTechno; sciTree sciTree1 = new sciTree(); sciTree1.ShowDialog(); } else { // accept currentResearch = (byte)possibleTechnos[ res ]; } } else { if ( currentResearch != 0 ) System.Windows.Forms.MessageBox.Show( String.Format( language.getAString( language.order.uiYouJustDiscoveredEverything ), Statistics.technologies[ Form1.game.playerList[ player ].currentResearch ].name ), language.getAString( language.order.uiNewTechnology ) ); currentResearch = 0; technos[ currentResearch ].pntDiscovered = 0; } } else // cpu { if ( possibleTechnos.Length > 0 ) { byte nextTechnos = ai.randomTechnology( player ); currentResearch = nextTechnos; } else { currentResearch = 0; technos[ Form1.game.playerList[ player ].currentResearch ].pntDiscovered = 0; } } } /* Form1.game.playerList[ player ].technos[ techno ].researched = true; if ( Form1.game.playerList[ player ].currentResearch == techno ) { if ( player == Form1.game.curPlayerInd ) { uiWrap.chooseNextTechno( player, "You just aquired " + Statistics.technologies[ Form1.game.playerList[ player ].currentResearch ].name.ToLower() + ". Please choose your next research.", "Technology aquired" ); } else { ai Ai = new ai(); Form1.game.playerList[ player ].currentResearch = Ai.randomTechnology( player ); } }*/ }