public Bacteria CreateBacteria(Bacteria Mom) { if (Mom.type == (int)Game.bacteriaType.Evil) { Control.nowEvilCounter++; Control.allTimeEvilCounter++; Bacteria Bac = Mom.Reproduction(); RefreshStatistic(Bac); return(Bac); } else if (rnd.Next(0, 1000) < Settings.changeOfBeginEvil) { Control.nowEvilCounter++; Control.allTimeEvilCounter++; PeacBacteria Bac = (PeacBacteria)Mom.Reproduction(); RefreshStatistic(Bac); return(Bac.BeginToEvil()); } else { Control.nowPeacCounter++; Control.allTimePeacCounter++; Bacteria Bac = Mom.Reproduction(); RefreshStatistic(Bac); return(Bac); } }
private void AddBacteria(Bacteria Bac) { bacterias.Add(Bac); Canvas.SetLeft(Bac.Texture, Bac.x); Canvas.SetTop(Bac.Texture, Bac.y); Field.CanvasMap.Children.Add(Bac.Texture); }
private void NewBacteria(Bacteria Mom) { if (Mom != null) { AddBacteria(god.CreateBacteria(Mom)); } }
public void RefreshStatistic(Bacteria Bac) { Control.maxSpeed = Math.Round(Bac.speed, 2); Control.maxRotationSpeed = Math.Round(Bac.rotationSpeed, 2); Control.maxVision = Bac.vision; Control.maxMaxHeal = Bac.maxHeal; Control.maxMaxAge = Bac.maxAge; }
private Food DieBacteria(Bacteria Bac) { god.RefreshCountAfterDie(Bac); bacterias.Remove(Bac); Field.CanvasMap.Children.Remove(Bac.Texture); Bac.isAlive = false; CheckEndGame(); return(god.BacteriaDie(Bac)); }
private void NewFood(Bacteria F = null) { if (F == null) { F = god.CreateFood(); } bacterias.Add(F); Canvas.SetLeft(F.Texture, F.x); Canvas.SetTop(F.Texture, F.y); Field.CanvasMap.Children.Add(F.Texture); }
public void RefreshCountAfterDie(Bacteria Bac) { if (Bac.type == (int)Game.bacteriaType.Evil) { Control.nowEvilCounter--; } else if (Bac.type == (int)Game.bacteriaType.Peac) { Control.nowPeacCounter--; } }
public static void CopySpecifications(Bacteria Mom, Bacteria child, string PathToTexture) { child.Texture = new Image { Source = (new ImageSourceConverter()).ConvertFromString(PathToTexture) as ImageSource, Width = Settings.bacterialWidth, Height = Settings.bacterialHeight, }; child.x = Mom.x; child.y = Mom.y; child.maxAge = Mom.maxAge; child.maxHeal = Mom.maxHeal; child.speed = Mom.speed; child.rotationSpeed = Mom.rotationSpeed; child.vision = Mom.vision; }
private void EatFood(Bacteria Bac) { if (Bac.Target.isAlive) { god.RefreshCountAfterEat(Bac); Bac.Eat(); bacterias.Remove(Bac.Target); Field.CanvasMap.Children.Remove(Bac.Target.Texture); Bac.Target.isAlive = false; Bac.Target = null; if (Bac.heal > Bac.maxHeal) { Bac.heal = Convert.ToInt32(Bac.maxHeal / 2); NewBacteria(Bac); } } }
protected void BestTarget(List <Bacteria> bacterias) { double bestTarget = 9999999999; double bufTarget; for (int i = 0; i < bacterias.Count; i++) { if ((bacterias[i].type == typeOfFood) && bacterias[i].isAlive) { bufTarget = Math.Pow(bacterias[i].x - x, 2) + Math.Pow(bacterias[i].y - y, 2); if ((bufTarget < bestTarget) && (bufTarget < vision * vision)) { Target = bacterias[i]; bestTarget = bufTarget; } } } }
public Food BacteriaDie(Bacteria Bac) { Control.nowFoodCounter++; return(Bac.Die()); }