Example #1
0
        public static string[] technoListStrings(byte player, byte[] technos)
        {
            string[] choices = new string[technos.Length];

            getPFT getPft = new getPFT();

            //	int nationTrade = Form1.game.playerList[ player ].totalTrade;
            for (int h = 0; h < choices.Length; h++)
            {
                choices[h] = Statistics.technologies[technos[h]].name;

                int sciTurn = (Statistics.technologies[technos[h]].cost - Form1.game.playerList[Form1.game.curPlayerInd].technos[technos[h]].pntDiscovered) * 100 / (Form1.game.playerList[player].totalTrade * Form1.game.playerList[player].preferences.science);

                if (sciTurn > 1)
                {
                    choices[h] += " ( " + sciTurn.ToString() + " turns )";
                }
                else
                {
                    choices[h] += " ( " + sciTurn.ToString() + " turn )";
                }
            }

            return(choices);
        }
Example #2
0
        public static int turnsLeftToBuild(byte owner, int city, Stat.Construction c)          //byte type, int ind )
        {
            getPFT getPFT1 = new getPFT();
            int    turnsLeft;

            if (c is Stat.Wealth)
            {
                turnsLeft = -1;
            }
            else
            {
                turnsLeft = (c.cost - Form1.game.playerList[owner].cityList[city].construction.points) / Form1.game.playerList[owner].cityList[city].production + 1;
            }

            return(turnsLeft);
        }
Example #3
0
        public civPref()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            getPFT getPft = new getPFT();

            nationTrade = Form1.game.playerList[Form1.game.curPlayerInd].totalTrade;

            /*	trackBar1.Value = Form1.game.playerList[ 0 ].preferences.laborProd;
             *      trackBar2.Value = Form1.game.playerList[ 0 ].preferences.laborTrade;
             *      trackBar3.Value = Form1.game.playerList[ 0 ].preferences.laborFood;*/

            pref = Form1.game.playerList[Form1.game.curPlayerInd].preferences;

            values = new byte[6];

            #region back (color)

            /*		PictureBox pb = new PictureBox();
             *              pb.Parent = this;
             *
             *              pb.Location = new Point( 0, 0 );
             *              pb.Size = new Size( this.Width, this.Height );
             *
             *              Bitmap back = new Bitmap( this.Width, this.Height );
             *              Graphics g = Graphics.FromImage( back );
             *              g.Clear( Form1.defaultBackColor );
             *
             *              pb.Image = back;*/
            #endregion


            platformSpec.resolution.set(this.Controls);

            affSlideBars();
            updateSlideBars();
            setValues();
        }
Example #4
0
        public static int turnsLeftToBuild(byte owner, int city, Construction construction, Stat.Construction c)           //byte type, int ind )
        {
            getPFT getPFT1 = new getPFT();
            int    costLeft;
            int    cp = construction.points;

            for (int i = 0; i < construction.list.Length && construction.list[i] != null && cp > 0; i++)
            {
                //	if ( construction.list[ i ].type == (byte)enums.cityBuildType.unit )
                cp -= construction.list[i].cost;
            }

            /*	else if ( construction.list[ i ].type == (byte)enums.cityBuildType.building ) // buildings
             *              cp -= construction.list[ i ].cost;*/

            if (c is Stat.Wealth)
            {
                costLeft = -1;
            }
            else
            {
                costLeft = c.cost;
            }

            /*		if ( type == (byte)enums.cityBuildType.unit )
             *                      costLeft = Statistics.units[ ind ].cost;
             *              else if ( type == (byte)enums.cityBuildType.building ) // buildings
             *                      costLeft = Statistics.buildings[ ind ].cost;
             *              else
             *                      costLeft = -1;		*/

            if (cp > 0)
            {
                costLeft -= cp;
            }

            int turnsLeft = costLeft / Form1.game.playerList[owner].cityList[city].production + 1;

            if (turnsLeft < 1)
            {
                turnsLeft = 1;
            }

            return(turnsLeft);
        }
Example #5
0
        public static int turnsLeftToBuild(byte owner, int city, int pos, Construction construction)
        {
            getPFT getPFT1 = new getPFT();
            int    costLeft;
            int    cp = construction.points;

            for (int i = 0; i < pos && cp > 0; i++)
            {
                cp -= construction.list[i].cost;
            }

            /*	if ( construction.list[ i ].type == (byte)enums.cityBuildType.unit )
             *              cp -= Statistics.units[ construction.list[ i ].ind ].cost;
             *      else if ( construction.list[ i ].type == (byte)enums.cityBuildType.building )// buildings
             *              cp -= Statistics.buildings[ construction.list[ i ].ind ].cost;*/

            if (construction.list[pos] is Stat.Wealth)
            {
                costLeft = -1;
            }
            else
            {
                costLeft = construction.list[pos].cost;
            }

            /*		costLeft = Statistics.units[ construction.list[ pos ].ind ].cost;
             *      else if ( construction.list[ pos ].type == (byte)enums.cityBuildType.building )// buildings
             *              costLeft = Statistics.buildings[ construction.list[ pos ].ind ].cost;
             *      else */

            if (cp > 0)
            {
                costLeft -= cp;
            }

            int turnsLeft = costLeft / Form1.game.playerList[owner].cityList[city].production + 1;

            if (turnsLeft < 1)
            {
                turnsLeft = 1;
            }

            return(turnsLeft);
        }
