void Hatch()
        {
            Child.IsEgg = null;
            Child.Brain.CopyFrom(Parents[0].Brain);
            int EyeMin = Parents[0].Eyes.Count;
            int EyeMax = EyeMin;

            for (int i2 = 1; i2 < Parents.Count; i2++)
            {
                int C = Parents[i2].Eyes.Count;
                if (C > EyeMax)
                {
                    EyeMax = C;
                }
                if (C < EyeMin)
                {
                    EyeMin = C;
                }
            }
            int EyeAmount = Form1.Rand.Next(EyeMin, EyeMax + 1);

            Child.Eyes = new List <Creature.Eye>();
            for (int i = 0; i < EyeAmount; i++)
            {
                int Id = Form1.Rand.Next(Parents.Count);
                while (Parents[Id].Eyes.Count < i + 1)
                {
                    Id = (Id + 1) % Parents.Count;
                }
                Child.Eyes.Add(new Creature.Eye(Child, Parents[Id].Eyes[i].Pos, Parents[Id].Eyes[i].Fov));
            }

            int    EyeId  = Form1.Rand.Next(Child.Eyes.Count);
            double Angle  = (Form1.Rand.NextDouble() * 2 - 1) * Math.PI * 0.1;
            float  Sin    = (float)Math.Sin(Angle);
            float  Cos    = (float)Math.Cos(Angle);
            Vector OldPos = Child.Eyes[EyeId].Pos;

            Child.Eyes[EyeId].Pos  = new Vector(OldPos.X * Cos + OldPos.Y * Sin, OldPos.Y * Cos - OldPos.X * Sin);
            Child.Eyes[EyeId].Fov += (float)Form1.Rand.NextDouble() * 0.1f;
            Child.Eyes[EyeId].Fov  = Child.Eyes[EyeId].Fov < 0 ? 0 : Child.Eyes[EyeId].Fov;
            Child.Eyes[EyeId].Fov  = Child.Eyes[EyeId].Fov > 1 ? 1 : Child.Eyes[EyeId].Fov;
            //mutate
            Child.Name   = Parents[0].Name;
            Child.Hue    = Parents[0].Hue;
            Child.EggHue = Parents[0].EggHue;
            Child.Mutate();

            UpdateWorld.AddEntity(Child, Pos, ChunkPos);
            UpdateWorld.RemoveEntity(this);
        }
Beispiel #2
0
 public void Kill()
 {
     Dead   = true;
     Energy = 0;
     foreach (var E in Eyes)
     {
         E.LookAt = null;
     }
     if (Family != null)
     {
         Family.Remove(this);
     }
     UpdateWorld.RemoveEntity(this);
 }
 void Kill()
 {
     Dead = true;
     foreach (var T in NearbyTrees)
     {
         T.Key.AreaMultiplier /= T.Value;
         T.Key.NearbyTrees.Remove(this);
     }
     NearbyTrees.Clear();
     UpdateWorld.RemoveEntity(this);
     for (int i = Leaves.Count - 1; i >= 0; i--)
     {
         Leaves[i].Kill();
     }
 }
 public void Kill()
 {
     Parent.Leaves.Remove(this);
     if (CurrentFlower != null)
     {
         UpdateWorld.RemoveEntity(CurrentFlower);
     }
     if (CurrentSeed != null)
     {
         UpdateWorld.RemoveEntity(CurrentSeed);
     }
     Tree.Leaves.Remove(this);
     if (Tree.Leaves.Count == 0)
     {
         Tree.Kill();
     }
 }
Beispiel #5
0
        void Eat(Entity E)
        {
            bool Extend;

            if (!(Draw.Selected == this && Form1.ManualControl))
            {
                Extend = UseSpike;
            }
            else
            {
                Extend = Form1.HoldKeys.Contains(System.Windows.Forms.Keys.Space);
            }
            if (E is Seed S && S.EnableCollide && !Extend)
            {
                Energy += 125;
                S.Dead  = true;
                UpdateWorld.RemoveEntity(S);
            }
 public void Update()
 {
     if (EnableCollide)
     {
         SeedTimer += 1 / Form1.fps;
         if (Dead)
         {
             UpdateWorld.RemoveEntity(this);
         }
         if (SeedTimer > SeedTimerMax)
         {
             Tree Tree = new Tree(Parent, Pos, ChunkPos)
             {
                 Energy = StartEnergy
             };
             UpdateWorld.AddEntity(Tree, Pos, ChunkPos);
             UpdateWorld.RemoveEntity(this);
         }
     }
 }