Example #1
0
 /*
  * Sepia spawn
  * */
 private void SpawnSepia(Sepia creature)
 {
     for (int i = 0; i < _sepiasChildren; i++)
     {
         Creature child;
         child = new Sepia(creature.LifeTime, new Library.Pair());
         if (i == 0)
         {
             KillCreature(creature.Position.X, creature.Position.Y);
             child.Position = creature.Position;
         }
         else
         {
             child.Position = FindPlaceForSepia(child, creature.Position.X, creature.Position.Y);
         }
         _simulationField[child.Position.X, child.Position.Y] = child;
     }
 }
Example #2
0
        /*
         * Initializing the field
         * */
        private void InitializeField(Library.Pair size)
        {
            _simulationField = new Creature[size.X, size.Y];

            for (int i = 0; i < _sharksCount; i++)
            {
                Library.Pair position = FindPlaceForCreature();
                Shark shark = new Shark(_sharksLifeTime, 0, _sharksHunger, position);
                _simulationField[position.X, position.Y] = shark;
            }
            for (int i = 0; i < _sepiasCount; i++)
            {
                Library.Pair position = FindPlaceForCreature();
                Sepia sepia = new Sepia(_sepiasLifeTime, position);
                _simulationField[position.X, position.Y] = sepia;
            }
        }
Example #3
0
 /*
  * Moveing Sepia
  * */
 private void MoveSepia(Sepia creature, int x, int y)
 {
     Library.Pair position = FindPlaceForSepia(creature, x, y);
     if (_simulationField[position.X, position.Y] is Shark)
     {
         KillCreature(x, y);
         try
         {
             ((Shark)_simulationField[position.X, position.Y]).Hunger = 0;
         }
         catch (Exception) { }
     }
     else
     {
         _simulationField[x, y] = null;
         _simulationField[position.X, position.Y] = creature;
     }
 }
Example #4
0
 /*
  * Checking if sepia is old enough to have children
  * */
 private bool CheckForSpawnSepia(Sepia creature)
 {
     if (creature.Age == 2 * creature.LifeTime / 3)
     {
         SpawnSepia(creature);
         return true;
     }
     return false;
 }