Example #6
0
		public static string[] technoListStrings( byte player, byte[] technos )
		{
			string[] choices = new string[ technos.Length ];

			getPFT getPft = new getPFT();
		//	int nationTrade = Form1.game.playerList[ player ].totalTrade;
			for ( int h = 0; h < choices.Length; h ++ )
			{
				choices[ h ] = Statistics.technologies[ technos[ h ] ].name;

				int sciTurn = ( Statistics.technologies[ technos[ h ] ].cost - Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ technos[ h ] ].pntDiscovered ) * 100 / ( Form1.game.playerList[ player ].totalTrade * Form1.game.playerList[ player ].preferences.science );
				
				if ( sciTurn > 1 )
					choices[ h ] += " ( " + sciTurn.ToString() + " turns )";
				else
					choices[ h ] += " ( " + sciTurn.ToString() + " turn )";
			}

			return choices;
		}
Example #7
0
        public static int turnsLeftToBuild(byte owner, int city, byte type, int ind)
        {
            getPFT getPFT1 = new getPFT();
            int    turnsLeft;

            if (type == (byte)enums.cityBuildType.unit)
            {
                turnsLeft = (Statistics.units[ind].cost - Form1.game.playerList[owner].cityList[city].construction.points) / Form1.game.playerList[owner].cityList[city].production + 1;
            }
            else if (type == (byte)enums.cityBuildType.building)              // buildings
            {
                turnsLeft = (Statistics.buildings[ind].cost - Form1.game.playerList[owner].cityList[city].construction.points) / Form1.game.playerList[owner].cityList[city].production + 1;
            }
            else
            {
                turnsLeft = -1;
            }

            return(turnsLeft);
        }
Example #8
0
        public static int findWorstLaboredCase(byte owner, int city)
        {
            getPFT gpft = new getPFT();

            int x1 = Form1.game.playerList[owner].cityList[city].X;
            int y1 = Form1.game.playerList[owner].cityList[city].Y;

            //	//	Radius radius = new Radius();
            Point[] pntCovered = new Point[Form1.game.playerList[owner].cityList[city].laborOnField];

            if (pntCovered.Length != 0)
            {
                for (int i = 0; i < pntCovered.Length; i++)
                {
                    pntCovered[i] = Form1.game.playerList[owner].cityList[city].laborPos[i];
                }

                double[] caseValue = new double[pntCovered.Length];

                for (int i = 0; i < pntCovered.Length; i++)
                {
                    /*	if(
                     *              ( Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].territory - 1 == owner ||
                     *              Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].type == (byte)enums.terrainType.sea ) &&
                     *              Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].city == 0 &&
                     *              Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].laborCity == 0
                     *              )
                     *      {*/
                    caseValue[i] =
                        Form1.game.playerList[owner].preferences.laborProd * getPFT.getCaseProd(pntCovered[i].X, pntCovered[i].Y) +
                        Form1.game.playerList[owner].preferences.laborFood * getPFT.getCaseFood(pntCovered[i].X, pntCovered[i].Y) +
                        Form1.game.playerList[owner].preferences.laborTrade * getPFT.getCaseTrade(pntCovered[i].X, pntCovered[i].Y);

                    if (Form1.game.radius.isNextToIrrigation(pntCovered[i].X, pntCovered[i].Y))
                    {
                        caseValue[i] += 3;
                    }

                    /*	}
                     *      else
                     *              caseValue[ i ] = -1;*/
                }

                int caseChoose = 0;

                for (int i = 1; i < pntCovered.Length; i++)
                {
                    if (caseValue[caseChoose] > caseValue[i])
                    {
                        caseChoose = i;
                    }
                }

                if (caseValue[caseChoose] >= 0)
                {
                    return(caseChoose);
                }
                else
                {
                    return(-1);
                }
            }
            return(-1);
        }
