示例#1
0
 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);
     }
 }
示例#2
0
 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);
 }
示例#3
0
 private void NewBacteria(Bacteria Mom)
 {
     if (Mom != null)
     {
         AddBacteria(god.CreateBacteria(Mom));
     }
 }
示例#4
0
 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;
 }
示例#5
0
 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));
 }
示例#6
0
 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);
 }
示例#7
0
 public void RefreshCountAfterDie(Bacteria Bac)
 {
     if (Bac.type == (int)Game.bacteriaType.Evil)
     {
         Control.nowEvilCounter--;
     }
     else if (Bac.type == (int)Game.bacteriaType.Peac)
     {
         Control.nowPeacCounter--;
     }
 }
示例#8
0
 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;
 }
示例#9
0
 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);
         }
     }
 }
示例#10
0
        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;
                    }
                }
            }
        }
示例#11
0
 public Food BacteriaDie(Bacteria Bac)
 {
     Control.nowFoodCounter++;
     return(Bac.Die());
 }