Exemple #1
0
        static void SaveFeatureMapMusic(string filename, Graphic img, TMX map)
        {
            //Farben
            Color green=Color.FromArgb(128, 0, 255, 0);
            //Color yellow=Color.FromArgb(128, 255, 255, 0);
            Color red=Color.FromArgb(128, 255, 0, 0);
            //Color blue=Color.FromArgb(128, 0, 0, 255);

            //Images
            Graphic tmpImage=img.GetImage();
            Graphic tmpDraw=new Graphic(tmpImage.Width, tmpImage.Height, tmpImage.ChannelFormat);

            //Properties durchsuchen
            bool found=false;

            foreach(Property prop in map.Properties)
            {
                if(prop.Name=="music")
                {
                    found=true;
                    break;
                }
            }

            if(found)
                tmpDraw.Fill(green);
            else
                tmpDraw.Fill(red);

            //Drawen
            tmpImage.Draw(0, 0, tmpDraw, true);
            tmpImage.SaveToFile(filename);
        }
Exemple #2
0
		/// <summary>
		/// Converts a bitmap to ascii art.
		/// </summary>
		/// <param name="bitmap">A bitmap.</param>
		/// <returns>Ascii art.</returns>
		/// <example>
		/* 0:::::::::::::::::::::::::::::$MMMMM%:::::::::::::::::::::::::::::::::::::M
			%                            (#''` !M8                                    M
			%                    :QMMMMMMMM849640MMM@(                                M
			%                 "MMMMMMM4*' HM:  !MB#MMMMMM$                            M
			%               'MMMM3        ''$844$    `6MMMMM'                         M
			% '#MNN#H@@@@@@HMMM!          '''`           $MMM3                        M
			%1M@99889QB81!!M*M4'`                          @QM:                       M
			%1Q'"B000008MMM*`MM:`''`                       !M@3                :&$;`  M
			%0`  $`      !B  `*MM6  ''''`                 'MM(!:            $MMMMMMMMMM
			%!&  `8'     #`    ''1MM@H3'`'''`         '$MMMH   %          4M$''!@BMMM4M
			% ;0   46   (3       `''''1#@HBH#&$&$448MMMM0'     :'       (M& ':@BQ@"   M
			%  !B(16BMQ`B                       :894:          `*     'MH   B8Q0`     M
			%    &MM` *M&                      !4               ;:"Q#M#'  !@3Q`       M
			%      4MM;&`                      "                (01'`'''`"Q0"         M
			%        :MN                      `(                `'''`  '84B'          M
			%                                 &                 `` `''QB09`           M
			%          !                     :(                 '389088@;             M
			%          1:                   '9                  !"6QQQ!               M
			%          `#                  :B                  `84'                   M
			%           (#                04                   &'                     M
			%            1M6           `9B!                   $:                      M
			%             !M#006(:'"6490`                   `Q:                       M
			%               4B! :(1!                      `48`                        M
			%                 4@9'                      ;@B!                          M
			%                   '9QB0!              ;8QB3                             M
			%                       `&88909444099898%                                 M
			0:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::M 
		*/
		/// </example>
		public string ToAscii()
		{
			Graphic edgeMap=DetectEdges(this);

			string output="";

			for(int y=0; y<edgeMap.Height; y+=13)
			{
				for(int x=0; x<edgeMap.Width; x+=8)
				{
					int minDistance=999999999;
					char minChar=' ';

					for(int i=32; i<127; i++)
					{
						char c=(char)i;
						string str=""+c;

						Graphic characterMap=new Graphic(8, 13, Format.RGB);
						//System.Drawing.Graphics g=System.Drawing.Graphics.FromImage(characterMap);
						characterMap.Fill(System.Drawing.Color.White);

						//characterMap.Rendertex
						Graphic mytext=Graphic.RenderText(new System.Drawing.Font("Courier New", 10), str, System.Drawing.Color.Blue);
						characterMap.Draw(-2, -2, mytext);

						int tmp=ComputeDistance(characterMap,
							new System.Drawing.Rectangle(0, 0, (int)characterMap.Width, (int)characterMap.Height),
							edgeMap,
							new System.Drawing.Rectangle(x, y, (int)characterMap.Width, (int)characterMap.Height));

						if(tmp<minDistance)
						{
							minDistance=tmp;
							minChar=c;
						}
					}

					output+=minChar;
				}

				output+="\r\n";
			}

			return output;
		}