Example #9
0
		private void showTechnoInfo( byte techno )
		{
			infoBmp = new Bitmap( pictureBox2.Width, pictureBox2.Height );
			Graphics g = Graphics.FromImage( infoBmp );
			g.FillRectangle( new SolidBrush( Color.Wheat ), 0, 0, pictureBox2.Width - 1, pictureBox2.Height - 1 );
			g.DrawRectangle( new Pen( Color.Black ), 0, 0, pictureBox2.Width - 1, pictureBox2.Height - 1 );
			g.DrawString( 
				Statistics.technologies[ techno ].name, 
				new Font( "Tahoma", 10, FontStyle.Regular ),
				new SolidBrush( Color.Black ),
				50, 
				5
				);

		/*	cmdCCR = new Button();
			cmdCCR.Parent = this;*/
			cmdCCR.BringToFront();
			cmdCCR.Width = 80 * platformSpec.resolution.mod;
			cmdCCR.Height = 20 * platformSpec.resolution.mod;
			cmdCCR.Left = pictureBox2.Width - cmdCCR.Width - 5;
			cmdCCR.Top = pictureBox2.Top + 5;
#if !CF
			cmdCCR.FlatStyle = FlatStyle.System;
#endif

		/*	
			cmdInfo = new Button();
			cmdInfo.Parent = this;*/
			cmdInfo.BringToFront();
			cmdInfo.Height = 20 * platformSpec.resolution.mod;
			cmdInfo.Width = cmdInfo.Height;
			cmdInfo.Left = pictureBox2.Width - cmdCCR.Width - cmdInfo.Width - 10;
			cmdInfo.Top = pictureBox2.Top + 5;
			cmdInfo.Text = "?";

			if ( techno == Form1.game.playerList[ Form1.game.curPlayerInd ].currentResearch )
			{
				cmdCCR.Text = language.getAString( language.order.stResearching ); // "Researching";
				cmdCCR.Enabled = false;

				getPFT getPFT1 = new getPFT();

				float sciTurn; 
				if ( Form1.game.playerList[ Form1.game.curPlayerInd ].totalTrade * Form1.game.playerList[ Form1.game.curPlayerInd ].preferences.science != 0 )
					sciTurn = ( Statistics.technologies[ Form1.game.playerList[ Form1.game.curPlayerInd ].currentResearch ].cost - Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ Form1.game.playerList[ Form1.game.curPlayerInd ].currentResearch ].pntDiscovered ) * 100 / ( Form1.game.playerList[ Form1.game.curPlayerInd ].totalTrade * Form1.game.playerList[ Form1.game.curPlayerInd ].preferences.science );
				else
					sciTurn = 999;

				string strNTurn;
				if ( Convert.ToInt32( sciTurn ) > 1 )
					strNTurn = String.Format( language.getAString( language.order.turnLeft ), Convert.ToInt32( sciTurn ) );
				else
					strNTurn = String.Format( language.getAString( language.order.turnsLeft ), Convert.ToInt32( sciTurn ) );

				SizeF strSize = g.MeasureString( 
					strNTurn,
					new Font( "Tahoma", 8, FontStyle.Regular )
					);
				g.DrawString( 
					strNTurn,
					new Font( "Tahoma", 8, FontStyle.Regular ),
					new SolidBrush( Color.Black ),
					pictureBox2.Width - 5 - strSize.Width,
					cmdCCR.Bottom - pictureBox2.Top
					);
			}
			else if ( !Statistics.technologies[ techno ].canBeResearched )
			{
				if ( Form1.game.playerList[ 0 ].technos[ techno ].researched )
				{
					cmdCCR.Text = language.getAString( language.order.stFound ); // "Found";
					cmdCCR.Enabled = false;
				}
				else
				{
					cmdCCR.Text = language.getAString( language.order.stUnknown ); // "Unknown";
					cmdCCR.Enabled = false;
				}
			}
			else if ( Form1.game.playerList[ 0 ].technos[ techno ].researched )
			{
				cmdCCR.Text = language.getAString( language.order.stResearched ); // "Researched";
				cmdCCR.Enabled = false;
			}
			else if ( 
				Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ Statistics.technologies[ techno ].needs[ 0 ] ].researched && 
				Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ Statistics.technologies[ techno ].needs[ 1 ] ].researched && 
				Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ Statistics.technologies[ techno ].needs[ 2 ] ].researched
				)
			{
				cmdCCR.Text = language.getAString( language.order.stResearch ); // "Research";
				cmdCCR.Enabled = true;

				getPFT getPFT1 = new getPFT();

			/*	float sciTurn;
				if ( Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ techno ].pntDiscovered > 0 )*/
				float sciTurn;
				if ( Form1.game.playerList[ Form1.game.curPlayerInd ].totalTrade * Form1.game.playerList[ Form1.game.curPlayerInd ].preferences.science != 0 )
					sciTurn = ( Statistics.technologies[ techno ].cost - Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ techno ].pntDiscovered ) * 100 / ( ( Form1.game.playerList[ Form1.game.curPlayerInd ].totalTrade * Form1.game.playerList[ Form1.game.curPlayerInd ].preferences.science ) );
				else
					sciTurn = 999;
			/*	else
					sciTurn = Statistics.technologies[ techno ].cost * 10 / ( getPFT1.getNationTrade( Form1.game.curPlayerInd ) * Form1.game.playerList[ Form1.game.curPlayerInd ].preferences.science );
*/
				string strNTurn;
				if ( Convert.ToInt32( sciTurn ) > 1 )
					strNTurn = String.Format( language.getAString( language.order.turnLeft ), Convert.ToInt32( sciTurn ) );
				else
					strNTurn = String.Format( language.getAString( language.order.turnsLeft ), Convert.ToInt32( sciTurn ) );


				SizeF strSize = g.MeasureString( 
					strNTurn,
					new Font( "Tahoma", 8, FontStyle.Regular )
					);
				g.DrawString( 
					strNTurn,
					new Font( "Tahoma", 8, FontStyle.Regular ),
					new SolidBrush( Color.Black ),
					pictureBox2.Width - 5 - strSize.Width,
					cmdCCR.Bottom - pictureBox2.Top
					);

			}
			else
			{
				cmdCCR.Text = language.getAString( language.order.stUnavailable ); // "Unavailable";
				cmdCCR.Enabled = false;
			}

			int j = 0;
			for ( int i = 0; i < Form1.nbrUnit; i ++ )
			{
				if ( Statistics.units[ i ].disponibility == techno )
				{
					g.DrawImage(
						Statistics.units[ i ].bmp,
						new Rectangle( 
							40 + j * 50, 
							pictureBox2.Height - 50, 
							70, 
							50 
							),
						0,
						0,
						70,
						50,
						GraphicsUnit.Pixel,
						Form1.ia
						);

					Font nameFont = new Font( "Tahoma", 8, FontStyle.Regular );
					SizeF nameSize = g.MeasureString( Statistics.units[ i ].name, nameFont );

					g.DrawString( 
						Statistics.units[ i ].name, 
						nameFont,
						new SolidBrush( Color.Black ),
						50 + j * 50 + 50 / 2 - nameSize.Width / 2,
						pictureBox2.Height - nameSize.Height - 2
						);

					j ++;
				}
			}

			if ( Statistics.technologies[ techno ].shortDesc != "" )
			{
				string strShortDesc = Statistics.technologies[ techno ].shortDesc;
				Font shortDescFont = new Font( "Tahoma", 10, FontStyle.Regular );
				SizeF shortDescSize = g.MeasureString( strShortDesc, shortDescFont );

				g.DrawString( 
					strShortDesc,
					shortDescFont,
					new SolidBrush( Color.Black ),
					pictureBox2.Width - shortDescSize.Width - 3,
					pictureBox2.Height - shortDescSize.Height - 2
					);
			}

			pictureBox2.Image = infoBmp;
		}
