Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Animal"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 /// <param name="field">
 /// The field.
 /// </param>
 protected Animal(IWatorSettings settings, WatorField field)
 {
     this.Settings         = settings;
     this.IsMoved          = false;
     this.Lifetime         = 0;
     this.Field            = field;
     this.FoundDirections  = new List <Direction>();
     this.AnimalRandomizer = new Random(DateTime.Now.Millisecond * field.Position.X);
 }
Example #2
0
        /// <summary>
        /// Checks if lock required.
        /// </summary>
        /// <param name="direction">
        /// The direction.
        /// </param>
        /// <param name="targetField">
        /// The target field.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        protected bool CheckLockRequired(Direction direction, WatorField targetField)
        {
            if (direction == Direction.Up && this.Field.Position.Y == 0)
            {
                return(targetField.Position.Y > this.Field.Position.Y);
            }

            if (direction == Direction.Down && this.Field.Position.Y == this.Settings.WorldHeight - 1)
            {
                return(targetField.Position.Y < this.Field.Position.Y);
            }

            return(false);
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Shark"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 /// <param name="field">
 /// The field.
 /// </param>
 public Shark(IWatorSettings settings, WatorField field)
     : base(settings, field)
 {
     this.Starve = 0; // "Hunger"
 }
Example #4
0
 /// <summary>
 /// Creates the sibling depending on inherited type.
 /// </summary>
 /// <param name="siblingField">
 /// The sibling Field.
 /// </param>
 /// <returns>
 /// The <see cref="Animal"/>.
 /// </returns>
 protected override Animal CreateSibling(WatorField siblingField)
 {
     return(new Shark(this.Settings, siblingField));
 }
Example #5
0
 /// <summary>
 /// Creates the sibling depending on inherited type.
 /// </summary>
 /// <param name="siblingField">
 /// The sibling field.
 /// </param>
 /// <returns>
 /// The <see cref="Animal"/>.
 /// </returns>
 protected abstract Animal CreateSibling(WatorField siblingField);
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Fish"/> class.
 /// </summary>
 /// <param name="settings">
 /// The settings.
 /// </param>
 /// <param name="field">
 /// The field.
 /// </param>
 public Fish(IWatorSettings settings, WatorField field)
     : base(settings, field)
 {
 }