/// <summary> /// Generates a creature based on seed value. /// </summary> /// <param name="Seed">Seed value.</param> public Creature(int Seed, Texture2D texture, Vector2 position2D, float moveSpeed, int frameWidth, int frameHeight, int millisecondsBetweenFrame) : base(texture, position2D, moveSpeed, frameWidth, frameWidth, millisecondsBetweenFrame) { _seed = Seed; int[] Points = new int[2]; int[] BDMax = new int[2]; int[] TUMax = new int[2]; ushort[,] Stats = new ushort[2, 7]; ushort[,] BD = new ushort[2, 7]; StatsBool[,] Toggles = new StatsBool[2, 5]; Random rand = new Random(Seed); for (int y = 0; y < 2; y++) { Points[y] = 800; BDMax[y] = 32; TUMax[y] = 32; //stats for (int i = 0; i < 7; i++) { Stats[y, i] = (ushort)rand.Next(Points[y] / (7 - (i))); Points[y] -= Stats[y, i]; BD[y, i] = (ushort)rand.Next(BDMax[y] / (7 - (i))); BDMax[y] -= BD[y, i]; } //left over points get allocated int looper = 0; while (Points[y] != 0) { int value = (ushort)rand.Next(1, Points[y]); Stats[y, looper] += (ushort)value; Points[y] -= value; looper = (looper + 1) % 7; } while (BDMax[y] != 0) { int value = (ushort)rand.Next(1, BDMax[y]); BD[y, looper] += (ushort)value; BDMax[y] -= value; looper = (looper + 1) % 7; } for (int i = 0; i < 5; i++) { Toggles[y, i].Active = rand.Next(0, 2) == 0; Toggles[y, i].Used = (ushort)rand.Next(TUMax[y] / (5 - (i))); TUMax[y] -= BD[y, i]; } while (TUMax[y] != 0) { looper = (looper + 1) % 5; int value = (ushort)rand.Next(1, TUMax[y]); Toggles[y, looper].Used += value; TUMax[y] -= value; } } StatsUShort[] Health = new StatsUShort[2]; Health[0].Maximum = Stats[0, 0]; Health[0].Used = BD[0, 0]; Health[1].Maximum = Stats[1, 0]; Health[1].Used = BD[1, 0]; InitialValues(ref Health); StatsUShort[] Weight = new StatsUShort[2]; Weight[0].Maximum = Stats[0, 1]; Weight[0].Used = BD[0, 1]; Weight[1].Maximum = Stats[1, 1]; Weight[1].Used = BD[1, 1]; InitialValues(ref Weight); StatsUShort[] Size = new StatsUShort[2]; Size[0].Maximum = Stats[0, 2]; Size[0].Used = BD[0, 2]; Size[1].Maximum = Stats[1, 2]; Size[1].Used = BD[1, 2]; InitialValues(ref Size); StatsUShort[] Strength = new StatsUShort[2]; Strength[0].Maximum = Stats[0, 3]; Strength[0].Used = BD[0, 3]; Strength[1].Maximum = Stats[1, 3]; Strength[1].Used = BD[1, 3]; InitialValues(ref Strength); StatsUShort[] Dexterity = new StatsUShort[2]; Dexterity[0].Maximum = Stats[0, 4]; Dexterity[0].Used = BD[0, 4]; Dexterity[1].Maximum = Stats[1, 4]; Dexterity[1].Used = BD[1, 4]; InitialValues(ref Dexterity); StatsUShort[] Endurance = new StatsUShort[2]; Endurance[0].Maximum = Stats[0, 5]; Endurance[0].Used = BD[0, 5]; Endurance[1].Maximum = Stats[1, 5]; Endurance[1].Used = BD[1, 5]; InitialValues(ref Endurance); StatsUShort[] Speed = new StatsUShort[2]; Speed[0].Maximum = Stats[0, 6]; Speed[0].Used = BD[0, 6]; Speed[1].Maximum = Stats[1, 6]; Speed[1].Used = BD[1, 6]; InitialValues(ref Speed); Dominant.Health = Health[0]; Recessive.Health = Health[1]; Dominant.Weight = Weight[0]; Recessive.Weight = Weight[1]; Dominant.Size = Size[0]; Recessive.Size = Size[1]; Dominant.Strength = Strength[0]; Recessive.Strength = Strength[1]; Dominant.Dexterity = Dexterity[0]; Recessive.Dexterity = Dexterity[1]; Dominant.Endurance = Endurance[0]; Recessive.Endurance = Endurance[1]; Dominant.Speed = Speed[0]; Recessive.Speed = Speed[1]; Dominant.Head = Toggles[0, 0]; Recessive.Head = Toggles[1, 0]; Dominant.Legs = Toggles[0, 1]; Recessive.Legs = Toggles[1, 1]; Dominant.Arms = Toggles[0, 2]; Recessive.Arms = Toggles[1, 2]; Dominant.Wings = Toggles[0, 3]; Recessive.Wings = Toggles[1, 3]; Dominant.Claws = Toggles[0, 4]; Recessive.Claws = Toggles[1, 4]; this.Health = this.Dominant.Health.Level; //Not Yet Implimented Dominant.SpinalColumns.Maximum = 8; Dominant.TailColumns.Maximum = 4; avTacks = new AttackTypes(Dominant); CreateModel(); }
private StatsBool[] BoolMethod(StatsBool AD, StatsBool BD, StatsBool AR, StatsBool BR, float UsedRAvg) { StatsBool[] output = new StatsBool[2]; if (AD.Active && BD.Active) { output[0].Active = true; output[0].Used = 0; float num = (AD.Used + BD.Used) / 2; if (num < UsedRAvg) output[1].Active = false; else output[1].Active = true; output[1].Used = (int)num; } else if (AD.Active && BD.Active) { output[0].Active = true; output[0].Used = 0; float num = (AR.Used + BR.Used) / 2; if (num < UsedRAvg) output[1].Active = false; else output[1].Active = true; output[1].Used = (int)num; } else { output[0].Active = false; output[0].Used = (AD.Used + BD.Used) / 2; float num = (AR.Used + BR.Used) / 2; if (num < UsedRAvg) output[1].Active = false; else output[1].Active = true; output[1].Used = (int)num; } return output; }