Example #10
0
		public static int findWorstLaboredCase( byte owner, int city )
		{
			getPFT gpft = new getPFT();

			int x1 = Form1.game.playerList[ owner ].cityList[ city ].X;
			int y1 = Form1.game.playerList[ owner ].cityList[ city ].Y;
			
	//	//	Radius radius = new Radius();
			Point[] pntCovered = new Point[ Form1.game.playerList[ owner ].cityList[ city ].laborOnField ];

			if ( pntCovered.Length != 0 )
			{
				for ( int i = 0; i < pntCovered.Length; i ++ )
				{
					pntCovered[ i ] = Form1.game.playerList[ owner ].cityList[ city ].laborPos[ i ];
				}

				double[] caseValue = new double[ pntCovered.Length ];
			
				for ( int i = 0; i < pntCovered.Length ; i ++ )
				{
					/*	if( 
							( Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].territory - 1 == owner ||
							Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].type == (byte)enums.terrainType.sea ) && 
							Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].city == 0 && 
							Form1.game.grid[ pntCovered[ i ].X,  pntCovered[ i ].Y ].laborCity == 0 
							)
						{*/
					caseValue[ i ] = 
						Form1.game.playerList[ owner ].preferences.laborProd * getPFT.getCaseProd( pntCovered[ i ].X, pntCovered[ i ].Y ) + 
						Form1.game.playerList[ owner ].preferences.laborFood * getPFT.getCaseFood( pntCovered[ i ].X, pntCovered[ i ].Y ) + 
						Form1.game.playerList[ owner ].preferences.laborTrade * getPFT.getCaseTrade( pntCovered[ i ].X, pntCovered[ i ].Y );

					if ( Form1.game.radius.isNextToIrrigation( pntCovered[ i ].X,  pntCovered[ i ].Y ) )
						caseValue[ i ] += 3;
					/*	}
						else
							caseValue[ i ] = -1;*/
				}

				int caseChoose = 0;

				for ( int i = 1; i < pntCovered.Length; i++ )
				{
					if ( caseValue[ caseChoose ] > caseValue[ i ] )
						caseChoose = i ;
				}

				if ( caseValue[ caseChoose ] >= 0 )
					return caseChoose;
				else
					return -1;
			}
			return -1;
		}
Example #11
0
        public static int unitSupported(byte player)
        {
            getPFT gp = new getPFT();

            return((Form1.game.playerList[player].totalTrade * Form1.game.playerList[player].preferences.military / 100) / 3);                  /// Statistics.governements
        }
