Пример #1
0
        public CityList addCity(CityList city)
        {
            cityNumber++;

            if (cityNumber >= cityList.Length)
            {
                CityList[] cityListBuffer = cityList;
                cityList = new CityList[cityListBuffer.Length + 5];

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

            cityList[cityNumber] = city;

            return(cityList[cityNumber]);
        }
Пример #2
0
        public void transfertToPlayer(PlayerList nextOwner)
        {
            //		state = (byte)enums.cityState.dead;

            /*		nextOwner.cityNumber ++;
             *
             *              if ( nextOwner.cityNumber >= nextOwner.cityList.Length )
             *              {
             *                      CityList[] cityListBuffer = nextOwner.cityList;
             *                      nextOwner.cityList = new CityList[ cityListBuffer.Length + 5 ];
             *
             *                      for ( int i = 0; i < cityListBuffer.Length; i ++ )
             *                              nextOwner.cityList[ i ] = cityListBuffer[ i ];
             *              }
             *
             *              newCity = new CityList( nextOwner, nextOwner.cityNumber );*/

            CityList newCity = nextOwner.addCity();

            //		getTreasure( nextOwner.player, player, game.grid[ xDest, yDest ].city );

            #region get treasure

            byte[] posTechno = new byte[Statistics.technologies.Length];
            byte   nbr       = 0;
            for (int i = 1; i < Statistics.technologies.Length; i++)
            {
                if (
                    nextOwner.technos[i].researched &&
                    !player.technos[i].researched
                    )
                {
                    posTechno[nbr] = (byte)i;
                    nbr++;
                }
            }

            if (nbr > 0)
            {
                Random r = new Random();

                byte technoChose = posTechno[r.Next(nbr - 1) + 1];

                nextOwner.technos[technoChose].researched = true;
            }

            if (
                (
                    player.cityList[city].population > 6 ||
                    player.cityList[city].isCapitale
                ) &&
                player.technos[(byte)Form1.technoList.mapMaking].researched
                )
            {
                for (int x = 0; x < Form1.game.width; x++)
                {
                    for (int y = 0; y < Form1.game.height; y++)
                    {
                        if (Form1.game.grid[x, y].territory - 1 == player.player || player.discovered[x, y])
                        {
                            nextOwner.discovered[x, y] = true;
                        }
                    }
                }
            }
            else if (
                player.cityList[city].population > 3 &&
                player.technos[(byte)Form1.technoList.mapMaking].researched)
            {
                for (int x = 0; x < Form1.game.width; x++)
                {
                    for (int y = 0; y < Form1.game.height; y++)
                    {
                        if (Form1.game.grid[x, y].territory - 1 == player.player)
                        {
                            nextOwner.discovered[x, y] = true;
                        }
                    }
                }
            }
            #endregion

            labor.removeAllLabor(player.player, city);

            newCity.buildingList  = this.buildingList;
            newCity.foodReserve   = this.foodReserve;
            newCity.name          = this.name;
            newCity.population    = this.population;
            newCity.X             = this.X;
            newCity.Y             = this.Y;
            newCity.originalOwner = this.originalOwner;

            state = (byte)enums.cityState.dead;

            //	game.grid[ xDest, yDest ].territory - 1 = owner;
            player.game.grid[X, Y].city = newCity.city;

            if (
                nextOwner.economyType == (byte)enums.economies.slaveryRacial &&
                newCity.population > 0
                )
            {
                int slavesToTransfert = newCity.population / 2;
                nextOwner.slaves.addSlave(slavesToTransfert);
                newCity.population -= (byte)slavesToTransfert;
                System.Windows.Forms.MessageBox.Show(
                    String.Format(language.getAString(language.order.slaveryAquiredFromCity), slavesToTransfert, newCity.name),
                    language.getAString(language.order.slaveryTitle)
                    );
            }

            ai.chooseConstruction(nextOwner.player, nextOwner.cityNumber);

            player.game.frontier.setFrontiers();

            newCity.laborPos = new Point[0];
            labor.addAllLabor(nextOwner.player, nextOwner.cityNumber);
            newCity.setHasDirectAccessToRessource();

            bool oneCityLeft = false;
            for (int i = 1; i <= player.cityNumber; i++)
            {
                if (player.cityList[i].state != (byte)enums.cityState.dead)
                {
                    oneCityLeft = true;
                    break;
                }
            }

            if (!oneCityLeft)
            {
                player.kill(nextOwner);
            }
            else if (this.isCapitale)
            {
                bool found = false;
                for (int c = 1; c <= player.cityNumber && !found; c++)
                {
                    if (player.cityList[c].state != (byte)enums.cityState.dead)
                    {
                        found = true;
                        player.cityList[c].isCapitale = true;
                    }
                }

                if (!found)
                {
                    System.Windows.Forms.MessageBox.Show("error in finding a capital");
                }
            }

            if (player.player == Form1.game.curPlayerInd)
            {
                open.cityFrm(newCity);                          //owner, city, this );
            }
            //		openCityFrm( owner, nextOwner.cityNumber );
        }
Пример #3
0
		public static void cityFrm( CityList city )
		{
			cityFrm( city.player.player, city.city, null );
		}
Пример #4
0
        public PlayerList(Game game, byte player, byte civType, string playerName, sbyte prefFood, sbyte prefProd, sbyte prefTrade, sbyte prefScience, sbyte prefHapiness, sbyte prefWealth)
        {
            #region short

            this.game   = game;
            this.player = (byte)player;

            memory = new Memory(this, 0);

            curCapital = -1;
            for (int i = 1; i <= cityNumber; i++)
            {
                if (
                    cityList[i].state != (byte)enums.cityState.dead &&
                    cityList[i].isCapitale
                    )
                {
                    curCapital = i;
                    break;
                }
            }

            if (curCapital == -1)
            {
                for (int i = 1; i <= cityNumber; i++)
                {
                    if (cityList[i].state != (byte)enums.cityState.dead)
                    {
                        capital = i;
                        break;
                    }
                }
            }

            slaves  = new playerSlavery(this);
            govType = Statistics.governements[(byte)enums.governements.despotism];
            invalidateTrade();

            #endregion

            lastSeen = new structures.lastSeen[game.width, game.height];

            this.civType    = civType;
            this.playerName = playerName;
            money           = 0;
            currentResearch = 0;

            unitList        = new UnitList[10];
            cityList        = new CityList[5];
            foreignRelation = new structures.sForeignRelation[game.playerList.Length];

            for (int i = 0; i < game.playerList.Length; i++)
            {
                foreignRelation[i].quality = 100;
                foreignRelation[i].spies   = new xycv_ppc.structures.sSpies[4];

                for (int j = 0; j < 4; j++)
                {
                    foreignRelation[i].spies[j]     = new xycv_ppc.structures.sSpies();
                    foreignRelation[i].spies[j].nbr = 0;
                }
            }

            technos = new xycv_ppc.structures.technoList[Statistics.technologies.Length];

            unitNumber = 0;
            cityNumber = 0;
            technos[0].pntDiscovered = 0;

            preferences.laborFood  = prefFood;
            preferences.laborProd  = prefProd;
            preferences.laborTrade = prefTrade;
            preferences.science    = prefScience;
            preferences.reserve    = prefWealth;
            discovered             = new bool[game.width, game.height];
            see = new bool[game.width, game.height];
            //	p.unitList = new UnitList[ 50 ];
            //	p.foreignRelation = new structures.sForeignRelation[ game.playerList.Length ];

            setResourcesAccess();
            //		p.memory = new Memory( this, 0 );

            smallWonderList = new WonderList(Statistics.smallWonders.Length);
        }
Пример #5
0
 public static void cityFrm(CityList city)
 {
     cityFrm(city.player.player, city.city, null);
 }
Пример #6
0
		public CityList addCity( CityList city )
		{
			cityNumber ++;

			if ( cityNumber >= cityList.Length )
			{
				CityList[] cityListBuffer = cityList;
				cityList = new CityList[ cityListBuffer.Length + 5 ];

				for ( int i = 0; i < cityListBuffer.Length; i ++ )
					cityList[ i ] = cityListBuffer[ i ];
			}

			cityList[ cityNumber ] = city;

			return cityList[ cityNumber ];
		}
Пример #7
0
		public PlayerList( Game game, byte player, byte civType, string playerName, sbyte prefFood, sbyte prefProd, sbyte prefTrade, sbyte prefScience, sbyte prefHapiness, sbyte prefWealth )
		{
			#region short
			
			this.game = game;
			this.player = (byte)player;

			memory = new Memory( this, 0 );
			
			curCapital = -1; 
			for ( int i = 1; i <= cityNumber; i ++ ) 
				if ( 
					cityList[ i ].state != (byte)enums.cityState.dead && 
					cityList[ i ].isCapitale 
					) 
				{
					curCapital = i;
					break;
				}

			if ( curCapital == -1 )
				for ( int i = 1; i <= cityNumber; i ++ ) 
					if ( cityList[ i ].state != (byte)enums.cityState.dead )
					{
						capital = i; 
						break; 
					}

			slaves = new playerSlavery( this );
			govType = Statistics.governements[ (byte)enums.governements.despotism ];
			invalidateTrade();

			#endregion

			lastSeen = new structures.lastSeen[ game.width, game.height ];

			this.civType = civType;
			this.playerName = playerName;
			money = 0;
			currentResearch = 0;

			unitList = new UnitList[ 10 ];
			cityList = new CityList[ 5 ];
			foreignRelation = new structures.sForeignRelation[ game.playerList.Length ];

			for ( int i = 0; i < game.playerList.Length; i ++ )
			{
				foreignRelation[ i ].quality = 100;
				foreignRelation[ i ].spies = new xycv_ppc.structures.sSpies[ 4 ];
				
				for ( int j = 0; j < 4; j ++ )
				{
					foreignRelation[ i ].spies[ j ] = new xycv_ppc.structures.sSpies();
					foreignRelation[ i ].spies[ j ].nbr = 0;
				}
			}
	
			technos = new xycv_ppc.structures.technoList[ Statistics.technologies.Length ];

			unitNumber = 0;
			cityNumber = 0;
			technos[ 0 ].pntDiscovered = 0;
			
			preferences.laborFood = prefFood;
			preferences.laborProd = prefProd;
			preferences.laborTrade = prefTrade;
			preferences.science = prefScience;
			preferences.reserve = prefWealth;
			discovered = new bool[ game.width, game.height ];
			see = new bool[ game.width, game.height ];
			//	p.unitList = new UnitList[ 50 ];
			//	p.foreignRelation = new structures.sForeignRelation[ game.playerList.Length ];
			
			setResourcesAccess();
			//		p.memory = new Memory( this, 0 );

			smallWonderList = new WonderList( Statistics.smallWonders.Length );
		}