/// <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); }
/// <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); }
/// <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" }
/// <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)); }
/// <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);
/// <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) { }