Example #12
0
        public void createUnit(int x, int y, byte unitType)
        {
            if (Statistics.units[unitType].speciality != enums.speciality.builder)
            {
                int   mf      = count.militaryFunding(player);
                int   un      = totMilitaryUnits;          //count.militaryUnits( player );
                sbyte nextMFp = 0;
                bool  mod     = true;

                getPFT gp = new getPFT();

                if (un == 0)
                {
                    nextMFp = (sbyte)(3 * 100 / totalTrade + 1);
                }
                else                  // game.playerList[ player ].preferences.military
                {
                    if (un <= mf / 3) // over yellow
                    {
                        nextMFp = (sbyte)(3 * 100 * (un + 1) / totalTrade + 1);
                    }
                    else if (un <= mf * 6 / (3 * 5))                         // over red
                    {
                        nextMFp = (sbyte)(3 * 100 * 4 * (un + 1) / (5 * totalTrade) + 1);
                    }
                    else
                    {
                        mod = false;
                    }
                }

                if (mod)
                {
                    aiPref.setMilitary(player, nextMFp);
                }
            }

            unitNumber++;

            if (unitNumber >= unitList.Length)
            {
                UnitList[] unitListBuffer = unitList;
                unitList = new UnitList[unitListBuffer.Length + 10];

                for (int i = 0; i < unitListBuffer.Length; i++)
                {
                    unitList[i] = unitListBuffer[i];
                }
            }

            unitList[unitNumber] = new UnitList(game.playerList[player], unitNumber);

            unitList[unitNumber].X                = x;
            unitList[unitNumber].Y                = y;
            unitList[unitNumber].type             = unitType;
            unitList[unitNumber].moveLeft         = (sbyte)Statistics.units[unitType].move;
            unitList[unitNumber].moveLeftFraction = 0;
            unitList[unitNumber].state            = (byte)Form1.unitState.idle;
            unitList[unitNumber].health           = 3;
            unitList[unitNumber].level            = 1;

            // transport
            if (Statistics.units[unitType].transport > 0)
            {
                unitList[unitNumber].transport   = new int[Statistics.units[unitType].transport];
                unitList[unitNumber].transported = 0;
            }

            move.moveUnitToCase(x, y, player, unitNumber);

            sight.discoverRadius(x, y, Statistics.units[unitType].sight, player);

            #region special resources

            /*		if ( game.grid[ x, y ].resources > 0 && game.grid[ x, y ].resources < 100 )
             *              {
             *                      if ( game.grid[  x, y ].resources == (byte)enums.speciaResources.horses )
             *                      {
             *                              if ( !technos[ (byte)Form1.technoList.horseBreed ].researched )
             *                              {
             *                                      technos[ (byte)Form1.technoList.horseBreed ].researched = true;
             *
             *                                      if ( Form1.game.curPlayerInd == player )
             *                                      {
             *                                              DrawMap();
             *                                              MessageBox.Show( "You just discovered horses.", "Rare resources" );
             *                                      }
             *                              }
             *                      }
             *                      else if ( game.grid[  x, y ].resources == (byte)enums.speciaResources.elephant )
             *                      {
             *                              if ( !technos[ (byte)Form1.technoList.elephantBreed ].researched )
             *                              {
             *                                      technos[ (byte)Form1.technoList.elephantBreed ].researched = true;
             *
             *                                      if ( Form1.game.curPlayerInd == player )
             *                                      {
             *                                              DrawMap();
             *                                              MessageBox.Show( "You just discovered elephants.", "Rare resources" );
             *                                      }
             *                              }
             *                      }
             *                      else if ( game.grid[  x, y ].resources == (byte)enums.speciaResources.camel )
             *                      {
             *                              if ( !technos[ (byte)Form1.technoList.camelBreed ].researched )
             *                              {
             *                                      technos[ (byte)Form1.technoList.camelBreed ].researched = true;
             *
             *                                      if ( Form1.game.curPlayerInd == player )
             *                                      {
             *                                              DrawMap();
             *                                              MessageBox.Show( "You just discovered camels.", "Rare resources" );
             *                                      }
             *                              }
             *                      }
             *
             *                      game.grid[  x, y ].resources = 0;
             *              }*/
            #endregion
        }
Example #13
0
        /*	public static int militaryUnits( byte player )
         *      {
         *              int un = 0;
         *              for ( int i = 1; i <= Form1.game.playerList[ player ].unitNumber; i ++ )
         *                      if (
         *                              Form1.game.playerList[ player ].unitList[ i ].state !=  (byte)Form1.unitState.dead &&
         *                              Statistics.units[ Form1.game.playerList[ player ].unitList[ i ].type ].speciality != enums.speciality.builder
         *                              )
         *                              un ++;
         *
         *              return un;
         *      }	*/

        public static int militaryFunding(byte player)
        {
            getPFT gp = new getPFT();

            return(Form1.game.playerList[player].totalTrade * Form1.game.playerList[player].preferences.military / 100);
        }
Example #14
0
		public static int unitSupported( byte player )
		{
			getPFT gp = new getPFT();
			return ( Form1.game.playerList[ player ].totalTrade * Form1.game.playerList[ player ].preferences.military / 100 ) / 3; /// Statistics.governements
		}