Exemple #3
0
        /// <summary>
        /// Speichert eine Karte welche je nach Monsterstärke eingefärbt wird
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="img"></param>
        /// <param name="map"></param>
        public static void SaveFeatureMapMonsterSpreading(string clientdata, string filename, Graphic img, TMX map)
        {
            //Farben
            Color green=Color.FromArgb(128, 0, 255, 0);
            Color yellow=Color.FromArgb(128, 255, 255, 0);
            Color red=Color.FromArgb(128, 255, 0, 0);
            Color blue=Color.FromArgb(128, 0, 0, 255);

            //Images
            Graphic tmpImage=img.GetImage();
            Graphic tmpDraw=new Graphic(tmpImage.Width, tmpImage.Height, tmpImage.ChannelFormat);

            //Ermittlung der Durchschnittswerte
            string fnMonsterXml=clientdata+"monsters.xml";
            List<Monster> monsters=Monster.GetMonstersFromMonsterXml(fnMonsterXml);
            monsters.Sort();

            Int64 minFightingStrength=999999999999;
            Int64 maxFightingStrength=-999999999999;

            Int64 medianFightingStrength=0;

            Dictionary<int, Int64> MonsterIDsAndFightingStrength=new Dictionary<int, Int64>();

            foreach(Monster monster in monsters)
            {
                if(monster.ID==1) continue; //Killermade ignorieren
                if(monster.ID==31) continue; //Seraphim Nex ignorieren
                if(monster.ID>9999) continue; //Experimentelle Monster ignorieren
                Int64 fightingStrength=monster.FightingStrength;

                if(fightingStrength<minFightingStrength) minFightingStrength=fightingStrength;
                if(fightingStrength>maxFightingStrength) maxFightingStrength=fightingStrength;

                MonsterIDsAndFightingStrength.Add(monster.ID, fightingStrength);
            }

            medianFightingStrength=(maxFightingStrength+minFightingStrength)/2;

            //Monster der Karte ermitteln
            List<MonsterSpawn> mSpawns=Monsters.GetMonsterSpawnFromMap(map);

            if(mSpawns.Count>0)
            {
                Int64 fss=0;

                foreach(MonsterSpawn spawn in mSpawns)
                {
                    if(spawn.MonsterID==1) continue; //Killermade ignorieren
                    if(spawn.MonsterID==31) continue; //Seraphim Nex ignorieren
                    if(spawn.MonsterID>=10000) continue; //Pflanzen etc ignorieren
                    fss+=MonsterIDsAndFightingStrength[spawn.MonsterID];
                }

                fss=fss/mSpawns.Count;

                //Einfärben je nach Stärke
                Int64 vSmarterGreen=(medianFightingStrength+minFightingStrength)/2;
                Int64 vSmarterYellow=(maxFightingStrength+medianFightingStrength)/2;

                if(fss<vSmarterGreen)
                {
                    tmpDraw.Fill(green);
                }
                else if(fss<vSmarterYellow)
                {
                    tmpDraw.Fill(yellow);
                }
                else
                {
                    tmpDraw.Fill(red);
                }
            }
            else //Keine Monster auf der Karte vorhanden
            {
                tmpDraw.Fill(blue);
            }

            //Drawen
            tmpImage.Draw(0, 0, tmpDraw, true);
            tmpImage.SaveToFile(filename);
        }