Пример #1
0
 public override void Touch(Movier other)
 {
     if (other != null && other is Food && !other.ground)
     {
         DoDamage(other);
     }
 }
Пример #2
0
        public double Dist(Movier other)
        {
            if (other == null)
            {
                return(double.MaxValue);
            }
            var cx = other.x - this.x;
            var cy = other.y - this.y;

            return(Math.Sqrt(cx * cx + cy * cy));
        }
Пример #3
0
        public void DoDamage(Movier other)
        {
            if (other == null)
            {
                return;
            }
            var dmg = Math.Min(other.hp, this.damage);

            this.hp  += dmg;
            other.hp -= dmg;
        }
Пример #4
0
        void AquariumObjectWhantToSpawn(Movier obj)
        {
            if (obj == null)
            {
                return;
            }
            var child = obj.CreateChild();

            if (child == null)
            {
                return;
            }
            objects.AddRange(child);
        }
Пример #5
0
        protected (double dx, double dy) Shift(Movier other, double shift)
        {
            if (other == null)
            {
                return(0, 0);
            }
            var dist = Dist(other);

            if (dist < 0.00001)
            {
                return(0, 0);
            }
            var cx = other.x - this.x;
            var cy = other.y - this.y;

            shift = Math.Min(shift, dist);
            return(shift * cx / dist, shift *cy / dist);
        }
Пример #6
0
        public override (double dx, double dy) GetNextMove(IEnumerable <Movier> others)
        {
            //var enemy = Nearest(others, obj => obj is BadFish && Dist(obj) < EYE_RANGE);
            //if (enemy == null)
            //    return Shift(enemy, -speed);

            var target = Nearest(others, obj => obj is Food && !obj.ground && Dist(obj) < EYE_RANGE);

            if (target == null)
            {
                target = new Movier()
                {
                    x = this.x + targetx, y = this.y + targety
                }
            }
            ;
            return(Shift(target, speed));
        }
Пример #7
0
 public virtual void Touch(Movier other)
 {
 }