Example #15
0
		public FrmCity( byte player1, int city1 ) //, string name1
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			//
			// TODO: Add any constructor code after InitializeComponent call
			//

			this.Text = Form1.game.playerList[ player1 ].cityList[ city1 ].name;

			listConst = new ArrayList();

			getPFT1 = new getPFT(); 
			player = player1; 
			city = city1; 
			lbBuildings.Items.Clear();

			for ( byte i = 0; i < Form1.game.playerList[ player ].cityList[ city ].buildingList.Length; i ++ ) 
				if ( Form1.game.playerList[ player1 ].cityList[ city1 ].buildingList[ i ] )
				{
					listConst.Add( i );
					lbBuildings.Items.Add( Statistics.buildings[ i ].name );
				}

			int tot = 0;
			for ( int c = 1; c <= Form1.game.playerList[ player ].cityNumber; c ++ )
				if ( Form1.game.playerList[ player ].cityList[ c ].state != (byte)enums.cityState.dead )
					tot ++;

			if ( tot <= 1 )
			{
				cmdNext.Enabled = false; 
				cmdPrev.Enabled = false; 
			}

			cmdNext.Text = language.getAString( language.order.next );
			cmdPrev.Text = language.getAString( language.order.previous );

			miSetAsCapital = new MenuItem();
			miSetAsCapital.Text = language.getAString( language.order.citySetAsCapital );
			miSetAsCapital.Click += new EventHandler(cmdSetAsCapital_Click);
			miSetAsCapital.Enabled = false;

			miRename = new MenuItem();
			miRename.Text = language.getAString( language.order.cityRename );
			miRename.Click += new EventHandler( cmdRename_Click );

			miEvacuate = new MenuItem();
			miEvacuate.Text = language.getAString( language.order.cityEvacuate );
			miEvacuate.Click += new EventHandler( cmdEvacuate_Click );


			miTransfertSlave = new MenuItem();
			miTransfertSlave.Text = "Transfert slaves";//language.getAString( language.order.cityEvacuate );
			miTransfertSlave.Click += new EventHandler( miTransfertSlave_Click );

			cmMore = new ContextMenu();
			cmMore.MenuItems.Add( miSetAsCapital );
			cmMore.MenuItems.Add( miRename );
			cmMore.MenuItems.Add( miEvacuate );

			if ( Statistics.economies[ Form1.game.playerList[ player ].economyType ].supportSlavery )
			{
				cmMore.MenuItems.Add( miTransfertSlave );

				if ( Form1.game.playerList[ player ].cityList[ city ].slaves.total == 0 )
					miTransfertSlave.Enabled = false;
			}
			
			cmdBuy.Text = language.getAString( language.order.cityBuy );
			cmdBuild.Text = language.getAString( language.order.cityBuild );
			cmdMore.Text = language.getAString( language.order.cityMore );

			cmdBuild.Width = ( lbBuildings.Left - 8 * 4 ) / 3;
			cmdBuy.Width = ( lbBuildings.Left - 8 * 4 ) / 3;
			cmdMore.Width = ( lbBuildings.Left - 8 * 4 ) / 3;

			cmdBuild.Left = 8;
			cmdBuy.Left = cmdBuild.Right + 8;
			cmdMore.Left = cmdBuy.Right + 8;

			platformSpec.manageWindows.setDialogSize( this );

			platformSpec.resolution.set( this.Controls );

			initGraphVar();
			drawStaticBack();
			enableButtons();
			showInfo();
		}
