Ejemplo n.º 1
0
 public virtual WellFishSilhouette PondFishToWellFish(PondFishSilhouette pFish)
 {
     if (pFish.GetType().Equals(typeof(WellFishSilhouette)))
     {
         return((WellFishSilhouette)pFish);
     }
     else
     {
         return(new WellFishSilhouette(this, border_width));
     }
 }
        /// <summary>
        /// Modifications to shadow movement, primarily allowed bounds
        /// </summary>
        /// <param name="time"></param>
        public new void Update(float time)
        {
            nextDart     -= time;
            _age         += time;
            _wiggleTimer += time;
            if (nextDart <= 0f || (nextDart <= 0.5f && Game1.random.NextDouble() < 0.10000000149011612))
            {
                ResetDartTime();
                int direction = Game1.random.Next(0, 2) * 2 - 1;
                if (direction < 0)
                {
                    _flipped = true;
                }
                else
                {
                    _flipped = false;
                }
                //increased Y variance a bit
                _velocity = new Vector2((float)direction * Utility.Lerp(50f, 100f, (float)Game1.random.NextDouble()), Utility.Lerp(-75f, 75f, (float)Game1.random.NextDouble()));
            }
            bool moving = false;

            if (_velocity.LengthSquared() > 0f)
            {
                moving        = true;
                _wiggleTimer += time * 30f;
                _sinkAmount   = Utility.MoveTowards(_sinkAmount, 0f, 2f * time);
            }
            else
            {
                _sinkAmount = Utility.MoveTowards(_sinkAmount, 1f, 1f * time);
            }
            position += _velocity * time;
            for (int i = 0; i < _pond.GetWellSilhouettes().Count; i++)
            {
                PondFishSilhouette other_silhouette = _pond.GetWellSilhouettes()[i];
                if (other_silhouette == this)
                {
                    continue;
                }
                //slightly more pushy
                float push_amount       = 40f;
                float push_other_amount = 40f;
                if (IsMoving())
                {
                    push_amount = 0f;
                }
                if (other_silhouette.IsMoving())
                {
                    push_other_amount = 0f;
                }
                if (Math.Abs(other_silhouette.position.X - position.X) < 32f)
                {
                    if (other_silhouette.position.X > position.X)
                    {
                        other_silhouette.position.X += push_other_amount * time;
                        position.X += (0f - push_amount) * time;
                    }
                    else
                    {
                        other_silhouette.position.X -= push_other_amount * time;
                        position.X += push_amount * time;
                    }
                }
                if (Math.Abs(other_silhouette.position.Y - position.Y) < 32f)
                {
                    if (other_silhouette.position.Y > position.Y)
                    {
                        other_silhouette.position.Y += push_other_amount * time;
                        position.Y += -1f * time;
                    }
                    else
                    {
                        other_silhouette.position.Y -= push_other_amount * time;
                        position.Y += 1f * time;
                    }
                }
            }
            _velocity.X = Utility.MoveTowards(_velocity.X, 0f, 35f * time);
            _velocity.Y = Utility.MoveTowards(_velocity.Y, 0f, 15f * time);
            //corrected border width
            if (position.X > ((float)((int)_pond.tileX + (int)_pond.tilesWide) - border_width) * 64f)
            {
                position.X   = ((float)((int)_pond.tileX + (int)_pond.tilesWide) - border_width) * 64f - 1f;
                _velocity.X *= -1f;
                if (moving && (Game1.random.NextDouble() < 0.25 || Math.Abs(_velocity.X) > 30f))
                {
                    _flipped = !_flipped;
                }
            }
            if (position.X < ((float)(int)_pond.tileX + border_width) * 64f)
            {
                position.X   = ((float)(int)_pond.tileX + border_width) * 64f + 1f;
                _velocity.X *= -1f;
                if (moving && (Game1.random.NextDouble() < 0.25 || Math.Abs(_velocity.X) > 30f))
                {
                    _flipped = !_flipped;
                }
            }
            if (position.Y > ((float)((int)_pond.tileY + (int)_pond.tilesHigh) - border_width) * 64f)
            {
                position.Y   = ((float)((int)_pond.tileY + (int)_pond.tilesHigh) - border_width) * 64f - 1f;
                _velocity.Y *= -1f;
            }
            if (position.Y < ((float)(int)_pond.tileY + border_width) * 64f)
            {
                position.Y   = ((float)(int)_pond.tileY + border_width) * 64f + 1f;
                _velocity.Y *= -1f;
            }
        }