+ 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:
11
Einwohner.cs
11
Einwohner.cs
@ -13,14 +13,16 @@ namespace vampi
|
|||||||
get { return this.infected; }
|
get { return this.infected; }
|
||||||
}
|
}
|
||||||
public static int legalSexAge = Settings.humanLegalSexAge;
|
public static int legalSexAge = Settings.humanLegalSexAge;
|
||||||
public static int vampireConversionRate = Settings.humanVampireConversionPercent;
|
public static int vampireConversionRate = Settings.humanVampireConversionPercent;
|
||||||
|
public bool ismale;
|
||||||
|
|
||||||
public Einwohner(Spielfeld sfeld)
|
public Einwohner(Spielfeld sfeld)
|
||||||
: base(sfeld) {
|
: base(sfeld) {
|
||||||
this.typ = Typliste.EINWOHNER;
|
this.typ = Typliste.EINWOHNER;
|
||||||
this.maxAge = Settings.humanMaxAge;
|
this.maxAge = Settings.humanMaxAge;
|
||||||
this.age = Program.random.Next(0, Settings.humanMaxInitAge);
|
this.age = Program.random.Next(0, Settings.humanMaxInitAge);
|
||||||
Einwohner.count++;
|
Einwohner.count++;
|
||||||
|
if (Program.random.Next(0, 100) < 85) this.ismale = true; else this.ismale = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void infect() {
|
public void infect() {
|
||||||
@ -54,8 +56,9 @@ namespace vampi
|
|||||||
Spielfeld neighbor = this.sfeld.getNachbarfeld(i);
|
Spielfeld neighbor = this.sfeld.getNachbarfeld(i);
|
||||||
if (neighbor != null && neighbor.Sfigur != null) {
|
if (neighbor != null && neighbor.Sfigur != null) {
|
||||||
if (neighbor.Sfigur.Typ == Typliste.EINWOHNER) {
|
if (neighbor.Sfigur.Typ == Typliste.EINWOHNER) {
|
||||||
if (neighbor.Sfigur.Age >= Einwohner.legalSexAge && (Settings.humanNormalCanReproduceWithInfected || !((Einwohner)neighbor.Sfigur).Infected)) {
|
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) {
|
} else if (neighbor != null && neighbor.Sfigur == null) {
|
||||||
|
@ -38,6 +38,7 @@ class FastPixel {
|
|||||||
this._width = bitmap.Width;
|
this._width = bitmap.Width;
|
||||||
this._height = bitmap.Height;
|
this._height = bitmap.Height;
|
||||||
this.bytesPerPixel = (this._isAlpha)?4:3;
|
this.bytesPerPixel = (this._isAlpha)?4:3;
|
||||||
|
this.rgbValues = new byte[(this.Width * this.Height) * this.bytesPerPixel];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Lock() {
|
public void Lock() {
|
||||||
@ -46,7 +47,6 @@ class FastPixel {
|
|||||||
|
|
||||||
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
|
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
|
||||||
this.bmpData = this.Bitmap.LockBits(rect, ImageLockMode.ReadWrite, this.Bitmap.PixelFormat);
|
this.bmpData = this.Bitmap.LockBits(rect, ImageLockMode.ReadWrite, this.Bitmap.PixelFormat);
|
||||||
this.rgbValues = new byte[(this.Width * this.Height) * this.bytesPerPixel];
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
byte* ptr= (byte*)this.bmpData.Scan0;
|
byte* ptr= (byte*)this.bmpData.Scan0;
|
||||||
|
@ -11,18 +11,19 @@ namespace vampi {
|
|||||||
public class Output_GUI : Output {
|
public class Output_GUI : Output {
|
||||||
const int statsHeight = 45;
|
const int statsHeight = 45;
|
||||||
int scale = 1;
|
int scale = 1;
|
||||||
Form f = new Form();
|
Form f;
|
||||||
FastPixel fp;
|
FastPixel fp;
|
||||||
Graphics fg;
|
Graphics fg;
|
||||||
Bitmap field;
|
Bitmap field;
|
||||||
Bitmap stats;
|
Bitmap stats;
|
||||||
|
|
||||||
public Output_GUI() {
|
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.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);
|
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";
|
f.Text = "Vampi GUI --- ©2008 Markus Birth, FA76";
|
||||||
|
|
||||||
// attach some events
|
// attach some events
|
||||||
@ -80,7 +81,7 @@ namespace vampi {
|
|||||||
int mapSteps = gradientMap.GetLength(0)-1;
|
int mapSteps = gradientMap.GetLength(0)-1;
|
||||||
double percSteps = 100/(double)mapSteps;
|
double percSteps = 100/(double)mapSteps;
|
||||||
int bestMatch = (int)(percent/percSteps);
|
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);
|
int curStep = (int)Math.Floor(percent/percSteps);
|
||||||
if (curStep == gradientMap.GetLength(0)-1) curStep--;
|
if (curStep == gradientMap.GetLength(0)-1) curStep--;
|
||||||
Color left = gradientMap[curStep];
|
Color left = gradientMap[curStep];
|
||||||
|
@ -3,7 +3,7 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace vampi {
|
namespace vampi {
|
||||||
public abstract class Settings {
|
public abstract class Settings {
|
||||||
public const int size = 500;
|
public const int size = 120;
|
||||||
public const int coveragePercent = 77;
|
public const int coveragePercent = 77;
|
||||||
public const int vampireRatio = 3;
|
public const int vampireRatio = 3;
|
||||||
public const int drawEveryNthStep = 1;
|
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[] guiColorHuman = {Color.FromArgb(0, 60, 0), Color.LimeGreen};
|
||||||
public static Color[] guiColorHumanInfected = {Color.FromArgb(60, 0, 60), Color.DarkMagenta};
|
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[] 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 Font guiFont = new Font("sans-serif", 8);
|
||||||
public static Brush guiFontBrush = Brushes.Black;
|
public static Brush guiFontBrush = Brushes.Black;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
namespace vampi
|
namespace vampi
|
||||||
{
|
{
|
||||||
@ -6,7 +7,8 @@ namespace vampi
|
|||||||
protected Spielfeld sfeld;
|
protected Spielfeld sfeld;
|
||||||
protected int typ;
|
protected int typ;
|
||||||
protected int maxAge = 80;
|
protected int maxAge = 80;
|
||||||
protected int age = -1;
|
protected int age = -1;
|
||||||
|
|
||||||
public int Age {
|
public int Age {
|
||||||
get { return this.age; }
|
get { return this.age; }
|
||||||
}
|
}
|
||||||
@ -18,8 +20,8 @@ namespace vampi
|
|||||||
public Spielfigur(Spielfeld sfeld) {
|
public Spielfigur(Spielfeld sfeld) {
|
||||||
sfeld.Sfigur = this;
|
sfeld.Sfigur = this;
|
||||||
this.sfeld = sfeld;
|
this.sfeld = sfeld;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void runStep() {
|
public virtual void runStep() {
|
||||||
if (this.age != -1) {
|
if (this.age != -1) {
|
||||||
this.age++;
|
this.age++;
|
||||||
@ -33,5 +35,4 @@ namespace vampi
|
|||||||
this.sfeld.Sfigur = null;
|
this.sfeld.Sfigur = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user