Example #16
0
        private void showTechnoInfo(byte techno)
        {
            infoBmp = new Bitmap(pictureBox2.Width, pictureBox2.Height);
            Graphics g = Graphics.FromImage(infoBmp);

            g.FillRectangle(new SolidBrush(Color.Wheat), 0, 0, pictureBox2.Width - 1, pictureBox2.Height - 1);
            g.DrawRectangle(new Pen(Color.Black), 0, 0, pictureBox2.Width - 1, pictureBox2.Height - 1);
            g.DrawString(
                Statistics.technologies[techno].name,
                new Font("Tahoma", 10, FontStyle.Regular),
                new SolidBrush(Color.Black),
                50,
                5
                );

            /*	cmdCCR = new Button();
             *      cmdCCR.Parent = this;*/
            cmdCCR.BringToFront();
            cmdCCR.Width  = 80 * platformSpec.resolution.mod;
            cmdCCR.Height = 20 * platformSpec.resolution.mod;
            cmdCCR.Left   = pictureBox2.Width - cmdCCR.Width - 5;
            cmdCCR.Top    = pictureBox2.Top + 5;
#if !CF
            cmdCCR.FlatStyle = FlatStyle.System;
#endif

            /*
             *      cmdInfo = new Button();
             *      cmdInfo.Parent = this;*/
            cmdInfo.BringToFront();
            cmdInfo.Height = 20 * platformSpec.resolution.mod;
            cmdInfo.Width  = cmdInfo.Height;
            cmdInfo.Left   = pictureBox2.Width - cmdCCR.Width - cmdInfo.Width - 10;
            cmdInfo.Top    = pictureBox2.Top + 5;
            cmdInfo.Text   = "?";

            if (techno == Form1.game.playerList[Form1.game.curPlayerInd].currentResearch)
            {
                cmdCCR.Text    = language.getAString(language.order.stResearching);                // "Researching";
                cmdCCR.Enabled = false;

                getPFT getPFT1 = new getPFT();

                float sciTurn;
                if (Form1.game.playerList[Form1.game.curPlayerInd].totalTrade * Form1.game.playerList[Form1.game.curPlayerInd].preferences.science != 0)
                {
                    sciTurn = (Statistics.technologies[Form1.game.playerList[Form1.game.curPlayerInd].currentResearch].cost - Form1.game.playerList[Form1.game.curPlayerInd].technos[Form1.game.playerList[Form1.game.curPlayerInd].currentResearch].pntDiscovered) * 100 / (Form1.game.playerList[Form1.game.curPlayerInd].totalTrade * Form1.game.playerList[Form1.game.curPlayerInd].preferences.science);
                }
                else
                {
                    sciTurn = 999;
                }

                string strNTurn;
                if (Convert.ToInt32(sciTurn) > 1)
                {
                    strNTurn = String.Format(language.getAString(language.order.turnLeft), Convert.ToInt32(sciTurn));
                }
                else
                {
                    strNTurn = String.Format(language.getAString(language.order.turnsLeft), Convert.ToInt32(sciTurn));
                }

                SizeF strSize = g.MeasureString(
                    strNTurn,
                    new Font("Tahoma", 8, FontStyle.Regular)
                    );
                g.DrawString(
                    strNTurn,
                    new Font("Tahoma", 8, FontStyle.Regular),
                    new SolidBrush(Color.Black),
                    pictureBox2.Width - 5 - strSize.Width,
                    cmdCCR.Bottom - pictureBox2.Top
                    );
            }
            else if (!Statistics.technologies[techno].canBeResearched)
            {
                if (Form1.game.playerList[0].technos[techno].researched)
                {
                    cmdCCR.Text    = language.getAString(language.order.stFound);                    // "Found";
                    cmdCCR.Enabled = false;
                }
                else
                {
                    cmdCCR.Text    = language.getAString(language.order.stUnknown);                    // "Unknown";
                    cmdCCR.Enabled = false;
                }
            }
            else if (Form1.game.playerList[0].technos[techno].researched)
            {
                cmdCCR.Text    = language.getAString(language.order.stResearched);                // "Researched";
                cmdCCR.Enabled = false;
            }
            else if (
                Form1.game.playerList[Form1.game.curPlayerInd].technos[Statistics.technologies[techno].needs[0]].researched &&
                Form1.game.playerList[Form1.game.curPlayerInd].technos[Statistics.technologies[techno].needs[1]].researched &&
                Form1.game.playerList[Form1.game.curPlayerInd].technos[Statistics.technologies[techno].needs[2]].researched
                )
            {
                cmdCCR.Text    = language.getAString(language.order.stResearch);                // "Research";
                cmdCCR.Enabled = true;

                getPFT getPFT1 = new getPFT();

                /*	float sciTurn;
                 *      if ( Form1.game.playerList[ Form1.game.curPlayerInd ].technos[ techno ].pntDiscovered > 0 )*/
                float sciTurn;
                if (Form1.game.playerList[Form1.game.curPlayerInd].totalTrade * Form1.game.playerList[Form1.game.curPlayerInd].preferences.science != 0)
                {
                    sciTurn = (Statistics.technologies[techno].cost - Form1.game.playerList[Form1.game.curPlayerInd].technos[techno].pntDiscovered) * 100 / ((Form1.game.playerList[Form1.game.curPlayerInd].totalTrade * Form1.game.playerList[Form1.game.curPlayerInd].preferences.science));
                }
                else
                {
                    sciTurn = 999;
                }

                /*	else
                 *              sciTurn = Statistics.technologies[ techno ].cost * 10 / ( getPFT1.getNationTrade( Form1.game.curPlayerInd ) * Form1.game.playerList[ Form1.game.curPlayerInd ].preferences.science );
                 */
                string strNTurn;
                if (Convert.ToInt32(sciTurn) > 1)
                {
                    strNTurn = String.Format(language.getAString(language.order.turnLeft), Convert.ToInt32(sciTurn));
                }
                else
                {
                    strNTurn = String.Format(language.getAString(language.order.turnsLeft), Convert.ToInt32(sciTurn));
                }


                SizeF strSize = g.MeasureString(
                    strNTurn,
                    new Font("Tahoma", 8, FontStyle.Regular)
                    );
                g.DrawString(
                    strNTurn,
                    new Font("Tahoma", 8, FontStyle.Regular),
                    new SolidBrush(Color.Black),
                    pictureBox2.Width - 5 - strSize.Width,
                    cmdCCR.Bottom - pictureBox2.Top
                    );
            }
            else
            {
                cmdCCR.Text    = language.getAString(language.order.stUnavailable);                // "Unavailable";
                cmdCCR.Enabled = false;
            }

            int j = 0;
            for (int i = 0; i < Form1.nbrUnit; i++)
            {
                if (Statistics.units[i].disponibility == techno)
                {
                    g.DrawImage(
                        Statistics.units[i].bmp,
                        new Rectangle(
                            40 + j * 50,
                            pictureBox2.Height - 50,
                            70,
                            50
                            ),
                        0,
                        0,
                        70,
                        50,
                        GraphicsUnit.Pixel,
                        Form1.ia
                        );

                    Font  nameFont = new Font("Tahoma", 8, FontStyle.Regular);
                    SizeF nameSize = g.MeasureString(Statistics.units[i].name, nameFont);

                    g.DrawString(
                        Statistics.units[i].name,
                        nameFont,
                        new SolidBrush(Color.Black),
                        50 + j * 50 + 50 / 2 - nameSize.Width / 2,
                        pictureBox2.Height - nameSize.Height - 2
                        );

                    j++;
                }
            }

            if (Statistics.technologies[techno].shortDesc != "")
            {
                string strShortDesc  = Statistics.technologies[techno].shortDesc;
                Font   shortDescFont = new Font("Tahoma", 10, FontStyle.Regular);
                SizeF  shortDescSize = g.MeasureString(strShortDesc, shortDescFont);

                g.DrawString(
                    strShortDesc,
                    shortDescFont,
                    new SolidBrush(Color.Black),
                    pictureBox2.Width - shortDescSize.Width - 3,
                    pictureBox2.Height - shortDescSize.Height - 2
                    );
            }

            pictureBox2.Image = infoBmp;
        }
