예제 #1
0
        public static structures.intByte locateNearestAlliedCity(byte owner, Point pos)
        {
            structures.intByte retour = new structures.intByte();
            int lastDist = -1;

            for (int player = 0; player < Form1.game.playerList.Length; player++)
            {
                if (
                    player == owner ||
                    Form1.game.playerList[owner].foreignRelation[player].politic == (byte)Form1.relationPolType.alliance ||
                    Form1.game.playerList[owner].foreignRelation[player].politic == (byte)Form1.relationPolType.Protected
                    )
                {
                    for (int city = 1; city <= Form1.game.playerList[player].cityNumber; city++)
                    {
                        if (Form1.game.playerList[player].cityList[city].state != (byte)enums.cityState.dead)
                        {
                            int dist = Form1.game.radius.getDistWith(pos, new Point(Form1.game.playerList[player].cityList[city].X, Form1.game.playerList[player].cityList[city].Y));
                            if (lastDist == -1 || dist < lastDist)
                            {
                                retour.type = (byte)player;
                                retour.info = city;
                            }
                        }
                    }
                }
            }

            return(retour);
        }
예제 #2
0
파일: aiWar.cs 프로젝트: jithuin/infogeezer
		public static structures.intByte locateNearestAlliedCity( byte owner, Point pos )
		{
			structures.intByte retour = new structures.intByte();
			int lastDist = -1;

			for ( int player = 0; player < Form1.game.playerList.Length; player ++ )
				if ( 
					player == owner || 
					Form1.game.playerList[ owner ].foreignRelation[ player ].politic == (byte)Form1.relationPolType.alliance || 
					Form1.game.playerList[ owner ].foreignRelation[ player ].politic == (byte)Form1.relationPolType.Protected
					)
					for ( int city = 1; city <= Form1.game.playerList[ player ].cityNumber; city ++ )
						if ( Form1.game.playerList[ player ].cityList[ city ].state != (byte)enums.cityState.dead )
						{
							int dist = Form1.game.radius.getDistWith( pos, new Point( Form1.game.playerList[ player ].cityList[ city ].X, Form1.game.playerList[ player ].cityList[ city ].Y ) );
							if ( lastDist == -1 || dist < lastDist )
							{
								retour.type = (byte)player;
								retour.info = city;
							}
						}

			return retour;
		}