Archived
1
0

+ introduced "ismale"-attribute for humans

* humans can only mate with someone from the other sex
x bugfixing for Windows (FontRendering setting)
* some optimizations
This commit is contained in:
Markus Birth 2009-01-30 13:00:32 +01:00
parent fa5ad89d6b
commit 422210793e
5 changed files with 21 additions and 16 deletions

View File

@ -14,6 +14,7 @@ namespace vampi
}
public static int legalSexAge = Settings.humanLegalSexAge;
public static int vampireConversionRate = Settings.humanVampireConversionPercent;
public bool ismale;
public Einwohner(Spielfeld sfeld)
: base(sfeld) {
@ -21,6 +22,7 @@ namespace vampi
this.maxAge = Settings.humanMaxAge;
this.age = Program.random.Next(0, Settings.humanMaxInitAge);
Einwohner.count++;
if (Program.random.Next(0, 100) < 85) this.ismale = true; else this.ismale = false;
}
public void infect() {
@ -55,7 +57,8 @@ namespace vampi
if (neighbor != null && neighbor.Sfigur != null) {
if (neighbor.Sfigur.Typ == Typliste.EINWOHNER) {
if (neighbor.Sfigur.Age >= Einwohner.legalSexAge && (Settings.humanNormalCanReproduceWithInfected || !((Einwohner)neighbor.Sfigur).Infected)) {
mateFound = true;
if (((Einwohner)neighbor.Sfigur).ismale != this.ismale)
mateFound = true;
}
}
} else if (neighbor != null && neighbor.Sfigur == null) {

View File

@ -38,6 +38,7 @@ class FastPixel {
this._width = bitmap.Width;
this._height = bitmap.Height;
this.bytesPerPixel = (this._isAlpha)?4:3;
this.rgbValues = new byte[(this.Width * this.Height) * this.bytesPerPixel];
}
public void Lock() {
@ -46,7 +47,6 @@ class FastPixel {
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
this.bmpData = this.Bitmap.LockBits(rect, ImageLockMode.ReadWrite, this.Bitmap.PixelFormat);
this.rgbValues = new byte[(this.Width * this.Height) * this.bytesPerPixel];
unsafe {
byte* ptr= (byte*)this.bmpData.Scan0;

View File

@ -11,18 +11,19 @@ namespace vampi {
public class Output_GUI : Output {
const int statsHeight = 45;
int scale = 1;
Form f = new Form();
Form f;
FastPixel fp;
Graphics fg;
Bitmap field;
Bitmap stats;
public Output_GUI() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
this.f = new Form();
this.field = new Bitmap(Settings.size, Settings.size, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
this.stats = new Bitmap(f.ClientSize.Width, Output_GUI.statsHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
f.Text = "Vampi GUI --- ©2008 Markus Birth, FA76";
// attach some events
@ -80,7 +81,7 @@ namespace vampi {
int mapSteps = gradientMap.GetLength(0)-1;
double percSteps = 100/(double)mapSteps;
int bestMatch = (int)(percent/percSteps);
if (percent/percSteps == Math.Floor(percent/percSteps)) return gradientMap[bestMatch];
if (percent/percSteps == Math.Floor(percent/percSteps)) return gradientMap[bestMatch]; // shortcut
int curStep = (int)Math.Floor(percent/percSteps);
if (curStep == gradientMap.GetLength(0)-1) curStep--;
Color left = gradientMap[curStep];

View File

@ -3,7 +3,7 @@ using System.Drawing;
namespace vampi {
public abstract class Settings {
public const int size = 500;
public const int size = 120;
public const int coveragePercent = 77;
public const int vampireRatio = 3;
public const int drawEveryNthStep = 1;
@ -19,7 +19,7 @@ namespace vampi {
*/ public static Color[] guiColorHuman = {Color.FromArgb(0, 60, 0), Color.LimeGreen};
public static Color[] guiColorHumanInfected = {Color.FromArgb(60, 0, 60), Color.DarkMagenta};
public static Color[] guiColorVampire = {Color.FromArgb(60, 0, 0), Color.Red};
public static Color guiColorEmpty = Color.Silver;
public static Color guiColorEmpty = Color.Wheat;
public static Font guiFont = new Font("sans-serif", 8);
public static Brush guiFontBrush = Brushes.Black;

View File

@ -1,4 +1,5 @@
using System;
using System.Collections;
namespace vampi
{
@ -7,6 +8,7 @@ namespace vampi
protected int typ;
protected int maxAge = 80;
protected int age = -1;
public int Age {
get { return this.age; }
}
@ -33,5 +35,4 @@ namespace vampi
this.sfeld.Sfigur = null;
}
}
}