Example #17
0
		public void createUnit( int x, int y, byte unitType )
		{
			if ( Statistics.units[ unitType ].speciality != enums.speciality.builder )
			{
				int mf = count.militaryFunding( player );
				int un = totMilitaryUnits; //count.militaryUnits( player );
				sbyte nextMFp = 0;
				bool mod = true;

				getPFT gp = new getPFT(); 

				if ( un == 0 ) 
				{ 
					nextMFp = (sbyte)( 3 * 100 / totalTrade + 1 ); 
				} 
				else // game.playerList[ player ].preferences.military 
				{ 
					if ( un <= mf / 3 ) // over yellow 
						nextMFp = (sbyte)( 3 * 100 * ( un + 1 ) / totalTrade + 1 ); 
					else if ( un <= mf * 6 / ( 3 * 5 ) ) // over red 
						nextMFp = (sbyte)( 3 * 100 * 4 * ( un + 1 ) / ( 5 * totalTrade ) + 1 ); 
					else 
						mod = false;
				}

				if ( mod )
					aiPref.setMilitary( player, nextMFp );
			}

			unitNumber ++;

			if ( unitNumber >= unitList.Length )
			{
				UnitList[] unitListBuffer = unitList;
				unitList = new UnitList[ unitListBuffer.Length + 10 ];

				for ( int i = 0; i < unitListBuffer.Length; i ++ )
					unitList[ i ] = unitListBuffer[ i ];
			}

			unitList[ unitNumber ] = new UnitList( game.playerList[ player ], unitNumber );

			unitList[ unitNumber ].X = x;
			unitList[ unitNumber ].Y = y;
			unitList[ unitNumber ].type = unitType;
			unitList[ unitNumber ].moveLeft = (sbyte)Statistics.units[ unitType].move;
			unitList[ unitNumber ].moveLeftFraction = 0;
			unitList[ unitNumber ].state = (byte)Form1.unitState.idle;
			unitList[ unitNumber ].health = 3;
			unitList[ unitNumber ].level = 1;

			// transport
			if ( Statistics.units[ unitType ].transport > 0 )
			{
				unitList[ unitNumber ].transport = new int[ Statistics.units[ unitType ].transport ];
				unitList[ unitNumber ].transported = 0;
			}

			move.moveUnitToCase( x, y, player, unitNumber );

			sight.discoverRadius( x, y, Statistics.units[ unitType ].sight, player );

			#region special resources
	/*		if ( game.grid[ x, y ].resources > 0 && game.grid[ x, y ].resources < 100 )
			{
				if ( game.grid[  x, y ].resources == (byte)enums.speciaResources.horses )
				{
					if ( !technos[ (byte)Form1.technoList.horseBreed ].researched )
					{
						technos[ (byte)Form1.technoList.horseBreed ].researched = true;

						if ( Form1.game.curPlayerInd == player )
						{
							DrawMap();
							MessageBox.Show( "You just discovered horses.", "Rare resources" );
						}
					}
				}
				else if ( game.grid[  x, y ].resources == (byte)enums.speciaResources.elephant )
				{
					if ( !technos[ (byte)Form1.technoList.elephantBreed ].researched )
					{
						technos[ (byte)Form1.technoList.elephantBreed ].researched = true;

						if ( Form1.game.curPlayerInd == player )
						{
							DrawMap();
							MessageBox.Show( "You just discovered elephants.", "Rare resources" );
						}
					}
				}
				else if ( game.grid[  x, y ].resources == (byte)enums.speciaResources.camel )
				{
					if ( !technos[ (byte)Form1.technoList.camelBreed ].researched )
					{
						technos[ (byte)Form1.technoList.camelBreed ].researched = true;

						if ( Form1.game.curPlayerInd == player )
						{
							DrawMap();
							MessageBox.Show( "You just discovered camels.", "Rare resources" );
						}
					}
				}

				game.grid[  x, y ].resources = 0;
			}*/
			#endregion

		}